Ejemplo n.º 1
0
        public int PromoteAdjacentSegments(PathEditContext pathEditContext)
        {
            int partIndex = pathEditContext.PartIndex;
            int index     = partIndex;
            PathFigureEditor figureEditor = this.PathEditorTarget.CreateFigureEditor(pathEditContext.FigureIndex);
            bool             flag         = false;

            if (figureEditor.GetPointKind(partIndex) != PathPointKind.Cubic && figureEditor.GetPointKind(partIndex) != PathPointKind.Start)
            {
                index = this.PromoteSegment(pathEditContext.FigureIndex, partIndex);
                if (index != partIndex)
                {
                    flag = true;
                }
            }
            int num = figureEditor.GetLastIndexOfDownstreamSegment(index) % PathFigureUtilities.PointCount(figureEditor.PathFigure);

            if (index != num && figureEditor.GetPointKind(num) != PathPointKind.Cubic && this.PromoteSegment(pathEditContext.FigureIndex, num) != num)
            {
                flag = true;
            }
            if (flag)
            {
                this.PathEditorTarget.EndEditing(false);
                this.PathEditorTarget.BeginEditing();
            }
            return(index);
        }
Ejemplo n.º 2
0
        protected override void OnDrag(MouseDevice mouseDevice, double zoom)
        {
            Point  point  = PathFigureUtilities.GetPoint(this.PathEditContext.GetPathFigure(this.Path), this.PathEditContext.PartIndex);
            Point  point1 = this.geometryToDocument.Transform(point);
            Point  viewRootCoordinates = this.GetPointInViewRootCoordinates(mouseDevice, true);
            Vector vector = viewRootCoordinates - point1;
            Vector correspondingVector = ElementUtilities.GetCorrespondingVector(vector, this.geometryToDocument, this.IsShiftDown ? this.AxisConstraint : (AxisConstraint)null);

            if (this.hasMoved || Tolerances.HaveMoved(point1, viewRootCoordinates, zoom))
            {
                this.hasMoved = true;
                PathGeometry       path               = this.Path;
                int                figureIndex        = this.PathEditContext.FigureIndex;
                int                partIndex          = this.PathEditContext.PartIndex;
                PathGeometryEditor pathGeometryEditor = this.BeginEditing();
                PathFigureEditor   pathFigureEditor   = new PathFigureEditor(path.Figures[figureIndex]);
                if (partIndex > 0 || PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure))
                {
                    pathGeometryEditor.SetPoint(figureIndex, partIndex - 1, point - correspondingVector);
                }
                if (pathFigureEditor.GetLastIndexOfDownstreamSegment(partIndex) != partIndex)
                {
                    pathGeometryEditor.SetPoint(figureIndex, partIndex + 1, point + correspondingVector);
                }
                if (partIndex == PathFigureUtilities.PointCount(pathFigureEditor.PathFigure) - 1 && PathFigureUtilities.IsOpen(pathFigureEditor.PathFigure))
                {
                    this.LastTangent = vector;
                }
                this.PathEditorTarget.AddCriticalEdit();
            }
            base.OnDrag(mouseDevice, zoom);
        }
Ejemplo n.º 3
0
        protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
        {
            this.View.ViewModel.PathPartSelectionSet.SetSelection((PathPart) new PathPoint((SceneElement)this.PathEditorTarget.EditingElement, this.PathEditorTarget.PathEditMode, pathEditContext.FigureIndex, pathEditContext.PartIndex));
            this.geometryToDocument = this.EditingElementTransformToRoot;
            int figureIndex = pathEditContext.FigureIndex;
            int num         = pathEditContext.PartIndex;
            PathFigureEditor pathFigureEditor = new PathFigureEditor(pathEditContext.GetPathFigure(this.Path));
            Point            point            = pathFigureEditor.GetPoint(num);
            int downstreamSegment             = pathFigureEditor.GetLastIndexOfDownstreamSegment(num);

            if (pathFigureEditor.GetPointKind(num) != PathPointKind.Cubic && pathFigureEditor.GetPointKind(num) != PathPointKind.Start || pathFigureEditor.GetPointKind(downstreamSegment) != PathPointKind.Cubic)
            {
                PathGeometryEditor pathGeometryEditor = this.BeginEditing();
                num = this.PromoteAdjacentSegments(pathEditContext);
                pathFigureEditor     = new PathFigureEditor(pathGeometryEditor.PathGeometry.Figures[figureIndex]);
                this.PathEditContext = new PathEditContext(figureIndex, num);
                this.View.ViewModel.PathPartSelectionSet.SetSelection((PathPart) new PathPoint((SceneElement)this.PathEditorTarget.EditingElement, this.PathEditorTarget.PathEditMode, this.PathEditContext.FigureIndex, this.PathEditContext.PartIndex));
            }
            if (this.zeroTangents)
            {
                if ((num > 0 || PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure)) && !VectorUtilities.ArePathPointsVeryClose(pathFigureEditor.GetPoint(num), pathFigureEditor.GetPoint(num - 1)))
                {
                    this.BeginEditing().SetPoint(figureIndex, num - 1, point);
                }
                if (pathFigureEditor.GetLastIndexOfDownstreamSegment(num) != num && !VectorUtilities.ArePathPointsVeryClose(pathFigureEditor.GetPoint(num), pathFigureEditor.GetPoint(num + 1)))
                {
                    this.BeginEditing().SetPoint(figureIndex, num + 1, point);
                }
                if (num == PathFigureUtilities.PointCount(pathFigureEditor.PathFigure) - 1 && PathFigureUtilities.IsOpen(pathFigureEditor.PathFigure))
                {
                    this.LastTangent = new Vector(0.0, 0.0);
                }
            }
            base.OnBegin(pathEditContext, mouseDevice);
        }
Ejemplo n.º 4
0
 public void Execute(ICollection <PathPart> pathPartSelection)
 {
     this.SplitComponentsByFigure(pathPartSelection);
     for (int figureIndex = this.pathEditorTarget.PathGeometry.Figures.Count - 1; figureIndex >= 0; --figureIndex)
     {
         List <int> segmentsByFigure = this.selectedSegments[figureIndex];
         List <int> pointsByFigure   = this.selectedPoints[figureIndex];
         segmentsByFigure.Sort();
         segmentsByFigure.Reverse();
         pointsByFigure.Sort();
         pointsByFigure.Reverse();
         if (segmentsByFigure.Count == 0)
         {
             this.RemovePointsByFigure(figureIndex, pointsByFigure);
         }
         else
         {
             if (PathFigureUtilities.IsClosed(this.pathEditorTarget.PathGeometry.Figures[figureIndex]))
             {
                 this.OpenFigureAndShiftIndices(figureIndex, segmentsByFigure, pointsByFigure);
             }
             this.RemovePointsAndSegmentsFromOpenFigure(figureIndex, segmentsByFigure, pointsByFigure);
         }
         if (PathFigureUtilities.IsIsolatedPoint(this.pathEditorTarget.PathGeometry.Figures[figureIndex]))
         {
             this.pathEditorTarget.CreateGeometryEditor().RemoveFigure(figureIndex);
         }
     }
 }
