private void ExecuteSave(object sender, ExecutedRoutedEventArgs e) { if (!this._vm.CanSave) { this.statusMessage.Content = "Please ensure that all event and programme information has been entered correctly."; Storyboard sb = (Storyboard)this.FindResource("StatusMessageFadeIn"); this.statusMessage.BeginStoryboard(sb); } else { if (this._vm.Save()) { // Redirect back to Event Main screen with notify box showing that it has been saved. SessionModel.GetInstance().StatusCode = SessionModel.STATUS_NOTICE; if (this._vm.IsNewEvent) { SessionModel.GetInstance().StatusMessage = "Your event has been successfully created."; } else { SessionModel.GetInstance().StatusMessage = "Your event has been successfully edited."; } EventsView eventsScreen = new EventsView(); eventsScreen.SetupNavigationHandler(this.NavigationService); this.NavigationService.Navigate(eventsScreen); } } }
public ParticipantWindow() { InitializeComponent(); //Subscribe to changes on the model SessionModel.GetInstance().PropertyChanged += ReactToSessionModelPropertyChanged; //Determine whether to maximize the window or not double w = System.Windows.SystemParameters.PrimaryScreenWidth; double h = System.Windows.SystemParameters.PrimaryScreenHeight; if (w >= (h * 2)) { this.WindowState = WindowState.Normal; this.Width = 1024; this.Height = 768; } else { this.WindowState = WindowState.Maximized; } //Initialize the UI InitializeUserInterface(); }
public void EditEventByID(int id) { // Redirect user to EditEventScreen to edit their event. SessionModel.GetInstance().EditEventID = id; EventView editEventScreen = new EventView(); editEventScreen.SetupNavigationHandler(this.NavigationService); this.NavigationService.Navigate(editEventScreen); }
/// <summary> /// Constructor /// </summary> public LoginView() { this.InitializeComponent(); // Clear SessionModel SessionModel.GetInstance().Clear(); // Set the ViewModel as the DataContext. this._vm = new LoginViewModel(); this.DataContext = this._vm; }
/// <summary> /// Unregisters the current logged in user for the event. /// </summary> /// <param name="eventId">Event ID</param> /// <returns>True if successful, false if unsuccessful.</returns> public bool UnregisterGuest(int eventId) { if (DBLayer.DomainModels.EventModel.unregisterGuest(SessionModel.GetInstance().LoggedInUser.MatricId, eventId)) { this.UpdateRegisteredEvents(); this.UpdateUpcomingEvents(); return(true); } return(false); }
/// <summary> /// Constructor /// </summary> public EventViewModel() { this.Venues = DBLayer.DomainModels.VenueModel.getAll(); this.Event = new EventModel(); this._subEventCollection = new ObservableCollection <SubEventModel>(); this._budgetCollection = new ObservableCollection <BudgetItemModel>(); this._subEventsToDeleteList = new ObservableCollection <SubEventModel>(); this._budgetItemToDeleteList = new ObservableCollection <BudgetItemModel>(); this._curBudgetItem = new BudgetItemModel(); this._warningMessages = new Dictionary <string, string>(); if (SessionModel.GetInstance().EditEventID > 0) { // Load Event from DB Model this.Event = new EventModel(DBLayer.DomainModels.EventModel.getByID(SessionModel.GetInstance().EditEventID)); List <DBLayer.BudgetItem> bList = DBLayer.DomainModels.BudgetItemModel.getByBudgetId(this.Event.Budget.Id); foreach (DBLayer.BudgetItem b in bList) { this._budgetCollection.Add(new BudgetItemModel(b)); } List <DBLayer.SubEvent> sList = DBLayer.DomainModels.SubEventModel.getAllByEventID(this.Event.Id); foreach (DBLayer.SubEvent s in sList) { this._subEventCollection.Add(new SubEventModel(s)); } this.IsNewEvent = false; // Set default warning messages. if (this.Event.IsBudgetOverflow) { this.AddWarningMessage("BudgetOverflow", "Oops! Looks like you have busted your budget! Remove some items or increase your budget."); } if (!this.IsNotCloseToEventDate) { this.AddWarningMessage("CloseToEventDate", "You cannot change certain information (capacity, programme) when your event's start date is less than 3 days from now."); } if (this.Event.IsRegistrationFull) { this.AddWarningMessage("RegistrationFull", "Guest registration is full. Unless you increase the event's capacity, no new registrations are allowed."); } } else { // Add new SubEvent since there must be at least one SubEvent. this.AddNewSubEvent(); } }
private void NavigationService_LoadCompleted(object sender, NavigationEventArgs e) { this.NavigationService.LoadCompleted -= NavigationService_LoadCompleted; if (!SessionModel.GetInstance().LoggedIn) { this.NavigationService.Navigate(new Uri("Views/LoginView.xaml", UriKind.Relative)); } else { this.loggedInUserLabel.Content = SessionModel.GetInstance().LoggedInUser.Name; } }
/// <summary> /// Validates login information. To be used when user submits the login form in the View. /// </summary> /// <returns>True if user and password are valid, false if invalid.</returns> public bool ValidateUser() { if (DBLayer.DomainModels.StudentModel.authenticate(this.Login.Username, this.Login.Password)) { DBLayer.Student s = DBLayer.DomainModels.StudentModel.getByMatricId(this.Login.Username); SessionModel.GetInstance().Login(s); return(true); } else { return(false); } }
private void ReactToSessionModelPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var model = SessionModel.GetInstance(); var program_state = model.ProgramState; if (e.PropertyName.Equals("ProgramState")) { if (program_state == SessionModel.ProgramStateEnumeration.Finished) { ParticipantWindow_MainGrid.Children.Clear(); ParticipantWindow_MainGrid.Children.Add(new Screen_Closing()); } } else if (e.PropertyName.Equals("CurrentPhase")) { ParticipantWindow_MainGrid.Children.Clear(); switch (model.CurrentPhase.PhaseType) { case PhaseType.InstructionsScreen: ParticipantWindow_MainGrid.Children.Add(new Screen_Instructions()); break; case PhaseType.BlockScreen: ParticipantWindow_MainGrid.Children.Add(new Screen_BlockNumber()); break; case PhaseType.DistractionScreen: ParticipantWindow_MainGrid.Children.Add(new Screen_Distraction()); break; case PhaseType.StudySession: ParticipantWindow_MainGrid.Children.Add(new Screen_Study()); break; case PhaseType.TestSession: ParticipantWindow_MainGrid.Children.Add(new Screen_Test()); break; case PhaseType.ObjectLocation_StudySession: ParticipantWindow_MainGrid.Children.Add(new Screen_ObjectLocation(0)); break; case PhaseType.ObjectLocation_TestSession: ParticipantWindow_MainGrid.Children.Add(new Screen_ObjectLocation(1)); break; } } }
private void Window_Closed(object sender, EventArgs e) { foreach (Window w in System.Windows.Application.Current.Windows) { if (w != this) { w.Close(); } } //Stop the session if need be var model = SessionModel.GetInstance(); model.StopSession(); }
/// <summary> /// Get events created by the logged in user from the database and update the List for created events. /// </summary> public void UpdateCreatedEvents() { // Update created events list. this._createdEventsList.Clear(); // Refresh the session first! SessionModel.GetInstance().Refresh(); ICollection <DBLayer.Event> ownedEvents = SessionModel.GetInstance().LoggedInUser.OwnedEvents; foreach (DBLayer.Event e in ownedEvents) { this._createdEventsList.Add(new EventModel(e)); } this.NotifyPropertyChanged("CreatedEventsList"); }
private void LoginButton_Click(object sender, System.Windows.RoutedEventArgs e) { this._vm.Login.Password = this.passwordText.Password; if (this._vm.ValidateUser()) { SessionModel.GetInstance().StatusCode = SessionModel.STATUS_NOTICE; SessionModel.GetInstance().StatusMessage = "You have successfully logged in. Welcome!"; EventsView eventsScreen = new EventsView(); eventsScreen.SetupNavigationHandler(this.NavigationService); this.NavigationService.Navigate(eventsScreen); } else { MessageBox.Show( "Your matriculation number and password were not recognized. Please check and try again.", "Authentication Failed", MessageBoxButton.OK, MessageBoxImage.Exclamation ); } }
private void NavigationService_LoadCompleted(object sender, NavigationEventArgs e) { this.NavigationService.LoadCompleted -= NavigationService_LoadCompleted; if (!SessionModel.GetInstance().LoggedIn) { this.NavigationService.Navigate(new Uri("Views/LoginView.xaml", UriKind.Relative)); } else { SessionModel.GetInstance().Refresh(); this.loggedInUserLabel.Content = SessionModel.GetInstance().LoggedInUser.Name; this.eventInfoDialog.SetLoggedInUser(SessionModel.GetInstance().LoggedInUser); this._vm.UpdateUpcomingEvents(); this._vm.UpdateCreatedEvents(); this._vm.UpdateRegisteredEvents(); } if (SessionModel.GetInstance().StatusCode != SessionModel.STATUS_NONE) { if (SessionModel.GetInstance().StatusCode == SessionModel.STATUS_ERROR) { this.statusMessage.Style = (Style)this.FindResource("StatusMessageErrorStyle"); } else { this.statusMessage.Style = (Style)this.FindResource("StatusMessageNoticeStyle"); } this.statusMessage.Content = SessionModel.GetInstance().StatusMessage; Storyboard sb = (Storyboard)this.FindResource("StatusMessageFadeIn"); this.statusMessage.BeginStoryboard(sb); } SessionModel.GetInstance().ClearStatus(); }