Exemple #1
0
        public void DoubleAnimationKeyFrameRepeatTest()
        {
            DoubleAnimationUsingKeyFrames animation;

            animation = new DoubleAnimationUsingKeyFrames();
            animation.KeyFrames.Add(new LinearDoubleKeyFrame {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0
            });
            animation.KeyFrames.Add(new LinearDoubleKeyFrame {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)), Value = 1
            });
            animation.Duration       = new Duration(TimeSpan.FromSeconds(2));
            animation.RepeatBehavior = RepeatBehavior.Forever;

            TestRootClock          rootClock = new TestRootClock();
            AnimationTimelineClock clock     = (AnimationTimelineClock)animation.CreateClock();

            clock.Begin(rootClock);

            rootClock.Tick(TimeSpan.FromSeconds(0.1));
            Assert.AreEqual(0.1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(0.9));
            Assert.AreEqual(0.9, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1.9));
            Assert.AreEqual(1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.1));
            Assert.AreEqual(0.1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.9));
            Assert.AreEqual(0.9, (double)animation.GetCurrentValue(0.0, 0.0, clock));
        }