Ejemplo n.º 5
0
            private void OpenFigureAndShiftIndices(int figureIndex, List <int> segmentsByFigure, List <int> pointsByFigure)
            {
                PathFigureEditor figureEditor = this.pathEditorTarget.CreateFigureEditor(figureIndex);
                int pointIndex = segmentsByFigure[0];

                figureEditor.Open(pointIndex);
                if (pointIndex == 0)
                {
                    int num = PathFigureUtilities.PointCount(figureEditor.PathFigure) - 1;
                    segmentsByFigure[0] = num;
                }
                else
                {
                    int num = PathFigureUtilities.PointCount(figureEditor.PathFigure) - 1 - pointIndex;
                    for (int index = 0; index < segmentsByFigure.Count; ++index)
                    {
                        segmentsByFigure[index] = segmentsByFigure[index] + num;
                    }
                    for (int index = 0; index < pointsByFigure.Count; ++index)
                    {
                        pointsByFigure[index] = pointsByFigure[index] < pointIndex ? pointsByFigure[index] + num : pointsByFigure[index] - pointIndex;
                    }
                }
                segmentsByFigure.Sort();
                segmentsByFigure.Reverse();
                pointsByFigure.Sort();
                pointsByFigure.Reverse();
            }
Ejemplo n.º 6
0
        protected override void CreatePathAdorners(List <Adorner> oldAdornerList, List <Adorner> newAdornerList)
        {
            base.CreatePathAdorners(oldAdornerList, newAdornerList);
            this.lastTangentAdorner        = (PenTangentAdorner)null;
            this.activeSegmentAdornerIndex = -1;
            this.activePointAdornerIndex   = -1;
            if (!this.IsActive || this.AdornerList.Count <= 0 || (this.PathGeometry == null || this.PathGeometry.Figures.Count <= 0))
            {
                return;
            }
            int index1 = this.ActiveFigureIndex;

            if (index1 < 0 || index1 >= this.PathGeometry.Figures.Count)
            {
                index1 = 0;
            }
            PathFigure       figure            = this.PathGeometry.Figures[index1];
            int              num               = !PathFigureUtilities.IsClosed(figure) ? PathFigureUtilities.PointCount(figure) - 1 : 0;
            PathPointAdorner pathPointAdorner1 = (PathPointAdorner)null;

            for (int index2 = 0; index2 < this.AdornerList.Count; ++index2)
            {
                Adorner          adorner           = this.AdornerList[index2];
                PathPointAdorner pathPointAdorner2 = adorner as PathPointAdorner;
                if (pathPointAdorner2 != null)
                {
                    if (pathPointAdorner2.FigureIndex == this.ActiveFigureIndex && pathPointAdorner2.PointIndex == num)
                    {
                        pathPointAdorner2.IsActive   = true;
                        pathPointAdorner1            = pathPointAdorner2;
                        this.activePointAdornerIndex = index2;
                    }
                    else
                    {
                        pathPointAdorner2.IsActive = false;
                    }
                }
                PathSegmentAdorner pathSegmentAdorner = adorner as PathSegmentAdorner;
                if (pathSegmentAdorner != null)
                {
                    if (pathSegmentAdorner.FigureIndex == this.ActiveFigureIndex && pathSegmentAdorner.LastPointIndex == num)
                    {
                        pathSegmentAdorner.IsActive    = true;
                        this.activeSegmentAdornerIndex = index2;
                    }
                    else
                    {
                        pathSegmentAdorner.IsActive = false;
                    }
                }
            }
            if (pathPointAdorner1 == null || PathFigureUtilities.IsClosed(this.PathGeometry.Figures[this.ActiveFigureIndex]))
            {
                return;
            }
            this.lastTangentAdorner = new PenTangentAdorner(pathPointAdorner1);
            newAdornerList.Add((Adorner)this.lastTangentAdorner);
        }
Ejemplo n.º 7
0
        protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
        {
            this.ViewModel.PathPartSelectionSet.SetSelection((PathPart) new PathPoint((SceneElement)this.PathEditorTarget.EditingElement, this.PathEditorTarget.PathEditMode, pathEditContext.FigureIndex, pathEditContext.PartIndex));
            Point  point = PathFigureUtilities.GetPoint(pathEditContext.GetPathFigure(this.Path), pathEditContext.PartIndex);
            Matrix elementTransformToRoot = this.EditingElementTransformToRoot;

            this.Initialize(elementTransformToRoot.Transform(point), false, elementTransformToRoot);
            base.OnBegin(pathEditContext, mouseDevice);
        }
Ejemplo n.º 8
0
        protected override void OnDrag(MouseDevice mouseDevice, double zoom)
        {
            this.currentTangentPoint = this.GetPointInViewRootCoordinates(mouseDevice, true);
            Vector correspondingVector = ElementUtilities.GetCorrespondingVector(this.currentTangentPoint - this.currentNodePoint, this.geometryToDocument, this.IsShiftDown ? this.AxisConstraint : (AxisConstraint)null);
            Vector lastTangent         = this.LastTangent;

            this.LastTangent = correspondingVector;
            PathFigure       pathFigure       = this.PathEditContext.GetPathFigure(this.Path);
            PathFigureEditor pathFigureEditor = pathFigure == null ? (PathFigureEditor)null : new PathFigureEditor(pathFigure);

            if (pathFigureEditor != null && !PathFigureUtilities.IsIsolatedPoint(pathFigureEditor.PathFigure))
            {
                PathGeometryEditor pathGeometryEditor = this.BeginEditing();
                bool  flag   = PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure);
                int   index  = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure) - (flag ? 0 : 1);
                Point point1 = pathFigureEditor.GetPoint(index - 1);
                Point point2 = pathFigureEditor.GetPoint(index);
                if (pathFigureEditor.GetPointKind(index) == PathPointKind.Line)
                {
                    pathGeometryEditor.RemoveLastSegmentOfFigure(this.PathEditContext.FigureIndex);
                    if (flag)
                    {
                        pathGeometryEditor.CloseFigureWithCubicBezier(point1, point2, this.PathEditContext.FigureIndex);
                    }
                    else
                    {
                        pathGeometryEditor.AppendCubicBezier(point1, point2, point2, this.PathEditContext.FigureIndex);
                    }
                    pathFigureEditor = new PathFigureEditor(this.PathEditContext.GetPathFigure(this.Path));
                }
                if (!this.IsAltDown)
                {
                    if (!this.areTangentsSymmetric)
                    {
                        double length = this.LastTangent.Length;
                        if (length > 0.0)
                        {
                            int    num1 = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure);
                            double num2 = (pathFigureEditor.GetPoint(num1 - 1) - pathFigureEditor.GetPoint(num1 - 2)).Length / length;
                            pathGeometryEditor.SetPoint(this.PathEditContext.FigureIndex, num1 - 2, point2 - num2 * this.LastTangent);
                        }
                    }
                    else
                    {
                        int pointIndex = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure) - (PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure) ? 1 : 2);
                        pathGeometryEditor.SetPoint(this.PathEditContext.FigureIndex, pointIndex, point2 - this.LastTangent);
                    }
                }
                if (PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure) && pathFigureEditor.GetPointKind(3) == PathPointKind.Cubic && this.areTangentsSymmetric)
                {
                    pathGeometryEditor.SetPoint(this.PathEditContext.FigureIndex, 1, point2 + this.LastTangent);
                }
                this.PathEditorTarget.AddCriticalEdit();
            }
            base.OnDrag(mouseDevice, zoom);
        }
