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); }
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); }
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); }
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); } }