コード例 #1
0
        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);
            }
        }
コード例 #2
0
 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();
         }
     }
 }