Ejemplo n.º 9
0
        private PenAction GetAction(PathPartAdorner adorner)
        {
            PenAction          penAction          = (PenAction)null;
            PathSegmentAdorner pathSegmentAdorner = adorner as PathSegmentAdorner;
            PathEditorTarget   pathEditorTarget   = (PathEditorTarget)null;

            if (adorner != null)
            {
                pathEditorTarget = adorner.PathAdornerSet.PathEditorTarget;
            }
            if (pathSegmentAdorner != null)
            {
                penAction = (PenAction) new InsertAction(pathEditorTarget, this.ActiveSceneViewModel);
            }
            else
            {
                PathPointAdorner pathPointAdorner = adorner as PathPointAdorner;
                if (pathPointAdorner != null)
                {
                    penAction = (PenAction) new DeletePointAction(pathEditorTarget, this.ActiveSceneViewModel);
                    PathFigure figure1 = pathEditorTarget.PathGeometry.Figures[pathPointAdorner.FigureIndex];
                    if (PathFigureUtilities.IsOpen(figure1) && !PathFigureUtilities.IsIsolatedPoint(figure1))
                    {
                        bool       flag1   = pathPointAdorner.PointIndex == 0;
                        bool       flag2   = pathPointAdorner.PointIndex == PathFigureUtilities.PointCount(figure1) - 1;
                        bool       flag3   = pathPointAdorner.PathAdornerSet.PathEditorTarget == this.pathEditorTarget;
                        bool       flag4   = this.pathEditContext != null && pathPointAdorner.FigureIndex == this.pathEditContext.FigureIndex;
                        bool       flag5   = this.pathEditorTarget != null && pathPointAdorner.PathAdornerSet.PathEditorTarget.PathEditMode == this.pathEditorTarget.PathEditMode;
                        bool       flag6   = pathPointAdorner.PathAdornerSet.PathEditorTarget.PathEditMode == PathEditMode.ScenePath;
                        PathFigure figure2 = this.pathEditContext == null || this.pathEditorTarget == null ? (PathFigure)null : this.pathEditContext.GetPathFigure(this.pathEditorTarget.PathGeometry);
                        bool       flag7   = figure2 != null && PathFigureUtilities.IsOpen(figure2);
                        bool       flag8   = (flag3 && !flag4 || flag5 && flag6) && flag7;
                        if (flag1)
                        {
                            penAction = !flag3 || !flag4 ? (!flag8 ? (PenAction) new ExtendAction(pathEditorTarget, this.ActiveSceneViewModel) : (PenAction) new JoinAction(pathEditorTarget, this.ActiveSceneViewModel, this.pathEditorTarget, this.pathEditContext)) : (PenAction) new CloseAction(pathEditorTarget, this.ActiveSceneViewModel);
                        }
                        else if (flag2)
                        {
                            penAction = !flag3 || !flag4 ? (!flag8 ? (PenAction) new ExtendAction(pathEditorTarget, this.ActiveSceneViewModel) : (PenAction) new JoinAction(pathEditorTarget, this.ActiveSceneViewModel, this.pathEditorTarget, this.pathEditContext)) : (PenAction) new AdjustAction(pathEditorTarget, this.ActiveSceneViewModel);
                        }
                    }
                    if (PathFigureUtilities.IsIsolatedPoint(figure1) && this.pathEditContext == null)
                    {
                        penAction = (PenAction) new ExtendAction(pathEditorTarget, this.ActiveSceneViewModel);
                    }
                }
            }
            if (penAction == null)
            {
                penAction = !this.IsActive || this.pathEditorTarget == null || (this.pathEditorTarget.PathGeometry.Figures.Count <= 0 || this.pathEditorTarget.PathGeometry.Figures[this.pathEditorTarget.PathGeometry.Figures.Count - 1].IsClosed) ? (PenAction) new StartAction(this, (PathEditorTarget)null, this.ActiveSceneViewModel) : (PenAction) new AppendAction(this.pathEditorTarget, this.ActiveSceneViewModel);
            }
            return(penAction);
        }
Ejemplo n.º 10
0
            private void RemovePointsAndSegmentsFromOpenFigure(int figureIndex, List <int> segmentsByFigure, List <int> pointsByFigure)
            {
                PathGeometryEditor geometryEditor = this.pathEditorTarget.CreateGeometryEditor();
                int index1 = 0;
                int index2 = 0;

                while (index1 < segmentsByFigure.Count || index2 < pointsByFigure.Count)
                {
                    int pointIndex1 = -1;
                    int pointIndex2 = -1;
                    if (index1 < segmentsByFigure.Count)
                    {
                        pointIndex1 = segmentsByFigure[index1];
                    }
                    if (index2 < pointsByFigure.Count)
                    {
                        pointIndex2 = pointsByFigure[index2];
                    }
                    int num = PathFigureUtilities.PointCount(geometryEditor.PathGeometry.Figures[figureIndex]) - 1;
                    if (pointIndex2 == num || pointIndex1 == num)
                    {
                        geometryEditor.RemoveLastSegmentOfFigure(figureIndex);
                        if (pointIndex2 == num)
                        {
                            ++index2;
                        }
                        if (pointIndex1 == num)
                        {
                            ++index1;
                        }
                    }
                    else if (pointIndex1 > pointIndex2)
                    {
                        geometryEditor.SplitFigure(figureIndex, pointIndex1);
                        geometryEditor.RemoveLastSegmentOfFigure(figureIndex);
                        ++index1;
                    }
                    else if (pointIndex1 < pointIndex2)
                    {
                        geometryEditor.RemovePoint(figureIndex, pointIndex2);
                        ++index2;
                    }
                    else
                    {
                        geometryEditor.SplitFigure(figureIndex, pointIndex2);
                        geometryEditor.RemoveLastSegmentOfFigure(figureIndex);
                        geometryEditor.RemoveFirstSegmentOfFigure(geometryEditor.PathGeometry.Figures.Count - 1);
                        ++index2;
                        ++index1;
                    }
                }
            }
