Пример #1
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);
                }
            }
        }