Ejemplo n.º 1
0
        /// <summary>
        /// Gets the animation time for the specified time value on the timeline. (This helper method
        /// can be used for animations which start at time 0 and run with normal speed.)
        /// </summary>
        /// <param name="timeline">The timeline.</param>
        /// <param name="time">The time on the timeline.</param>
        /// <returns>
        /// The animation time. (Or <see langword="null"/> if the animation is not active at
        /// <paramref name="time"/>.)
        /// </returns>
        internal static TimeSpan?GetAnimationTime(ITimeline timeline, TimeSpan time)
        {
            if (time < TimeSpan.Zero)
            {
                // The animation has not started.
                return(null);
            }

            TimeSpan duration = timeline.GetTotalDuration();

            if (time > duration)
            {
                if (timeline.FillBehavior == FillBehavior.Stop)
                {
                    // The animation has stopped.
                    return(null);
                }

                // The animation holds the final value.
                Debug.Assert(timeline.FillBehavior == FillBehavior.Hold);
                return(duration);
            }

            return(time);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the state of the animation for the specified time on the timeline. (This helper method
        /// can be used for animations which start at time 0 and run with normal speed.)
        /// </summary>
        /// <param name="timeline">The timeline.</param>
        /// <param name="time">The time on the timeline.</param>
        /// <returns>The animation state.</returns>
        internal static AnimationState GetState(ITimeline timeline, TimeSpan time)
        {
            if (time < TimeSpan.Zero)
            {
                // The animation has not started.
                return(AnimationState.Delayed);
            }

            TimeSpan duration = timeline.GetTotalDuration();

            if (time > duration)
            {
                if (timeline.FillBehavior == FillBehavior.Stop)
                {
                    // The animation has stopped.
                    return(AnimationState.Stopped);
                }

                // The animation holds the last value.
                Debug.Assert(timeline.FillBehavior == FillBehavior.Hold);
                return(AnimationState.Filling);
            }

            return(AnimationState.Playing);
        }