예제 #1
0
        /// <summary>
        ///     Method, executed each animation step.
        /// </summary>
        /// <param name="xGlobal">Current X [0;1] value.</param>
        /// <param name="state">
        ///     Animation state object, created by <see cref="AnimationBase{TState}.StoreAnimationState" /> and
        ///     returned.
        /// </param>
        protected override void Update(double xGlobal, KeyFrameAnimationState <TAnimationValue> state)
        {
            var animationDuration = Duration.ToTimeSpan().TotalMilliseconds;

            for (var i = 0; i < KeyFrames.Count; i++)
            {
                var keyFrame = KeyFrames[i];
                var x1       = keyFrame.KeyTime.TotalMilliseconds / animationDuration;
                if (xGlobal < x1)
                {
                    continue;
                }
                if (i == 1)
                {
                }

                var x2 = (i < KeyFrames.Count - 1
                             ? KeyFrames[i + 1].KeyTime.TotalMilliseconds
                             : animationDuration) / animationDuration;
                if (xGlobal > x2)
                {
                    continue;
                }
                var x = (xGlobal - x1) / (x2 - x1);

                state.PreviousKeyFrameValue = i > 0 ? KeyFrames[i - 1].Value : state.StoredValue;

                keyFrame.Update(x, state);
            }
        }
예제 #2
0
 /// <summary>
 ///     Method, executed when animation finished execution.
 /// </summary>
 /// <param name="target"><see cref="BindableObject" />target bindable, changed in scope of animation.</param>
 /// <param name="state">
 ///     Animation state object, created by <see cref="AnimationBase{TState}.StoreAnimationState" /> and
 ///     returned.
 /// </param>
 protected override void RestoreAnimationState(BindableObject target,
                                               KeyFrameAnimationState <TAnimationValue> state)
 {
     if (FillBehavior == FillBehavior.Stop)
     {
         state.Target.SetValue(TargetProperty, state.StoredValue);
     }
 }
예제 #3
0
 ///<inheritdoc cref="KeyFrame{TValue}"/>
 /// <summary>
 /// <see cref="AnimationState.Target"/>.<see cref="KeyFrameAnimationState{T}.TargetProperty"/> update logic.
 /// </summary>
 /// <param name="x">
 ///     [0;1] value, describes KeyFrame's owner animation position, calculated based on <see cref="IAnimation.BeginTime" />,
 ///     <see cref="IAnimation.Duration" /> and current animation's position.
 /// </param>
 /// <param name="state"><see cref="KeyFrameAnimation{TAnimationValue}"/> animation state object.</param>
 public override void Update(double x, KeyFrameAnimationState <TValue> state)
 {
     state.Target.SetValue(state.TargetProperty, Value);
 }
예제 #4
0
 /// <summary>
 ///     Should be implemented in descendants and contains some <see cref="KeyFrameAnimationState{T}.TargetProperty" />
 ///     updation logic.
 /// </summary>
 /// <param name="x">
 ///     [0;1] value, describes KeyFrame's owner animation position, calculated based on <see cref="IAnimation.BeginTime" />,
 ///     <see cref="IAnimation.Duration" /> and current animation's position.
 /// </param>
 /// <param name="state"><see cref="KeyFrameAnimation{TAnimationValue}" /> animation state object.</param>
 public override void Update(double x, KeyFrameAnimationState <TValue> state)
 {
     state.Target.SetValue(state.TargetProperty, GetInterpolatedValue(x, state.PreviousKeyFrameValue));
 }