Ejemplo n.º 11
0
        protected override void DoDelete(PathEditContext pathEditContext)
        {
            PathFigure       pathFigure       = pathEditContext.GetPathFigure(this.Path);
            PathFigureEditor pathFigureEditor = new PathFigureEditor(pathFigure);
            int index1 = PathFigureUtilities.PointCount(pathFigure) - (PathFigureUtilities.IsClosed(pathFigure) ? 0 : 1);

            if (pathFigureEditor.GetPointKind(index1) == PathPointKind.Cubic)
            {
                int index2 = index1 - 3;
                this.LastTangent = pathFigureEditor.GetPoint(index2 + 1) - pathFigureEditor.GetPoint(index2);
            }
            this.BeginEditing().RemoveLastSegmentOfFigure(pathEditContext.FigureIndex);
        }
Ejemplo n.º 12
0
        public static List <PathElement> ReleaseCompoundPaths(PathElement pathElement, SceneEditTransaction editTransaction)
        {
            List <PathElement> list              = new List <PathElement>();
            PathGeometry       pathGeometry1     = pathElement.PathGeometry;
            Transform          geometryTransform = pathElement.GeometryTransform;
            ISceneNodeCollection <SceneNode> collectionContainer = pathElement.GetCollectionContainer();
            int num            = collectionContainer.IndexOf((SceneNode)pathElement);
            int oldFigureIndex = 0;

            foreach (PathFigure original in pathGeometry1.Figures)
            {
                PathFigure   pathFigure    = PathFigureUtilities.Copy(original, geometryTransform);
                PathGeometry pathGeometry2 = new PathGeometry();
                if (pathGeometry1.Transform != null && pathGeometry1.Transform.Value != Matrix.Identity)
                {
                    pathGeometry2.Transform = pathGeometry1.Transform.Clone();
                }
                if (pathGeometry2.FillRule != pathGeometry1.FillRule)
                {
                    pathGeometry2.FillRule = pathGeometry1.FillRule;
                }
                pathGeometry2.Figures.Add(pathFigure);
                DocumentNode node         = pathElement.DocumentNode.Clone(pathElement.DocumentContext);
                PathElement  pathElement1 = (PathElement)pathElement.ViewModel.GetSceneNode(node);
                collectionContainer.Insert(num++, (SceneNode)pathElement1);
                Rect extent = pathGeometry2.Bounds;
                extent = PathCommandHelper.InflateRectByStrokeWidth(extent, pathElement1, false);
                Vector vector = new Vector(-extent.Left, -extent.Top);
                PathCommandHelper.ReplacePathGeometry(pathElement1, pathGeometry2, editTransaction);
                Matrix transformToElement = pathElement.GetComputedTransformToElement((SceneElement)pathElement1);
                transformToElement.OffsetX += vector.X;
                transformToElement.OffsetY += vector.Y;
                PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(pathElement.Platform);
                PathCommandHelper.TransferPathFigureAnimations(pathElement, pathElement1, propertyReference, oldFigureIndex, 0, (Transform) new MatrixTransform(transformToElement));
                PathCommandHelper.AdjustPathForAnimations(pathElement1, editTransaction);
                list.Add(pathElement1);
                ++oldFigureIndex;
            }
            string name = pathElement.Name;

            pathElement.ViewModel.ElementSelectionSet.RemoveSelection((SceneElement)pathElement);
            pathElement.ViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)pathElement);
            pathElement.Remove();
            foreach (SceneNode sceneNode in list)
            {
                sceneNode.Name = name;
            }
            return(list);
        }
Ejemplo n.º 13
0
 private void DeleteIsolatedPoint(PathEditContext pathEditContext)
 {
     if (!PathFigureUtilities.IsIsolatedPoint(pathEditContext.GetPathFigure(this.Path)))
     {
         return;
     }
     if (this.Path.Figures.Count > 1)
     {
         this.BeginEditing().RemoveFigure(pathEditContext.FigureIndex);
     }
     else
     {
         this.RemovePath();
     }
 }
Ejemplo n.º 14
0
 protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
 {
     this.DoPreDelete();
     if (!PathFigureUtilities.IsIsolatedPoint(pathEditContext.GetPathFigure(this.Path)))
     {
         this.DoDelete(pathEditContext);
         if (this.PathEditorTarget.PathEditMode == PathEditMode.MotionPath)
         {
             this.DeleteIsolatedPoint(pathEditContext);
         }
     }
     else
     {
         this.DeleteIsolatedPoint(pathEditContext);
     }
     base.OnBegin(pathEditContext, mouseDevice);
     this.End();
 }
Ejemplo n.º 15
0
        protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
        {
            PathGeometryEditor pathGeometryEditor = this.BeginEditing();
            Point  point = PathFigureUtilities.FirstPoint(pathEditContext.GetPathFigure(this.Path));
            Matrix elementTransformToRoot = this.EditingElementTransformToRoot;

            if (VectorUtilities.IsZero(this.LastTangent))
            {
                pathGeometryEditor.CloseFigureWithLineSegment(pathEditContext.FigureIndex);
            }
            else
            {
                Point q = this.GetLastPoint(pathEditContext.FigureIndex) + this.LastTangent;
                pathGeometryEditor.CloseFigureWithCubicBezier(q, point, pathEditContext.FigureIndex);
            }
            this.Initialize(elementTransformToRoot.Transform(point), true, elementTransformToRoot);
            base.OnBegin(pathEditContext, mouseDevice);
        }
