Esempio n. 1
0
        /// <summary>
        /// Called when the user clicks the save button
        /// </summary>
        private void SaveAlarm_Click(object sender, RoutedEventArgs e)
        {
            //collect form info
            string name = mainControl.AddEditLabelBox.Text;

            int hour, minute;

            timeController.GetDisplayTime(out hour, out minute);

            bool repeat = mainControl.RepeatCheckbox.IsChecked.HasValue ? (bool)mainControl.RepeatCheckbox.IsChecked : false;

            List <DayOfWeek> days = weekdayControl.GetActiveDays();

            string audioFile = audioFileController.GetSelected();

            //pass to alarm GuiEventCaller
            if (alarmBeingEdited == null)
            {
                GuiEventCaller.GetCaller().NotifyAlarmRequested(hour, minute, repeat, audioFile, repeat, days, name);
            }
            else
            {
                GuiEventCaller.GetCaller().NotifyAlarmEditRequest(alarmBeingEdited, name, hour, minute, repeat, audioFile, repeat, days);
            }

            GuiController.GetController().OpenAlarmListPanel();
        }
        public OptionsPanel_Controller(MainPage mainControl)
        {
            this.mainControl        = mainControl;
            this.isPanelOpen        = false;
            snooze_duration_minutes = 5;
            GuiEventCaller.GetCaller().NotifySnoozePeriodChangeRequested(snooze_duration_minutes);
            this.mainControl.sDuration_Label.Content = snooze_duration_minutes.ToString();
            this.timeController = new TimeSelector(this, true);

            this.dropdownSelectorController = new DropdownSelectorController(mainControl.timezoneComboBox);

            InitDefaultTimeZone();

            mainControl.sDuration_dec.Click += SDuration_MinuteDown_Click;
            mainControl.sDuration_inc.Click += SDuration_MinuteUp_Click;
            mainControl.cdDatePicker.SelectedDateChanged += CdDatePicker_SelectedDateChanged;

            mainControl.timezoneComboBox.SelectionChanged += Timezone_SelectionChanged;

            mainControl.AnalogButton.Click  += Analog_Click;
            mainControl.DigitalButton.Click += Digital_Click;

            new DarkButton(mainControl.sDuration_dec);
            new DarkButton(mainControl.sDuration_inc);

            new DarkButton(mainControl.AnalogButton);
            new DarkButton(mainControl.DigitalButton);
        }
        //note: currently not working in silverlight, nor in desktop

        /// <summary>
        /// modifies internal date representation according to selection.
        /// 99% copied from seng403alarmclock_desktop_frontend.OptionsWindow.xaml.cs
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CdDatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            string newDate = this.mainControl.cdDatePicker.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);
        }
 /// <summary>
 /// decreases snooze duration by 1 minute
 /// </summary>
 private void SDuration_MinuteDown_Click(object sender, RoutedEventArgs e)
 {
     if (snooze_duration_minutes > 0)
     {
         snooze_duration_minutes--;
     }
     this.mainControl.sDuration_Label.Content = snooze_duration_minutes.ToString();
     GuiEventCaller.GetCaller().NotifySnoozePeriodChangeRequested(snooze_duration_minutes);
 }
Esempio n. 5
0
 private void btn_cancel_Click(object sender, RoutedEventArgs e)
 {
     if (alarm.IsRinging)
     {
         GuiEventCaller.GetCaller().NotifyDismiss();
     }
     else
     {
         GuiEventCaller.GetCaller().NotifyCancel(this.alarm, false);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Called when the application starts
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            AlarmController ac = new AlarmController();

            GuiEventCaller.GetCaller().AddListener(ac);
            TimeController tc = new TimeController();

            TimePulseGenerator.fetch().add(tc);
            TimePulseGenerator.fetch().add(ac);

            setAudioFileNames();
        }
        /// <summary>
        /// When the timezone combobox is changed, this is called to update the timezone via changing the offset.
        /// 99% copied from desktop version
        /// </summary>
        private void Timezone_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem timeZone = (ComboBoxItem)mainControl.timezoneComboBox.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);
        }
Esempio n. 8
0
        /// <summary>
        /// Called when the application starts
        /// </summary>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            LaunchOnRestart();
            AssignPlatformControllers();
            SetAudioFileNames();

            TimePulseGenerator.Instance = new TimePulseGenerator(new SengDispatcherTimer());


            ac = new AlarmController();
            GuiEventCaller.GetCaller().AddListener(ac);
            TimePulseGenerator.Instance.registerListener(ac);

            tc = new TimeController();
            GuiEventCaller.GetCaller().AddListener(tc);
            TimePulseGenerator.Instance.registerListener(tc);
        }
Esempio n. 9
0
        /// <summary>
        /// Builds controller objects and starts th e app
        /// </summary>
        public App()
        {
            AbstractGuiController.SetController(new GuiController());
            TimePulseGenerator.Instance = new TimePulseGenerator(new SengDispatcherTimer());
            AbstractAudioController.SetController(new AudioController());

            this.Startup            += this.Application_Startup;
            this.Exit               += this.Application_Exit;
            this.UnhandledException += this.Application_UnhandledException;

            InitializeComponent();


            TimeController tc = new TimeController();

            GuiEventCaller.GetCaller().AddListener(tc);
            TimePulseGenerator.Instance.registerListener(tc);

            AlarmController ac = new AlarmController();

            GuiEventCaller.GetCaller().AddListener(ac);
            TimePulseGenerator.Instance.registerListener(ac);
        }
 /// <summary>
 /// Called when the time is updated
 /// </summary>
 /// <param name="hour"></param>
 /// <param name="minute"></param>
 void TimeSelectorI.OnTimeUpdated(int hour, int minute)
 {
     GuiEventCaller.GetCaller().NotifyManualTimeRequested(hour, minute);
 }
