Exemplo n.º 1
0
        private void TimerModel_Tick(object sender, TickEventArgs e)
        {
            string s = null;

            if (Mode == ClockMode.Clock)
            {
                s = e.Clock.ToString("HH:mm:ss");
            }
            if (Mode == ClockMode.Chronometer)
            {
                TimeSpan chronometerValue = TimeSpan.Zero;
                switch (_chronometerStatus)
                {
                case ChronometerStatus.NotStarted:
                    chronometerValue = TimeSpan.Zero;
                    break;

                case ChronometerStatus.Running:
                    chronometerValue = DateTime.Now - _startedTimestamp;
                    break;

                case ChronometerStatus.Stopped:
                    chronometerValue = _stoppedTimestamp - _startedTimestamp;
                    break;
                }
                int centiSecond = chronometerValue.Milliseconds / 10;

                if (chronometerValue.Hours > 0)
                {
                    s += chronometerValue.Hours.ToString("D2") + ":";
                }

                if (chronometerValue.Minutes > 0)
                {
                    s += chronometerValue.Minutes.ToString("D2") + "'";
                }

                s += chronometerValue.Seconds.ToString("D2") + "\"" +
                     centiSecond.ToString("D2");
            }
            DisplayTime = s;
        }
Exemplo n.º 2
0
        void MyTimerCallback(object state)
        {
            var args = new TickEventArgs(DateTime.Now);

            Tick?.Invoke(this, args);
        }