/// <summary> /// Initializes a new instance of the <see cref="Quiz"/> class. /// </summary> public Quiz() { InitializeComponent(); buttonList = new List<Button>(); //create a new list of questions buttonList.Add(option_A); buttonList.Add(option_B); buttonList.Add(option_c); buttonList.Add(option_D); questionButtons = new List<Button>(); questionButtons.Add(QnOne); questionButtons.Add(QnTwo); questionButtons.Add(QnThree); questionButtons.Add(QnFour); questionButtons.Add(QnFive); questionButtons.Add(QnSix); DropShadowEffect dShdow = new DropShadowEffect(); dShdow.BlurRadius = 10; dShdow.Opacity = 0.365; fifty_fifty_button.Effect = dShdow; skip_button.Effect = dShdow; hint_button.Effect = dShdow; String path = Path.Combine(Path.GetFullPath("."), "Resources/xml/Questions.xml"); PageModel model = XMLUtilities.GetContentFromFile(path); PageModelText[] textList = model.TextList; List<Question> Questions = new List<Question>(); for (int i = 0; i < textList.Count(); i = i + 6) { List<String> options = new List<string>(); for (int j = i + 1; j < i + 5; j++) { options.Add(textList[j].Value); } String hint = textList[i + 5].Value; Question q = new Question(textList[i].Value, options[0], options, "", hint); Questions.Add(q); } ChooseQuestions(Questions); activeQuestion = chosenQuestions[0]; addButtonColours(0); closeButton.Background = SELECTED_COLOR; closeButton.Effect = dShdow; }
/// <summary> /// Handles the Click event of the question6 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private void question6_Click(object sender, RoutedEventArgs e) { activeQuestion = chosenQuestions[5]; addButtonColours(5); setContent(activeQuestion); ResetTimer(); }
/// <summary> /// Sets the content. /// </summary> /// <param name="qn">The qn.</param> private void setContent(Question qn) { content_title.Text = qn.QuestionContent; option_A.Content = qn.AllAvailableOptions[0]; option_B.Content = qn.AllAvailableOptions[1]; option_c.Content = qn.AllAvailableOptions[2]; option_D.Content = qn.AllAvailableOptions[3]; if (qn.IsAnswered) { changeButtonState(); if (qn.IsCorrect) { correctField.Foreground = CORRECT_COLOR; correctField.Text = "Correct!"; StatusBar.Text = "Answer was: " + activeQuestion.CorrectAnswer; } else { correctField.Foreground = INCORRECT_COLOR; correctField.Text = "Incorrect!"; StatusBar.Text = "Answer was: " + activeQuestion.CorrectAnswer + "\nYou answered: " + activeQuestion.OptionSelected; } } else if (qn.HintUsed) { StatusBar.Text = "Hint: " + activeQuestion.Hint; } else { correctField.Text = ""; changeButtonState(); StatusBar.Text = ""; } setScore(); }
/// <summary> /// Handles the click event of the question5 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void question5_click(object sender, RoutedEventArgs e) { activeQuestion = chosenQuestions[4]; questionNumber.Text = "Question 5"; setContent(activeQuestion); addButtonColours(4); ResetTimer(); }