Esempio n. 11
0
 /// <summary>
 /// Called when the dismiss button is clicked
 /// </summary>
 private void Dismiss_Click(object sender, RoutedEventArgs e)
 {
     GuiEventCaller.GetCaller().NotifyDismiss();
 }
Esempio n. 12
0
 /// <summary>
 /// Called when the snooze button is clicked
 /// </summary>
 private void Snooze_Click(object sender, RoutedEventArgs e)
 {
     GuiEventCaller.GetCaller().NotifySnoozeRequested();
 }
Esempio n. 13
0
        /// <summary>
        /// Called when the add alarm button is clicked
        /// </summary>
        /// <param name="sender">?</param>
        /// <param name="e">?</param>
        private void AddAlarmClick(object sender, RoutedEventArgs e)
        {
            /*Why is this here?
             * if (hoursStr == "")
             * {
             *  this.hours.Text = "0";
             * }
             * if (minutesStr == "")
             * {
             *  this.minutes.Text = "0";
             * }
             */

            string hoursStr   = this.hours.Text;
            string minutesStr = this.minutes.Text;

            int hours;
            int minutes;

            try {
                hours   = int.Parse(hoursStr);
                minutes = int.Parse(minutesStr);
            } catch (FormatException) {
                MessageBox.Show("The number of hours or minutes that was input is not a number.");
                return;
            }

            if (hours < 0 || hours > 12)
            {
                MessageBox.Show(this, "The number of hours input is not between 0 and 12");
                return;
            }

            if (minutes < 0 || minutes > 59)
            {
                MessageBox.Show(this, "The number of minutes input is not between 0 and 59");
                return;
            }

            if (this.pm && hours != 12)
            {
                hours += 12;
            }
            else if (!this.pm && hours == 12)
            {
                hours = 0;
            }

            //parse out which days of the week this alarm occurs on
            List <DayOfWeek> alarmDays;

            if (Weekly.IsChecked.Value)
            {
                alarmDays = new List <DayOfWeek>();
                foreach (KeyValuePair <DayOfWeek, bool> entry in dayStatusCodes)
                {
                    if (entry.Value)
                    {
                        alarmDays.Add(entry.Key);
                    }
                }

                if (alarmDays.Count == 0)
                {
                    //if there are no days the alarm cannot go off :/
                    MessageBox.Show(this, "No days were selected for the alarm to go off on.");
                    return;
                }
            }
            else
            {
                alarmDays = null;
            }
            string audioFile = "";

            try {
                audioFile = getSelectedAudioFile();
            } catch (IndexOutOfRangeException) {
                MessageBox.Show(this, "No alarm tone was set.");
                return;
            }


            //call the modified version...
            GuiEventCaller.GetCaller().NotifyAlarmRequested(hours, minutes, Repeats.IsChecked.Value, audioFile, Weekly.IsChecked.Value, alarmDays);
            this.Close();
        }
Esempio n. 14
0
        /// <summary>
        /// Called when the add alarm button is clicked
        /// </summary>
        /// <param name="sender">?</param>
        /// <param name="e">?</param>
        private void SaveAlarmClick(object sender, RoutedEventArgs e)
        {
            int    hours, minutes;
            string alarmName = AlarmLabel.Text;

            try
            {
                timeSelector.GetTime(out hours, out minutes);
            }
            catch (FormatException)
            {
                MessageBox.Show("The number of hours or minutes that was input is not a number.");
                return;
            }

            if (hours < 0 || hours > 23)
            {
                MessageBox.Show(this, "The number of hours input is not between 0 and 12");
                return;
            }

            if (minutes < 0 || minutes > 59)
            {
                MessageBox.Show(this, "The number of minutes input is not between 0 and 59");
                return;
            }

            //parse out which days of the week this alarm occurs on
            List <DayOfWeek> alarmDays;

            if (Repeats.IsChecked.Value)
            {
                alarmDays = new List <DayOfWeek>();
                foreach (KeyValuePair <DayOfWeek, bool> entry in dayStatusCodes)
                {
                    if (entry.Value)
                    {
                        alarmDays.Add(entry.Key);
                    }
                }

                if (alarmDays.Count == 0)
                {
                    //if there are no days the alarm cannot go off :/
                    MessageBox.Show(this, "No days were selected for the alarm to go off on.");
                    return;
                }
            }
            else
            {
                alarmDays = null;
            }
            string audioFile = "";

            try
            {
                audioFile = getSelectedAudioFile();
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show(this, "No alarm tone was set.");
                return;
            }


            //call the modified version...
            if (alarm != null)
            {
                GuiEventCaller.GetCaller().NotifyAlarmEditRequest(alarm, alarmName, hours, minutes, Repeats.IsChecked.Value, audioFile, Repeats.IsChecked.Value, alarmDays);
            }
            else
            {
                GuiEventCaller.GetCaller().NotifyAlarmRequested(hours, minutes, Repeats.IsChecked.Value, audioFile, Repeats.IsChecked.Value, alarmDays, alarmName);
            }

            Close();
        }
Esempio n. 15
0
 private void Snooze_Button_Click(object sender, RoutedEventArgs e)
 {
     GuiEventCaller.GetCaller().NotifySnoozeRequested(new Alarm());
     // I think we should skip snoozing indivitual alarms. Users want X minutes of quiet time imo -Nathan
 }