private void OnTimerChanged(TimerChangedMessage message)
        {
            TextColor  = GreenYellowRedSelector.GetBrushForTimeRemaining(message.RemainingSecs);
            TimeString = TimeFormatter.FormatTimeRemaining(message.RemainingSecs);

            // if duration of talk is greater than 1hr we only start showing the sector
            // when remaining time is less than 1 hr (for sake of clarity)...
            InitOverallDurationSector(message.RemainingSecs);

            if (DurationSector != null)
            {
                DateTime now          = DateTime.Now;
                var      currentAngle = CalcAngleFromTime(now);
                if (Math.Abs(currentAngle - DurationSector.CurrentAngle) > 0.15) // prevent gratuitous updates
                {
                    var d = DurationSector.Clone();
                    d.CurrentAngle = currentAngle;
                    d.IsOvertime   = message.RemainingSecs < 0;
                    DurationSector = d;
                }
            }
        }
예제 #2
0
        public void TestOperatorViewStartStop()
        {
            const int TALK_ID_START = 500;
            const int NUM_TALKS     = 3;

            Mock <IOptionsService> optionsService = new Mock <IOptionsService>();

            optionsService.Setup(o => o.Options).Returns(MockOptions.Create());

            Mock <ITalkTimerService>     timerService         = new Mock <ITalkTimerService>();
            Mock <IAdaptiveTimerService> adaptiveTimerService = new Mock <IAdaptiveTimerService>();
            ITalkScheduleService         scheduleService      = new MockTalksScheduleService(TALK_ID_START, NUM_TALKS);

            OperatorPageViewModel vm = new OperatorPageViewModel(timerService.Object, scheduleService,
                                                                 adaptiveTimerService.Object, optionsService.Object);

            Assert.IsFalse(vm.IsRunning);
            Assert.IsFalse(vm.IsManualMode);

            for (int n = 0; n < NUM_TALKS; ++n)
            {
                int talkId = TALK_ID_START + n;
                Assert.IsTrue(vm.TalkId == talkId);

                var talk = scheduleService.GetTalkScheduleItem(talkId);
                Assert.IsNotNull(talk);
                Assert.AreEqual(vm.CurrentTimerValueString, TimeFormatter.FormatTimeRemaining(talk.GetDurationSeconds()));

                vm.StartCommand.Execute(null);
                Assert.IsTrue(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == TALK_ID_START + n);

                vm.StopCommand.Execute(null);
                Assert.IsFalse(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == (n == NUM_TALKS - 1 ? 0 : TALK_ID_START + n + 1));
            }
        }
 private void OnTimerStarted(TimerStartMessage message)
 {
     TimeString = TimeFormatter.FormatTimeRemaining(message.TargetSeconds);
     IsRunning  = true;
     InitOverallDurationSector(message.TargetSeconds);
 }