Ejemplo n.º 16
0
        protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
        {
            PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.EditPath);
            Vector lastTangent = this.LastTangent;

            base.OnBegin(pathEditContext, mouseDevice);
            PathGeometryEditor pathGeometryEditor     = this.BeginEditing();
            Matrix             elementTransformToRoot = this.EditingElementTransformToRoot;
            Point  lastPoint       = this.GetLastPoint(pathEditContext.FigureIndex);
            Point  point1          = elementTransformToRoot.Transform(lastPoint);
            Vector vector          = this.GetPointInViewRootCoordinates(mouseDevice, true) - point1;
            Size   devicePixelSize = DeviceUtilities.GetDevicePixelSize(this.View.Zoom);

            if (Math.Abs(vector.X) < devicePixelSize.Width / 2.0)
            {
                vector.X = 0.0;
            }
            if (Math.Abs(vector.Y) < devicePixelSize.Height / 2.0)
            {
                vector.Y = 0.0;
            }
            Vector correspondingVector = ElementUtilities.GetCorrespondingVector(vector, elementTransformToRoot, this.IsShiftDown ? this.AxisConstraint : (AxisConstraint)null);
            Point  point2 = lastPoint + correspondingVector;

            if (VectorUtilities.IsZero(lastTangent))
            {
                pathGeometryEditor.AppendLineSegment(point2, pathEditContext.FigureIndex);
            }
            else
            {
                Point q = lastPoint + lastTangent;
                pathGeometryEditor.AppendCubicBezier(q, point2, point2, pathEditContext.FigureIndex);
            }
            int        figureIndex = pathEditContext.FigureIndex;
            PathFigure figure      = this.Path.Figures[figureIndex];

            this.PathEditContext = new PathEditContext(figureIndex, PathFigureUtilities.PointCount(figure) - 1);
            this.Initialize(elementTransformToRoot.Transform(point2), true, elementTransformToRoot);
        }
Ejemplo n.º 17
0
 public static void UpdateAllPoints(PathGeometry geometry, Transform transform)
 {
     for (int index1 = 0; index1 < geometry.Figures.Count; ++index1)
     {
         PathFigure       figure           = geometry.Figures[index1];
         PathFigureEditor pathFigureEditor = new PathFigureEditor(figure);
         int index2 = 1;
         if (!PathFigureUtilities.IsClosed(figure) || !PathFigureUtilities.IsCloseSegmentDegenerate(figure))
         {
             pathFigureEditor.SetPoint(0, transform.Transform(figure.StartPoint));
         }
         for (int index3 = 0; index3 < figure.Segments.Count; ++index3)
         {
             System.Windows.Media.PathSegment segment = figure.Segments[index3];
             int pointCount = PathSegmentUtilities.GetPointCount(segment);
             for (int index4 = 0; index4 < pointCount; ++index4)
             {
                 Point point = PathSegmentUtilities.GetPoint(segment, index4);
                 pathFigureEditor.SetPoint(index2, transform.Transform(point));
                 ++index2;
             }
         }
     }
 }
