コード例 #1
0
ファイル: Transitions.cs プロジェクト: wingc-china/wpaudio
 /// <summary>
 /// Creates an
 /// <see cref="T:Microsoft.Phone.Controls.ITransition"/>
 /// for a
 /// <see cref="T:System.Windows.UIElement"/>
 /// for the turnstile feather transition family.
 /// </summary>
 /// <param name="element">The <see cref="T:System.Windows.UIElement"/>.</param>
 /// <param name="turnstileFeatherTransitionMode">The transition mode.</param>
 /// <param name="beginTime">The time at which the transition should begin.</param>
 /// <returns>The <see cref="T:Microsoft.Phone.Controls.ITransition"/>.</returns>
 public static ITransition TurnstileFeather(UIElement element, TurnstileFeatherTransitionMode turnstileFeatherTransitionMode, TimeSpan?beginTime)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     if (!Enum.IsDefined(typeof(TurnstileFeatherTransitionMode), turnstileFeatherTransitionMode))
     {
         throw new ArgumentOutOfRangeException("turnstileFeatherTransitionMode");
     }
     element.Projection = new PlaneProjection {
         CenterOfRotationX = 0
     };
     return(new FeatheredTransition(element, new Storyboard(), turnstileFeatherTransitionMode, beginTime));
 }
コード例 #2
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();
            };
        }
コード例 #3
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();
            };
        }
コード例 #4
0
 /// <summary>
 /// Constructs a
 /// <see cref="T:Microsoft.Phone.Controls.FeatheredTransition"/>
 /// for a
 /// <see cref="T:System.Windows.UIElement"/>
 /// and a
 /// <see cref="T:System.Windows.Media.Animation.Storyboard"/>,
 /// based on a 
 /// <see cref="T:Microsoft.Phone.Controls.TurnstileFeatherTransitionMode"/>
 /// </summary>
 /// <param name="element">
 /// The <see cref="T:System.Windows.UIElement"/>.
 /// </param>
 /// <param name="storyboard">
 /// The <see cref="T:System.Windows.Media.Animation.Storyboard"/>.
 /// </param>
 /// <param name="mode">
 /// The <see cref="T:Microsoft.Phone.Controls.TurnstileFeatherTransitionMode"/>.
 /// </param>
 /// <param name="beginTime">
 /// The time at which the transition should begin.
 /// </param>
 public FeatheredTransition(UIElement element, Storyboard storyboard, TurnstileFeatherTransitionMode mode, TimeSpan? beginTime)
     : base(element, storyboard)
 {
     _mode = mode;
     _beginTime = beginTime;
 }
コード例 #5
0
 /// <summary>
 /// Constructs a
 /// <see cref="T:Microsoft.Phone.Controls.FeatheredTransition"/>
 /// for a
 /// <see cref="T:System.Windows.UIElement"/>
 /// and a
 /// <see cref="T:System.Windows.Media.Animation.Storyboard"/>,
 /// based on a
 /// <see cref="T:Microsoft.Phone.Controls.TurnstileFeatherTransitionMode"/>
 /// </summary>
 /// <param name="element">
 /// The <see cref="T:System.Windows.UIElement"/>.
 /// </param>
 /// <param name="storyboard">
 /// The <see cref="T:System.Windows.Media.Animation.Storyboard"/>.
 /// </param>
 /// <param name="mode">
 /// The <see cref="T:Microsoft.Phone.Controls.TurnstileFeatherTransitionMode"/>.
 /// </param>
 /// <param name="beginTime">
 /// The time at which the transition should begin.
 /// </param>
 public FeatheredTransition(UIElement element, Storyboard storyboard, TurnstileFeatherTransitionMode mode, TimeSpan?beginTime)
     : base(element, storyboard)
 {
     _mode      = mode;
     _beginTime = beginTime;
 }