Esempio n. 1
0
        public static LineSegment CreateLineSegment(Point point, bool isStroked, bool?isSmoothJoin)
        {
            LineSegment lineSegment = new LineSegment();

            lineSegment.Point = point;
            PathSegmentUtilities.SetStrokeAndJoinOnSegment((PathSegment)lineSegment, isStroked, isSmoothJoin);
            return(lineSegment);
        }
Esempio n. 2
0
        public static QuadraticBezierSegment CreateQuadraticBezierSegment(Point point1, Point point2, bool isStroked, bool?isSmoothJoin)
        {
            QuadraticBezierSegment quadraticBezierSegment = new QuadraticBezierSegment();

            quadraticBezierSegment.Point1 = point1;
            quadraticBezierSegment.Point2 = point2;
            PathSegmentUtilities.SetStrokeAndJoinOnSegment((PathSegment)quadraticBezierSegment, isStroked, isSmoothJoin);
            return(quadraticBezierSegment);
        }
Esempio n. 3
0
        public static BezierSegment CreateBezierSegment(Point point1, Point point2, Point point3, bool isStroked, bool?isSmoothJoin)
        {
            BezierSegment bezierSegment = new BezierSegment();

            bezierSegment.Point1 = point1;
            bezierSegment.Point2 = point2;
            bezierSegment.Point3 = point3;
            PathSegmentUtilities.SetStrokeAndJoinOnSegment((PathSegment)bezierSegment, isStroked, isSmoothJoin);
            return(bezierSegment);
        }
Esempio n. 4
0
        public static bool CollapseSingleSegmentsToPolySegments(PathFigure original)
        {
            bool flag = false;
            PathSegmentCollection segmentCollection = new PathSegmentCollection();

            for (int index = 0; index < original.Segments.Count; ++index)
            {
                LineSegment            lineSegment             = original.Segments[index] as LineSegment;
                QuadraticBezierSegment quadraticBezierSegment1 = original.Segments[index] as QuadraticBezierSegment;
                BezierSegment          bezierSegment1          = original.Segments[index] as BezierSegment;
                int num = index;
                if (lineSegment != null)
                {
                    PointCollection pointCollection = (PointCollection)null;
                    for (; index + 1 < original.Segments.Count && original.Segments[index + 1] is LineSegment && !PathFigureUtilities.IsSignificantChangeBetweenSegments((PathSegment)lineSegment, original.Segments[index + 1]); ++index)
                    {
                        if (pointCollection == null)
                        {
                            pointCollection = new PointCollection();
                            pointCollection.Add(lineSegment.Point);
                        }
                        pointCollection.Add(((LineSegment)original.Segments[index + 1]).Point);
                    }
                    if (index != num)
                    {
                        PolyLineSegment polyLineSegment = new PolyLineSegment();
                        polyLineSegment.Points = pointCollection;
                        PathSegmentUtilities.SetStrokeAndJoinOnSegment((PathSegment)polyLineSegment, lineSegment.IsStroked, new bool?(lineSegment.IsSmoothJoin));
                        segmentCollection.Add((PathSegment)polyLineSegment);
                        flag = true;
                    }
                    else
                    {
                        segmentCollection.Add((PathSegment)lineSegment);
                    }
                }
                else if (quadraticBezierSegment1 != null)
                {
                    PointCollection        pointCollection = (PointCollection)null;
                    QuadraticBezierSegment quadraticBezierSegment2;
                    for (; index + 1 < original.Segments.Count && (quadraticBezierSegment2 = original.Segments[index + 1] as QuadraticBezierSegment) != null && !PathFigureUtilities.IsSignificantChangeBetweenSegments((PathSegment)quadraticBezierSegment1, (PathSegment)quadraticBezierSegment2); ++index)
                    {
                        if (pointCollection == null)
                        {
                            pointCollection = new PointCollection();
                            pointCollection.Add(quadraticBezierSegment1.Point1);
                            pointCollection.Add(quadraticBezierSegment1.Point2);
                        }
                        pointCollection.Add(quadraticBezierSegment2.Point1);
                        pointCollection.Add(quadraticBezierSegment2.Point2);
                    }
                    if (index != num)
                    {
                        PolyQuadraticBezierSegment quadraticBezierSegment3 = new PolyQuadraticBezierSegment();
                        quadraticBezierSegment3.Points = pointCollection;
                        PathSegmentUtilities.SetStrokeAndJoinOnSegment((PathSegment)quadraticBezierSegment3, quadraticBezierSegment1.IsStroked, new bool?(quadraticBezierSegment1.IsSmoothJoin));
                        segmentCollection.Add((PathSegment)quadraticBezierSegment3);
                        flag = true;
                    }
                    else
                    {
                        segmentCollection.Add((PathSegment)quadraticBezierSegment1);
                    }
                }
                else if (bezierSegment1 != null)
                {
                    PointCollection pointCollection = (PointCollection)null;
                    BezierSegment   bezierSegment2;
                    for (; index + 1 < original.Segments.Count && (bezierSegment2 = original.Segments[index + 1] as BezierSegment) != null && !PathFigureUtilities.IsSignificantChangeBetweenSegments((PathSegment)bezierSegment1, (PathSegment)bezierSegment2); ++index)
                    {
                        if (pointCollection == null)
                        {
                            pointCollection = new PointCollection();
                            pointCollection.Add(bezierSegment1.Point1);
                            pointCollection.Add(bezierSegment1.Point2);
                            pointCollection.Add(bezierSegment1.Point3);
                        }
                        pointCollection.Add(bezierSegment2.Point1);
                        pointCollection.Add(bezierSegment2.Point2);
                        pointCollection.Add(bezierSegment2.Point3);
                    }
                    if (index != num)
                    {
                        PolyBezierSegment polyBezierSegment = new PolyBezierSegment();
                        polyBezierSegment.Points = pointCollection;
                        PathSegmentUtilities.SetStrokeAndJoinOnSegment((PathSegment)polyBezierSegment, bezierSegment1.IsStroked, new bool?(bezierSegment1.IsSmoothJoin));
                        segmentCollection.Add((PathSegment)polyBezierSegment);
                        flag = true;
                    }
                    else
                    {
                        segmentCollection.Add((PathSegment)bezierSegment1);
                    }
                }
                else
                {
                    segmentCollection.Add(original.Segments[index]);
                }
            }
            if (flag)
            {
                original.Segments = segmentCollection;
            }
            return(flag);
        }