/// <summary> /// Check Answer if Submit button is clicked /// </summary> /// <param name="e"></param> private void CheckAnswer(RoutedEventArgs e) { //Check and see if the answer is right, if it is add one to score if (Int32.Parse(AnswerBox.Text) == game.getAnswer(counter)) { counter++; GradeLabel.Content = "Correct"; player.addUserScore(); } else { counter++; GradeLabel.Content = "Incorrect"; } if (counter >= 10) { FinalScoreWindow final = new FinalScoreWindow(player); MyTimer.Stop(); counter = 0; this.Hide(); final.ShowDialog(); } else { // List the new Question QuestionLabel.Content = game.questionToString(counter); } AnswerBox.Text = ""; }
/// <summary> /// Checks answer to see if it is correct or incorrect /// </summary> /// <param name="e"></param> private void CheckAnswer(KeyEventArgs e) { ///Exception handling for the normal method try { if (e.Key == Key.Enter) { //Check and see if the answer is right, if it is add one to score if (Int32.Parse(AnswerBox.Text) == game.getAnswer(counter)) { counter++; GradeLabel.Content = "Correct"; player.addUserScore(); } else { counter++; GradeLabel.Content = "Incorrect"; } if (counter >= 10) { MyTimer.Stop(); counter = 0; FinalScoreWindow final = new FinalScoreWindow(player); if (player.getUserScore() <= 4) { final.BackgroundImage.ImageSource = new BitmapImage(new Uri(@"Images/LizardMan.jpg", UriKind.Relative)); } else if (player.getUserScore() >= 5 || player.getUserScore() <= 7) { final.BackgroundImage.ImageSource = new BitmapImage(new Uri(@"Images/Background1.jpg", UriKind.Relative)); } else { final.BackgroundImage.ImageSource = new BitmapImage(new Uri(@"Images/Background2.jpg", UriKind.Relative)); } final.ShowDialog(); } else { // List the new Question QuestionLabel.Content = game.questionToString(counter); } AnswerBox.Text = ""; } } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } }
/// <summary> /// Method shows the FinalScoreWindow by creating a new instance and shows it as a Dialog /// </summary> public void showFinalScoresWindow() { try { if (this.mGameLogic != null && this.mGameLogic.getPlayer() != null) { hideMainErrorLabel(); mFinalScoreWindow = new FinalScoreWindow(this); mFinalScoreWindow.ShowDialog(); } else { showMainErrorLabel(); } } catch (Exception e) { throw e; } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.HighScoreWindow = ((KidsMathGame.FinalScoreWindow)(target)); return; case 2: this.label = ((System.Windows.Controls.Label)(target)); return; case 3: this.topTenScoresListBox = ((System.Windows.Controls.ListBox)(target)); return; case 4: this.labelnone = ((System.Windows.Controls.Label)(target)); return; case 5: this.labelTopScores = ((System.Windows.Controls.Label)(target)); return; case 6: this.mainMenuNavButton = ((System.Windows.Controls.Button)(target)); #line 25 "..\..\FinalScoreWindow.xaml" this.mainMenuNavButton.Click += new System.Windows.RoutedEventHandler(this.mainMenuNavButton_Click); #line default #line hidden return; case 7: this.topScoreHeaderLabel = ((System.Windows.Controls.Label)(target)); return; case 8: this.labelnone_Score = ((System.Windows.Controls.Label)(target)); return; case 9: this.labelPlayerScore = ((System.Windows.Controls.Label)(target)); return; case 10: this.finalCorrectLabel = ((System.Windows.Controls.Label)(target)); return; case 11: this.finalIncorrectLabel = ((System.Windows.Controls.Label)(target)); return; case 12: this.finalTimeLabel = ((System.Windows.Controls.Label)(target)); return; case 13: this.finalNameLabel = ((System.Windows.Controls.Label)(target)); return; } this._contentLoaded = true; }