Ejemplo n.º 18
0
        private void SubdivideSegment(PathGeometry oldGeometry, int figure, int segment, int pointIndex, double parameter, Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> subdivisionProperties)
        {
            PropertyReference propertyReference1 = new PropertyReference(this.pathProperty).Append(PathElement.FiguresProperty).Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathFigureCollection, figure));
            PropertyReference propertyReference2 = propertyReference1.Append(PathElement.PathFigureSegmentsProperty);
            PropertyReference propertyReference3 = segment != oldGeometry.Figures[figure].Segments.Count ? propertyReference2.Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathSegmentCollection, segment)) : propertyReference1.Append(PathElement.PathFigureStartPointProperty);
            PropertyReference propertyReference4;

            if (segment == 0)
            {
                propertyReference4 = propertyReference1.Append(PathElement.PathFigureStartPointProperty);
            }
            else
            {
                ReferenceStep step = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathSegmentCollection, segment - 1);
                propertyReference4 = propertyReference2.Append(step).Append(this.LastPointProperty(oldGeometry.Figures[figure].Segments[segment - 1]));
            }
            PropertyReference propertyReference5 = (PropertyReference)null;

            if (segment == oldGeometry.Figures[figure].Segments.Count - 1 && PathFigureUtilities.IsClosed(oldGeometry.Figures[figure]) && PathFigureUtilities.IsCloseSegmentDegenerate(oldGeometry.Figures[figure]))
            {
                propertyReference5 = propertyReference1.Append(PathElement.PathFigureStartPointProperty);
            }
            foreach (StoryboardTimelineSceneNode timelineSceneNode1 in this.targetElement.ViewModel.AnimationEditor.EnumerateStoryboardsForContainer(this.targetElement.StoryboardContainer))
            {
                Dictionary <double, List <KeyFrameSceneNode> > keyFrames1 = new Dictionary <double, List <KeyFrameSceneNode> >();
                foreach (KeyValuePair <TimelineSceneNode, StoryboardTimelineSceneNode> keyValuePair in subdivisionProperties)
                {
                    if (keyValuePair.Value == timelineSceneNode1)
                    {
                        KeyFrameAnimationSceneNode keyFrameNode = keyValuePair.Key as KeyFrameAnimationSceneNode;
                        if (keyFrameNode != null)
                        {
                            this.RecordKeyFrames(keyFrames1, keyFrameNode);
                        }
                    }
                }
                Dictionary <double, List <KeyFrameSceneNode> > keyFrames2 = new Dictionary <double, List <KeyFrameSceneNode> >();
                foreach (TimelineSceneNode timelineSceneNode2 in (IEnumerable <TimelineSceneNode>)timelineSceneNode1.Children)
                {
                    if (timelineSceneNode2.TargetElement == this.targetElement && timelineSceneNode2.TargetProperty != null && (propertyReference3.Equals((object)timelineSceneNode2.TargetProperty) || propertyReference3.IsPrefixOf(timelineSceneNode2.TargetProperty) || propertyReference4.Equals((object)timelineSceneNode2.TargetProperty) || propertyReference5 != null && propertyReference5.Equals((object)timelineSceneNode2.TargetProperty)))
                    {
                        KeyFrameAnimationSceneNode keyFrameNode = timelineSceneNode2 as KeyFrameAnimationSceneNode;
                        if (keyFrameNode != null)
                        {
                            this.RecordKeyFrames(keyFrames2, keyFrameNode);
                        }
                    }
                }
                foreach (KeyValuePair <double, List <KeyFrameSceneNode> > keyValuePair in keyFrames2)
                {
                    PathGeometry       path = oldGeometry.Clone();
                    PathGeometryEditor pathGeometryEditor = new PathGeometryEditor(path);
                    foreach (KeyFrameSceneNode keyFrameSceneNode in keyValuePair.Value)
                    {
                        PropertyReference propertyReference6 = this.targetElement.ViewModel.DefaultView.ConvertToWpfPropertyReference(keyFrameSceneNode.TargetProperty.Subreference(1));
                        object            valueToSet         = this.targetElement.ViewModel.DefaultView.ConvertToWpfValue(keyFrameSceneNode.Value);
                        propertyReference6.SetValue((object)path, valueToSet);
                    }
                    pathGeometryEditor.SubdivideSegment(figure, pointIndex, parameter);
                    List <KeyFrameSceneNode> list;
                    if (keyFrames1.TryGetValue(keyValuePair.Key, out list))
                    {
                        foreach (KeyFrameSceneNode keyFrameSceneNode in list)
                        {
                            object obj = this.targetElement.ViewModel.DefaultView.ConvertFromWpfValue(this.targetElement.ViewModel.DefaultView.ConvertToWpfPropertyReference(keyFrameSceneNode.TargetProperty.Subreference(1)).GetCurrentValue((object)path));
                            keyFrameSceneNode.Value = obj;
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
        private void MoveSelection()
        {
            Matrix             matrixToAdornerLayer = this.pathPartAdorner.PathAdornerSet.GetTransformMatrixToAdornerLayer();
            Point              pointInAdornerLayer  = this.GetSnappedPointInAdornerLayer();
            PathTangentAdorner pathTangentAdorner   = this.pathPartAdorner as PathTangentAdorner;
            PathEditContext    pathEditContext      = new PathEditContext(this.pathPartAdorner.FigureIndex, this.pathPartAdorner.PartIndex);

            if (pathTangentAdorner != null)
            {
                this.EnsureEditTransaction();
                this.pathEditorTarget.BeginEditing();
                if (!this.HasMouseMovedAfterDown)
                {
                    this.startRootPoint     = PathFigureUtilities.GetPoint(this.pathEditorTarget.PathGeometry.Figures[pathEditContext.FigureIndex], pathEditContext.PartIndex, false);
                    this.correspondingPoint = PathFigureUtilities.GetPoint(this.pathEditorTarget.PathGeometry.Figures[pathEditContext.FigureIndex], pathEditContext.PartIndex, true);
                }
                Point  point = this.IsShiftDown ? this.correspondingPoint : this.startRootPoint;
                Vector correspondingVector = ElementUtilities.GetCorrespondingVector(pointInAdornerLayer - point * matrixToAdornerLayer, matrixToAdornerLayer, this.IsShiftDown ? this.axisConstraint : (AxisConstraint)null);
                new PathFigureEditor(pathEditContext.GetPathFigure(this.pathEditorTarget.PathGeometry)).MoveTangent(pathEditContext.PartIndex, point + correspondingVector, this.isEnforcingSmoothness);
                this.ActiveView.AdornerLayer.InvalidateAdornerVisuals(this.EditingElement);
            }
            else
            {
                this.EnsureEditTransaction();
                PathPointAdorner   pathPointAdorner   = this.pathPartAdorner as PathPointAdorner;
                PathSegmentAdorner pathSegmentAdorner = this.pathPartAdorner as PathSegmentAdorner;
                this.pathPartAdorner.PathAdornerSet.PathEditorTarget.BeginEditing();
                if (!this.HasMouseMovedAfterDown)
                {
                    Point point;
                    if (pathPointAdorner != null)
                    {
                        point = PathFigureUtilities.GetPoint(pathEditContext.GetPathFigure(this.pathEditorTarget.PathGeometry), pathEditContext.PartIndex);
                    }
                    else
                    {
                        PathFigureEditor pathFigureEditor = new PathFigureEditor(pathEditContext.GetPathFigure(this.pathEditorTarget.PathGeometry));
                        int segmentIndex;
                        int segmentPointIndex;
                        PathFigureUtilities.GetSegmentFromPointIndex(pathEditContext.GetPathFigure(this.pathEditorTarget.PathGeometry), pathEditContext.PartIndex, out segmentIndex, out segmentPointIndex);
                        point = pathFigureEditor.Evaluate(segmentIndex, segmentPointIndex, this.pathSegmentParameter) * pathSegmentAdorner.PathGeometryTransformMatrix;
                    }
                    this.startRootPoint    = point;
                    this.previousRootPoint = this.startRootPoint;
                }
                Vector correspondingVector = ElementUtilities.GetCorrespondingVector(pointInAdornerLayer - this.startRootPoint * matrixToAdornerLayer, matrixToAdornerLayer, this.IsShiftDown ? this.axisConstraint : (AxisConstraint)null);
                double zoom = this.ActiveView.Artboard.Zoom;
                Vector rootToArtboardScale = this.ActiveView.Artboard.ViewRootToArtboardScale;
                correspondingVector.X /= zoom * rootToArtboardScale.X;
                correspondingVector.Y /= zoom * rootToArtboardScale.Y;
                Vector vector = this.startRootPoint - this.previousRootPoint + correspondingVector;
                this.previousRootPoint = this.startRootPoint + correspondingVector;
                Vector deltaOffset = matrixToAdornerLayer.Transform(vector);
                PathPartSelectionSet partSelectionSet = this.ActiveSceneViewModel.PathPartSelectionSet;
                if (partSelectionSet == null)
                {
                    return;
                }
                foreach (BaseFrameworkElement sceneElement in (IEnumerable <SceneElement>)partSelectionSet.SelectedPaths)
                {
                    this.MovePathParts(partSelectionSet, sceneElement, PathEditMode.ScenePath, deltaOffset);
                    this.MovePathParts(partSelectionSet, sceneElement, PathEditMode.MotionPath, deltaOffset);
                    this.MovePathParts(partSelectionSet, sceneElement, PathEditMode.ClippingPath, deltaOffset);
                }
            }
        }
Ejemplo n.º 20
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));
                    }
                }
            }
        }
Ejemplo n.º 21
0
 protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
 {
     this.startRootPoint     = PathFigureUtilities.GetPoint(this.PathEditorTarget.PathGeometry.Figures[pathEditContext.FigureIndex], pathEditContext.PartIndex, true);
     this.geometryToDocument = this.PathEditorTarget.GetTransformToAncestor((IViewObject)this.View.HitTestRoot);
     base.OnBegin(pathEditContext, mouseDevice);
 }
