public static Geometry ToNTSGeometry(this DrawingPolygon drawingPolygon)
        {
            var shell = drawingPolygon.Shell.Select(p => p.ToCoordinate()).ToArray();

            if (drawingPolygon.HasHoles)
            {
                var holes = drawingPolygon.Holes.Select(h => new LinearRing(h.Select(p => p.ToCoordinate()).ToArray())).ToArray();
                return(new Polygon(new LinearRing(shell), holes));
            }

            return(new Polygon(new LinearRing(shell)));
        }
        public override void HandleMouseMove(MouseEventArgs e)
        {
            base.HandleMouseMove(e);
            if (prePoint == default)
            {
                return;
            }

            var targetPoints = new List <Point>(points);

            var currentPoint = e.GetPosition(Canvas);

            currentPoint = AlignPointToXY(currentPoint);

            targetPoints.Add(currentPoint);

            if (element == null)
            {
                element = new DrawingLineString(targetPoints, false);
                Canvas.AddVisual(element);
            }
            else
            {
                if (targetPoints.Count <= 2)
                {
                    (element as DrawingLineString).Update(targetPoints, false);
                }
                else
                {
                    if (element is DrawingLineString)
                    {
                        Canvas.RemoveVisual(element);
                        element = new DrawingPolygon(targetPoints);
                        Canvas.AddVisual(element);
                    }
                    else
                    {
                        (element as DrawingPolygon).Update(targetPoints);
                    }
                }
            }

            element.Render(DrawingCanvas.DefaultPen);
        }