Exemple #1
0
        /// <summary>
        /// Loads the current alarms saved in the files into the program
        /// </summary>
        private void LoadAlarms()
        {
            BindingList <DateTime> alarms      = new BindingList <DateTime>();
            BindingList <bool>     alarmsOnOff = new BindingList <bool>();

            using (StreamReader file = new StreamReader("alarms.txt"))
            {
                string line;
                while ((line = file.ReadLine()) != null)
                {
                    alarms.Add(Convert.ToDateTime(line));
                }
            }
            using (StreamReader file = new StreamReader("alarmsOnOff.txt"))
            {
                string line;
                while ((line = file.ReadLine()) != null)
                {
                    alarmsOnOff.Add(Convert.ToBoolean(line));
                }
            }
            for (int i = 0; i < alarms.Count; i++)
            {
                AddEditAlarm alarm = new AddEditAlarm(alarms[i], alarmsOnOff[i]);
                alarmList.Add(alarm);
                listBox.Items.Add(alarm.ToString());
            }
            CreateAlarmDelay();
        }
Exemple #2
0
        /// <summary>
        /// Event handler for when the add alarm button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAddAlarm_Click(object sender, EventArgs e)
        {
            AddEditAlarm addEditAlarm = new AddEditAlarm();

            if (addEditAlarm.ShowDialog() == DialogResult.OK)
            {
                alarmList.Add(addEditAlarm);
                listBox.Items.Add(addEditAlarm.ToString());
            }
            WriteAlarms();
        }
Exemple #3
0
        /// <summary>
        /// Event handler for when the edit button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnEdit_Click(object sender, EventArgs e)
        {
            int          index        = listBox.SelectedIndex;
            AddEditAlarm addEditAlarm = new AddEditAlarm();

            if (index >= 0)
            {
                if (addEditAlarm.ShowDialog() == DialogResult.OK)
                {
                    alarmList[index]     = addEditAlarm;
                    listBox.Items[index] = addEditAlarm.ToString();
                }
                WriteAlarms();
            }
        }