public static ITypeId GetPathAnimationForType(ITypeId type) { ITypeId typeId; AnimationSceneNode.PlatformNeutralTypeDictionaryTryGetValue(PathAnimationSceneNode.animationsForTypes, type, out typeId); return(typeId); }
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); }
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 static ITypeId GetFromToAnimationForType(ITypeId type, IProjectContext projectContext) { ITypeId type1 = (ITypeId)null; bool flag = AnimationSceneNode.PlatformNeutralTypeDictionaryTryGetValue(FromToAnimationSceneNode.animationsForTypes, type, out type1); if (flag) { flag = projectContext.Platform.Metadata.IsSupported((ITypeResolver)projectContext, type1); } if (!flag) { type1 = (ITypeId)null; } return(type1); }
public void UpdateTransitionStoryboard(bool updateDocument, Dictionary <TimelineSceneNode.PropertyNodePair, TransitionAnimationData> transitionTable) { StoryboardTimelineSceneNode transitionStoryboard = this.Storyboard; bool flag1 = false; if (transitionStoryboard == null && updateDocument) { transitionStoryboard = StoryboardTimelineSceneNode.Factory.Instantiate(this.ViewModel); this.Storyboard = transitionStoryboard; flag1 = false; } VisualStateSceneNode fromState = this.FromState; VisualStateSceneNode toState = this.ToState; Dictionary <TimelineSceneNode.PropertyNodePair, TransitionAnimationData> animations = transitionTable; if (animations == null) { animations = new Dictionary <TimelineSceneNode.PropertyNodePair, TransitionAnimationData>(); } else { animations.Clear(); } if (transitionStoryboard != null) { foreach (TimelineSceneNode timelineSceneNode in (IEnumerable <TimelineSceneNode>)transitionStoryboard.Children) { AnimationSceneNode animation = timelineSceneNode as AnimationSceneNode; if (animation != null) { animations[animation.TargetElementAndProperty] = new TransitionAnimationData(animation, !animation.ShouldSerialize); if (animation.ShouldSerialize) { flag1 = true; } } } } bool flag2 = flag1 | this.UpdateTransitionTimelineForState(fromState, true, updateDocument, animations, transitionStoryboard) | this.UpdateTransitionTimelineForState(toState, false, updateDocument, animations, transitionStoryboard); if (!updateDocument) { return; } transitionStoryboard.ShouldSerialize = flag2; }
public static object GetTransitionValue(AnimationSceneNode stateAnimation, bool animationIsFromFromState) { KeyFrameAnimationSceneNode animationSceneNode1 = stateAnimation as KeyFrameAnimationSceneNode; FromToAnimationSceneNode animationSceneNode2 = stateAnimation as FromToAnimationSceneNode; object obj = (object)null; if (animationSceneNode1 != null) { int keyFrameCount = animationSceneNode1.KeyFrameCount; if (keyFrameCount > 0) { obj = !animationIsFromFromState?animationSceneNode1.GetKeyFrameAtIndex(0).Value : animationSceneNode1.GetKeyFrameAtIndex(keyFrameCount - 1).Value; } } if (animationSceneNode2 != null) { obj = !animationIsFromFromState ? animationSceneNode2.From ?? animationSceneNode2.To : animationSceneNode2.To; } return(obj); }
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; } } } }
private ITypeId GetKeyFrameType(KeyFrameInterpolationType keyFrameInterpolationType) { ITypeId typeId; switch (keyFrameInterpolationType) { case KeyFrameInterpolationType.Discrete: AnimationSceneNode.PlatformNeutralTypeDictionaryTryGetValue(KeyFrameAnimationSceneNode.discreteKeyFrameTypes, this.AnimatedType, out typeId); break; case KeyFrameInterpolationType.Spline: AnimationSceneNode.PlatformNeutralTypeDictionaryTryGetValue(KeyFrameAnimationSceneNode.splineKeyFrameTypes, this.AnimatedType, out typeId); break; case KeyFrameInterpolationType.Easing: AnimationSceneNode.PlatformNeutralTypeDictionaryTryGetValue(KeyFrameAnimationSceneNode.easingKeyFrameTypes, this.AnimatedType, out typeId); break; default: typeId = (ITypeId)null; break; } return(typeId); }
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); }
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); }