// CompositorExtensions
        public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(this Compositor compositor, float to, float?from, TimeSpan duration, TimeSpan?delay, CompositionEasingFunction ease)
        {
            var ani = compositor.CreateScalarKeyFrameAnimation();

            // Set duration and delay time
            ani.Duration = duration;
            if (delay.HasValue)
            {
                ani.DelayTime = delay.Value;
            }

            // Insert "to" and "from" keyframes
            ani.InsertKeyFrame(1, to, ease ?? compositor.CreateLinearEasingFunction());
            if (from.HasValue)
            {
                ani.InsertKeyFrame(0, from.Value);
            }
            return(ani);
        }
Esempio n. 2
0
        public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(
            [NotNull] this Compositor compositor,
            float?from, [NotNull] string to,
            TimeSpan duration, TimeSpan?delay,
            [CanBeNull] CompositionEasingFunction ease = null)
        {
            // Set duration and delay time
            ScalarKeyFrameAnimation ani = compositor.CreateScalarKeyFrameAnimation();

            ani.Duration = duration;
            if (delay.HasValue)
            {
                ani.DelayTime = delay.Value;
            }

            // Insert "to" and "from" keyframes
            ani.InsertExpressionKeyFrame(1, to, ease ?? compositor.CreateLinearEasingFunction());
            if (from.HasValue)
            {
                ani.InsertKeyFrame(0, from.Value);
            }
            return(ani);
        }