Ejemplo n.º 1
0
 public static PathPointKind GetPointKind(PathSegment segment, int index)
 {
     if (index < 0 || index >= PathSegmentUtilities.GetPointCount(segment))
     {
         throw new ArgumentOutOfRangeException("index", (object)index, "Index must be between zero and the segment point count.");
     }
     if (segment is ArcSegment)
     {
         return(PathPointKind.Arc);
     }
     if (segment is LineSegment || segment is PolyLineSegment)
     {
         return(PathPointKind.Line);
     }
     if (segment is QuadraticBezierSegment || segment is PolyQuadraticBezierSegment)
     {
         return(index % 2 == 1 ? PathPointKind.Quadratic : PathPointKind.BezierHandle);
     }
     if (segment is BezierSegment || segment is PolyBezierSegment)
     {
         return(index % 3 == 2 ? PathPointKind.Cubic : PathPointKind.BezierHandle);
     }
     throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.UnknownPathSegmentType, new object[1]
     {
         (object)segment.GetType().Name
     }), "segment");
 }
Ejemplo n.º 2
0
        public static void GetSegmentFromPointIndex(PathFigure pathFigure, int pointIndex, out int segmentIndex, out int segmentPointIndex)
        {
            PathSegmentCollection segments = pathFigure.Segments;

            if (pointIndex == 0)
            {
                if (pathFigure.IsClosed && PathFigureUtilities.IsCloseSegmentDegenerate(pathFigure))
                {
                    segmentIndex      = pathFigure.Segments.Count - 1;
                    segmentPointIndex = PathSegmentUtilities.GetPointCount(segments[segmentIndex]) - 1;
                }
                else
                {
                    segmentIndex      = 0;
                    segmentPointIndex = -1;
                }
            }
            else
            {
                segmentIndex      = 0;
                segmentPointIndex = 0;
                int num        = 1;
                int pointCount = PathSegmentUtilities.GetPointCount(segments[segmentIndex]);
                while (pointCount < pointIndex)
                {
                    num         = pointCount + 1;
                    pointCount += PathSegmentUtilities.GetPointCount(segments[++segmentIndex]);
                }
                segmentPointIndex = pointIndex - num;
            }
        }
Ejemplo n.º 3
0
 public static void SetLastPoint(PathSegment segment, Point point)
 {
     if (PathSegmentUtilities.IsEmpty(segment))
     {
         throw new ArgumentException(ExceptionStringTable.CannotGetLastPointFromAnEmptySegment, "segment");
     }
     PathSegmentUtilities.SetPoint(segment, PathSegmentUtilities.GetPointCount(segment) - 1, point);
 }
Ejemplo n.º 4
0
        public static int PointCount(PathFigure figure)
        {
            int num = 1;

            foreach (PathSegment segment in figure.Segments)
            {
                num += PathSegmentUtilities.GetPointCount(segment);
            }
            if (PathFigureUtilities.IsClosed(figure) && PathFigureUtilities.IsCloseSegmentDegenerate(figure))
            {
                --num;
            }
            return(num);
        }
Ejemplo n.º 5
0
 public static bool IsEmpty(PathSegment segment)
 {
     return(PathSegmentUtilities.GetPointCount(segment) == 0);
 }
Ejemplo n.º 6
0
        public static void SetPoint(PathSegment segment, int index, Point point)
        {
            if (index < 0 || index >= PathSegmentUtilities.GetPointCount(segment))
            {
                throw new ArgumentOutOfRangeException("index", (object)index, "Index must be between zero and the segment point count.");
            }
            ArcSegment arcSegment;

            if ((arcSegment = segment as ArcSegment) != null)
            {
                arcSegment.Point = point;
            }
            else
            {
                LineSegment lineSegment;
                if ((lineSegment = segment as LineSegment) != null)
                {
                    lineSegment.Point = point;
                }
                else
                {
                    QuadraticBezierSegment quadraticBezierSegment1;
                    if ((quadraticBezierSegment1 = segment as QuadraticBezierSegment) != null)
                    {
                        if (index == 0)
                        {
                            quadraticBezierSegment1.Point1 = point;
                        }
                        else
                        {
                            quadraticBezierSegment1.Point2 = point;
                        }
                    }
                    else
                    {
                        BezierSegment bezierSegment;
                        if ((bezierSegment = segment as BezierSegment) != null)
                        {
                            if (index == 0)
                            {
                                bezierSegment.Point1 = point;
                            }
                            else if (index == 1)
                            {
                                bezierSegment.Point2 = point;
                            }
                            else
                            {
                                bezierSegment.Point3 = point;
                            }
                        }
                        else
                        {
                            PolyLineSegment polyLineSegment;
                            if ((polyLineSegment = segment as PolyLineSegment) != null)
                            {
                                polyLineSegment.Points[index] = point;
                            }
                            else
                            {
                                PolyQuadraticBezierSegment quadraticBezierSegment2;
                                if ((quadraticBezierSegment2 = segment as PolyQuadraticBezierSegment) != null)
                                {
                                    quadraticBezierSegment2.Points[index] = point;
                                }
                                else
                                {
                                    PolyBezierSegment polyBezierSegment;
                                    if ((polyBezierSegment = segment as PolyBezierSegment) != null)
                                    {
                                        polyBezierSegment.Points[index] = point;
                                    }
                                    else
                                    {
                                        throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.UnknownPathSegmentType, new object[1]
                                        {
                                            (object)segment.GetType().Name
                                        }), "segment");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }