Example #1
0
 public static void MoveVertexAnimations(SceneElement source, PropertyReference sourceReferencePrefix, SceneElement destination, PropertyReference destinationReferencePrefix, Transform transform, PathAnimationMovePackage animationMove)
 {
     foreach (StoryboardTimelineSceneNode parent in source.ViewModel.AnimationEditor.EnumerateStoryboardsForContainer(source.StoryboardContainer))
     {
         foreach (TimelineSceneNode timeline1 in (IEnumerable <TimelineSceneNode>)parent.Children)
         {
             if (timeline1.TargetElement == source && timeline1.TargetProperty != null && sourceReferencePrefix.IsPrefixOf(timeline1.TargetProperty))
             {
                 PropertyReference propertyReference = destinationReferencePrefix;
                 for (int count = sourceReferencePrefix.Count; count < timeline1.TargetProperty.Count; ++count)
                 {
                     propertyReference = propertyReference.Append(timeline1.TargetProperty[count]);
                 }
                 TimelineSceneNode timeline2 = (TimelineSceneNode)source.ViewModel.GetSceneNode(timeline1.DocumentNode.Clone(timeline1.DocumentContext));
                 if (transform != null)
                 {
                     PathCommandHelper.ApplyTransformToAnimation(timeline2, transform);
                 }
                 timeline2.TargetProperty = propertyReference;
                 timeline2.TargetElement  = (SceneNode)destination;
                 animationMove.Add(parent, timeline2);
                 animationMove.Remove(parent, timeline1);
             }
         }
     }
 }
Example #2
0
        public static void MakeCompoundPath(PathElement mainElement, List <PathElement> otherElements, SceneEditTransaction editTransaction)
        {
            PathElement              pathElement       = otherElements[otherElements.Count - 1];
            ISceneElementCollection  elementCollection = (ISceneElementCollection) new SceneElementCollection();
            PathAnimationMovePackage animationMove     = new PathAnimationMovePackage();
            PathGeometry             pathGeometry      = new PathGeometry();

            System.Windows.Media.Geometry geometry1 = (System.Windows.Media.Geometry)mainElement.TransformedGeometry;
            pathGeometry.AddGeometry(geometry1);
            foreach (PathElement oldElement in otherElements)
            {
                System.Windows.Media.Geometry geometry2 = (System.Windows.Media.Geometry)oldElement.TransformedGeometry;
                Matrix    transformToElement            = oldElement.GetComputedTransformToElement((SceneElement)mainElement);
                bool      isIdentity = transformToElement.IsIdentity;
                Transform transform  = isIdentity ? Transform.Identity : (Transform) new MatrixTransform(transformToElement);
                transform.Freeze();
                if (!isIdentity)
                {
                    GeometryGroup geometryGroup = new GeometryGroup();
                    geometryGroup.Children.Add(geometry2);
                    geometryGroup.Transform = transform;
                    geometry2 = (System.Windows.Media.Geometry)geometryGroup;
                }
                int count = pathGeometry.Figures.Count;
                pathGeometry.AddGeometry(geometry2);
                int num = pathGeometry.Figures.Count - count;
                PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(oldElement.Platform);
                for (int oldFigureIndex = 0; oldFigureIndex < num; ++oldFigureIndex)
                {
                    PathCommandHelper.TransferPathFigureAnimations(oldElement, mainElement, propertyReference, oldFigureIndex, count + oldFigureIndex, transform, animationMove);
                }
                elementCollection.Add((SceneElement)oldElement);
            }
            animationMove.Remove();
            Transform transform1 = PathCommandHelper.ReplacePathGeometry(mainElement, pathGeometry, editTransaction);

            animationMove.ApplyTransformToNewAnimations(transform1);
            animationMove.Add();
            PathCommandHelper.AdjustPathForAnimations(mainElement, editTransaction);
            foreach (SceneElement element in (IEnumerable <SceneElement>)elementCollection)
            {
                element.ViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element);
                element.ViewModel.RemoveElement((SceneNode)element);
            }
        }