예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Timer"/> class.
        /// </summary>
        /// <param name="timerInfo">A <see cref="TimerInfo"/> representing the state of the <see
        /// cref="Timer"/>.</param>
        public Timer(TimerInfo timerInfo)
            : base(timerInfo)
        {
            this.timerStart = TimerStart.FromTimerStartInfo(timerInfo.TimerStart);
            this.options = TimerOptions.FromTimerOptionsInfo(timerInfo.Options) ?? new TimerOptions();

            this.UpdateHourglassTimer();
        }
예제 #2
0
        /// <summary>
        /// Returns a <see cref="Timer"/> for a <see cref="TimerInfo"/>.
        /// </summary>
        /// <param name="timerInfo">A <see cref="TimerInfo"/>.</param>
        /// <returns>The <see cref="Timer"/> for the <see cref="TimerInfo"/>.</returns>
        public static Timer FromTimerInfo(TimerInfo timerInfo)
        {
            if (timerInfo == null)
            {
                return null;
            }

            return new Timer(timerInfo);
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TimerBase"/> class.
        /// </summary>
        /// <param name="timerInfo">A <see cref="TimerInfo"/> representing the state of the <see cref="TimerBase"/>.</param>
        protected TimerBase(TimerInfo timerInfo)
            : this()
        {
            this.state = timerInfo.State;
            this.startTime = timerInfo.StartTime;
            this.endTime = timerInfo.EndTime;
            this.timeElapsed = timerInfo.TimeElapsed;
            this.timeLeft = timerInfo.TimeLeft;
            this.timeExpired = timerInfo.TimeExpired;
            this.totalTime = timerInfo.TotalTime;

            if (this.state == TimerState.Running)
            {
                this.dispatcherTimer.Start();
            }
        }