Ejemplo n.º 22
0
        protected virtual void CreatePathAdorners(List <Adorner> oldAdornerList, List <Adorner> newAdornerList)
        {
            this.adornerCounts.Clear();
            this.adornerOffsets.Clear();
            PathPartSelectionSet      partSelectionSet = this.PathPartSelectionSet;
            List <PathPointAdorner>   list1            = new List <PathPointAdorner>();
            List <PathSegmentAdorner> list2            = new List <PathSegmentAdorner>();
            List <PathTangentAdorner> list3            = new List <PathTangentAdorner>();
            int index1 = 0;
            int index2 = 0;
            int index3 = 0;

            foreach (Adorner adorner in oldAdornerList)
            {
                PathPointAdorner pathPointAdorner;
                if ((pathPointAdorner = adorner as PathPointAdorner) != null)
                {
                    list1.Add(pathPointAdorner);
                }
                else
                {
                    PathSegmentAdorner pathSegmentAdorner;
                    if ((pathSegmentAdorner = adorner as PathSegmentAdorner) != null)
                    {
                        list2.Add(pathSegmentAdorner);
                    }
                    else
                    {
                        PathTangentAdorner pathTangentAdorner;
                        if ((pathTangentAdorner = adorner as PathTangentAdorner) != null)
                        {
                            list3.Add(pathTangentAdorner);
                        }
                    }
                }
            }
            for (int figureIndex = 0; figureIndex < this.PathGeometry.Figures.Count; ++figureIndex)
            {
                PathFigure       figure           = this.PathGeometry.Figures[figureIndex];
                PathFigureEditor pathFigureEditor = new PathFigureEditor(figure);
                this.adornerOffsets.Add((object)this.AdornerList.Count);
                int length1 = PathFigureUtilities.PointCount(figure);
                int length2 = length1 + (PathFigureUtilities.IsClosed(figure) ? true : false);
                PathSegmentAdorner[] pathSegmentAdornerArray = new PathSegmentAdorner[length2];
                PathPointKind[]      pathPointKindArray      = new PathPointKind[length2];
                pathPointKindArray[0] = pathFigureEditor.GetPointKind(0);
                int num1 = 1;
                for (int index4 = 0; index4 < figure.Segments.Count; ++index4)
                {
                    System.Windows.Media.PathSegment segment = figure.Segments[index4];
                    int pointCount = PathSegmentUtilities.GetPointCount(segment);
                    for (int index5 = 0; index5 < pointCount; ++index5)
                    {
                        pathPointKindArray[num1++] = PathSegmentUtilities.GetPointKind(segment, index5);
                    }
                }
                int index6 = 1;
                for (int segmentIndex = 0; segmentIndex < figure.Segments.Count; ++segmentIndex)
                {
                    int pointCount = PathSegmentUtilities.GetPointCount(figure.Segments[segmentIndex]);
                    for (int segmentPointIndex = 0; segmentPointIndex < pointCount; ++segmentPointIndex)
                    {
                        if (pathPointKindArray[index6] != PathPointKind.BezierHandle)
                        {
                            PathSegmentAdorner pathSegmentAdorner;
                            if (index2 < list2.Count)
                            {
                                pathSegmentAdorner = list2[index2];
                                pathSegmentAdorner.Initialize(figureIndex, index6 % length1, segmentIndex, segmentPointIndex);
                                oldAdornerList.Remove((Adorner)pathSegmentAdorner);
                                ++index2;
                            }
                            else
                            {
                                pathSegmentAdorner = new PathSegmentAdorner(this, figureIndex, index6 % length1, segmentIndex, segmentPointIndex);
                            }
                            if (partSelectionSet != null)
                            {
                                pathSegmentAdorner.IsActive = partSelectionSet.IsSelected((PathPart)(PathSegment)pathSegmentAdorner);
                            }
                            newAdornerList.Add((Adorner)pathSegmentAdorner);
                            pathSegmentAdornerArray[index6] = pathSegmentAdorner;
                        }
                        else
                        {
                            pathSegmentAdornerArray[index6] = (PathSegmentAdorner)null;
                        }
                        ++index6;
                    }
                }
                if (figure.IsClosed && figure.Segments.Count > 0)
                {
                    Point lastPoint = PathSegmentUtilities.GetLastPoint(figure.Segments[figure.Segments.Count - 1]);
                    if (!VectorUtilities.ArePathPointsVeryClose(figure.StartPoint, lastPoint))
                    {
                        PathSegmentAdorner pathSegmentAdorner;
                        if (index2 < list2.Count)
                        {
                            pathSegmentAdorner = list2[index2];
                            pathSegmentAdorner.Initialize(figureIndex, index6 % length1, -1, 0);
                            oldAdornerList.Remove((Adorner)pathSegmentAdorner);
                            ++index2;
                        }
                        else
                        {
                            pathSegmentAdorner = new PathSegmentAdorner(this, figureIndex, index6 % length1, -1, 0);
                        }
                        if (partSelectionSet != null)
                        {
                            pathSegmentAdorner.IsActive = partSelectionSet.IsSelected((PathPart)(PathSegment)pathSegmentAdorner);
                        }
                        newAdornerList.Add((Adorner)pathSegmentAdorner);
                        pathSegmentAdornerArray[index6] = pathSegmentAdorner;
                    }
                }
                this.adornerCounts.Add((object)(this.AdornerList.Count - (int)this.adornerOffsets[this.adornerOffsets.Count - 1]));
                this.adornerTypes.Add((object)PathPart.PartType.PathSegment);
                PathPointAdorner[] pathPointAdornerArray = new PathPointAdorner[length1];
                int index7 = 0;
                for (int segmentIndex = -1; segmentIndex < figure.Segments.Count; ++segmentIndex)
                {
                    int num2 = 1;
                    if (segmentIndex != -1)
                    {
                        num2 = PathSegmentUtilities.GetPointCount(figure.Segments[segmentIndex]);
                    }
                    for (int segmentPointIndex = 0; segmentPointIndex < num2 && index7 < length1; ++segmentPointIndex)
                    {
                        if (pathPointKindArray[index7] == PathPointKind.BezierHandle)
                        {
                            pathPointAdornerArray[index7] = (PathPointAdorner)null;
                        }
                        else
                        {
                            PathPointAdorner pathPointAdorner;
                            if (index1 < list1.Count)
                            {
                                pathPointAdorner = list1[index1];
                                pathPointAdorner.Initialize(figureIndex, index7, segmentIndex, segmentPointIndex);
                                oldAdornerList.Remove((Adorner)pathPointAdorner);
                                ++index1;
                            }
                            else
                            {
                                pathPointAdorner = new PathPointAdorner(this, figureIndex, index7, segmentIndex, segmentPointIndex);
                            }
                            pathPointAdornerArray[index7] = pathPointAdorner;
                            if (partSelectionSet != null)
                            {
                                pathPointAdornerArray[index7].IsActive = partSelectionSet.IsSelected((PathPart)(PathPoint)pathPointAdornerArray[index7]);
                            }
                        }
                        ++index7;
                    }
                }
                int endPointIndex = 0;
                for (int segmentIndex = -1; segmentIndex < figure.Segments.Count; ++segmentIndex)
                {
                    int num2 = 1;
                    if (segmentIndex != -1)
                    {
                        num2 = PathSegmentUtilities.GetPointCount(figure.Segments[segmentIndex]);
                    }
                    for (int segmentPointIndex = 0; segmentPointIndex < num2 && endPointIndex < length1; ++segmentPointIndex)
                    {
                        if (pathPointKindArray[endPointIndex] == PathPointKind.BezierHandle)
                        {
                            PathPointAdorner   pathPointAdorner   = (PathPointAdorner)null;
                            PathSegmentAdorner pathSegmentAdorner = (PathSegmentAdorner)null;
                            if (pathPointKindArray[endPointIndex] == PathPointKind.BezierHandle && endPointIndex + 2 < pathPointKindArray.Length && pathPointKindArray[endPointIndex + 2] == PathPointKind.Cubic)
                            {
                                pathPointAdorner   = pathPointAdornerArray[endPointIndex - 1];
                                pathSegmentAdorner = pathSegmentAdornerArray[endPointIndex + 2];
                            }
                            else if (pathPointKindArray[endPointIndex] == PathPointKind.BezierHandle && endPointIndex + 1 < pathPointKindArray.Length && pathPointKindArray[endPointIndex + 1] == PathPointKind.Cubic)
                            {
                                pathPointAdorner   = pathPointAdornerArray[(endPointIndex + 1) % length1];
                                pathSegmentAdorner = pathSegmentAdornerArray[endPointIndex + 1];
                            }
                            if (pathPointAdorner != null)
                            {
                                PathTangentAdorner pathTangentAdorner;
                                if (index3 < list3.Count)
                                {
                                    pathTangentAdorner = list3[index3];
                                    pathTangentAdorner.Initialize(figureIndex, endPointIndex, segmentIndex, segmentPointIndex, pathPointAdorner, pathSegmentAdorner);
                                    oldAdornerList.Remove((Adorner)pathTangentAdorner);
                                    ++index3;
                                }
                                else
                                {
                                    pathTangentAdorner = new PathTangentAdorner(this, figureIndex, endPointIndex, segmentIndex, segmentPointIndex, pathPointAdorner, pathSegmentAdorner);
                                }
                                newAdornerList.Add((Adorner)pathTangentAdorner);
                            }
                        }
                        ++endPointIndex;
                    }
                }
                foreach (PathPointAdorner pathPointAdorner in pathPointAdornerArray)
                {
                    if (pathPointAdorner != null)
                    {
                        newAdornerList.Add((Adorner)pathPointAdorner);
                    }
                }
                this.adornerOffsets.Add((object)this.AdornerList.Count);
                this.adornerCounts.Add((object)(this.AdornerList.Count - (int)this.adornerOffsets[this.adornerOffsets.Count - 1]));
                this.adornerTypes.Add((object)PathPart.PartType.PathPoint);
            }
        }
