/// <summary> /// Called when the timezone offset changes /// </summary> /// <param name="offset"></param> public void TimeZoneOffsetChanged(double offset) { double localOffset = GetLocalTimeZoneOffset(); AbstractGuiController.GetController().SetActiveTimeZoneForDisplay(offset + localOffset); TimeFetcher.setOffset(offset); }
/// <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(); }
/// <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); } } }
/// <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); } }
/// <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(); } }
public void ManualDateRequested(int year, int month, int day) { TimeFetcher.SetNewDate(year, month, day); }
public void ManualTimeRequested(int hours, int minutes) { TimeFetcher.SetNewTime(hours, minutes); }