public void AddActiveAlarm(EntryType.Alarm newAl) { activeAlarms.Add(newAl); //trigger display update Display.updateDisplay(EntryType.Entries.Alarm); }
private void btnAddAlarm_Click(object sender, EventArgs e) { EntryType.Alarm godOuah = new EntryType.Alarm(); //problems? //need to implement better validation if ((tbxName.Text.Equals(Properties.Resources.InactiveNameTbx)) || (tbxName.Text.Length < 3)) { MessageBox.Show(Properties.Resources.NoNameSetError, Properties.Resources.NoTextError, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //this is done in the wrong place, isn't it? godOuah.Name = tbxName.Text; godOuah.ActiveAt = dtpAlarmTarget.Value; godOuah.Running = false; godOuah.SoundBite = null; //this'll just mean a console beep //godOuah.SoundBite = ofdLocateSoundbite.FileName. mainForm.AddActiveAlarm(godOuah); this.Close(); }
public static void updateDisplay(EntryType.Entries eType) { List <EntryType.Alarm> activeAlarms = new List <EntryType.Alarm>(); List <EntryType.Timer> activeTimers = new List <EntryType.Timer>(); List <EntryType.Reminder> activeReminders = new List <EntryType.Reminder>(); activeAlarms = mainForm.activeAlarms; activeTimers = mainForm.activeTimers; activeReminders = mainForm.activeReminders; switch (eType) { case EntryType.Entries.Alarm: mainForm.AlarmCLB.Items.Clear(); //swap this gross for loop out for a foreach like is done for //timer entries immediately below //or better yet, modularize for (int cntr2 = 0; cntr2 < activeAlarms.Count; cntr2++) { //switch the above to a 'for' loop & remove cntr++ below EntryType.Alarm al = activeAlarms[cntr2]; if (al.Running) { if (!al.IsPast()) { updateEntry(EntryType.Entries.Alarm, cntr2); } else { if (Debug.tickDebugging && Debug.alarmDebugging) { Debug.ShowDbgOut("Toggling alarm #" + cntr2.ToString()); } al.ToggleRunning(); } } else { mainForm.AlarmCLB.Items.Add(al.ActiveAt + " - " + al.Name, false); } } break; case EntryType.Entries.Timer: mainForm.TimerCLB.Items.Clear(); foreach (EntryType.Timer tm in activeTimers) { if (tm.Running && (tm.Remaining > new TimeSpan(0))) { //clbTimers.Items.Add(tm.Remaining + " - " + tm.Name, true); updateEntry(EntryType.Entries.Timer, activeTimers.IndexOf(tm)); } else if (!tm.Running || (tm.Running && (tm.Remaining <= new TimeSpan(0)))) { if (tm.Running) { tm.RingRingNeo(); } mainForm.TimerCLB.Items.Add(tm.Remaining + " - " + tm.Name, false); } } break; case EntryType.Entries.Reminder: mainForm.ReminderCLB.Items.Clear(); foreach (EntryType.Reminder rm in activeReminders) { if (rm.Running && (!rm.CheckInterval())) { updateEntry(EntryType.Entries.Reminder, activeReminders.IndexOf(rm)); } else if (!rm.Running) { mainForm.ReminderCLB.Items.Add(rm.ActiveAt + " - " + rm.Name, false); } } break; } }