Example #1
0
 private void gridControl1_OnCellPaint(object sender, GridControl.Cell cell, PaintEventArgs eventArgs)
 {
     DrawCellBackground(cell, eventArgs.ClipRectangle, eventArgs.Graphics);
     if (remderQualityOverlay)
         DrawCellQuality(cell, eventArgs.ClipRectangle, eventArgs.Graphics);
     if (renderAnalyzerOverlay)
         DrawCellAnalyzeLayer(cell, eventArgs.ClipRectangle, eventArgs.Graphics);
 }
Example #2
0
        private void gridControl1_CellMouseEnter(object sender, GridControl.Cell cell, MouseEventArgs eventArgs)
        {
            String tileType;
            if (map[cell.X, cell.Y].Quality != Quality.Unknown)
            {
                tileType = String.Format("{2},{3} {0} ({1})", map[cell.X, cell.Y].Type, map[cell.X, cell.Y].Quality, cell.X, cell.Y);
            } else {
                tileType = String.Format("{2},{3} {0}", map[cell.X, cell.Y].Type, map[cell.X, cell.Y].Quality, cell.X, cell.Y);
            }

            if (map[cell.X, cell.Y].IsSet || map[cell.X, cell.Y].IsUndecided || map[cell.X, cell.Y].HasSalt || map[cell.X, cell.Y].HasFlint)
            {
                toolStripStatusLabel1.Text = String.Format("{0}; {1}", tileType, map[cell.X, cell.Y].ToString());
            }
            else
            {
                toolStripStatusLabel1.Text = tileType;
            }
        }
Example #3
0
 private void gridControl1_CellMouseMove(object sender, GridControl.Cell cell, MouseEventArgs eventArgs)
 {
     if (eventArgs.Button == MouseButtons.Left && activeTool != null && Control.ModifierKeys == Keys.None)
     {
         if (activeTool.UseTool(map, CellToTile(cell)))
         {
             gridControl1.PaintCell(cell.X, cell.Y);
         }
     }
 }
Example #4
0
 private void gridControl1_CellClick(object sender, GridControl.Cell cell, MouseEventArgs eventArgs)
 {
     if (eventArgs.Button == MouseButtons.Left && (Control.ModifierKeys & Keys.Control) != 0)
     {
         map[cell.X, cell.Y].SetEmpty();
         Recalculate();
     }
     else if (eventArgs.Button == MouseButtons.Left)
     {
         if (activeTool != null)
         {
             if (activeTool.UseTool(map, CellToTile(cell)))
             {
                 gridControl1.PaintCell(cell.X, cell.Y);
             }
         }
     }
     else if (eventArgs.Button == MouseButtons.Right)
     {
         PopupTile = CellToTile(cell);
         Rectangle rect = gridControl1.RectFromCell(cell.X, cell.Y);
         gridContextMenu.Show(gridControl1, new Point(eventArgs.Location.X + rect.Left, eventArgs.Y + rect.Top));
     }
 }
Example #5
0
 private void DrawCellQuality(GridControl.Cell cell, Rectangle area, Graphics graphics)
 {
     Image texture = GetTileQualityTexture(CellToTile(cell));
     if (texture != null)
     {
         graphics.DrawImage(texture, area);
     }
 }
Example #6
0
        private void DrawCellBackground(GridControl.Cell cell, Rectangle area, Graphics graphics)
        {
            Image texture = GetTileTexture(cell.X, cell.Y);
            if (texture == null)
            {
                switch (map[cell.X, cell.Y].Type)
                {
                    case TileType.Tunnel:
                        graphics.FillRectangle(Brushes.White, area);
                        break;
                    case TileType.Rock:
                        graphics.FillRectangle(Brushes.Gray, area);
                        break;
                    default:
                        graphics.FillRectangle(Brushes.Green, area);
                        break;
                }
            }
            else
            {
                TileStatus tile = map[cell.X, cell.Y];
                if (tile.Estimates == null && tile.Found == null)
                {
                    float b = 0.7f;
                    ColorMatrix cm = new ColorMatrix(new float[][]
                            {
                                new float[] {b, 0, 0, 0, 0},
                                new float[] {0, b, 0, 0, 0},
                                new float[] {0, 0, b, 0, 0},
                                new float[] {0, 0, 0, 1, 0},
                                new float[] {0, 0, 0, 0, 1},
                            });
                    ImageAttributes imgAttr = new ImageAttributes();
                    imgAttr.SetColorMatrix(cm);

                    Point[] points =
                    {
                        new Point(area.Left, area.Top),
                        new Point(area.Right, area.Top),
                        new Point(area.Left, area.Bottom),
                    };
                    Rectangle srcRect = new Rectangle(0, 0, area.Width, area.Height);

                    graphics.DrawImage(texture, points, srcRect, GraphicsUnit.Pixel, imgAttr);
                }
                else
                {
                    graphics.DrawImage(texture, area);
                }
            }
            texture = GetSaltTexture(CellToTile(cell));
            if (texture != null)
            {
                graphics.DrawImage(texture, area);
            }
            texture = GetFlintTexture(CellToTile(cell));
            if (texture != null)
            {
                graphics.DrawImage(texture, area);
            }
        }
Example #7
0
        private void DrawCellAnalyzeLayer(GridControl.Cell cell, Rectangle area, Graphics graphics)
        {
            StringFormat drawFormat = new StringFormat();
            drawFormat.Alignment = StringAlignment.Center;
            drawFormat.LineAlignment = StringAlignment.Center;
            if (map[cell.X, cell.Y].IsEmpty)
            {
            }
            else if (map[cell.X, cell.Y].IsSet)
            {
            }
            else if (map[cell.X, cell.Y].IsUndecided)
            {
                graphics.DrawString("?", font, Brushes.Red, area, drawFormat);
            }

            if (map[cell.X, cell.Y].Result != null)
            {
                graphics.DrawRectangle(Pens.Red, new Rectangle(area.Left, area.Top, area.Width - 1, area.Height - 1));
            }
        }
Example #8
0
 private Tile CellToTile(GridControl.Cell cell)
 {
     return new Tile(cell.X, cell.Y);
 }