public void RemoveRegion(BTBLib.Region value) { if (_regionsToDraw.Contains(value)) { _regionsToDraw.Remove(value); } }
public void AddRegion(BTBLib.Region value) { if (!_regionsToDraw.Contains(value)) { _regionsToDraw.Add(value); } }
private void SetSelectedRegion(BTBLib.Region value) { if (_selectedRegion != value) { _selectedRegion = value; Redraw(); } }
private void SetHighlightedRegion(BTBLib.Region value) { if (_highlightedRegion != value) { _highlightedRegion = value; Redraw(); } }
private void UpdateTreeViewRegions() { TreeNode regionsNode = GetRegionsNode(); foreach (TreeNode node in regionsNode.Nodes) { TagData tagData = node.Tag as TagData; BTBLib.Region region = tagData.GetRegionLink(); node.Checked = _drawData.ContainsRegion(region); } }
public void SetRegion(bool show, BTBLib.Region value) { if (show) { AddRegion(value); } else { RemoveRegion(value); } }
public void SetData(BTBLib.Region region) { _region = region; UpdateUI(); }
private void CalcWalkableArea() { if (_battle == null) { return; } int width = _battle.Width / 8; int height = _battle.Height / 8; Image image = new Bitmap(width, height); Graphics graphics = Graphics.FromImage(image); graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, width, height)); BTBLib.Region battleBoundary = null; List <BTBLib.Region> boundaries = new List <BTBLib.Region>(); List <BTBLib.Region> inverseBoundaries = new List <BTBLib.Region>(); foreach (BTBLib.Region region in _battle.Regions) { if (region.IsClosed) { if (region.IsBattleBoundary) { battleBoundary = region; } else if (region.IsBoundaryInversed) { inverseBoundaries.Add(region); } else if (region.IsBoundary) { boundaries.Add(region); } } } if (battleBoundary == null) { return; } boundaries.Insert(0, battleBoundary); System.Drawing.Region graphicsRegion = new System.Drawing.Region(new Rectangle(0, 0, width, height)); foreach (BTBLib.Region region in boundaries) { Point[] points = new Point[region.Lines.Count]; for (int i = 0; i < points.Length; ++i) { var segment = region.Lines[i]; points[i] = new Point(segment.StartX / 8, height - segment.StartY / 8); } GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddPolygon(points); graphicsRegion.Intersect(graphicsPath); } foreach (BTBLib.Region region in inverseBoundaries) { Point[] points = new Point[region.Lines.Count]; for (int i = 0; i < points.Length; ++i) { var segment = region.Lines[i]; points[i] = new Point(segment.StartX / 8, height - segment.StartY / 8); } GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddPolygon(points); graphicsRegion.Exclude(graphicsPath); } graphics.FillRegion(new SolidBrush(Color.Red), graphicsRegion); //Form form = new Form(); //form.ClientSize = new Size(width * 3, height * 3); //PictureBox pictureBox = new PictureBox(); //pictureBox.Image = image; //pictureBox.SizeMode = PictureBoxSizeMode.Zoom; //form.Controls.Add(pictureBox); //pictureBox.Dock = DockStyle.Fill; //form.Show(); ImageForm form = new ImageForm(); form.SetImage(image); form.ShowDialog(); }
private void DrawRegion(Graphics graphics, Color color, bool drawPoints, bool fill, BTBLib.Region region) { Pen pen = new Pen(color, _regionPenWidth / _zoom); Brush brush = new SolidBrush(color); Point[] points = null; bool shouldFill = fill && region.IsClosed; if (shouldFill) { points = new Point[region.Lines.Count]; } for (int i = 0; i < region.Lines.Count; ++i) { var segment = region.Lines[i]; int startX = segment.StartX / 8; int startY = (_battle.Height - segment.StartY) / 8; int endX = segment.EndX / 8; int endY = (_battle.Height - segment.EndY) / 8; graphics.DrawLine(pen, startX, startY, endX, endY); if (drawPoints) { graphics.FillRectangle(brush, startX - _regionPointSize / 2, startY - _regionPointSize / 2, _regionPointSize, _regionPointSize); } if (shouldFill) { points[i] = new Point(startX, startY); } } if (drawPoints) { if (!region.IsClosed && region.Lines.Count > 0) { BTBLib.Region.LineSegment segment = region.Lines[region.Lines.Count - 1]; int endX = segment.EndX / 8; int endY = (_battle.Height - segment.EndY) / 8; graphics.FillRectangle(brush, endX - _regionPointSize / 2, endY - _regionPointSize / 2, _regionPointSize, _regionPointSize); } } if (shouldFill) { Brush regionBrush = new SolidBrush(Color.FromArgb(128, color.R, color.G, color.B)); if (region.IsBoundaryInversed) { System.Drawing.Region graphicsRegion = new System.Drawing.Region(); graphicsRegion.MakeInfinite(); GraphicsPath path = new GraphicsPath(); path.AddPolygon(points); graphicsRegion.Exclude(path); graphics.FillRegion(regionBrush, graphicsRegion); } else { graphics.FillPolygon(regionBrush, points); } } }
public bool ContainsRegion(BTBLib.Region value) { return(_regionsToDraw.Contains(value)); }