Represents an animation created using Monolith. Used to chain animations together.
示例#1
0
        /// <summary>
        /// <para>Executes the user code after a specified duration.</para>
        /// <para>Note: This method produces a working EventToken</para>
        /// </summary>
        /// <param name="duration"></param>
        /// <param name="timeType"></param>
        /// <returns>A token representing the animation</returns>
        public override EventToken After(double duration, OrSo timeType)
        {
            DispatcherTimer timer       = new DispatcherTimer();
            EventToken      placeholder = EventToken.PlaceholderToken();

            timer.Interval = GetTimeSpan(duration, timeType);
            timer.Tick    += (s, e) =>
            {
                timer.Stop();
                placeholder.PassOn(Now());
            };
            timer.Start();

            return(placeholder);
        }
示例#2
0
        /// <summary>
        /// Executes the animation after the animation represented by the specified token.
        /// </summary>
        /// <param name="token"></param>
        /// <returns>A token representing the animation</returns>
        public virtual EventToken After(EventToken token)
        {
            if (_storyboard == null)
            {
                CreateStoryboard();
            }

            _storyboard.AutoReverse = _reverse;

            token.AddChildAnimator(this);

            if (_eventToken == null)
            {
                _eventToken = new EventToken(_animation, _storyboard);
            }
            return _eventToken;
        }
示例#3
0
        /// <summary>
        /// Executes the animation immediately.
        /// </summary>
        /// <returns>A token representing the animation</returns>
        public virtual EventToken Now()
        {
            if (_storyboard == null)
            {
                CreateStoryboard();
            }

            _storyboard.AutoReverse = _reverse;

            _storyboard.Begin();

            if (_eventToken == null)
            {
                _eventToken = new EventToken(_animation, _storyboard);
            }
            return(_eventToken);
        }
示例#4
0
        /// <summary>
        /// Executes the animation after a specified duration after the animation represented by the specified token.
        /// </summary>
        /// <param name="token"></param>
        /// <param name="duration"></param>
        /// <param name="timeType"></param>
        /// <returns>A token representing the animation</returns>
        public virtual EventToken After(EventToken token, double duration, OrSo timeType)
        {
            if (_storyboard == null)
            {
                CreateStoryboard();
            }

            _storyboard.AutoReverse = _reverse;

            token.AddChildAnimator(this, GetTimeSpan(duration, timeType));

            if (_eventToken == null)
            {
                _eventToken = new EventToken(_animation, _storyboard);
            }
            return(_eventToken);
        }
示例#5
0
        /// <summary>
        /// Executes the animation after the animation represented by the specified token.
        /// </summary>
        /// <param name="token"></param>
        /// <returns>A token representing the animation</returns>
        public virtual EventToken After(EventToken token)
        {
            if (_storyboard == null)
            {
                CreateStoryboard();
            }

            _storyboard.AutoReverse = _reverse;

            token.AddChildAnimator(this);

            if (_eventToken == null)
            {
                _eventToken = new EventToken(_animation, _storyboard);
            }
            return(_eventToken);
        }
示例#6
0
        /// <summary>
        /// Executes the animation after a specified duration.
        /// </summary>
        /// <param name="duration"></param>
        /// <param name="timeType"></param>
        /// <returns>A token representing the animation</returns>
        public virtual EventToken After(double duration, OrSo timeType)
        {
            if (_storyboard == null)
            {
                CreateStoryboard();
            }

            _animation.BeginTime = GetTimeSpan(duration, timeType);

            _storyboard.AutoReverse = _reverse;

            _storyboard.Begin();

            if (_eventToken == null)
            {
                _eventToken = new EventToken(_animation, _storyboard);
            }
            return _eventToken;
        }
