public void OnDragEnd() { if (this.transform == null) { return; } PathCommandHelper.TransformPointKeyframes((SceneElement)this.pathElement, new PropertyReference((ReferenceStep)this.pathElement.ProjectContext.ResolveProperty(PathElement.DataProperty)), this.transform); }
public PathTransformHelper(PathElement pathElement, Size initialSize) { this.pathElement = pathElement; this.initialGeometry = new PathGeometry(); this.initialGeometry.AddGeometry((System.Windows.Media.Geometry)pathElement.PathGeometry); this.initialSize = initialSize; this.halfStrokeThickness = PathCommandHelper.GetHalfStrokeWidth(pathElement); }
private void NormalizePathGeometry() { PathGeometry pathGeometry = this.PathGeometry; Rect extent = PathCommandHelper.InflateRectByStrokeWidth(PathGeometryUtilities.TightExtent(pathGeometry, Matrix.Identity), this, false); Rect computedBounds = this.GetComputedBounds((Base2DElement)this); Transform transform = ScenePathEditorTarget.NormalizePathGeometry(pathGeometry, extent, computedBounds); this.PathGeometry = pathGeometry; PathCommandHelper.TransformPointKeyframes((SceneElement)this, new PropertyReference((ReferenceStep)this.ProjectContext.ResolveProperty(PathElement.DataProperty)), transform); }
public void SimplifyPathData(ref System.Windows.Media.Geometry geometry) { PathGeometry geometry1 = geometry as PathGeometry; BooleanCommand.CleanUpPathGeometry(ref geometry1); PathGeometry geometry2 = PathConversionHelper.RemoveDegeneratePoints((System.Windows.Media.Geometry)geometry1); PathGeometryUtilities.CollapseSingleSegmentsToPolySegments(geometry2); PathCommandHelper.GrokPathPointPrecision(geometry2, 3); geometry = (System.Windows.Media.Geometry)geometry2; }
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); } }
protected override void EndEditingInternal(bool pathJustCreated) { Matrix identity = Matrix.Identity; if (!pathJustCreated) { Transform geometryTransform = this.pathElement.GeometryTransform; if (geometryTransform != null) { identity = geometryTransform.Value; } } Rect extent1 = PathGeometryUtilities.TightExtent(this.PathGeometry, identity); Rect extent2 = extent1; bool flag1 = false; if (this.ViewModel.AnimationEditor.IsKeyFraming) { if ((Stretch)this.pathElement.GetLocalOrDefaultValueAsWpf(ShapeElement.StretchProperty) != Stretch.None) { flag1 = true; if (!pathJustCreated) { extent1 = PathGeometryUtilities.TightExtent(this.pathElement.PathGeometry, Matrix.Identity); } using (this.ViewModel.ForceBaseValue()) { using (this.ViewModel.AnimationEditor.DeferKeyFraming()) { this.pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)Stretch.None); this.ViewModel.Document.OnUpdatedEditTransaction(); } } } if (this.pathElement.EnsureSingleSegmentsInPathGeometry()) { this.ViewModel.Document.OnUpdatedEditTransaction(); } } Rect extent3 = PathCommandHelper.InflateRectByStrokeWidth(extent1, this.pathElement, pathJustCreated); Rect rect1 = PathCommandHelper.InflateRectByStrokeWidth(extent2, this.pathElement, pathJustCreated); Rect computedBounds = this.pathElement.GetComputedBounds((Base2DElement)this.pathElement); PathGeometry pathGeometry1 = this.PathGeometry; if (flag1 && !pathJustCreated) { ScenePathEditorTarget.NormalizePathGeometry(pathGeometry1, extent3, computedBounds); } if (flag1) { this.OnMatrixChanged(); } Vector vector1 = new Vector(extent3.Left, extent3.Top); Transform transform = (Transform)null; Point centerPoint = new Point(); bool flag2 = (Stretch)this.pathElement.GetComputedValueAsWpf(ShapeElement.StretchProperty) == Stretch.None && (this.ViewModel.AnimationEditor.IsKeyFraming || this.pathElement.HasVertexAnimations) && !pathJustCreated; if (flag2 && !computedBounds.Contains(rect1)) { ILayoutDesigner designerForChild = this.ViewModel.GetLayoutDesignerForChild((SceneElement)this.pathElement, true); Rect childRect = designerForChild.GetChildRect((BaseFrameworkElement)this.pathElement); double x = Math.Min(0.0, rect1.Left); double y = Math.Min(0.0, rect1.Top); Vector vector2 = new Vector(x, y); centerPoint = this.pathElement.RenderTransformOrigin; transform = this.pathElement.RenderTransform; if (transform != null && !transform.Value.IsIdentity) { using (this.ViewModel.ForceBaseValue()) { using (this.ViewModel.AnimationEditor.DeferKeyFraming()) this.UpdateCenterPoint(new Point(0.0, 0.0)); } vector2 *= transform.Value; } double num1 = Math.Max(0.0, rect1.Right - computedBounds.Right); double num2 = Math.Max(0.0, rect1.Bottom - computedBounds.Bottom); childRect.X += vector2.X; childRect.Y += vector2.Y; childRect.Width += -x + num1; childRect.Height += -y + num2; using (this.ViewModel.ForceBaseValue()) { using (this.ViewModel.AnimationEditor.DeferKeyFraming()) designerForChild.SetChildRect((BaseFrameworkElement)this.pathElement, childRect); } if (x != 0.0 || y != 0.0) { this.AdjustKeyframes(new Vector(x, y)); ScenePathEditorTarget.UpdateAllPoints(pathGeometry1, new Vector(x, y), 1.0, 1.0); PathGeometry pathGeometry2 = this.pathElement.PathGeometry; ScenePathEditorTarget.UpdateAllPoints(pathGeometry2, new Vector(x, y), 1.0, 1.0); this.pathElement.PathGeometry = pathGeometry2; } this.ViewModel.Document.OnUpdatedEditTransaction(); if (transform != null && !transform.Value.IsIdentity) { using (this.ViewModel.ForceBaseValue()) { using (this.ViewModel.AnimationEditor.DeferKeyFraming()) this.UpdateCenterPoint(centerPoint); } } } if (!flag2 && (Stretch)this.pathElement.GetComputedValueAsWpf(ShapeElement.StretchProperty) == Stretch.None) { ScenePathEditorTarget.UpdateAllPoints(pathGeometry1, vector1, 1.0, 1.0); } if (!flag2) { using (this.ViewModel.ForceBaseValue()) { using (this.ViewModel.AnimationEditor.DeferKeyFraming()) { centerPoint = this.pathElement.RenderTransformOrigin; transform = this.pathElement.RenderTransform; if (!extent3.IsEmpty) { if (transform != null && !transform.Value.IsIdentity) { this.UpdateCenterPoint(new Point(0.0, 0.0)); vector1 *= transform.Value; } ILayoutDesigner designerForChild = this.ViewModel.GetLayoutDesignerForChild((SceneElement)this.pathElement, false); Rect rect2 = designerForChild.GetChildRect((BaseFrameworkElement)this.pathElement); if (pathJustCreated) { rect2 = new Rect(0.0, 0.0, 0.0, 0.0); } double width = extent3.Width; double height = extent3.Height; rect2.Offset(vector1); rect2.Width = width; rect2.Height = height; designerForChild.SetChildRect((BaseFrameworkElement)this.pathElement, rect2); } } } } if (this.pathElement.IsAttached && (this.ViewModel.AnimationEditor.IsKeyFraming || this.pathElement.HasVertexAnimations) && !pathJustCreated) { new PathDiff((Base2DElement)this.pathElement, PathElement.DataProperty, this.PathDiffChangeList).SetPathUsingMinimalDiff(pathGeometry1); } else { this.pathElement.PathGeometry = pathGeometry1; } if (flag2) { return; } using (this.ViewModel.ForceBaseValue()) { using (this.ViewModel.AnimationEditor.DeferKeyFraming()) { if (extent3.IsEmpty) { return; } this.ViewModel.Document.OnUpdatedEditTransaction(); if (transform == null || transform.Value.IsIdentity) { return; } this.UpdateCenterPoint(centerPoint); } } }