Frontend for running arbitrary code after an animation.

Note: Specifying a duration using For() creates a dummy animation that lasts for the specified duration.

Inheritance: AbstractAnimator
示例#1
0
        /// <summary>
        /// <para>Executes the user code a specified duration after
        /// the animation represented by the specified token.</para>
        /// <para>Note: This method produces a working EventToken</para>
        /// </summary>
        /// <param name="token"></param>
        /// <param name="duration"></param>
        /// <param name="timeType"></param>
        /// <returns>A token representing the animation</returns>
        public override EventToken After(EventToken token, double duration, OrSo timeType)
        {
            EventToken placeholder = EventToken.PlaceholderToken();

            // Separate the delay into stages
            // Use another CodeAnimator to trigger the timer after
            // the original animation
            var afterTokenAnimator = new CodeAnimator(() =>
            {
                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval        = GetTimeSpan(duration, timeType);
                timer.Tick           += (s, e) =>
                {
                    timer.Stop();
                    placeholder.PassOn(Now());
                };
                timer.Start();
            });

            afterTokenAnimator.After(token);

            return(placeholder);
        }
示例#2
0
        /// <summary>
        /// <para>Executes the user code a specified duration after 
        /// the animation represented by the specified token.</para>
        /// <para>Note: This method produces a working EventToken</para>
        /// </summary>
        /// <param name="token"></param>
        /// <param name="duration"></param>
        /// <param name="timeType"></param>
        /// <returns>A token representing the animation</returns>
        public override EventToken After(EventToken token, double duration, OrSo timeType)
        {
            EventToken placeholder = EventToken.PlaceholderToken();

            // Separate the delay into stages
            // Use another CodeAnimator to trigger the timer after
            // the original animation
            var afterTokenAnimator = new CodeAnimator(() =>
            {
                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval = GetTimeSpan(duration, timeType);
                timer.Tick += (s, e) =>
                {
                    timer.Stop();
                    placeholder.PassOn(Now());
                };
                timer.Start();
            });

            afterTokenAnimator.After(token);

            return placeholder;
        }