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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
 }
Esempio n. 4
0
        protected Point GetLastPoint(int pathFigureIndex)
        {
            PathFigure pathFigure = this.Path.Figures[pathFigureIndex];

            return(PathFigureUtilities.GetPoint(pathFigure, PathFigureUtilities.PointCount(pathFigure) - 1));
        }
Esempio n. 5
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);
                }
            }
        }