Esempio n. 1
0
        // internally, hook up each tick requested
        private void setUpTicks()
        {
            this.timeClocks = new Clock[timeArray.Length];

            ParallelTimeline eventTimeline;

            foreach(int duration in timeArray)
            {
                eventTimeline = new ParallelTimeline();
                eventTimeline.BeginTime = null;
                eventTimeline.Duration = new Duration(TimeSpan.FromMilliseconds(duration));
                timeClocks[timeClockIndex] = eventTimeline.CreateClock();
                timeClocks[timeClockIndex].CurrentStateInvalidated += new EventHandler(OnEnded);

                // The last time in the list should be the only one with CurrentTimeInvalidated hooked up
                if (timeClockIndex == (timeArray.Length - 1))
                {
                    timeClocks[timeClockIndex].CurrentTimeInvalidated += new EventHandler(EnsureIndividualTick);
                }

                timeClocks[timeClockIndex].Controller.Begin();
                timeClockIndex ++;
            }
            timeClockIndex ++;
        }
 public ReusableFollowTracker()
 {
     _timeline  = new ParallelTimeline(null, Duration.Forever);
     _timeClock = _timeline.CreateClock();
     _timeClock.Controller?.Begin();
     _lastTime = TimeSpan.FromSeconds(0);
 }
Esempio n. 3
0
        public void ParallelClockBasicTest()
        {
            ParallelTimeline timeline = new ParallelTimeline();

            timeline.Children.Add(new TestTimeline());
            timeline.Children.Add(new TestTimeline {
                BeginTime = TimeSpan.FromSeconds(2)
            });

            TimelineClock clock = (TimelineClock)timeline.CreateClock();

            clock.Tick(TimeSpan.FromSeconds(-0.2));
            Assert.AreEqual(Granular.Compatibility.TimeSpan.MinValue, clock.CurrentState.PreviousTick);
            Assert.AreEqual(TimeSpan.Zero, clock.CurrentState.NextTick);
            Assert.AreEqual(ClockProgressState.BeforeStarted, clock.CurrentState.ProgressState);

            clock.Tick(TimeSpan.FromSeconds(0.2));
            Assert.AreEqual(TimeSpan.FromSeconds(0.2), clock.CurrentState.PreviousTick);
            Assert.AreEqual(TimeSpan.FromSeconds(0.2), clock.CurrentState.NextTick);
            Assert.AreEqual(ClockProgressState.Active, clock.CurrentState.ProgressState);

            clock.Tick(TimeSpan.FromSeconds(1.2));
            Assert.AreEqual(TimeSpan.FromSeconds(1), clock.CurrentState.PreviousTick);
            Assert.AreEqual(TimeSpan.FromSeconds(2), clock.CurrentState.NextTick);
            Assert.AreEqual(ClockProgressState.Active, clock.CurrentState.ProgressState);

            clock.Tick(TimeSpan.FromSeconds(2.2));
            Assert.AreEqual(TimeSpan.FromSeconds(2.2), clock.CurrentState.PreviousTick);
            Assert.AreEqual(TimeSpan.FromSeconds(2.2), clock.CurrentState.NextTick);
            Assert.AreEqual(ClockProgressState.Active, clock.CurrentState.ProgressState);

            clock.Tick(TimeSpan.FromSeconds(3.2));
            Assert.AreEqual(TimeSpan.FromSeconds(3), clock.CurrentState.PreviousTick);
            Assert.AreEqual(Granular.Compatibility.TimeSpan.MaxValue, clock.CurrentState.NextTick);
            Assert.AreEqual(ClockProgressState.AfterEnded, clock.CurrentState.ProgressState);
        }