/// <summary> /// Adds a new alarm row onto the GUI using the provided alarm /// </summary> /// <param name="alarm"> /// The alarm to build the row from /// </param> /// <exception cref="ArgumentException"> /// If the alarm was set without being cleared already /// </exception> public void AddAlarm(Alarm alarm) { AlarmRow row = new AlarmRow(alarm); activeAlarms.Add(alarm, row); mainWindow.AddAlarmRow(row); }
/// <summary> /// Adds a new alarm row onto the GUI using the provided alarm /// </summary> /// <param name="alarm"> /// The alarm to build the row from /// </param> /// <exception cref="ArgumentException"> /// If the alarm was set without being cleared already /// </exception> public override void AddAlarm(Alarm alarm) { AlarmRow row = new AlarmRow(alarm); activeAlarms.Add(alarm, row); RenderAlarms(); }
/// <summary> /// Removes a row of the gui that represents the provided alarm /// </summary> /// <param name="alarm"> /// The alarm the row was initially built from /// </param> /// <exception cref="AlarmNotSetException"> /// If the provided alarm was never used to create a row, this exception will be thrown /// </exception> public void RemoveAlarm(Alarm alarm) { AlarmRow row = this.GetAlarmRow(alarm); mainWindow.RemoveAlarmRow(row); activeAlarms.Remove(alarm); }
/// <summary> /// Immedietly removes the alarm from the GUI (without the fading effect) /// </summary> /// <param name="alarm"></param> private void RemoveAlarmNow(Alarm alarm) { AlarmRow row = this.GetAlarmRow(alarm); mainWindow.RemoveAlarmRowImmediately(row); activeAlarms.Remove(alarm); RenderAlarms(); }
/// <summary> /// Removes a row of the gui that represents the provided alarm /// </summary> /// <param name="alarm"> /// The alarm the row was initially built from /// </param> /// <exception cref="AlarmNotSetException"> /// If the provided alarm was never used to create a row, this exception will be thrown /// </exception> public override void RemoveAlarm(Alarm alarm, bool wasPreempted) { AlarmRow row = this.GetAlarmRow(alarm); mainWindow.RemoveAlarmRow(row, wasPreempted); activeAlarms.Remove(alarm); RenderAlarms(); }
/// <summary> /// Compares two alarm times to prepare for sorting /// </summary> /// <param name="obj"></param> /// <returns></returns> public int CompareTo(object obj) { AlarmRow compareAlarmRow = obj as AlarmRow; if (compareAlarmRow == null) { return(1); } return(this.getAlarm().GetAlarmTime().CompareTo(compareAlarmRow.getAlarm().GetAlarmTime())); }
/// <summary> /// Fetches an AlarmRow from activeAlarms /// </summary> /// <param name="alarm">The alarm to lookup with</param> /// <returns>The fetched alarm row</returns> /// <exception cref="AlarmNotSetException"> /// If the provided alarm was never used to create a row, this exception will be thrown /// </exception> private AlarmRow GetAlarmRow(Alarm alarm) { AlarmRow toReturn = null; if (this.activeAlarms.TryGetValue(alarm, out toReturn)) { return(toReturn); } else { throw new AlarmNotSetException("The requested alarm did not exist"); } }
/// <summary> /// Causes the GUI to recheck an alarm object for a state change and change appropriately /// /// The alarm must already have been added with AddAlarm /// </summary> /// <param name="alarm">The alarm object to check</param> /// <exception cref="AlarmNotSetException"> /// If the provided alarm was never used to create a row, this exception will be thrown /// </exception> public override void UpdateAlarm(Alarm alarm) { if (mainWindow == null && alarm.IsRinging) { mainWindow = new MainWindow(); mainWindow.Show(); } else if (mainWindow == null) { //no update if the alarm isn't ringing, it isn't pressing return; } AlarmRow row = this.GetAlarmRow(alarm); row.Update(); RenderAlarms(); }
/// <summary> /// Causes the GUI to recheck an alarm object for a state change and change appropriately /// /// The alarm must already have been added with AddAlarm /// </summary> /// <param name="alarm">The alarm object to check</param> /// <exception cref="AlarmNotSetException"> /// If the provided alarm was never used to create a row, this exception will be thrown /// </exception> public void UpdateAlarm(Alarm alarm) { AlarmRow row = this.GetAlarmRow(alarm); row.Update(); }