コード例 #1
0
 public void SetTimerRow(TimerRow tr)
 {
     if (tr != null)
     {
         this.timerRow = tr;
         TimerDisplay  = timerRow.IsTimerDescending ? DisplayTime(timerRow.RemainingSeconds) : DisplayTime(0);
     }
 }
コード例 #2
0
        public BaseTimer(TimerRow timerRow) //: this()
        {
            this.timerRow  = timerRow;
            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 0, 1, 0);
            if (timerRow.IsTimerDescending)
            {
                timer.Tick += (obj, ea) =>
                {
                    if (timerRow.RemainingSeconds-- == 0)
                    {
                        Stop();
                    }
                    else
                    {
                        TimerDisplay = DisplayTime(timerRow.RemainingSeconds);

                        if (!alertStarted)
                        {
                            CheckAndStartAlert(timerRow.RemainingSeconds);
                        }
                    }
                }
            }
            ;
            else
            {
                timer.Tick += (obj, ea) =>
                {
                    if (timerRow.SecondsPassed++ == timerRow.RemainingSeconds)
                    {
                        Stop();
                    }
                    else
                    {
                        TimerDisplay = DisplayTime(timerRow.SecondsPassed);

                        if (!alertStarted)
                        {
                            CheckAndStartAlert(timerRow.RemainingSeconds - timerRow.SecondsPassed);
                        }
                    }
                }
            };
        }