private void addButton_Click(object sender, RoutedEventArgs e) { alarmName = alarmNameTextBox.Text; alarmDesc = alarmDescriptionTextBox.Text; alarmSched = hourComboBox.Text + ":" + minuteComboBox.Text + " " + amPMComboBox.Text; alarmDay = dateOfAlarm.Text; if (alarmName.Length > 0 && alarmDesc.Length > 0 && alarmSched.Length > 0 && alarmDay.Length > 0) { // Adds an alarm to the list displayer alarmObject newAlarm = new alarmObject { alarmID = alarmName, alarmDescription = alarmDesc, alarmTime = alarmSched, alarmDate = alarmDay }; this.alarmList.Items.Add(newAlarm); // Adds an alarm to the linked list try { alarmLinkedList.AddLast(newAlarm); } catch (Exception exception) { Console.WriteLine(exception.Message); } MessageBox.Show("Alarm Added!"); clearControls(); } else { MessageBox.Show("Invalid input"); } }
// Method for ringing alarm that will make a new alarm window which rings and has the option // To dismiss and to snooze // w - the window that calls the ringAlarm function // a - the alarmFunction associated with the ringing public void ringAlarm(Window w, alarmObject a) { // Create a new AlarmWindow that is var alarmWindow = new AlarmWindow(); // Get the proper title and description alarmWindow.title.Text = a.alarmID; alarmWindow.description.Text = a.alarmDescription; alarmWindow.Show(); // Play a simple ringtone sound // Open the window that called the ringAlarm function }
private void EditAlarm_Click(object sender, RoutedEventArgs e) { if (alarmList.SelectedIndex == -1) { return; } else { try { temp_alarm = alarmLinkedList.ElementAt(alarmList.SelectedIndex); save.Visibility = Visibility.Visible; cancel.Visibility = Visibility.Visible; addButton.Visibility = Visibility.Hidden; } catch (Exception exception) { Console.WriteLine(exception.Message); } } }
private void save_Click(object sender, RoutedEventArgs e) { alarmName = alarmNameTextBox.Text; alarmDesc = alarmDescriptionTextBox.Text; alarmSched = hourComboBox.Text + ":" + minuteComboBox.Text + " " + amPMComboBox.Text; alarmDay = dateOfAlarm.Text; if (alarmName.Length > 0 && alarmDesc.Length > 0 && alarmSched.Length > 0 && alarmDay.Length > 0) { alarmObject newAlarm = new alarmObject { alarmID = alarmName, alarmDescription = alarmDesc, alarmTime = alarmSched, alarmDate = alarmDay }; try { this.alarmList.Items.Remove(temp_alarm); this.alarmList.Items.Add(newAlarm); alarmLinkedList.Remove(temp_alarm); alarmLinkedList.AddLast(newAlarm); temp_alarm = null; } catch (Exception exception) { Console.WriteLine(exception.Message); } MessageBox.Show("Alarm Saved!"); clearControls(); save.Visibility = Visibility.Hidden; cancel.Visibility = Visibility.Hidden; addButton.Visibility = Visibility.Visible; } else { MessageBox.Show("Invalid input"); } }