Пример #1
0
        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);
            }
        }
Пример #2
0
        private bool IsCloseToPolygon(Point mousePoint, MyPolygon polygon, ref Point nearestPoint)
        {
            var pointCount = polygon.PointList.Count;

            if (pointCount < 3)
            {
                return(false);
            }

            for (int i = 0; i < polygon.PointList.Count; i++)
            {
                var vertex1 = polygon.PointList[i % pointCount];
                var vertex2 = polygon.PointList[(i + 1) % pointCount];
                var result  = IsCloseTo(mousePoint, vertex1.ToPoint(), vertex2.ToPoint(), ref nearestPoint);
                if (result)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
        private bool IsCloseToPolygon(Point mousePoint, MyPolygon polygon, ref Point nearestPoint)
        {
            var pointCount = polygon.PointList.Count;
            if (pointCount < 3)
                return false;

            for (int i = 0; i < polygon.PointList.Count; i++)
            {
                var vertex1 = polygon.PointList[i% pointCount];
                var vertex2 = polygon.PointList[(i + 1)%pointCount];
                var result = IsCloseTo(mousePoint, vertex1.ToPoint(), vertex2.ToPoint(),ref nearestPoint);
                if (result)
                    return true;
            }
            return false;
        }
Пример #4
0
        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);
            }
        }