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 bool OnDragEnd(Point dragStartPosition, Point dragEndPosition) { if (!this.IsProjectedInsertionPoint) { SceneView activeView = this.ActiveView; SceneViewModel viewModel = activeView.ViewModel; bool flag = false; if (this.pointList.Count >= 4) { Point point1 = this.pointList[0]; Point point2 = this.pointList[this.pointList.Count - 1]; if (Tolerances.DoPointsHit(point1, point2, activeView.Zoom)) { this.pointList[this.pointList.Count - 1] = point1; flag = true; } } PropertyManager propertyManager = (PropertyManager)this.ToolBehaviorContext.PropertyManager; BezierCurveFitter bezierCurveFitter = new BezierCurveFitter(); PathGeometry pathGeometry = !DebugVariables.Instance.EnableRealTimeFitting ? (!flag ? bezierCurveFitter.OpenFit(this.pointList, true, Tolerances.CurveFitCornerThreshold, Tolerances.CurveFittingDistanceTolerance(activeView.Zoom), true) : bezierCurveFitter.ClosedFit(this.pointList, true, Tolerances.CurveFitCornerThreshold, Tolerances.CurveFittingDistanceTolerance(activeView.Zoom), true)) : this.vpFitter.Path; try { this.EnsureEditTransaction(); Matrix transformFromRoot = activeView.GetComputedTransformFromRoot(this.ActiveSceneInsertionPoint.SceneElement); new PathFigureEditor(pathGeometry.Figures[0]).ApplyTransform(transformFromRoot); viewModel.ElementSelectionSet.Clear(); this.CreatePathElement(); this.UpdateEditTransaction(); if (this.EditingElement.IsViewObjectValid) { using (ScenePathEditorTarget pathEditorTarget = new ScenePathEditorTarget((PathElement)this.EditingElement)) { pathEditorTarget.BeginEditing(); pathEditorTarget.PathGeometry = pathGeometry; pathEditorTarget.EndEditing(true); } } this.CommitEditTransaction(); this.Tool.RebuildAdornerSets(); } finally { this.CancelEditTransaction(); this.ClearFeedback(); this.PreviewInsertionPoint = (ISceneInsertionPoint)null; } } return(true); }