diff --git a/ShpViewer/MapViewControl.cs b/ShpViewer/MapViewControl.cs index c19b696823..c6b410e3ac 100644 --- a/ShpViewer/MapViewControl.cs +++ b/ShpViewer/MapViewControl.cs @@ -16,47 +16,49 @@ namespace ShpViewer public MapViewControl() { + SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + UpdateStyles(); } static Font font = new Font( FontFamily.GenericMonospace, 10 ); - protected override void OnPaint( PaintEventArgs e ) + protected override void OnPaint(PaintEventArgs e) { - base.OnPaint( e ); - if( Map == null || TileSet == null ) + base.OnPaint(e); + if (Map == null || TileSet == null) return; - using( Graphics g = e.Graphics ) + + Graphics g = e.Graphics; + + for (int x = 50; x >= 0; x--) { - for( int x = 50 ; x >= 0 ; x-- ) + int tX = x + Map.XOffset + XScroll; + if (tX < Map.XOffset || tX >= Map.XOffset + Map.Width) + continue; + + for (int y = 50; y >= 0; y--) { - int tX = x + Map.XOffset + XScroll; - if( tX < Map.XOffset || tX >= Map.XOffset + Map.Width ) + int tY = y + Map.YOffset + YScroll; + if (tY < Map.YOffset || tY >= Map.YOffset + Map.Height) continue; - for( int y = 50 ; y >= 0 ; y-- ) + Terrain t; + if (TileSet.tiles.TryGetValue(Map.MapTiles[tX, tY].tile, out t)) { - int tY = y + Map.YOffset + YScroll; - if( tY < Map.YOffset || tY >= Map.YOffset + Map.Height ) - continue; - - Terrain t; - if( TileSet.tiles.TryGetValue( Map.MapTiles[ tX, tY ].tile, out t ) ) + Bitmap b = t.GetTile(Map.MapTiles[tX, tY].image); + if (b == null) { - Bitmap b = t.GetTile( Map.MapTiles[ tX, tY ].image ); - if( b == null ) - { - g.FillRectangle( Brushes.Blue, x * 24, y * 24, 24, 24 ); - g.DrawString( string.Format( "{0:x}", Map.MapTiles[ tX, tY ].image ), - font, Brushes.White, x * 24, y * 24 ); - } - else - g.DrawImage( b, x * 24, y * 24 ); + g.FillRectangle(Brushes.Blue, x * 24, y * 24, 24, 24); + g.DrawString(string.Format("{0:x}", Map.MapTiles[tX, tY].image), + font, Brushes.White, x * 24, y * 24); } else - { - g.FillRectangle( Brushes.Red, x * 24, y * 24, 24, 24 ); - g.DrawString( string.Format( "{0:x}", Map.MapTiles[ tX, tY ].tile ), - font, Brushes.White, x * 24, y * 24 ); - } + g.DrawImage(b, x * 24, y * 24); + } + else + { + g.FillRectangle(Brushes.Red, x * 24, y * 24, 24, 24); + g.DrawString(string.Format("{0:x}", Map.MapTiles[tX, tY].tile), + font, Brushes.White, x * 24, y * 24); } } }