Ejemplo n.º 1
0
        /// <summary>
        /// Called when seek.
        /// </summary>
        protected override void OnSeek(TimeSpan currentPosition, TimeSpan previousPosition)
        {
            float percentage = 0;
            float position   = (float)(Position.TotalSeconds / Duration.TotalSeconds);

            ICurve evaluator = curve ?? Curves.Linear;

            if (!float.IsNaN(position))
            {
                switch (Easing)
                {
                case Easing.In:
                    percentage = evaluator.Evaluate(position);
                    break;

                case Easing.Out:
                    percentage = 1.0f - evaluator.Evaluate(1.0f - position);
                    break;

                case Easing.InOut:
                    percentage = position < 0.5f ? (0.5f - Curve.Evaluate(1.0f - position * 2) * 0.5f) :
                                 (0.5f + Curve.Evaluate((position - 0.5f) * 2) * 0.5f);
                    break;
                }
            }

            Value = lerp(from, to, percentage);
            if (expression != null)
            {
                expression.Value = Value;
            }
        }