Exemplo n.º 1
0
 private void DrawMap(IMap iMap, PaintEventArgs e)
 {
     const int cell_px_size = 1;
     if (iMap == null || iMap.getCurentMapView() == null)
     {
         pictureBoxMap.Size = panelMap.ClientSize;
         Brush brush = new SolidBrush(Color.White);
         e.Graphics.FillRectangle(brush, 0, 0, pictureBoxMap.Width, pictureBoxMap.Height);
         brush.Dispose();
     }
     else
     {
         MapHolder mapHolder = iMap.getCurentMapView();
         pictureBoxMap.Width = mapHolder.SizeX * cell_px_size;
         pictureBoxMap.Height = mapHolder.SizeY * cell_px_size;
         SolidBrush brush = new SolidBrush(DrawMapHelper.getUnknownColor());
         e.Graphics.FillRectangle(brush, 0, 0, pictureBoxMap.Width, pictureBoxMap.Height);
         for (int x = 0; x < mapHolder.SizeX; x++ )
         {
             for (int y = 0; y < mapHolder.SizeY; y++ )
             {
                 brush.Color = DrawMapHelper.getColor(mapHolder.Map[x,y]);
                 e.Graphics.FillRectangle(brush,x* cell_px_size, y *cell_px_size, cell_px_size,cell_px_size);
             }
         }
         brush.Dispose();
     }
 }