//Method to add the alarm to the _alarms list. public void Add(Alarm alarm) { _alarms.Add(alarm); }
private void okButton_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; //Getting the hour and minute values from the up/down boxes. DateTime rightNow = DateTime.Now; int hour = Convert.ToInt32(hourNumericUpDown.Value); int minutes = Convert.ToInt32(minuteNumericUpDown.Value); //Using the hour and minute values for DateTime. DateTime value = new DateTime(rightNow.Year, rightNow.Month, rightNow.Day, hour, minutes, 0); //Getting the alarm category if selected. string category = ""; if (categoryComboBox.SelectedIndex > -1) { category = categoryComboBox.SelectedItem.ToString(); } else categoryComboBox.Text = "Personal"; //Checking to see if the alarm is enabled. bool isEnabled = false; if (enabledCheckBox.Checked) isEnabled = true; //Creating the alarm object to be added to the list. _alarm = new Alarm() { AlarmCategory = category, AlarmTime = value, Enabled = isEnabled }; }