Пример #1
0
        internal static void TranslateSelection(PathEditorTarget pathEditorTarget, ICollection <PathPart> pathParts, Vector offset)
        {
            List <BitArray> list = new List <BitArray>(pathEditorTarget.PathGeometry.Figures.Count);

            for (int index = 0; index < pathEditorTarget.PathGeometry.Figures.Count; ++index)
            {
                list.Add(new BitArray(PathFigureUtilities.PointCount(pathEditorTarget.PathGeometry.Figures[index]), false));
            }
            foreach (PathPart pathPart in (IEnumerable <PathPart>)pathParts)
            {
                PathPoint pathPoint = pathPart as PathPoint;
                if ((PathPart)pathPoint != (PathPart)null)
                {
                    if (pathPoint.PartIndex < list[pathPoint.FigureIndex].Count)
                    {
                        list[pathPoint.FigureIndex][pathPoint.PartIndex] = true;
                    }
                }
                else
                {
                    PathSegment pathSegment = pathPart as PathSegment;
                    if ((PathPart)pathSegment != (PathPart)null)
                    {
                        list[pathSegment.FigureIndex][pathSegment.PartIndex] = true;
                        PathFigure pathFigure = pathEditorTarget.PathGeometry.Figures[pathPart.FigureIndex];
                        if (pathFigure.IsClosed && pathPart.PartIndex == 0)
                        {
                            int num1 = PathFigureUtilities.PointCount(pathFigure);
                            int num2 = 1;
                            if (PathFigureUtilities.IsCloseSegmentDegenerate(pathFigure))
                            {
                                num2 = PathSegmentUtilities.GetPointCount(pathFigure.Segments[pathFigure.Segments.Count - 1]);
                            }
                            list[pathSegment.FigureIndex][num1 - num2] = true;
                        }
                        else
                        {
                            int segmentIndex;
                            int segmentPointIndex;
                            PathFigureUtilities.GetSegmentFromPointIndex(pathFigure, pathPart.PartIndex, out segmentIndex, out segmentPointIndex);
                            int pointCount = PathSegmentUtilities.GetPointCount(pathFigure.Segments[segmentIndex]);
                            int index      = pathSegment.PartIndex - pointCount;
                            if (index >= 0)
                            {
                                list[pathSegment.FigureIndex][index] = true;
                            }
                        }
                    }
                }
            }
            for (int figureIndex = 0; figureIndex < pathEditorTarget.PathGeometry.Figures.Count; ++figureIndex)
            {
                BitArray         bitArray         = list[figureIndex];
                PathFigureEditor pathFigureEditor = new PathFigureEditor(pathEditorTarget.PathGeometry.Figures[figureIndex], pathEditorTarget.PathDiffChangeList, figureIndex);
                int num = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure);
                for (int index = 0; index < num; ++index)
                {
                    if (bitArray[index])
                    {
                        pathFigureEditor.MovePoint(index, offset + pathFigureEditor.GetPoint(index));
                    }
                }
            }
        }