示例#7
0
        /// <summary>
        /// Executes the animation after a specified duration.
        /// </summary>
        /// <param name="duration"></param>
        /// <param name="timeType"></param>
        /// <returns>A token representing the animation</returns>
        public virtual EventToken After(double duration, OrSo timeType)
        {
            if (_storyboard == null)
            {
                CreateStoryboard();
            }


            _animation.BeginTime = GetTimeSpan(duration, timeType);

            _storyboard.AutoReverse = _reverse;

            _storyboard.Begin();

            if (_eventToken == null)
            {
                _eventToken = new EventToken(_animation, _storyboard);
            }
            return(_eventToken);
        }
示例#8
0
        /// <summary>
        /// Passes on child animations to the specified successor.
        ///
        /// The current EventToken's child animations are activated by the
        /// successor's completion events.
        ///
        /// Used in conjunction with EventToken.PlaceHolderToken for creating
        /// animations out of order.
        /// </summary>
        /// <param name="successor"></param>
        /// <returns></returns>
        public EventToken PassOn(EventToken successor)
        {
            // Unregister for the predecessor's completion events
            if (_Animation != null)
            {
                _Animation.Completed -= AnimationEventHandler;
            }

            // Hand off the children to the successor
            if (_Children != null)
            {
                foreach (IAnimator anim in _Children.Keys)
                {
                    successor.AddChildAnimator(anim, _Children[anim]);
                }

                _Children.Clear();
            }

            return(successor);
        }
示例#9
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);
        }
示例#10
0
        /// <summary>
        /// Executes the animation after a specified duration after the animation represented by the specified token.
        /// </summary>
        /// <param name="token"></param>
        /// <param name="duration"></param>
        /// <param name="timeType"></param>
        /// <returns>A token representing the animation</returns>
        public virtual EventToken After(EventToken token, double duration, OrSo timeType)
        {
            if (_storyboard == null)
            {
                CreateStoryboard();
            }

            _storyboard.AutoReverse = _reverse;

            token.AddChildAnimator(this, GetTimeSpan(duration, timeType));

            if (_eventToken == null)
            {
                _eventToken = new EventToken(_animation, _storyboard);
            }
            return _eventToken;
        }
示例#11
0
        /// <summary>
        /// Executes the animation immediately.
        /// </summary>
        /// <returns>A token representing the animation</returns>
        public virtual EventToken Now()
        {
            if (_storyboard == null)
            {
                CreateStoryboard();
            }

            _storyboard.AutoReverse = _reverse;

            _storyboard.Begin();

            if (_eventToken == null)
            {
                _eventToken = new EventToken(_animation, _storyboard);
            }
            return _eventToken;
        }
示例#12
0
        /// <summary>
        /// Passes on child animations to the specified successor.
        ///
        /// The current EventToken's child animations are activated by the
        /// successor's completion events.
        ///
        /// Used in conjunction with EventToken.PlaceHolderToken for creating
        /// animations out of order.
        /// </summary>
        /// <param name="successor"></param>
        /// <returns></returns>
        public EventToken PassOn(EventToken successor)
        {
            // Unregister for the predecessor's completion events
            if (_Animation != null)
            {
                _Animation.Completed -= AnimationEventHandler;
            }

            // Hand off the children to the successor
            if (_Children != null)
            {
                foreach (IAnimator anim in _Children.Keys)
                {
                    successor.AddChildAnimator(anim, _Children[anim]);
                }

                _Children.Clear();
            }

            return successor;
        }
示例#13
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;
        }
示例#14
0
 /// <summary>
 /// <para>Executes the user code after the animation
 /// animation represented by the specified token.</para>
 /// <para>Note: This method produces a working EventToken</para>
 /// </summary>
 /// <param name="token"></param>
 /// <returns>A token representing the animation</returns>
 public override EventToken After(EventToken token)
 {
     return base.After(token);
 }
示例#15
0
 /// <summary>
 /// <para>Executes the user code after the animation
 /// animation represented by the specified token.</para>
 /// <para>Note: This method produces a working EventToken</para>
 /// </summary>
 /// <param name="token"></param>
 /// <returns>A token representing the animation</returns>
 public override EventToken After(EventToken token)
 {
     return(base.After(token));
 }