示例#1
0
 private bool ShouldGenerateHandoffAnimationFor(AnimationSceneNode animation, TimelineSceneNode.PropertyNodePair targetElementAndProperty)
 {
     if ((animation.TargetName == null || targetElementAndProperty.SceneNode != null && targetElementAndProperty.SceneNode.IsInDocument) && (targetElementAndProperty.PropertyReference != null && !DesignTimeProperties.ExplicitAnimationProperty.Equals((object)targetElementAndProperty.PropertyReference[0])))
     {
         return(!AnimationProxyManager.IsAnimationProxy((TimelineSceneNode)animation));
     }
     return(false);
 }
示例#2
0
 private void ChangeAnimationProperty(PropertyReference fromProperty, PropertyReference toProperty, Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> toAdd, Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> toRemove, bool exactMatch)
 {
     foreach (StoryboardTimelineSceneNode timelineSceneNode in this.targetElement.ViewModel.AnimationEditor.EnumerateStoryboardsForContainer(this.targetElement.StoryboardContainer))
     {
         foreach (TimelineSceneNode timeline in (IEnumerable <TimelineSceneNode>)timelineSceneNode.Children)
         {
             if (timeline.TargetElement == this.targetElement && timeline.TargetProperty != null)
             {
                 PropertyReference propertyReference = toProperty;
                 bool flag1 = AnimationProxyManager.IsOptimizedAnimation(timeline);
                 bool flag2 = !flag1 && fromProperty.Equals((object)timeline.TargetProperty);
                 if (!flag1 && !exactMatch && !flag2)
                 {
                     flag2 = fromProperty.IsPrefixOf(timeline.TargetProperty);
                     if (flag2)
                     {
                         for (int count = toProperty.Count; count < timeline.TargetProperty.Count; ++count)
                         {
                             propertyReference = propertyReference.Append(timeline.TargetProperty[count]);
                         }
                     }
                 }
                 if (flag2)
                 {
                     if (toRemove != null)
                     {
                         toRemove[timeline] = timelineSceneNode;
                     }
                     TimelineSceneNode index = (TimelineSceneNode)this.targetElement.ViewModel.GetSceneNode(timeline.DocumentNode.Clone(timeline.DocumentContext));
                     index.TargetProperty  = propertyReference;
                     index.ShouldSerialize = true;
                     KeyFrameAnimationSceneNode animationSceneNode = index as KeyFrameAnimationSceneNode;
                     if (animationSceneNode != null)
                     {
                         animationSceneNode.IsAnimationProxy = false;
                     }
                     toAdd[index] = timelineSceneNode;
                 }
             }
         }
     }
 }
        protected override List <TimelineSceneNode> GetAnimationsToCopy()
        {
            List <TimelineSceneNode> list = new List <TimelineSceneNode>();

            if (this.ViewModel.ElementSelectionSet.Count == 0 && this.ViewModel.KeyFrameSelectionSet.Count > 0)
            {
                Dictionary <TimelineSceneNode.PropertyNodePair, KeyFrameAnimationSceneNode> dictionary = new Dictionary <TimelineSceneNode.PropertyNodePair, KeyFrameAnimationSceneNode>();
                foreach (KeyFrameSceneNode keyFrameSceneNode1 in this.ViewModel.KeyFrameSelectionSet.Selection)
                {
                    if (!AnimationProxyManager.IsAnimationProxy((TimelineSceneNode)keyFrameSceneNode1.KeyFrameAnimation))
                    {
                        KeyFrameSceneNode keyFrameSceneNode2 = this.ViewModel.GetSceneNode(keyFrameSceneNode1.DocumentNode.Clone(keyFrameSceneNode1.DocumentNode.DocumentRoot.DocumentContext)) as KeyFrameSceneNode;
                        if (keyFrameSceneNode2 != null)
                        {
                            TimelineSceneNode.PropertyNodePair key1 = new TimelineSceneNode.PropertyNodePair(keyFrameSceneNode1.TargetElement, keyFrameSceneNode1.TargetProperty);
                            KeyFrameAnimationSceneNode         animationSceneNode;
                            if (!dictionary.ContainsKey(key1))
                            {
                                animationSceneNode = (KeyFrameAnimationSceneNode)KeyFrameAnimationSceneNode.Factory.Instantiate(this.ViewModel, (ITypeId)keyFrameSceneNode1.KeyFrameAnimation.Type);
                                DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)animationSceneNode.DocumentNode;
                                foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)((DocumentCompositeNode)keyFrameSceneNode1.KeyFrameAnimation.DocumentNode).Properties)
                                {
                                    IProperty key2 = keyValuePair.Key;
                                    if (!keyFrameSceneNode1.KeyFrameAnimation.KeyFramesProperty.Equals((object)key2) && !DesignTimeProperties.ShouldSerializeProperty.Equals((object)key2) && !DesignTimeProperties.IsAnimationProxyProperty.Equals((object)key2))
                                    {
                                        documentCompositeNode.Properties[(IPropertyId)key2] = keyValuePair.Value.Clone(documentCompositeNode.Context);
                                    }
                                }
                                dictionary.Add(key1, animationSceneNode);
                                list.Add((TimelineSceneNode)animationSceneNode);
                            }
                            else
                            {
                                animationSceneNode = dictionary[key1];
                            }
                            animationSceneNode.AddKeyFrame(keyFrameSceneNode2);
                        }
                    }
                    else
                    {
                        FromToAnimationSceneNode animationSceneNode1 = this.ViewModel.AnimationProxyManager != null?this.ViewModel.AnimationProxyManager.GetAnimationForProxy(keyFrameSceneNode1.KeyFrameAnimation) : (FromToAnimationSceneNode)null;

                        if (animationSceneNode1 != null)
                        {
                            FromToAnimationSceneNode animationSceneNode2 = this.ViewModel.GetSceneNode(animationSceneNode1.DocumentNode.Clone(animationSceneNode1.DocumentContext)) as FromToAnimationSceneNode;
                            list.Add((TimelineSceneNode)animationSceneNode2);
                            dictionary.Add(animationSceneNode1.TargetElementAndProperty, (KeyFrameAnimationSceneNode)null);
                        }
                    }
                }
            }
            else if (this.ViewModel.ElementSelectionSet.Count > 0 && this.ViewModel.KeyFrameSelectionSet.Count == 0)
            {
                foreach (TimelineSceneNode timelineSceneNode in (IEnumerable <TimelineSceneNode>) this.SourceState.Storyboard.Children)
                {
                    if (timelineSceneNode.ShouldSerialize)
                    {
                        SceneElement sceneElement = timelineSceneNode.TargetElement as SceneElement;
                        if (sceneElement != null && this.ViewModel.ElementSelectionSet.IsSelected(sceneElement))
                        {
                            list.Add(timelineSceneNode);
                        }
                    }
                }
            }
            return(list);
        }
        protected override void OnChildRemoving(SceneNode child)
        {
            base.OnChildRemoving(child);
            TimelineSceneNode timeline = child as TimelineSceneNode;

            if (this.ViewModel.AnimationProxyManager != null && AnimationProxyManager.IsAnimationProxy(timeline))
            {
                this.ViewModel.AnimationProxyManager.UpdateOnDeletion(child as KeyFrameAnimationSceneNode);
            }
            VisualStateSceneNode controllingState = this.ControllingState;

            if (controllingState == null)
            {
                return;
            }
            TimelineSceneNode.PropertyNodePair propertyNodePair = timeline != null ? timeline.TargetElementAndProperty : new TimelineSceneNode.PropertyNodePair((SceneNode)null, (PropertyReference)null);
            VisualStateGroupSceneNode          stateGroup       = controllingState.StateGroup;

            if (propertyNodePair.SceneNode == null || propertyNodePair.PropertyReference == null || (!timeline.ShouldSerialize || stateGroup == null))
            {
                return;
            }
            List <KeyValuePair <VisualStateSceneNode, bool> > list = new List <KeyValuePair <VisualStateSceneNode, bool> >(stateGroup.States.Count);

            list.Add(new KeyValuePair <VisualStateSceneNode, bool>(controllingState, true));
            foreach (VisualStateTransitionSceneNode transitionSceneNode in (IEnumerable <VisualStateTransitionSceneNode>)stateGroup.Transitions)
            {
                if (transitionSceneNode.Storyboard != null && (!string.IsNullOrEmpty(transitionSceneNode.FromStateName) || !string.IsNullOrEmpty(transitionSceneNode.ToStateName)))
                {
                    VisualStateSceneNode fromState = transitionSceneNode.FromState;
                    VisualStateSceneNode toState   = transitionSceneNode.ToState;
                    if (fromState == controllingState || toState == controllingState)
                    {
                        TimelineSceneNode timelineSceneNode = (TimelineSceneNode)transitionSceneNode.Storyboard.GetAnimation(propertyNodePair.SceneNode, propertyNodePair.PropertyReference);
                        if (timelineSceneNode != null)
                        {
                            VisualStateSceneNode key = fromState == controllingState ? toState : fromState;
                            bool?nullable            = new bool?();
                            if (key == null)
                            {
                                nullable = new bool?(false);
                            }
                            if (!nullable.HasValue)
                            {
                                foreach (KeyValuePair <VisualStateSceneNode, bool> keyValuePair in list)
                                {
                                    if (keyValuePair.Key == key)
                                    {
                                        nullable = new bool?(keyValuePair.Value);
                                    }
                                }
                            }
                            if (!nullable.HasValue)
                            {
                                nullable = new bool?(key.Storyboard != null && key.Storyboard.GetAnimation(propertyNodePair.SceneNode, propertyNodePair.PropertyReference) != null);
                                list.Add(new KeyValuePair <VisualStateSceneNode, bool>(key, nullable.Value));
                            }
                            if (!nullable.Value)
                            {
                                transitionSceneNode.Storyboard.Children.Remove(timelineSceneNode);
                            }
                        }
                    }
                }
            }
        }
        public AnimationSceneNode GetAnimation(SceneNode targetElement, PropertyReference targetProperty)
        {
            if (targetElement == null || targetProperty == null)
            {
                return((AnimationSceneNode)null);
            }
            StyleNode styleNode = targetElement as StyleNode;

            if (styleNode != null)
            {
                BaseFrameworkElement targetElement1 = styleNode.TargetElement;
            }
            PropertyReference propertyReference = targetProperty;

            if (propertyReference == null)
            {
                return((AnimationSceneNode)null);
            }
            string path = propertyReference.Path;

            foreach (TimelineSceneNode timelineSceneNode in (IEnumerable <TimelineSceneNode>) this.Children)
            {
                AnimationSceneNode animationSceneNode = timelineSceneNode as AnimationSceneNode;
                if (animationSceneNode != null)
                {
                    TimelineSceneNode.PropertyNodePair elementAndProperty = animationSceneNode.TargetElementAndProperty;
                    if (elementAndProperty.SceneNode == targetElement && elementAndProperty.PropertyReference != null && (elementAndProperty.PropertyReference.Path == path && !AnimationProxyManager.IsOptimizedAnimation((TimelineSceneNode)animationSceneNode)))
                    {
                        return(animationSceneNode);
                    }
                }
            }
            return((AnimationSceneNode)null);
        }
示例#6
0
 private void RemoveAnimation(PropertyReference animationPrefix, Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> toRemove)
 {
     foreach (StoryboardTimelineSceneNode timelineSceneNode in this.targetElement.ViewModel.AnimationEditor.EnumerateStoryboardsForContainer(this.targetElement.StoryboardContainer))
     {
         foreach (TimelineSceneNode timeline in (IEnumerable <TimelineSceneNode>)timelineSceneNode.Children)
         {
             if (timeline.TargetElement == this.targetElement && timeline.TargetProperty != null && !AnimationProxyManager.IsOptimizedAnimation(timeline) && (animationPrefix.Equals((object)timeline.TargetProperty) || animationPrefix.IsPrefixOf(timeline.TargetProperty)))
             {
                 toRemove[timeline] = timelineSceneNode;
             }
         }
     }
 }