Exemple #1
0
 public void Begin(PathEditContext pathEditContext, MouseDevice mouseDevice)
 {
     if (this.IsActive)
     {
         throw new InvalidOperationException(ExceptionStringTable.PenActionActionAlreadyBegun);
     }
     this.isActive        = true;
     this.pathEditContext = pathEditContext;
     this.EnsureEditTransaction();
     if (this.pathEditorTarget != null)
     {
         this.pathEditorTarget.BeginEditing();
     }
     this.OnBegin(pathEditContext, mouseDevice);
     if (this.pathEditorTarget == null)
     {
         return;
     }
     this.pathEditorTarget.AddCriticalEdit();
     this.View.AdornerLayer.InvalidateAdornerVisuals(this.EditingElement);
     if (!this.IsEditTransactionOpen)
     {
         return;
     }
     this.UpdateEditTransaction();
 }
        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);
        }
Exemple #3
0
        protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
        {
            this.EnsureEditTransaction();
            PathElement pathElement = this.penCreateBehavior.CreatePathElement();

            this.UpdateEditTransaction();
            IViewObject element = (IViewObject)null;

            if (pathElement.IsViewObjectValid)
            {
                element = ((IViewVisual)pathElement.ViewObject).VisualParent;
            }
            if (element != null)
            {
                this.PathEditorTarget = this.penCreateBehavior.Tool.PathEditorTargetMap.GetPathEditorTarget((Base2DElement)pathElement, PathEditMode.ScenePath);
                this.PathEditContext  = new PathEditContext(0, 0);
                Point  viewRootCoordinates     = this.GetPointInViewRootCoordinates(mouseDevice, true);
                Matrix computedTransformToRoot = this.View.GetComputedTransformToRoot((SceneElement)pathElement);
                this.Initialize(viewRootCoordinates, false, computedTransformToRoot);
                this.PathEditorTarget.BeginEditing();
                new PathGeometryEditor(this.Path, this.PathEditorTarget.PathDiffChangeList).StartFigure(this.View.GetComputedTransformFromRoot(element).Transform(viewRootCoordinates));
                this.PathEditorTarget.EndEditing(true);
                this.UpdateEditTransaction();
                base.OnBegin(pathEditContext, mouseDevice);
            }
            else
            {
                this.End();
            }
        }
        private void BeginAction(PenAction action, PathPartAdorner pathPartAdorner)
        {
            if (action == null)
            {
                return;
            }
            if (this.IsActive && action is StartAction)
            {
                this.FinalizePath(this.EditingElement);
            }
            PathEditContext pathEditContext = this.pathEditContext;

            if (pathPartAdorner != null)
            {
                pathEditContext = new PathEditContext(pathPartAdorner.FigureIndex, pathPartAdorner.PartIndex);
            }
            this.action             = action;
            this.Cursor             = action.DragCursor;
            this.isConstrainingAxes = this.IsShiftDown;
            action.Begin(pathEditContext, this.MouseDevice);
            this.pathEditorTarget = action.PathEditorTarget;
            this.pathEditContext  = action.PathEditContext;
            if (this.pathEditorTarget != null)
            {
                this.EditingElement = (BaseFrameworkElement)this.pathEditorTarget.EditingElement;
            }
            if (!action.SetPathActive || this.pathEditorTarget == null || this.pathEditContext == null || this.EditingElement != null && !this.EditingElement.IsViewObjectValid)
            {
                return;
            }
            ((PenTool)this.Tool).ActivePathEditInformation = new ActivePathEditInformation(this.pathEditorTarget, this.pathEditContext.FigureIndex);
        }
        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);
        }
Exemple #6
0
        private bool ShouldEnforceSmoothness(PathTangentAdorner pathTangentAdorner)
        {
            int              partIndex        = pathTangentAdorner.PartIndex;
            PathEditContext  pathEditContext  = new PathEditContext(pathTangentAdorner.FigureIndex, partIndex);
            PathFigureEditor pathFigureEditor = new PathFigureEditor(pathEditContext.GetPathFigure(this.pathEditorTarget.PathGeometry));
            Point            point1           = pathFigureEditor.GetPoint(pathEditContext.PartIndex);
            bool             flag             = false;

            if (pathFigureEditor.IsFirstCubicBezierHandle(partIndex))
            {
                if (pathFigureEditor.GetPointKind(partIndex - 1) == PathPointKind.Cubic)
                {
                    Point point2 = pathFigureEditor.GetPoint(partIndex - 1);
                    Point point3 = pathFigureEditor.GetPoint(partIndex - 2);
                    flag = VectorUtilities.HaveOppositeDirections(point1 - point2, point3 - point2);
                }
            }
            else if (pathFigureEditor.IsIndexValid(partIndex + 4) && pathFigureEditor.GetPointKind(partIndex + 4) == PathPointKind.Cubic)
            {
                Point point2 = pathFigureEditor.GetPoint(partIndex + 1);
                Point point3 = pathFigureEditor.GetPoint(partIndex + 2);
                flag = VectorUtilities.HaveOppositeDirections(point1 - point2, point3 - point2);
            }
            return(flag);
        }
 protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
 {
     if (!Tolerances.AreClose(this.LastTangent, new Vector(0.0, 0.0)))
     {
         this.LastTangent = new Vector(0.0, 0.0);
     }
     base.OnBegin(pathEditContext, mouseDevice);
 }
