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);
        }
Beispiel #2
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);
 }
        public void UpdateTransitionsForStateValueChange(TimelineSceneNode.PropertyNodePair targetElementAndProperty, object newValue)
        {
            VisualStateGroupSceneNode stateGroup = this.StateGroup;

            if (stateGroup != null)
            {
                foreach (VisualStateTransitionSceneNode transitionSceneNode in (IEnumerable <VisualStateTransitionSceneNode>)stateGroup.Transitions)
                {
                    if (transitionSceneNode.ToStateName == this.Name)
                    {
                        transitionSceneNode.UpdateToValuesForStateValueChange(targetElementAndProperty, newValue);
                    }
                }
            }
            this.UpdateAutoTransitions();
        }
Beispiel #4
0
        public void UpdateToValuesForStateValueChange(TimelineSceneNode.PropertyNodePair targetElementAndProperty, object newValue)
        {
            StoryboardTimelineSceneNode storyboard = this.Storyboard;

            if (storyboard == null)
            {
                return;
            }
            foreach (TimelineSceneNode timelineSceneNode in (IEnumerable <TimelineSceneNode>)storyboard.Children)
            {
                AnimationSceneNode animationSceneNode1 = timelineSceneNode as AnimationSceneNode;
                if (animationSceneNode1 != null && animationSceneNode1.TargetElementAndProperty.Equals((object)targetElementAndProperty))
                {
                    FromToAnimationSceneNode animationSceneNode2 = animationSceneNode1 as FromToAnimationSceneNode;
                    if (animationSceneNode2 != null)
                    {
                        bool shouldSerialize = animationSceneNode2.ShouldSerialize;
                        animationSceneNode2.To = newValue;
                        animationSceneNode2.ShouldSerialize = shouldSerialize;
                    }
                }
            }
        }
