public void UpdateAutoTransitionsForState(VisualStateSceneNode state) { if (!state.StateGroup.IsSketchFlowAnimation || !(this.FromStateName != VisualStateManagerSceneNode.SketchFlowAnimationHoldTimeStateName)) { return; } StoryboardTimelineSceneNode storyboard = state.Storyboard; Dictionary <TimelineSceneNode.PropertyNodePair, TimelineSceneNode> dictionary1 = new Dictionary <TimelineSceneNode.PropertyNodePair, TimelineSceneNode>(); Dictionary <TimelineSceneNode.PropertyNodePair, KeyFrameAnimationSceneNode> dictionary2 = new Dictionary <TimelineSceneNode.PropertyNodePair, KeyFrameAnimationSceneNode>(); StoryboardTimelineSceneNode timelineSceneNode1 = this.Storyboard; if (timelineSceneNode1 != null) { foreach (TimelineSceneNode timelineSceneNode2 in (IEnumerable <TimelineSceneNode>)timelineSceneNode1.Children) { KeyFrameAnimationSceneNode animationSceneNode = timelineSceneNode2 as KeyFrameAnimationSceneNode; if (animationSceneNode != null) { dictionary2[timelineSceneNode2.TargetElementAndProperty] = animationSceneNode; } } } if (storyboard != null) { foreach (TimelineSceneNode timelineSceneNode2 in (IEnumerable <TimelineSceneNode>)storyboard.Children) { dictionary1[timelineSceneNode2.TargetElementAndProperty] = timelineSceneNode2; KeyFrameAnimationSceneNode animationSceneNode1 = timelineSceneNode2 as KeyFrameAnimationSceneNode; if (animationSceneNode1 != null && animationSceneNode1.NoAutoTransitionsProvided) { if (dictionary2.ContainsKey(timelineSceneNode2.TargetElementAndProperty)) { KeyFrameAnimationSceneNode animationSceneNode2 = dictionary2[timelineSceneNode2.TargetElementAndProperty]; if (animationSceneNode1.KeyFrameCount > 0 && (bool)animationSceneNode2.GetLocalOrDefaultValue(DesignTimeProperties.AutoTransitionProperty)) { if (animationSceneNode2.KeyFrameCount > 0) { animationSceneNode2.GetKeyFrameAtIndex(animationSceneNode2.KeyFrameCount - 1).Value = animationSceneNode1.GetKeyFrameAtIndex(0).Value; } else { animationSceneNode2.AddKeyFrame(0.0, animationSceneNode1.GetKeyFrameAtIndex(0).Value); } } } else { if (timelineSceneNode1 == null) { timelineSceneNode1 = StoryboardTimelineSceneNode.Factory.Instantiate(this.ViewModel); this.Storyboard = timelineSceneNode1; } KeyFrameAnimationSceneNode animationSceneNode2 = KeyFrameAnimationSceneNode.Factory.InstantiateWithTarget(this.ViewModel, animationSceneNode1.TargetElementAndProperty.SceneNode, animationSceneNode1.TargetElementAndProperty.PropertyReference, this.StoryboardContainer, KeyFrameAnimationSceneNode.GetKeyFrameAnimationForType(animationSceneNode1.AnimatedType, this.ProjectContext)); animationSceneNode2.ShouldSerialize = true; animationSceneNode2.SetValue(DesignTimeProperties.AutoTransitionProperty, (object)true); if (animationSceneNode1.KeyFrameCount > 0) { animationSceneNode2.AddKeyFrame(0.0, animationSceneNode1.GetKeyFrameAtIndex(0).Value); } timelineSceneNode1.Children.Add((TimelineSceneNode)animationSceneNode2); } } } } if (timelineSceneNode1 == null) { return; } foreach (TimelineSceneNode timelineSceneNode2 in (IEnumerable <TimelineSceneNode>)timelineSceneNode1.Children) { if ((bool)timelineSceneNode2.GetLocalOrDefaultValue(DesignTimeProperties.AutoTransitionProperty) && !dictionary1.ContainsKey(timelineSceneNode2.TargetElementAndProperty)) { timelineSceneNode2.Remove(); } } if (timelineSceneNode1.Children.Count != 0) { return; } timelineSceneNode1.Remove(); }
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); }