Ejemplo n.º 1
0
 public void OnChangeEnabled(Alarm alarm)
 {
     if (alarm.IsEnabled)
     {
         enabledAlarms.Add(alarm.GetTotalSeconds(), alarm);
     }
     else
     {
         enabledAlarms.Remove(alarm.GetTotalSeconds());
     }
     Settings.SaveToSettings();
 }
Ejemplo n.º 2
0
        private void AlarmAdd_Click(object sender, RoutedEventArgs e)
        {
            int hour = 1;
            int min  = 1;

            if (!(int.TryParse(cbxAlarmHour.Text, out hour) && int.TryParse(cbxAlarmMinute.Text, out min)))
            {
                MessageBox.Show("시각 표기란에는 정수를 입력해야합니다.", "오류", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (hour <= 0 || hour > 12)
            {
                MessageBox.Show("시는 1과 12사이의 정수이어야 합니다.", "오류", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (min < 0 || min > 59)
            {
                MessageBox.Show("분은 0과 59사이의 정수이어야 합니다.", "오류", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            string   ampm       = (string)cbxAlarmAmPm.SelectedValue;
            string   hour_      = (hour < 10) ? ("0" + hour) : hour.ToString();
            string   min_       = (min < 10) ? ("0" + min) : min.ToString();
            DateTime targetTime = DateTime.ParseExact(hour_ + ":" + min_ + " " + ampm, "hh:mm tt", CultureInfo.InvariantCulture);

            Alarms.InsertAlarm(new Alarm()
            {
                Manager = Alarms, Label = tbxAlarmName.Text, TargetTime = targetTime
            });
            patterns.SaveToSettings();
            pnlAddAlarm.Visibility = Visibility.Hidden;
            wndGrid.Effect         = null;
        }