Beispiel #5
0
        public StoryboardTimelineSceneNode BuildHandoffStoryboardNode()
        {
            if (this.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
            {
                return((StoryboardTimelineSceneNode)null);
            }
            VisualStateSceneNode        fromState          = this.FromState;
            StoryboardTimelineSceneNode timelineSceneNode1 = StoryboardTimelineSceneNode.Factory.Instantiate(this.ViewModel);
            Dictionary <TimelineSceneNode.PropertyNodePair, AnimationSceneNode> dictionary = new Dictionary <TimelineSceneNode.PropertyNodePair, AnimationSceneNode>();

            if (fromState != null && fromState.Storyboard != null)
            {
                foreach (TimelineSceneNode timelineSceneNode2 in (IEnumerable <TimelineSceneNode>)fromState.Storyboard.Children)
                {
                    AnimationSceneNode animationSceneNode1 = timelineSceneNode2 as AnimationSceneNode;
                    if (animationSceneNode1 != null)
                    {
                        TimelineSceneNode.PropertyNodePair elementAndProperty = animationSceneNode1.TargetElementAndProperty;
                        if (this.ShouldGenerateHandoffAnimationFor(animationSceneNode1, elementAndProperty))
                        {
                            ITypeId            animationForType    = FromToAnimationSceneNode.GetFromToAnimationForType(animationSceneNode1.AnimatedType, animationSceneNode1.ProjectContext);
                            AnimationSceneNode animationSceneNode2 = (AnimationSceneNode)null;
                            if (animationForType != null)
                            {
                                FromToAnimationSceneNode animationSceneNode3 = FromToAnimationSceneNode.Factory.InstantiateWithTarget(animationSceneNode1.ViewModel, animationSceneNode1.TargetElement, animationSceneNode1.TargetProperty, animationSceneNode1.StoryboardContainer, animationForType);
                                object transitionValue = VisualStateTransitionSceneNode.GetTransitionValue(animationSceneNode1, true);
                                animationSceneNode3.To       = transitionValue;
                                animationSceneNode3.Duration = 0.0;
                                animationSceneNode2          = (AnimationSceneNode)animationSceneNode3;
                            }
                            else
                            {
                                object transitionValue = VisualStateTransitionSceneNode.GetTransitionValue(animationSceneNode1, true);
                                if (transitionValue != null && elementAndProperty.SceneNode != null && elementAndProperty.PropertyReference != null)
                                {
                                    KeyFrameAnimationSceneNode animationSceneNode3 = KeyFrameAnimationSceneNode.Factory.InstantiateWithTarget(animationSceneNode1.ViewModel, elementAndProperty.SceneNode, elementAndProperty.PropertyReference, animationSceneNode1.StoryboardContainer, PlatformTypes.ObjectAnimationUsingKeyFrames);
                                    animationSceneNode3.AddKeyFrame(0.0, transitionValue);
                                    animationSceneNode2 = (AnimationSceneNode)animationSceneNode3;
                                }
                            }
                            if (animationSceneNode2 != null)
                            {
                                timelineSceneNode1.Children.Add((TimelineSceneNode)animationSceneNode2);
                                dictionary[elementAndProperty] = animationSceneNode2;
                            }
                        }
                    }
                }
            }
            foreach (TimelineSceneNode timelineSceneNode2 in (IEnumerable <TimelineSceneNode>) this.Storyboard.Children)
            {
                AnimationSceneNode animation = timelineSceneNode2 as AnimationSceneNode;
                if (animation != null)
                {
                    TimelineSceneNode.PropertyNodePair elementAndProperty = timelineSceneNode2.TargetElementAndProperty;
                    if (this.ShouldGenerateHandoffAnimationFor(animation, elementAndProperty) && !dictionary.ContainsKey(elementAndProperty))
                    {
                        ITypeId animationForType = FromToAnimationSceneNode.GetFromToAnimationForType(animation.AnimatedType, animation.ProjectContext);
                        if (elementAndProperty.SceneNode != null && elementAndProperty.PropertyReference != null)
                        {
                            if (animationForType != null)
                            {
                                FromToAnimationSceneNode animationSceneNode = FromToAnimationSceneNode.Factory.InstantiateWithTarget(animation.ViewModel, elementAndProperty.SceneNode, elementAndProperty.PropertyReference, animation.StoryboardContainer, animationForType);
                                timelineSceneNode1.Children.Add((TimelineSceneNode)animationSceneNode);
                                animationSceneNode.Duration = 0.0;
                            }
                            else
                            {
                                object computedValue = elementAndProperty.SceneNode.GetComputedValue(elementAndProperty.PropertyReference);
                                if (computedValue != null)
                                {
                                    KeyFrameAnimationSceneNode animationSceneNode = KeyFrameAnimationSceneNode.Factory.InstantiateWithTarget(animation.ViewModel, elementAndProperty.SceneNode, elementAndProperty.PropertyReference, animation.StoryboardContainer, PlatformTypes.ObjectAnimationUsingKeyFrames);
                                    animationSceneNode.AddKeyFrame(0.0, computedValue);
                                    timelineSceneNode1.Children.Add((TimelineSceneNode)animationSceneNode);
                                }
                            }
                        }
                    }
                }
            }
            return(timelineSceneNode1);
        }
Beispiel #6
0
        private bool UpdateTransitionTimelineForState(VisualStateSceneNode state, bool stateIsFromState, bool updateDocument, Dictionary <TimelineSceneNode.PropertyNodePair, TransitionAnimationData> animations, StoryboardTimelineSceneNode transitionStoryboard)
        {
            bool      flag1    = false;
            bool      flag2    = false;
            IProperty property = this.ProjectContext.ResolveProperty(VisualStateManagerSceneNode.TransitionEffectProperty);

            if (property != null && this.GetLocalValueAsDocumentNode((IPropertyId)property) != null)
            {
                flag2 = true;
            }
            if (state != null && state.Storyboard != null)
            {
                foreach (TimelineSceneNode timelineSceneNode in (IEnumerable <TimelineSceneNode>)state.Storyboard.Children)
                {
                    TransitionAnimationData transitionAnimationData = (TransitionAnimationData)null;
                    AnimationSceneNode      stateAnimation          = timelineSceneNode as AnimationSceneNode;
                    if (stateAnimation != null && stateAnimation.ShouldSerialize)
                    {
                        if (!animations.TryGetValue(stateAnimation.TargetElementAndProperty, out transitionAnimationData))
                        {
                            ITypeId animatedType = stateAnimation.AnimatedType;
                            bool    isConforming = VisualStateManagerSceneNode.IsSupportedTransitionAnimationType(animatedType);
                            if (updateDocument)
                            {
                                TimelineSceneNode.PropertyNodePair elementAndProperty = stateAnimation.TargetElementAndProperty;
                                if (isConforming && !flag2 && (elementAndProperty.SceneNode != null && elementAndProperty.PropertyReference != null))
                                {
                                    FromToAnimationSceneNode animationSceneNode1 = FromToAnimationSceneNode.Factory.InstantiateWithTarget(stateAnimation.ViewModel, elementAndProperty.SceneNode, elementAndProperty.PropertyReference, stateAnimation.StoryboardContainer, FromToAnimationSceneNode.GetFromToAnimationForType(animatedType, stateAnimation.ProjectContext));
                                    animationSceneNode1.EasingFunction = this.GeneratedEasingFunction;
                                    AnimationSceneNode animationSceneNode2 = (AnimationSceneNode)animationSceneNode1;
                                    transitionStoryboard.Children.Add((TimelineSceneNode)animationSceneNode2);
                                    animationSceneNode1.ShouldSerialize = false;
                                    transitionAnimationData             = new TransitionAnimationData((AnimationSceneNode)animationSceneNode1, true);
                                    animations[stateAnimation.TargetElementAndProperty] = transitionAnimationData;
                                }
                                else
                                {
                                    transitionAnimationData = new TransitionAnimationData((AnimationSceneNode)null, false);
                                    animations[stateAnimation.TargetElementAndProperty] = transitionAnimationData;
                                }
                            }
                            else
                            {
                                transitionAnimationData = new TransitionAnimationData((AnimationSceneNode)null, isConforming);
                                animations[stateAnimation.TargetElementAndProperty] = transitionAnimationData;
                            }
                        }
                        else if (flag2 && transitionAnimationData.TransitionAnimation != null && !transitionAnimationData.TransitionAnimation.ShouldSerialize)
                        {
                            if (updateDocument)
                            {
                                transitionStoryboard.Children.Remove((TimelineSceneNode)transitionAnimationData.TransitionAnimation);
                            }
                            transitionAnimationData.TransitionAnimation = (AnimationSceneNode)null;
                        }
                        AnimationSceneNode transitionAnimation = transitionAnimationData.TransitionAnimation;
                        if (transitionAnimation != null)
                        {
                            FromToAnimationSceneNode animationSceneNode = transitionAnimation as FromToAnimationSceneNode;
                            if (animationSceneNode != null)
                            {
                                object objB = !stateIsFromState?VisualStateTransitionSceneNode.GetTransitionValue(stateAnimation, stateIsFromState) : (object)null;

                                if (!transitionAnimation.ShouldSerialize)
                                {
                                    if (updateDocument)
                                    {
                                        if (!stateIsFromState)
                                        {
                                            animationSceneNode.To = objB;
                                        }
                                        Duration generatedDuration = this.GeneratedDuration;
                                        if (generatedDuration.HasTimeSpan)
                                        {
                                            animationSceneNode.Duration = generatedDuration.TimeSpan.TotalSeconds;
                                        }
                                        else
                                        {
                                            animationSceneNode.Duration = 0.0;
                                        }
                                        animationSceneNode.EasingFunction  = this.GeneratedEasingFunction;
                                        animationSceneNode.ShouldSerialize = false;
                                    }
                                }
                                else
                                {
                                    transitionAnimationData.IsConforming = !stateIsFromState ? animationSceneNode.From == null && object.Equals(animationSceneNode.To, objB) : animationSceneNode.To == null;
                                    flag1 = true;
                                }
                            }
                            else
                            {
                                flag1 = true;
                            }
                        }
                    }
                }
            }
            return(flag1);
        }
        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);
                            }
                        }
                    }
                }
            }
        }