GetOriginalOpacity() 개인적인 정적인 메소드

Gets the original opacity of the specified dependency object before the turnstile feather effect is applied to it.
private static GetOriginalOpacity ( DependencyObject obj ) : double
obj System.Windows.DependencyObject The dependency object.
리턴 double
예제 #1
0
        /// <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();
            };
        }
예제 #2
0
        /// <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++;
            }
        }