/// <summary>
        /// if file for alarm objects exists, load serialized objects
        /// </summary>
        private void loadAlarmFile()
        {
            fileStream = new FileStream("alarmFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read);

            //AlarmList_Panel.Children.Clear();

            //read all alarm objects from file
            while (fileStream.Position != fileStream.Length)
            {
                Alarm            loadedAlarm  = (Alarm)formatter.Deserialize(fileStream);
                AlarmUserControl alarmControl = new AlarmUserControl(AlarmList_Panel, loadedAlarm);
                alarmControl.updateDisplay();
                AlarmList_Panel.Children.Add(alarmControl);
            }

            fileStream.Close();
        }
Exemple #2
0
        /// <summary>
        /// Confirms settings and updates the user controls alarm when done button is clicked
        /// </summary>
        private void Done_Click(object sender, RoutedEventArgs e)
        {
            DateTime alarmTime;

            DateTime.TryParse(Alarm_TimePicker.Text, out alarmTime);
            int mask = 0;

            if (repeat_checkBox.IsChecked == true)
            {
                if (CheckBox_Sun.IsChecked == true)
                {
                    mask |= (1 << (int)DayOfWeek.Sunday);
                }
                if (CheckBox_Mon.IsChecked == true)
                {
                    mask |= (1 << (int)DayOfWeek.Monday);
                }
                if (CheckBox_Tue.IsChecked == true)
                {
                    mask |= (1 << (int)DayOfWeek.Tuesday);
                }
                if (CheckBox_Wed.IsChecked == true)
                {
                    mask |= (1 << (int)DayOfWeek.Wednesday);
                }
                if (CheckBox_Thu.IsChecked == true)
                {
                    mask |= (1 << (int)DayOfWeek.Thursday);
                }
                if (CheckBox_Fri.IsChecked == true)
                {
                    mask |= (1 << (int)DayOfWeek.Friday);
                }
                if (CheckBox_Sat.IsChecked == true)
                {
                    mask |= (1 << (int)DayOfWeek.Saturday);
                }
                alarmControl.alarm.setNotificationTime(mask, alarmTime);
            }
            else
            {
                if (Alarm_DatePicker.SelectedDate == null)
                {
                    return;
                }
                DateTime singleAlarmTime = (DateTime)Alarm_DatePicker.SelectedDate;
                singleAlarmTime = singleAlarmTime.Add(alarmTime.TimeOfDay);
                alarmControl.alarm.oneTimeAlarm     = true;
                alarmControl.alarm.defaultAlarmTime = alarmControl.alarm.notifyTime = singleAlarmTime;
            }

            alarmControl.alarm.firstcreation = true;

            if (String.IsNullOrEmpty(AlarmMessage.Text) || String.IsNullOrWhiteSpace(AlarmMessage.Text))
            {
                alarmControl.alarm.label = "Alarm";
            }
            else
            {
                alarmControl.alarm.label = AlarmMessage.Text;
            }

            alarmControl.updateDisplay();
            Console.WriteLine((string)AlarmTone_comboBox.SelectedItem);
            alarmControl.alarm.SetSound((string)AlarmTone_comboBox.SelectedItem);
            Close();
        }