public static void AdjustPathForAnimations(PathElement pathElement, SceneEditTransaction editTransaction) { using (pathElement.ViewModel.ForceBaseValue()) { System.Windows.Media.Geometry geometry1 = (System.Windows.Media.Geometry)pathElement.GetLocalOrDefaultValueAsWpf(PathElement.DataProperty); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.AddGeometry(geometry1); Rect bounds = PathCommandHelper.InflateRectByStrokeWidth(pathGeometry.Bounds, pathElement, false); PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(pathElement.Platform); Rect maxAnimatedExtent = PathCommandHelper.FindMaxAnimatedExtent((SceneElement)pathElement, bounds, propertyReference); double num1 = Math.Min(0.0, maxAnimatedExtent.Left); double num2 = Math.Min(0.0, maxAnimatedExtent.Top); Vector vector = new Vector(-num1, -num2); ILayoutDesigner designerForChild = pathElement.ViewModel.GetLayoutDesignerForChild((SceneElement)pathElement, true); editTransaction.Update(); Rect childRect = designerForChild.GetChildRect((BaseFrameworkElement)pathElement); childRect.X += num1; childRect.Y += num2; childRect.Width = Math.Max(maxAnimatedExtent.Width, childRect.Width); childRect.Height = Math.Max(maxAnimatedExtent.Height, childRect.Height); designerForChild.SetChildRect((BaseFrameworkElement)pathElement, childRect); Transform transform = (Transform) new TranslateTransform(vector.X, vector.Y); PathGeometry geometry2 = PathGeometryUtilities.TransformGeometry((System.Windows.Media.Geometry)pathGeometry, transform); if (!pathElement.DesignerContext.ActiveDocument.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf)) { PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(geometry2); } pathElement.PathGeometry = geometry2; PathCommandHelper.TransformPointKeyframes((SceneElement)pathElement, propertyReference, transform); pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)(Stretch)(pathElement.HasVertexAnimations ? 0 : 1)); } }
protected override void EndEditingInternal(bool pathJustCreated) { PathGeometry pathGeometry1 = PathGeometryUtilities.Copy(this.PathGeometry, false); bool isAnimated = this.IsAnimated; if (!isAnimated && this.ViewModel.AnimationEditor.IsKeyFraming) { System.Windows.Media.Geometry geometry1 = (System.Windows.Media.Geometry) this.editingElement.GetComputedValueAsWpf(Base2DElement.ClipProperty); PathGeometry geometry2 = new PathGeometry(); if (geometry1 != null) { geometry2.AddGeometry(geometry1); } PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(geometry2); SceneNode sceneNode = this.editingElement.ViewModel.CreateSceneNode(this.editingElement.ViewModel.DefaultView.ConvertFromWpfValue((object)geometry2)); sceneNode.SetLocalValueAsWpf(DesignTimeProperties.IsAnimatedProperty, (object)true); this.editingElement.SetValueAsSceneNode(Base2DElement.ClipProperty, sceneNode); this.editingElement.ViewModel.Document.OnUpdatedEditTransaction(); } if (this.EditingElement.IsAttached && (this.ViewModel.AnimationEditor.IsKeyFraming || isAnimated)) { new PathDiff(this.EditingElement, Base2DElement.ClipProperty, this.PathDiffChangeList).SetPathUsingMinimalDiff(pathGeometry1); } else { PathGeometry pathGeometry2 = PathGeometryUtilities.RemoveMapping(pathGeometry1, true); this.EditingElement.SetValueAsWpf(Base2DElement.ClipProperty, (object)pathGeometry2); } }
public bool EnsureSingleSegmentsInPathGeometry() { PathGeometry pathGeometry = this.PathGeometry; bool flag = PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(pathGeometry); this.PathGeometry = pathGeometry; return(flag); }
protected void EnsureOnlySingleSegments() { if (!PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(this.PathGeometry)) { return; } this.AddCriticalEdit(); }
public override void Execute() { using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove()) { SceneElement clipper; SceneElement elementToBeClipped; this.GetClipperAndElementToBeClipped(this.SceneViewModel.ElementSelectionSet, out clipper, out elementToBeClipped); if (elementToBeClipped == null) { SceneElement root = this.SceneViewModel.ActiveEditingContainer as SceneElement; if (root != null) { elementToBeClipped = (SceneElement)PathTargetDialog.ChooseClippingPathTarget(root, clipper); } } if (elementToBeClipped == null) { return; } using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitMakeClippingPath, false)) { using (this.SceneViewModel.ForceBaseValue()) { this.SceneViewModel.ElementSelectionSet.Clear(); Transform geometryTransform = this.GetGeometryTransform(clipper, elementToBeClipped); System.Windows.Media.Geometry targetGeometry = this.GetTransformedClippingGeometry(clipper, geometryTransform); if (!this.DesignerContext.ActiveDocument.ProjectContext.IsCapabilitySet(PlatformCapability.PrefersRectangularClippingPath)) { targetGeometry = this.ApplyCurrentClippingToGeometry(targetGeometry, elementToBeClipped); } if (!this.DesignerContext.ActiveDocument.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf)) { PathGeometry original = targetGeometry as PathGeometry; if (original != null) { PathGeometry geometry = PathGeometryUtilities.RemoveMapping(original, true); PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(geometry); targetGeometry = (System.Windows.Media.Geometry)geometry; } } elementToBeClipped.SetValueAsWpf(Base2DElement.ClipProperty, (object)targetGeometry); ReferenceStep singleStep1 = (ReferenceStep)this.SceneViewModel.ProjectContext.ResolveProperty(PathElement.DataProperty); ReferenceStep singleStep2 = (ReferenceStep)this.SceneViewModel.ProjectContext.ResolveProperty(Base2DElement.ClipProperty); PathCommandHelper.MoveVertexAnimations(clipper, new PropertyReference(singleStep1), elementToBeClipped, new PropertyReference(singleStep2), geometryTransform); this.SceneViewModel.DeleteElementTree(clipper); this.SceneViewModel.ElementSelectionSet.SetSelection(elementToBeClipped); } editTransaction.Commit(); } } }
public void SetPathUsingMinimalDiff(PathGeometry path) { PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(path); PathGeometry pathGeometry = this.targetElement.GetComputedValueAsWpf((IPropertyId)this.pathProperty) as PathGeometry; if (pathGeometry != null && path != null) { PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(pathGeometry); if (this.changeList.Changes.Count == 0 && this.DoesStructureMatch(path, pathGeometry)) { this.SetPathGeometryUsingMinimalDiff(path, pathGeometry); } else { this.SetPathUsingMapping(path); } } else { this.targetElement.SetValueAsWpf((IPropertyId)this.pathProperty, (object)path); } }