private static GetOriginalOpacity ( |
||
obj | The dependency object. | |
return | double |
/// <summary> /// Adds a set of animations corresponding to the /// turnstile feather effect. /// </summary> /// <param name="storyboard"> /// The storyboard where the animations /// will be added.</param> /// <param name="beginTime"> /// The time at which the storyboard should begin.</param> /// <param name="mode"> /// The mode of the turnstile feather effect. /// </param> internal static void ComposeStoryboard(Storyboard storyboard, TimeSpan?beginTime, TurnstileFeatherTransitionMode mode) { RestoreProjectionsAndTransforms(); _featheringTargets = GetTargetsToAnimate(); if (_featheringTargets == null) { return; } _pendingRestore = true; switch (mode) { case TurnstileFeatherTransitionMode.ForwardIn: ComposeForwardInStoryboard(storyboard); break; case TurnstileFeatherTransitionMode.ForwardOut: ComposeForwardOutStoryboard(storyboard); break; case TurnstileFeatherTransitionMode.BackwardIn: ComposeBackwardInStoryboard(storyboard); break; case TurnstileFeatherTransitionMode.BackwardOut: ComposeBackwardOutStoryboard(storyboard); break; default: break; } storyboard.BeginTime = beginTime; storyboard.Completed += (s, e) => { foreach (WeakReference r in _featheringTargets) { FrameworkElement element = (FrameworkElement)r.Target; double originalOpacity = TurnstileFeatherEffect.GetOriginalOpacity(element); element.Opacity = originalOpacity; } RestoreProjectionsAndTransforms(); }; }
/// <summary> /// Adds a set of animations corresponding to the /// turnstile feather forward in effect. /// </summary> /// <param name="storyboard"> /// The storyboard where the animations /// will be added. /// </param> private static void ComposeForwardInStoryboard(Storyboard storyboard) { int counter = 0; PhoneApplicationFrame root = Application.Current.RootVisual as PhoneApplicationFrame; foreach (WeakReference r in _featheringTargets) { FrameworkElement element = (FrameworkElement)r.Target; double originalOpacity = element.Opacity; TurnstileFeatherEffect.SetOriginalOpacity(element, originalOpacity); // Hide the element until the storyboard is begun. element.Opacity = 0.0; if (!TryAttachProjectionAndTransform(root, element)) { continue; } DoubleAnimation doubleAnimation = new DoubleAnimation() { Duration = TimeSpan.FromMilliseconds(ForwardInFeatheringDuration), From = ForwardInFeatheringAngle, To = 0.0, BeginTime = TimeSpan.FromMilliseconds(ForwardInFeatheringDelay * counter), EasingFunction = TurnstileFeatheringExponentialEaseOut }; Storyboard.SetTarget(doubleAnimation, element); Storyboard.SetTargetProperty(doubleAnimation, RotationYPropertyPath); storyboard.Children.Add(doubleAnimation); doubleAnimation = new DoubleAnimation() { Duration = TimeSpan.Zero, From = 0.0, To = TurnstileFeatherEffect.GetOriginalOpacity(element), BeginTime = TimeSpan.FromMilliseconds(ForwardInFeatheringDelay * counter) }; Storyboard.SetTarget(doubleAnimation, element); Storyboard.SetTargetProperty(doubleAnimation, OpacityPropertyPath); storyboard.Children.Add(doubleAnimation); counter++; } }