public void Execute(ICollection <PathPart> pathPartSelection) { this.SplitComponentsByFigure(pathPartSelection); for (int figureIndex = this.pathEditorTarget.PathGeometry.Figures.Count - 1; figureIndex >= 0; --figureIndex) { List <int> segmentsByFigure = this.selectedSegments[figureIndex]; List <int> pointsByFigure = this.selectedPoints[figureIndex]; segmentsByFigure.Sort(); segmentsByFigure.Reverse(); pointsByFigure.Sort(); pointsByFigure.Reverse(); if (segmentsByFigure.Count == 0) { this.RemovePointsByFigure(figureIndex, pointsByFigure); } else { if (PathFigureUtilities.IsClosed(this.pathEditorTarget.PathGeometry.Figures[figureIndex])) { this.OpenFigureAndShiftIndices(figureIndex, segmentsByFigure, pointsByFigure); } this.RemovePointsAndSegmentsFromOpenFigure(figureIndex, segmentsByFigure, pointsByFigure); } if (PathFigureUtilities.IsIsolatedPoint(this.pathEditorTarget.PathGeometry.Figures[figureIndex])) { this.pathEditorTarget.CreateGeometryEditor().RemoveFigure(figureIndex); } } }
protected override void OnDrag(MouseDevice mouseDevice, double zoom) { this.currentTangentPoint = this.GetPointInViewRootCoordinates(mouseDevice, true); Vector correspondingVector = ElementUtilities.GetCorrespondingVector(this.currentTangentPoint - this.currentNodePoint, this.geometryToDocument, this.IsShiftDown ? this.AxisConstraint : (AxisConstraint)null); Vector lastTangent = this.LastTangent; this.LastTangent = correspondingVector; PathFigure pathFigure = this.PathEditContext.GetPathFigure(this.Path); PathFigureEditor pathFigureEditor = pathFigure == null ? (PathFigureEditor)null : new PathFigureEditor(pathFigure); if (pathFigureEditor != null && !PathFigureUtilities.IsIsolatedPoint(pathFigureEditor.PathFigure)) { PathGeometryEditor pathGeometryEditor = this.BeginEditing(); bool flag = PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure); int index = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure) - (flag ? 0 : 1); Point point1 = pathFigureEditor.GetPoint(index - 1); Point point2 = pathFigureEditor.GetPoint(index); if (pathFigureEditor.GetPointKind(index) == PathPointKind.Line) { pathGeometryEditor.RemoveLastSegmentOfFigure(this.PathEditContext.FigureIndex); if (flag) { pathGeometryEditor.CloseFigureWithCubicBezier(point1, point2, this.PathEditContext.FigureIndex); } else { pathGeometryEditor.AppendCubicBezier(point1, point2, point2, this.PathEditContext.FigureIndex); } pathFigureEditor = new PathFigureEditor(this.PathEditContext.GetPathFigure(this.Path)); } if (!this.IsAltDown) { if (!this.areTangentsSymmetric) { double length = this.LastTangent.Length; if (length > 0.0) { int num1 = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure); double num2 = (pathFigureEditor.GetPoint(num1 - 1) - pathFigureEditor.GetPoint(num1 - 2)).Length / length; pathGeometryEditor.SetPoint(this.PathEditContext.FigureIndex, num1 - 2, point2 - num2 * this.LastTangent); } } else { int pointIndex = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure) - (PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure) ? 1 : 2); pathGeometryEditor.SetPoint(this.PathEditContext.FigureIndex, pointIndex, point2 - this.LastTangent); } } if (PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure) && pathFigureEditor.GetPointKind(3) == PathPointKind.Cubic && this.areTangentsSymmetric) { pathGeometryEditor.SetPoint(this.PathEditContext.FigureIndex, 1, point2 + this.LastTangent); } this.PathEditorTarget.AddCriticalEdit(); } base.OnDrag(mouseDevice, zoom); }
private PenAction GetAction(PathPartAdorner adorner) { PenAction penAction = (PenAction)null; PathSegmentAdorner pathSegmentAdorner = adorner as PathSegmentAdorner; PathEditorTarget pathEditorTarget = (PathEditorTarget)null; if (adorner != null) { pathEditorTarget = adorner.PathAdornerSet.PathEditorTarget; } if (pathSegmentAdorner != null) { penAction = (PenAction) new InsertAction(pathEditorTarget, this.ActiveSceneViewModel); } else { PathPointAdorner pathPointAdorner = adorner as PathPointAdorner; if (pathPointAdorner != null) { penAction = (PenAction) new DeletePointAction(pathEditorTarget, this.ActiveSceneViewModel); PathFigure figure1 = pathEditorTarget.PathGeometry.Figures[pathPointAdorner.FigureIndex]; if (PathFigureUtilities.IsOpen(figure1) && !PathFigureUtilities.IsIsolatedPoint(figure1)) { bool flag1 = pathPointAdorner.PointIndex == 0; bool flag2 = pathPointAdorner.PointIndex == PathFigureUtilities.PointCount(figure1) - 1; bool flag3 = pathPointAdorner.PathAdornerSet.PathEditorTarget == this.pathEditorTarget; bool flag4 = this.pathEditContext != null && pathPointAdorner.FigureIndex == this.pathEditContext.FigureIndex; bool flag5 = this.pathEditorTarget != null && pathPointAdorner.PathAdornerSet.PathEditorTarget.PathEditMode == this.pathEditorTarget.PathEditMode; bool flag6 = pathPointAdorner.PathAdornerSet.PathEditorTarget.PathEditMode == PathEditMode.ScenePath; PathFigure figure2 = this.pathEditContext == null || this.pathEditorTarget == null ? (PathFigure)null : this.pathEditContext.GetPathFigure(this.pathEditorTarget.PathGeometry); bool flag7 = figure2 != null && PathFigureUtilities.IsOpen(figure2); bool flag8 = (flag3 && !flag4 || flag5 && flag6) && flag7; if (flag1) { penAction = !flag3 || !flag4 ? (!flag8 ? (PenAction) new ExtendAction(pathEditorTarget, this.ActiveSceneViewModel) : (PenAction) new JoinAction(pathEditorTarget, this.ActiveSceneViewModel, this.pathEditorTarget, this.pathEditContext)) : (PenAction) new CloseAction(pathEditorTarget, this.ActiveSceneViewModel); } else if (flag2) { penAction = !flag3 || !flag4 ? (!flag8 ? (PenAction) new ExtendAction(pathEditorTarget, this.ActiveSceneViewModel) : (PenAction) new JoinAction(pathEditorTarget, this.ActiveSceneViewModel, this.pathEditorTarget, this.pathEditContext)) : (PenAction) new AdjustAction(pathEditorTarget, this.ActiveSceneViewModel); } } if (PathFigureUtilities.IsIsolatedPoint(figure1) && this.pathEditContext == null) { penAction = (PenAction) new ExtendAction(pathEditorTarget, this.ActiveSceneViewModel); } } } if (penAction == null) { penAction = !this.IsActive || this.pathEditorTarget == null || (this.pathEditorTarget.PathGeometry.Figures.Count <= 0 || this.pathEditorTarget.PathGeometry.Figures[this.pathEditorTarget.PathGeometry.Figures.Count - 1].IsClosed) ? (PenAction) new StartAction(this, (PathEditorTarget)null, this.ActiveSceneViewModel) : (PenAction) new AppendAction(this.pathEditorTarget, this.ActiveSceneViewModel); } return(penAction); }
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(); } }
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(); }