/// <summary>
 /// Initializes alarm notification with alarm data
 /// </summary>
 public NotificationWindow(AlarmUserControl alarm)
 {
     InitializeComponent();
     alarmControl = alarm;
     alarm.alarm.alarmSound.Play();
     if (!alarmControl.alarm.label.Equals(""))
     {
         AlarmLabel.Content = alarmControl.alarm.label;
     }
 }
        /// <summary>
        /// Opens Window for New Alarm settings, and adds new alarm UserControl to StackPanel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddAlarmButton_Click(object sender, RoutedEventArgs e)
        {
            Alarm            newAlarm     = new Alarm(@"..\..\Sounds\missileAlert.wav", snoozeTime);
            AlarmUserControl alarmControl = new AlarmUserControl(AlarmList_Panel, newAlarm);

            new NewAlarmWindow(alarmControl).ShowDialog();

            if (newAlarm.firstcreation)
            {
                AlarmList_Panel.Children.Add(alarmControl);
            }
        }
Exemple #3
0
        /// <summary>
        /// Initializes edit alarm window with alarm data
        /// </summary>
        public NewAlarmWindow(AlarmUserControl alarmControl)
        {
            InitializeComponent();
            RadioGrid.Visibility = Visibility.Collapsed;
            OtherProps.Margin    = new Thickness(26, 149, 21, 34);
            this.alarmControl    = alarmControl;
            alarmSounds.Add(@"..\..\Sounds\missileAlert.wav");
            alarmSounds.Add(@"..\..\Sounds\fogHorn.wav");
            AlarmTone_comboBox.ItemsSource   = alarmSounds;
            AlarmTone_comboBox.SelectedIndex = 0;
            Alarm_TimePicker.Value           = alarmControl.alarm.notifyTime;
            AlarmMessage.Text = alarmControl.alarm.GetLabel();


            formatter = new BinaryFormatter();
        }
        /// <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();
        }