private void DrawAPoint(object sender, MouseButtonEventArgs e) { var point = e.GetPosition(Canvas); if (_drawingPolygonS) { if (_polygonSVertexNum == 0) { _polyS.PointList.Add(new Vertex(point.X, point.Y) { Name = "S" + (_polygonSVertexNum + 1) }); } _polyS.PointList.Add(new Vertex(point.X, point.Y) { Name = "S" + (_polygonSVertexNum + 1) }); _polyS.Render(Canvas); } if (_drawingPolygonC) { if (_polygonCVertexNum == 0) { _polyC.PointList.Add(new Vertex(point.X, point.Y) { Name = "C" + (_polygonCVertexNum + 1) }); } _polyC.PointList.Add(new Vertex(point.X, point.Y) { Name = "C" + (_polygonCVertexNum + 1) }); _polyC.Render(Canvas); } }
private void Cut(object sender, RoutedEventArgs e) { Status.Text = "裁剪结果"; ResetButton(); ButtonCut.Background = new SolidColorBrush(Colors.DodgerBlue); var polylineLst = ArbitraryPolygonCut.Cut(_polyS.PointList, _polyC.PointList); if (polylineLst.Count == 0) { MessageBox.Show("没有交点"); return; } foreach (var pointLst in polylineLst) { var polyResult = new MyPolygon(RenderType.Polygon) { StrokeColor = Colors.Transparent, StrokeThickess = 0, FillColor = Color.FromArgb(80, 30, 144, 255), Filled = true }; polyResult.PointList.AddRange(pointLst); polyResult.Render(Canvas); } }
private void Cut(object sender, RoutedEventArgs e) { Status.Text = "裁剪结果"; ResetButton(); ButtonCut.Background = new SolidColorBrush(Colors.DodgerBlue); var polylineLst = ArbitraryPolygonCut.Cut(_polyS.PointList, _polyC.PointList); if (polylineLst.Count == 0) { MessageBox.Show("没有交点"); return; } foreach (var pointLst in polylineLst) { var polyResult = new MyPolygon(RenderType.Polygon) { StrokeColor = Colors.Transparent, StrokeThickess = 0, FillColor = Color.FromArgb(80, 30, 144, 255), Filled = true }; polyResult.PointList.AddRange(pointLst); polyResult.Render(Canvas); } }