/// <summary> /// When the edit button is clicked the second form is loaded and the user can edit the alarm /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void uxEdit_Click(object sender, EventArgs e) { if (uxAlarmList.SelectedItem != null) { int index = uxAlarmList.SelectedIndex; curItem = uxAlarmList.SelectedItem.ToString(); curItem = curItem.Substring(0, 10); AddEditAlarm addEdit = new AddEditAlarm(curItem); if (addEdit.ShowDialog() == DialogResult.OK) { alarms.RemoveAt(index); curItem = addEdit.Time; if (addEdit.Run == true) { status = " Running"; alarms.Insert(index, curItem + status); } else { status = " Off"; alarms.Insert(index, curItem + status); } } } else { MessageBox.Show("Select an alarm to edit"); } }
/// <summary> /// The second form pops up and the user is able to set an alarm /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void uxAdd_Click(object sender, EventArgs e) { AddEditAlarm alarm = new AddEditAlarm(); if (alarm.ShowDialog() == DialogResult.OK) { if (alarms.Count != 10) { if (alarm.Run == true) { status = " Running"; alarms.Add(alarm.Time + status); } else { status = " Off"; alarms.Add(alarm.Time + status); } } } uxEdit.Enabled = true; }