示例#1
0
        public static void MoveVertexAnimations(SceneElement source, PropertyReference sourceReferencePrefix, SceneElement destination, PropertyReference destinationReferencePrefix, Transform transform)
        {
            PathAnimationMovePackage animationMove = new PathAnimationMovePackage();

            PathCommandHelper.MoveVertexAnimations(source, sourceReferencePrefix, destination, destinationReferencePrefix, transform, animationMove);
            animationMove.AddAndRemove();
        }
示例#2
0
        private static void TransferPathFigureAnimations(PathElement oldElement, PathElement newElement, PropertyReference pathProperty, int oldFigureIndex, int newFigureIndex, Transform transform, PathAnimationMovePackage animationMove)
        {
            IProjectContext   projectContext             = newElement.ProjectContext;
            IType             type                       = projectContext.ResolveType(PlatformTypes.PathFigureCollection);
            PropertyReference propertyReference          = pathProperty.Append(PathElement.FiguresProperty);
            ReferenceStep     step1                      = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((ITypeResolver)projectContext, type.RuntimeType, oldFigureIndex);
            PropertyReference sourceReferencePrefix      = propertyReference.Append(step1);
            ReferenceStep     step2                      = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((ITypeResolver)projectContext, type.RuntimeType, newFigureIndex);
            PropertyReference destinationReferencePrefix = propertyReference.Append(step2);

            PathCommandHelper.MoveVertexAnimations((SceneElement)oldElement, sourceReferencePrefix, (SceneElement)newElement, destinationReferencePrefix, transform, animationMove);
        }
 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();
         }
     }
 }
        private void ReleaseClippingPath(SceneElement sceneElement, SceneEditTransaction editTransaction)
        {
            if (sceneElement.IsSet(Base2DElement.ClipProperty) != PropertyState.Set)
            {
                return;
            }
            SceneNode sceneNode = (SceneNode)sceneElement;

            for (SceneNode parent = sceneElement.Parent; parent != null; parent = parent.Parent)
            {
                PanelElement panelElement = parent as PanelElement;
                if (panelElement != null)
                {
                    MatrixTransform matrixTransform        = new MatrixTransform(sceneElement.GetComputedTransformToElement((SceneElement)panelElement));
                    PathGeometry    pathGeometry1          = new PathGeometry();
                    System.Windows.Media.Geometry geometry = (System.Windows.Media.Geometry)sceneElement.GetLocalOrDefaultValueAsWpf(Base2DElement.ClipProperty);
                    if (geometry != null)
                    {
                        pathGeometry1 = PathGeometryUtilities.TransformGeometry(geometry, (Transform)matrixTransform);
                    }
                    PathElement pathElement = (PathElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Path);
                    using (pathElement.ViewModel.ForceBaseValue())
                    {
                        this.DesignerContext.AmbientPropertyManager.ApplyAmbientProperties((SceneNode)pathElement);
                        pathElement.SetValueAsWpf(ShapeElement.StrokeProperty, (object)Brushes.Black);
                        pathElement.ClearValue(ShapeElement.FillProperty);
                        pathElement.ClearValue(ShapeElement.StrokeThicknessProperty);
                        panelElement.Children.Insert(panelElement.Children.IndexOf(sceneNode) + 1, (SceneNode)pathElement);
                        ReferenceStep singleStep1 = (ReferenceStep)pathElement.ProjectContext.ResolveProperty(Base2DElement.ClipProperty);
                        ReferenceStep singleStep2 = (ReferenceStep)pathElement.ProjectContext.ResolveProperty(PathElement.DataProperty);
                        PathCommandHelper.MoveVertexAnimations(sceneElement, new PropertyReference(singleStep1), (SceneElement)pathElement, new PropertyReference(singleStep2), (Transform)matrixTransform);
                        Rect bounds            = PathCommandHelper.InflateRectByStrokeWidth(pathGeometry1.Bounds, pathElement, false);
                        Rect maxAnimatedExtent = PathCommandHelper.FindMaxAnimatedExtent((SceneElement)pathElement, bounds, new PropertyReference(singleStep2));
                        editTransaction.Update();
                        Vector vector = new Vector(-maxAnimatedExtent.Left, -maxAnimatedExtent.Top);
                        panelElement.LayoutDesigner.SetChildRect((BaseFrameworkElement)pathElement, maxAnimatedExtent);
                        Transform    transform     = (Transform) new TranslateTransform(vector.X, vector.Y);
                        PathGeometry pathGeometry2 = PathGeometryUtilities.TransformGeometry((System.Windows.Media.Geometry)pathGeometry1, transform);
                        pathElement.PathGeometry = pathGeometry2;
                        PathCommandHelper.TransformPointKeyframes((SceneElement)pathElement, new PropertyReference(singleStep2), transform);
                        pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)(Stretch)(pathElement.HasVertexAnimations ? 0 : 1));
                        break;
                    }
                }
                else
                {
                    sceneNode = parent;
                }
            }
        }