private void NewSchedule_Executed(object sender, ExecutedRoutedEventArgs e) { var scheduleDialog = new ScheduleName { Owner = this }; scheduleDialog.ShowDialog(); if (!string.IsNullOrEmpty(scheduleDialog.Name)) { if (_viewModel.LastOpenedSchedule != null) { _viewModel.LastOpenedSchedule.LastOpened = false; _viewModel.UpdateCurrentSchedule(); } _viewModel.LastOpenedSchedule = new Schedule { Id = scheduleDialog.Name, LastOpened = true }; //_viewModel.ScheduleAppointments = Schedule.Appointments; _viewModel.SaveCurrentSchedule(); _viewModel.InitRemainigSessions(); // in case this is the first time running ScheduleView.Visibility = Visibility.Visible; ClassromsPanel.Visibility = Visibility.Visible; ScheduleLabel.Visibility = Visibility.Hidden; GlobalButton.IsEnabled = true; Schedule.Appointments.Clear(); // reset schedule Title = $"{scheduleDialog.Name} - {_appTitle}"; } }
public void DoDemo() { Task.Factory.StartNew(() => { if (DemoStopped()) { return; } switch (_nextDemoState) { case Constants.ApplicationState.ScheduleAdd: Application.Current.Dispatcher.Invoke(() => { DrawerHost.IsLeftDrawerOpen = false; var dialog = new ScheduleName { Owner = this }; DemoStateHandler.Instance.DemoState = dialog; dialog.ShowDialog(); if (!string.IsNullOrEmpty(dialog.Name)) { if (_viewModel.LastOpenedSchedule != null) { _viewModel.UpdateCurrentSchedule(); } _viewModel.LastOpenedSchedule = new Schedule { Id = dialog.Name, }; _viewModel.SaveCurrentSchedule(); _viewModel.InitRemainigSessions(); // in case this is the first time running ScheduleView.Visibility = Visibility.Visible; ClassromsPanel.Visibility = Visibility.Visible; ScheduleLabel.Visibility = Visibility.Hidden; GlobalButton.IsEnabled = true; Schedule.Appointments.Clear(); Title = $"{dialog.Name} - {_appTitle}"; } _nextDemoState = Constants.ApplicationState.Courses; DrawerHost.IsLeftDrawerOpen = true; }); DemoStopped(); break; case Constants.ApplicationState.Courses: Application.Current.Dispatcher.Invoke(() => { var dialog = new CourseList(_viewModel); DemoStateHandler.Instance.DemoState = dialog; dialog.ShowDialog(); _nextDemoState = Constants.ApplicationState.Softwares; }); DemoStopped(); break; case Constants.ApplicationState.Softwares: Application.Current.Dispatcher.Invoke(() => { var dialog = new SoftwareList(_viewModel); DemoStateHandler.Instance.DemoState = dialog; dialog.ShowDialog(); _nextDemoState = Constants.ApplicationState.Subjects; }); DemoStopped(); break; case Constants.ApplicationState.Subjects: Application.Current.Dispatcher.Invoke(() => { var dialog = new SubjectList(_viewModel); DemoStateHandler.Instance.DemoState = dialog; dialog.ShowDialog(); _nextDemoState = Constants.ApplicationState.Classrooms; }); DemoStopped(); break; case Constants.ApplicationState.Classrooms: Application.Current.Dispatcher.Invoke(() => { var dialog = new ClassroomList(_viewModel); DemoStateHandler.Instance.DemoState = dialog; dialog.ShowDialog(); _nextDemoState = Constants.ApplicationState.SessionDetails; DrawerHost.IsLeftDrawerOpen = false; }); DemoStopped(); break; case Constants.ApplicationState.SessionDetails: Application.Current.Dispatcher.Invoke(() => { _viewModel.Classroom = _viewModel.Classrooms[0]; var startTime = DateTime.Now.StartOfWeek().Date + new TimeSpan(7, 15, 0); var session = _viewModel.RemainingSessions[0]; var avaibleTerms = _viewModel.GetAvailableTerms(null, startTime, session); var dialog = new SessionDetails(_viewModel, Schedule.Appointments, avaibleTerms, startTime, session); DemoStateHandler.Instance.DemoState = dialog; dialog.ShowDialog(); _nextDemoState = Constants.ApplicationState.ScheduleAdd; }); if (DemoStopped()) { return; } //if (DemoStopped()) return; Application.Current.Dispatcher.Invoke( () => { _viewModel.RemoveClassroom(DemoStateHandler.Instance.DemoClassroomId); }); DemoStateHandler.Instance.RemoveDemoEntities(); _viewModel.LastOpenedSchedule = null; break; } }); }