Exemple #8
0
 public void InsertPoint(PathEditContext pathEditContext, double segmentParameter)
 {
     if (segmentParameter <= 0.0 || segmentParameter >= 1.0)
     {
         return;
     }
     new PathFigureEditor(pathEditContext.GetPathFigure(this.Path), this.PathEditorTarget.PathDiffChangeList, pathEditContext.FigureIndex).SubdivideSegment(pathEditContext.PartIndex, segmentParameter);
 }
Exemple #9
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);
        }
Exemple #10
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);
        }
Exemple #11
0
        protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
        {
            PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.EditPath);
            Point            viewRootCoordinates    = this.GetPointInViewRootCoordinates(mouseDevice, false);
            PathFigureEditor pathFigureEditor       = new PathFigureEditor(pathEditContext.GetPathFigure(this.Path), this.PathEditorTarget.PathDiffChangeList, pathEditContext.FigureIndex);
            Matrix           elementTransformToRoot = this.EditingElementTransformToRoot;
            int    partIndex = pathEditContext.PartIndex;
            Point  closestPoint;
            double distanceSquared;
            double ofUpstreamSegment = pathFigureEditor.GetClosestPointOfUpstreamSegment(partIndex, viewRootCoordinates, elementTransformToRoot, Tolerances.CurveFlatteningTolerance, out closestPoint, out distanceSquared);

            this.InsertPoint(pathEditContext, ofUpstreamSegment);
            base.OnBegin(pathEditContext, mouseDevice);
            this.End();
        }
 protected override void OnDetach()
 {
     this.ActiveSceneViewModel.EarlySceneUpdatePhase -= new SceneUpdatePhaseEventHandler(this.ActiveSceneViewModel_EarlySceneUpdatePhase);
     if (this.IsActive && this.action != null)
     {
         this.EndAction();
     }
     if (this.EditingElement != null)
     {
         this.FinalizePath(this.EditingElement);
     }
     this.pathEditorTarget = (PathEditorTarget)null;
     this.pathEditContext  = (PathEditContext)null;
     base.OnDetach();
 }
Exemple #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();
     }
 }
Exemple #14
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);
        }
