Exemplo n.º 1
0
        /// <summary>
        /// Updates the current selected schedule with the current selected alarms
        /// </summary>
        public async void UpdateCurrentSchedule()
        {
            if (this.SelectedSchedule == null)
            {
                return;
            }

            string scheduleName = this.SelectedSchedule.Name;

            Controller.Master.AlarmScheduleCollection.Where(p => p.Name == this.SelectedSchedule.Name).First().Alarms = new List <AlarmItem>(Controller.Master.AlarmItemCollection.ToList());

            AlarmScheduleRepository.Save(this.SelectedSchedule);


            Controller.Master.AlarmScheduleCollection = new ObservableCollection <Models.AlarmSchedule>((new AlarmScheduleRepository()).GetAlarmSchedules());

            this.SelectedSchedule = Controller.Master.AlarmScheduleCollection.Where(s => s.Name == scheduleName).First();

            //MetroDialogSettings settings = new MetroDialogSettings();
            //settings.ColorScheme = MetroDialogColorScheme.Accented;
            //settings.AffirmativeButtonText = "Ok";
            //settings.AnimateHide = true;
            //settings.AnimateShow = true;
            //settings.DefaultButtonFocus = MessageDialogResult.Affirmative;
            //await MainWindow.View.ShowMessageAsync("Schedule Updated ", string.Format("Schedule \"{0}\" has been updated.", this.SelectedSchedule.Name), MessageDialogStyle.Affirmative, settings);

            this._eventAggregator.GetEvent <PushStatusMessageEvent>().Publish(string.Format("Schedule \"{0}\" has been updated.", this.SelectedSchedule.Name));
        }
Exemplo n.º 2
0
        //=========================================================
        //  Methods
        //=========================================================
        /// <summary>
        /// Creates a new schedule based on the current selected alarms
        /// </summary>
        public async void CreateNewSchedule()
        {
            MetroDialogSettings settings = new MetroDialogSettings();

            settings.AffirmativeButtonText = "Create";
            settings.AnimateHide           = true;
            settings.AnimateShow           = true;
            settings.DefaultButtonFocus    = MessageDialogResult.Affirmative;
            settings.NegativeButtonText    = "Cancel";
            string scheduleName = await MainWindow.View.ShowInputAsync("Create New Schedule", "Enter the name you would like to use for the new schedule", settings);

            var list = Controller.Master.AlarmScheduleCollection.Where(ap => ap.Name == scheduleName);

            if (list.Count() > 0)
            {
                settings.AffirmativeButtonText = "Ok";
                await MainWindow.View.ShowMessageAsync("Create Schedule Error", "Cannot create a sachedule with the same name as an existing one", MessageDialogStyle.Affirmative, settings);

                this._eventAggregator.GetEvent <PushStatusMessageEvent>().Publish("Cannot create a sachedule with the same name as an existing one");
            }
            else
            {
                if (scheduleName == null)
                {
                    return;
                }
                Models.AlarmSchedule schedule = new Models.AlarmSchedule(Controller.Master.AlarmItemCollection.ToList());

                if (scheduleName.Length > 0)
                {
                    schedule.Name = scheduleName;
                    AlarmScheduleRepository.Save(schedule);
                }

                Controller.Master.AlarmScheduleCollection.Add(schedule);

                ////settings.AffirmativeButtonText = "Ok";
                //await MainWindow.View.ShowMessageAsync("Schedule Created", string.Format("Schedule has been created and saved for {0}", scheduleName), MessageDialogStyle.Affirmative, settings);
                this._eventAggregator.GetEvent <PushStatusMessageEvent>().Publish(string.Format("Schedule has been created and saved for {0}", scheduleName));
                Controller.Master.AlarmScheduleCollection = new ObservableCollection <Models.AlarmSchedule>((new AlarmScheduleRepository()).GetAlarmSchedules());

                this.SelectedSchedule = Controller.Master.AlarmScheduleCollection.Where(p => p.Name == schedule.Name).First();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes the current selected schedule
        /// </summary>
        public async void DeleteCurrentSchedule()
        {
            string scheduleName = this.SelectedSchedule.Name;

            AlarmScheduleRepository.Delete(this.SelectedSchedule);

            Controller.Master.AlarmScheduleCollection.Remove(Controller.Master.AlarmScheduleCollection.Where(schedule => schedule.Name == this.SelectedSchedule.Name).First());

            this.SelectedSchedule = null;
            this.RemoveAllAlarms();


            //MetroDialogSettings settings = new MetroDialogSettings();
            //settings.AffirmativeButtonText = "Ok";
            //settings.AnimateHide = true;
            //settings.AnimateShow = true;
            //settings.DefaultButtonFocus = MessageDialogResult.Affirmative;
            //await MainWindow.View.ShowMessageAsync("Schedule Deleted ", string.Format("Schedule \"{0}\" has been deleted.", scheduleName), MessageDialogStyle.Affirmative, settings);

            this._eventAggregator.GetEvent <PushStatusMessageEvent>().Publish(string.Format("Schedule \"{0}\" has been deleted", scheduleName));
        }