Ejemplo n.º 23
0
        protected Point GetLastPoint(int pathFigureIndex)
        {
            PathFigure pathFigure = this.Path.Figures[pathFigureIndex];

            return(PathFigureUtilities.GetPoint(pathFigure, PathFigureUtilities.PointCount(pathFigure) - 1));
        }
Ejemplo n.º 24
0
        protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
        {
            BaseFrameworkElement frameworkElement = this.oldPathEditorTarget.EditingElement.GetCommonAncestor((SceneNode)this.EditingElement) as BaseFrameworkElement;
            Base2DElement        editingElement   = this.oldPathEditorTarget.EditingElement;
            Base2DElement        base2Delement    = (Base2DElement)this.EditingElement;

            if (frameworkElement != base2Delement && !base2Delement.GetComputedTransformToElement((SceneElement)frameworkElement).HasInverse)
            {
                this.End();
            }
            else
            {
                int figureIndex1 = pathEditContext.FigureIndex;
                int num1         = PathFigureUtilities.PointCount(this.oldPathEditContext.GetPathFigure(this.oldPathEditorTarget.PathGeometry));
                if (editingElement != base2Delement)
                {
                    this.PathEditorTarget.EndEditing(false);
                    figureIndex1 += this.oldPathEditorTarget.PathGeometry.Figures.Count;
                    List <PathElement> otherElements = new List <PathElement>();
                    PathElement        mainElement   = (PathElement)editingElement;
                    PathElement        pathElement   = (PathElement)base2Delement;
                    otherElements.Add(pathElement);
                    PathCommandHelper.MakeCompoundPath(mainElement, otherElements, this.EditTransaction);
                    this.UpdateEditTransaction();
                    this.PathEditorTarget = this.oldPathEditorTarget;
                }
                this.PathEditorTarget.BeginEditing();
                PathGeometryEditor geometryEditor = this.PathEditorTarget.CreateGeometryEditor();
                if (pathEditContext.PartIndex != 0)
                {
                    geometryEditor.CreatePathFigureEditor(figureIndex1).Reverse();
                }
                geometryEditor.JoinFigure(this.oldPathEditContext.FigureIndex, figureIndex1);
                int figureIndex2 = this.oldPathEditContext.FigureIndex;
                if (pathEditContext.FigureIndex < this.oldPathEditContext.FigureIndex && editingElement == base2Delement)
                {
                    --figureIndex2;
                }
                this.UpdateEditTransaction();
                this.View.UpdateLayout();
                PathFigureEditor pathFigureEditor = geometryEditor.CreatePathFigureEditor(figureIndex2);
                int downstreamSegment1            = pathFigureEditor.GetLastIndexOfDownstreamSegment(num1 - 1);
                if (pathFigureEditor.GetPointKind(downstreamSegment1) == PathPointKind.Cubic)
                {
                    Vector lastTangent = this.oldPathEditorTarget.LastTangent;
                    pathFigureEditor.SetPoint(downstreamSegment1 - 2, pathFigureEditor.GetPoint(downstreamSegment1 - 2) + lastTangent);
                }
                this.PathEditorTarget.EndEditing(false);
                int downstreamSegment2 = pathFigureEditor.GetLastIndexOfDownstreamSegment(num1 - 1);
                this.PathEditContext = new PathEditContext(figureIndex2, downstreamSegment2);
                int num2 = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure);
                if (pathFigureEditor.GetPointKind(num2 - 1) == PathPointKind.Cubic)
                {
                    this.LastTangent = pathFigureEditor.GetPoint(num2 - 1) - pathFigureEditor.GetPoint(num2 - 2);
                }
                else
                {
                    this.LastTangent = new Vector(0.0, 0.0);
                }
                this.UpdateEditTransaction();
                this.zeroTangents = false;
                this.PathEditorTarget.BeginEditing();
                base.OnBegin(this.PathEditContext, mouseDevice);
            }
        }