/// <summary> /// The button that allows the user to add or update the current user playing the program. plays a sound when the user enters the window. hides the main window and /// shows the data entry window. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdUserInfo_Click(object sender, RoutedEventArgs e) { SoundPlayer answerRight = new SoundPlayer("addOrUpdate.wav"); answerRight.Play(); Grid mainWindowGrid = (Grid)((Button)sender).Parent; MainWindow mw = (MainWindow)mainWindowGrid.Parent; EnterUserDataWindow dataWindow = new EnterUserDataWindow(); dataWindow.DataContext = ((MainWindowViewModel)mw.DataContext).EnterUserDataVM; mw.Hide(); dataWindow.ShowDialog(); mw.Show(); mw.BringIntoView(); }
/// <summary> /// the button that loads the game selection menu. plays a sound when the user gets to choose which game they want to play /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdPlayGame_Click(object sender, RoutedEventArgs e) { SoundPlayer simpleSound = new SoundPlayer("Breathing.wav"); simpleSound.Play(); Grid mainWindowGrid = (Grid)((Button)sender).Parent; MainWindow mw = (MainWindow)mainWindowGrid.Parent; SelectGameTypeWindow sgt = new SelectGameTypeWindow(); sgt.DataContext = ((MainWindowViewModel)mw.DataContext).SelectGameTypeVM; mw.Hide(); sgt.ShowDialog(); mw.Show(); mw.BringIntoView(); }
/// <summary> /// The method that is ran when the user is choosing their game type. WHen the user chooses the game type and hits submit, this method /// brings the appropriate game window up. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdSelectGameTypeSubmit_Click(object sender, RoutedEventArgs e) { MainWindow mw = (MainWindow)Application.Current.MainWindow; MainWindowViewModel mwvm = (MainWindowViewModel)mw.DataContext; PlayGameViewModel pgw = (((MainWindowViewModel)Application.Current.MainWindow.DataContext).PlayGameWindowVM); pgw.IsGameStarted = false; Window theWindow = null; if (this.cmbSelectedGame.SelectedValue == Enum.GetName(typeof(GameTypesEnum), GameTypesEnum.Addition)) { theWindow = new AdditionGameWindow(); mwvm.PlayGameWindowVM.DesiredGameType = GameTypesEnum.Addition; } else if (this.cmbSelectedGame.SelectedValue == Enum.GetName(typeof(GameTypesEnum), GameTypesEnum.Subtraction)) { theWindow = new SubtractionGameWindow(); mwvm.PlayGameWindowVM.DesiredGameType = GameTypesEnum.Subtraction; } else if (this.cmbSelectedGame.SelectedValue == Enum.GetName(typeof(GameTypesEnum), GameTypesEnum.Multiplication)) { theWindow = new MultiplicationGameWindow(); mwvm.PlayGameWindowVM.DesiredGameType = GameTypesEnum.Multiplication; } else if (this.cmbSelectedGame.SelectedValue == Enum.GetName(typeof(GameTypesEnum), GameTypesEnum.Division)) { theWindow = new DivisionGameWindow(); mwvm.PlayGameWindowVM.DesiredGameType = GameTypesEnum.Division; } if (theWindow == null) { return; } //Closes the window select game window and brings the appropriate game window into view. Button btn = (Button)sender; Grid grid = (Grid)btn.Parent; SelectGameTypeWindow sgw = (SelectGameTypeWindow)grid.Parent; theWindow.DataContext = mwvm.PlayGameWindowVM; sgw.Close(); theWindow.ShowDialog(); mw.Show(); mw.BringIntoView(); }