protected override void DoUpdateElementPosition(Point pointBegin, Point pointEnd) { PathGeometry path = new PathGeometry(); PathGeometryEditor pathGeometryEditor = new PathGeometryEditor(path); pathGeometryEditor.StartFigure(pointBegin); pathGeometryEditor.AppendLineSegment(pointEnd); using (ScenePathEditorTarget pathEditorTarget = new ScenePathEditorTarget((PathElement)this.EditingElement)) { pathEditorTarget.BeginEditing(); pathEditorTarget.PathGeometry = path; pathEditorTarget.EndEditing(true); } }
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); }