Exemple #15
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();
 }
        protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
        {
            int        figureIndex = pathEditContext.FigureIndex;
            PathFigure figure      = this.Path.Figures[figureIndex];

            this.geometryToDocument = this.EditingElementTransformToRoot;
            int num1 = pathEditContext.PartIndex;
            PathFigureEditor pathFigureEditor = new PathFigureEditor(figure, this.PathEditorTarget.PathDiffChangeList, figureIndex);

            if (pathFigureEditor.GetPointKind(num1) != PathPointKind.Cubic)
            {
                PathGeometryEditor pathGeometryEditor = this.BeginEditing();
                pathFigureEditor     = new PathFigureEditor(pathGeometryEditor.PathGeometry.Figures[figureIndex], this.PathEditorTarget.PathDiffChangeList, figureIndex);
                num1                 = pathGeometryEditor.PromoteSegment(figureIndex, num1);
                this.PathEditContext = new PathEditContext(pathEditContext.FigureIndex, num1);
            }
            this.View.ViewModel.PathPartSelectionSet.SetSelection((PathPart) new PathSegment((SceneElement)this.PathEditorTarget.EditingElement, this.PathEditorTarget.PathEditMode, pathEditContext.FigureIndex, this.PathEditContext.PartIndex));
            int   ofUpstreamSegment   = pathFigureEditor.GetFirstIndexOfUpstreamSegment(num1);
            Point viewRootCoordinates = this.GetPointInViewRootCoordinates(mouseDevice, false);

            this.ComputeSegmentParameterAndClosestPoint(pathEditContext.GetPathFigure(this.Path), pathEditContext.PartIndex, viewRootCoordinates);
            this.pathSegmentParameter = Math.Max(this.pathSegmentParameter, ConvertSegmentAction.segmentTolerance);
            this.pathSegmentParameter = Math.Min(this.pathSegmentParameter, 1.0 - ConvertSegmentAction.segmentTolerance);
            double num2 = 3.0 * this.pathSegmentParameter * (1.0 - this.pathSegmentParameter);
            double num3 = num2 * this.pathSegmentParameter;
            double num4 = num2 * (1.0 - this.pathSegmentParameter);
            double num5 = (num4 * num4 + num3 * num3 + num4 * num3) * 2.0;

            this.firstHandleCoef          = (2.0 * num4 + num3) / num5;
            this.secondHandleCoef         = (2.0 * num3 + num4) / num5;
            this.initialFirstCubicHandle  = pathFigureEditor.GetPoint(ofUpstreamSegment + 1);
            this.initialSecondCubicHandle = pathFigureEditor.GetPoint(ofUpstreamSegment + 2);
            if (Math.Min(this.pathSegmentParameter, 1.0 - this.pathSegmentParameter) < ConvertSegmentAction.dampingThreshold)
            {
                this.damping = Math.Min(this.pathSegmentParameter, 1.0 - this.pathSegmentParameter);
                this.damping = Math.Sqrt(this.damping);
            }
            else
            {
                this.damping = 1.0;
            }
            this.hasDragged = false;
            base.OnBegin(pathEditContext, mouseDevice);
        }
 private void EndAction()
 {
     if (this.action == null)
     {
         return;
     }
     this.action.End();
     this.pathEditorTarget = this.action.PathEditorTarget;
     this.pathEditContext  = this.action.PathEditContext;
     if (this.pathEditorTarget != null)
     {
         this.EditingElement = (BaseFrameworkElement)this.pathEditorTarget.EditingElement;
     }
     if (this.action.SetPathActive && this.pathEditorTarget != null && this.pathEditContext != null && (this.EditingElement == null || this.EditingElement.IsViewObjectValid))
     {
         ((PenTool)this.Tool).ActivePathEditInformation = new ActivePathEditInformation(this.pathEditorTarget, this.pathEditContext.FigureIndex);
     }
     this.action = (PenAction)null;
 }
Exemple #18
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);
        }
        protected override bool OnButtonDownOverNonAdorner(Point pointerPosition)
        {
            this.IsProjectedInsertionPoint = Adorner.NonAffineTransformInParentStack(this.ActiveSceneInsertionPoint.SceneElement);
            if ((this.action ?? this.GetAction((PathPartAdorner)null)) is StartAction && this.IsProjectedInsertionPoint)
            {
                return(true);
            }
            this.EndAction();
            if (!this.ToolBehaviorContext.SnappingEngine.IsStarted)
            {
                this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null);
            }
            FrameworkElement frameworkElement = this.MouseDevice.DirectlyOver as FrameworkElement;

            if (frameworkElement == null || frameworkElement.Parent == null)
            {
                return(true);
            }
            ActivePathEditInformation pathEditInformation = ((PenTool)this.Tool).ActivePathEditInformation;

            if (pathEditInformation != null)
            {
                this.pathEditorTarget = pathEditInformation.ActivePathEditorTarget;
                this.pathEditContext  = new PathEditContext(pathEditInformation.ActiveFigureIndex, 0);
            }
            else
            {
                this.pathEditorTarget = (PathEditorTarget)null;
            }
            if (this.pathEditorTarget != null)
            {
                this.EditingElement = (BaseFrameworkElement)this.pathEditorTarget.EditingElement;
                this.pathEditorTarget.UpdateCachedPath();
            }
            this.BeginAction(this.GetAction((PathPartAdorner)null), (PathPartAdorner)null);
            return(true);
        }
Exemple #20
0
 protected override void DoDelete(PathEditContext pathEditContext)
 {
     this.BeginEditing().RemovePoint(pathEditContext.FigureIndex, pathEditContext.PartIndex);
 }
 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);
 }
Exemple #22
0
 protected void RemovePath()
 {
     this.pathEditorTarget.RemovePath();
     this.pathEditorTarget = (PathEditorTarget)null;
     this.pathEditContext  = (PathEditContext)null;
 }
Exemple #23
0
 protected virtual void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
 {
 }
Exemple #24
0
 protected abstract void DoDelete(PathEditContext pathEditContext);
Exemple #25
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);
            }
        }
Exemple #26
0
 public JoinAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel, PathEditorTarget oldPathEditorTarget, PathEditContext oldPathEditContext)
     : base(pathEditorTarget, viewModel)
 {
     this.oldPathEditorTarget = oldPathEditorTarget;
     this.oldPathEditContext  = oldPathEditContext;
 }
Exemple #27
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);
                }
            }
        }