Esempio n. 1
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            UpdateTime();
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            // try to read in "alarms.dat"..
            try
            {
                FileStream f = new FileStream(ALARMS_FILE,FileMode.Open);
                
                // read and load up the list box..
                try
                {
                    while(f.Length != f.Position)
                    {
                        int hour = (int) f.ReadByte();
                        int minute = (int) f.ReadByte();
                        AlarmTime m = new AlarmTime(hour,minute);
                        // add to list box..
                        AlarmTimes.Items.Add(m);
                        
                    }

                }
                catch(IOException exc)
                {
                    MessageBox.Show(exc.Message,
                        "File Reading...",
                        MessageBoxButtons.OK, 
                        MessageBoxIcon.Exclamation);

                }
                f.Close();

            }
            catch (System.IO.FileNotFoundException e)
            {
            }


        }
Esempio n. 2
0
        private void NewAlarmBtn_Click(object sender, System.EventArgs e)
        {
            // Get the hour/minute combination from the correct fields..

            int hour = (int) HoursUpDown.Value;
            int minute = (int) MinutesUpDown.Value;
            // do something..
            AlarmTime m = new AlarmTime(hour,minute);
            // add to list box..
            AlarmTimes.Items.Add(m);
            writeAlarms();            
            // write the new alarm file..
        }