private void DrawCellQuality(GridControl.Cell cell, Rectangle area, Graphics graphics) { Image texture = GetTileQualityTexture(CellToTile(cell)); if (texture != null) { graphics.DrawImage(texture, area); } }
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); } } }
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); } }
private void gridControl1_DragDrop(object sender, DragEventArgs e) { Point pt = gridControl1.PointToClient(new Point(e.X, e.Y)); System.Diagnostics.Debug.Print("DragDrop {0},{1}", pt.X, pt.Y); AnalyzeResult result = e.Data.GetData(typeof(AnalyzeResult)) as AnalyzeResult; if (result != null) { GridControl.Cell cell = gridControl1.CellFromPoint(pt.X, pt.Y); if (cell != null) { map.SetResult(cell.X, cell.Y, result); gridControl1.Redraw(); } } }
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; } }
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)); } }
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)); } }
void gridControl1_MouseWheel(object sender, MouseEventArgs e) { if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { Point hotSpot = new Point(e.Location.X, e.Location.Y); hotSpot.Offset(gridControl1.Location); GridControl.Cell cell = gridControl1.CellFromPoint(e.Location.X, e.Location.Y, false); Rectangle cellRect = gridControl1.RectFromCell(cell.X, cell.Y); Point hotSpotInCell = new Point(e.Location.X - cellRect.Left, e.Location.Y - cellRect.Top); if (e.Delta < 0) { if (gridControl1.CellWidth > 4) { gridControl1.CellWidth /= 2; gridControl1.CellHeight /= 2; hotSpotInCell.X /= 2; hotSpotInCell.Y /= 2; } } else { if (gridControl1.CellWidth < 256) { gridControl1.CellWidth *= 2; gridControl1.CellHeight *= 2; hotSpotInCell.X *= 2; hotSpotInCell.Y *= 2; } } if (gridControl1.CellWidth < 32) { gridControl1.BorderSize = 0; } else { gridControl1.BorderSize = 1; } this.textureWidth = gridControl1.CellWidth; this.textureHeight = gridControl1.CellHeight; this.textureCache.Clear(); Rectangle newCellRect = gridControl1.RectFromCell(cell.X, cell.Y); Point newHotSpot = new Point(newCellRect.Left + hotSpotInCell.X, newCellRect.Top + hotSpotInCell.Y); Point newLocation = new Point(hotSpot.X - newHotSpot.X, hotSpot.Y - newHotSpot.Y); if (newLocation.X > 0) { newLocation.X = 0; } if (newLocation.Y > 0) { newLocation.Y = 0; } panel1.HorizontalScroll.Value = -newLocation.X; panel1.VerticalScroll.Value = -newLocation.Y; //gridControl1.Location = newLocation; gridControl1.Invalidate(); ((HandledMouseEventArgs)e).Handled = true; } }
private Tile CellToTile(GridControl.Cell cell) { return(new Tile(cell.X, cell.Y)); }
private void RepaintTile(Tile tile) { GridControl.Cell cell = TileToCell(tile);; gridControl1.PaintCell(cell.X, cell.Y); }
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); } }