private void SetPathUsingMapping(PathGeometry path) { SceneViewModel viewModel = this.targetElement.ViewModel; using (viewModel.AnimationProxyManager != null ? viewModel.AnimationProxyManager.ExpandAllProxiesInActiveContainer() : (IDisposable)null) { foreach (PathAction action in this.changeList.Changes) { System.Windows.Media.Geometry geometry = this.targetElement.GetLocalOrDefaultValueAsWpf((IPropertyId)this.pathProperty) as System.Windows.Media.Geometry; if (geometry == null && this.targetElement.IsValueExpression((IPropertyId)this.pathProperty)) { geometry = this.targetElement.ViewModel.DefaultView.ConvertToWpfValue(this.targetElement.ViewModel.CreateInstance(this.targetElement.GetLocalValueAsSceneNode((IPropertyId)this.pathProperty).DocumentNodePath)) as System.Windows.Media.Geometry; if (geometry == null) { geometry = this.targetElement.GetComputedValueAsWpf((IPropertyId)this.pathProperty) as System.Windows.Media.Geometry; if (geometry == null) { return; } } } PathGeometry oldGeometry = new PathGeometry(); oldGeometry.AddGeometry(geometry.Clone()); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.AddGeometry(geometry); PathFigureEditor pathFigureEditor = new PathFigureEditor(pathGeometry.Figures[action.Figure]); PathGeometryEditor pathGeometryEditor = new PathGeometryEditor(pathGeometry); switch (action.Action) { case PathActionType.InsertPoint: pathFigureEditor.SubdivideSegment(action.PointIndex, action.Parameter); break; case PathActionType.DeletePoint: pathFigureEditor.RemovePoint(action.PointIndex); break; case PathActionType.DeleteSegment: if (action.Segment == 0 && pathFigureEditor.PathFigure.Segments.Count > 1) { pathFigureEditor.RemoveFirstSegment(); break; } pathFigureEditor.RemoveLastSegment(); break; case PathActionType.PromoteSegment: pathFigureEditor.PromoteSegment(action.PointIndex); break; case PathActionType.Rotate: pathFigureEditor.Rotate(); break; case PathActionType.Open: pathFigureEditor.Open(action.PointIndex); break; case PathActionType.Split: pathFigureEditor.Split(action.PointIndex); break; case PathActionType.SplitAndAdd: pathGeometryEditor.SplitFigure(action.Figure, action.PointIndex); break; case PathActionType.RemoveFigure: pathGeometryEditor.RemoveFigure(action.Figure); break; case PathActionType.AppendSegment: PathAppendLineAction appendLineAction; if ((appendLineAction = action as PathAppendLineAction) != null) { Point point = appendLineAction.Point; if (action.Figure < path.Figures.Count && action.Segment < path.Figures[action.Figure].Segments.Count) { LineSegment lineSegment = path.Figures[action.Figure].Segments[action.Segment] as LineSegment; if (lineSegment != null) { point = lineSegment.Point; } } pathFigureEditor.LineTo(point); break; } PathAppendQuadraticBezierAction quadraticBezierAction; if ((quadraticBezierAction = action as PathAppendQuadraticBezierAction) != null) { Point point1 = quadraticBezierAction.Point1; Point point2 = quadraticBezierAction.Point2; if (action.Figure < path.Figures.Count && action.Segment < path.Figures[action.Figure].Segments.Count) { QuadraticBezierSegment quadraticBezierSegment = path.Figures[action.Figure].Segments[action.Segment] as QuadraticBezierSegment; if (quadraticBezierSegment != null) { point1 = quadraticBezierSegment.Point1; point2 = quadraticBezierSegment.Point2; } } pathFigureEditor.QuadraticCurveTo(point1, point2); break; } PathAppendBezierAction appendBezierAction; if ((appendBezierAction = action as PathAppendBezierAction) != null) { Point point1 = appendBezierAction.Point1; Point point2 = appendBezierAction.Point2; Point point3 = appendBezierAction.Point3; if (action.Figure < path.Figures.Count && action.Segment < path.Figures[action.Figure].Segments.Count) { BezierSegment bezierSegment = path.Figures[action.Figure].Segments[action.Segment] as BezierSegment; if (bezierSegment != null) { point1 = bezierSegment.Point1; point2 = bezierSegment.Point2; point3 = bezierSegment.Point3; } } pathFigureEditor.CubicCurveTo(point1, point2, point3); break; } break; case PathActionType.Close: pathFigureEditor.CloseWithLineSegment(); break; case PathActionType.Join: pathGeometryEditor.JoinFigure(action.Figure, action.PointIndex); break; case PathActionType.Reverse: pathFigureEditor.Reverse(); break; } this.targetElement.SetLocalValueAsWpf((IPropertyId)this.pathProperty, (object)pathGeometry); this.ApplyAnimationChanges(oldGeometry, pathGeometry, action); if (action.Action == PathActionType.PromoteSegment && action.Segment < pathGeometry.Figures[action.Figure].Segments.Count) { this.targetElement.ViewModel.Document.OnUpdatedEditTransaction(); this.SetKeyframesForSegment(path, action.Figure, action.Segment); } } this.RemoveInvalidAnimations(PathGeometryUtilities.GetPathGeometryFromGeometry((System.Windows.Media.Geometry) this.targetElement.GetLocalOrDefaultValueAsWpf((IPropertyId)this.pathProperty))); } }