Exemple #1
0
 private void Snooze_Minus_Click(object sender, RoutedEventArgs e)
 {
     if (snooze_period_minutes > 0)
     {
         snooze_period_minutes--;
     }
     Snooze_Period_minutes_Label.Content = snooze_period_minutes.ToString();
     GuiEventCaller.GetCaller().NotifySnoozePeriodChangeRequested(snooze_period_minutes);
 }
Exemple #2
0
        private void Timezone_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem timeZone = (ComboBoxItem)Timezone.SelectedItem;

            string utcString = timeZone.Content.ToString();

            double offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now).TotalHours;

            string[] parts = utcString.Split(' ', ':');

            double offsetNum = double.Parse(parts[1]);


            if ((parts[1] == "0"))
            {
                offsetNum = 0;
            }
            if ((parts[2] == "15") && (parts[1].Contains("-")))
            {
                offsetNum = offsetNum - 0.25;
            }

            if ((parts[2] == "15") && (parts[1].Contains("+")))
            {
                offsetNum = offsetNum + 0.25;
            }

            else if ((parts[2] == "30") && (parts[1].Contains("-")))
            {
                offsetNum = offsetNum - 0.5;
            }

            else if ((parts[2] == "30") && (parts[1].Contains("+")))
            {
                offsetNum = offsetNum + 0.5;
            }

            else if ((parts[2] == "45") && (parts[1].Contains("-")))
            {
                offsetNum = offsetNum - 0.75;
            }

            else if ((parts[2] == "45") && (parts[1].Contains("+")))
            {
                offsetNum = offsetNum + 0.75;
            }

            double finalOffset = offsetNum - offset;

            GuiEventCaller.GetCaller().NotifyTimeZoneOffsetChanged(finalOffset);
        }
Exemple #3
0
        /// <summary>
        /// Event triggered by the button on a row
        /// </summary>
        /// <param name="sender">?</param>
        /// <param name="e">?</param>
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            switch (this.mode)
            {
            case ModeType.Cancel:
                GuiEventCaller.GetCaller().NotifyCancel(this.storedAlarm, false);
                break;

            case ModeType.Dismiss:
                GuiEventCaller.GetCaller().NotifyDismiss();
                break;

            default:
                throw new NotImplementedException("Invalid ModeType");
            }
        }
Exemple #4
0
        public OptionsWindow(double leftOffset, double topOffset, double heightOfMain, double widthOfMain, double relativeSize)
        {
            InitializeComponent();
            relativeSize_ofOptionsWindow = relativeSize;

            borderOffset_width  = widthOfMain - (widthOfMain * relativeSize_ofOptionsWindow);
            borderOffset_width *= 0.5;

            borderOffset_height  = heightOfMain - (heightOfMain * relativeSize_ofOptionsWindow);
            borderOffset_height *= 0.5;

            this.Left   = leftOffset + borderOffset_width;
            this.Top    = topOffset + borderOffset_height;
            this.Width  = widthOfMain * relativeSize_ofOptionsWindow;
            this.Height = heightOfMain * relativeSize_ofOptionsWindow;

            this.Snooze_Period_minutes_Label.Content = snooze_period_minutes.ToString();

            this.snooze_Minus.Visibility = Visibility.Visible;
            this.snooze_Plus.Visibility  = Visibility.Visible;
            this.Snooze_Period_minutes_Label.Visibility = Visibility.Visible;

            this.snooze_Minus.Click += Snooze_Minus_Click;
            this.snooze_Plus.Click  += Snooze_Plus_Click;


            this.timeSelector = new TimeSelector(this);
            timeSelector.Add(this);


            DatePicker.SelectedDateChanged += DatePicker_SelectedDateChanged;

            GuiEventCaller.GetCaller().NotifySnoozePeriodChangeRequested(snooze_period_minutes);

            SetDefaultTimeZone();

            this.analog.Click  += Analog_Click;
            this.digital.Click += Digital_Click;
        }
Exemple #5
0
        /// <summary>
        /// Called if the user changes the selected date
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            string newDate = this.DatePicker.Text;

            //this string should be in the format yyyy-mm-dd

            string[] yearMonthDay = newDate.Split('-');

            int year, month, day;

            try {
                year  = int.Parse(yearMonthDay[0]);
                month = int.Parse(yearMonthDay[1]);
                day   = int.Parse(yearMonthDay[2]);
            } catch (FormatException) {
                return; //the date was picked wrong in the case of both exceptions, don't pass the new data onwards
            } catch (IndexOutOfRangeException) {
                return;
            }


            GuiEventCaller.GetCaller().NotifyManualDateRequested(year, month, day);
        }
Exemple #6
0
 /// <summary>
 /// Called by the main window when it is shutting down, clears the alarm rows and notifying gui listeners that it has happened
 /// </summary>
 public void OnMainWindowShutdown()
 {
     GuiEventCaller.GetCaller().NotifyMainWindowClosing();
     this.activeAlarms = new Dictionary <Alarm, AlarmRow>();
     mainWindow        = null;
 }
Exemple #7
0
 /// <summary>
 /// Called whenever the user changes the time on the time display
 /// </summary>
 /// <param name="newHours"></param>
 /// <param name="newMinutes"></param>
 public void TimeChanged(int newHours, int newMinutes)
 {
     GuiEventCaller.GetCaller().NotifyManualTimeRequested(newHours, newMinutes);
 }
Exemple #8
0
 public static void SetSnoozePeriodMinutes(int minutes)
 {
     snooze_period_minutes = minutes;
     GuiEventCaller.GetCaller().NotifySnoozePeriodChangeRequested(snooze_period_minutes);
 }