Пример #1
0
 /// <summary>
 /// Constructor: initializes snoozeUntilTime to harmless value
 /// </summary>
 public AlarmController()
 {
     this.alarmList       = new List <Alarm>();
     this.audioController = AbstractAudioController.GetController();
     this.guiController   = AbstractGuiController.GetController();
     this.snoozeUntilTime = TimeFetcher.getCurrentTime();
 }
Пример #2
0
        /// <summary>
        /// snooze alarms from being able to ring for snoozePeriod_minutes
        /// </summary>
        public void SnoozeRequested()
        {
            DateTime now = TimeFetcher.getCurrentTime();

            if (!CheckIfSnoozeOver(now))
            {
                //dont start a new snooze if things are still snoozing
                return;
            }


            updateSnoozeUntilTime(now);
            guiController.SetSnoozeAvailable(false);
            guiController.SetDismissAvailable(false);

            //iterate over each alarm and if it is ringing, tell it to snooze
            foreach (Alarm alarm in alarmList)
            {
                if (alarm.IsRinging)
                {
                    alarm.Status = AlarmState.Off;
                    guiController.UpdateAlarm(alarm);
                }
            }
        }
Пример #3
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            DateTime currentTime = time.getCurrentTime();

            foreach (TimeListener listener in Listeners)
            {
                listener.TimePulse(currentTime);
            }
        }
Пример #4
0
        /// <summary>
        /// The pulse event, calls time pulse on each listener
        /// </summary>
        private void Timer_Tick()
        {
            //grab the time from the time fetcher
            DateTime currentTime = TimeFetcher.getCurrentTime();

            //call time pulse on each listener
            foreach (TimeListener listener in listeners)
            {
                listener.TimePulse(currentTime);
            }
        }
Пример #5
0
        /// <summary>
        /// Sets this alarm for either hour:minute today, or if it has already passed, hour:minute tomorrow
        /// </summary>
        /// <param name="hour">The hour of day this alarm goes off at</param>
        /// <param name="minute">The minute of day this alarm goes off at</param>
        private void SetAlarmForNextOccurenceOf(int hour, int minute)
        {
            //get the current time
            DateTime now = TimeFetcher.getCurrentTime();

            //create an alarm at hour:minute today
            alarmTime = new DateTime(now.Year, now.Month, now.Day, hour, minute, 0, DateTimeKind.Local);
            //if that time has already passed move it up one day
            if (alarmTime <= now)
            {
                AddOneDayToAlarm();
            }
        }