public static Point GetPoint(PathFigure pathFigure, int index, bool correspondingPoint) { if (index == 0) { return(pathFigure.StartPoint); } PathSegmentCollection segments = pathFigure.Segments; int segmentIndex; int segmentPointIndex; PathFigureUtilities.GetSegmentFromPointIndex(pathFigure, index, out segmentIndex, out segmentPointIndex); PathSegment segment = segments[segmentIndex]; if (correspondingPoint && segment is BezierSegment) { if (segmentPointIndex == 1) { segmentPointIndex = 2; } else if (segmentPointIndex == 0) { if (segmentIndex == 0) { return(pathFigure.StartPoint); } if (index > 0) { PathFigureUtilities.GetSegmentFromPointIndex(pathFigure, index - 1, out segmentIndex, out segmentPointIndex); segment = segments[segmentIndex]; } } } return(PathSegmentUtilities.GetPoint(segment, segmentPointIndex)); }
public static void SetPoint(PathFigure pathFigure, int pointIndex, Point point) { if (pointIndex == 0 || pointIndex == PathFigureUtilities.PointCount(pathFigure) && PathFigureUtilities.IsClosed(pathFigure) && !PathFigureUtilities.IsCloseSegmentDegenerate(pathFigure)) { pathFigure.StartPoint = point; } else { PathSegmentCollection segments = pathFigure.Segments; int segmentIndex; int segmentPointIndex; PathFigureUtilities.GetSegmentFromPointIndex(pathFigure, pointIndex, out segmentIndex, out segmentPointIndex); PathSegmentUtilities.SetPoint(segments[segmentIndex], segmentPointIndex, point); } }