Esempio n. 1
0
        public override IEnumerable <System.Windows.Point> GetPoints()
        {
            var ellipse = new EllipseGeometry()
            {
                Center  = new System.Windows.Point(Width / 2.0, Height / 2.0),
                RadiusX = Width / 2.0,
                RadiusY = Height / 2.0
            };

            var points   = new List <System.Windows.Point>();
            var segments = ellipse.GetFlattenedPathGeometry(0.01, ToleranceType.Absolute).Figures[0].Segments;

            foreach (var segment in segments)
            {
                if (segment is PolyLineSegment)
                {
                    foreach (var p in (segment as PolyLineSegment)?.Points ?? Enumerable.Empty <System.Windows.Point>())
                    {
                        points.Add(new System.Windows.Point((p.X + X).Round(), (p.Y + Y).Round()));
                    }
                }
            }

            foreach (var i in ShapeTool.CalculatePoints(points))
            {
                yield return(i);
            }
        }
Esempio n. 2
0
        protected override IEnumerable <Point> GetPoints(double x, double y, double height, double width)
        {
            var ellipse = new EllipseGeometry()
            {
                Center  = new Point(width / 2.0, height / 2.0),
                RadiusX = width / 2.0,
                RadiusY = height / 2.0
            };

            var points   = new List <Point>();
            var segments = ellipse.GetFlattenedPathGeometry(0.01, ToleranceType.Absolute).Figures[0].Segments;

            foreach (var segment in segments)
            {
                if (segment is PolyLineSegment)
                {
                    foreach (var p in (segment as PolyLineSegment)?.Points ?? Enumerable.Empty <Point>())
                    {
                        points.Add(new Point((p.X + x).Round(), (p.Y + y).Round()));
                    }
                }
            }

            foreach (var i in ShapeTool.CalculatePoints(points))
            {
                yield return(i);
            }
        }
Esempio n. 3
0
        public override void OnMouseDoubleClick(Point point)
        {
            var newSelection = new CustomPath();

            ShapeTool.CalculatePoints(Points).ForEach(i => newSelection.Points.Add(i.Int32().Double()));

            for (var i = 0; i < newSelection.Points.Count; i++)
            {
                var current = newSelection.Points[i];
                newSelection.Points[i] = current.Coerce(new Point(Document.Width, Document.Height), new Point(0, 0));
            }

            Document.Selections.Add(newSelection);
            Points.Clear();
            Preview = null;
        }