示例#1
0
        private void questionListBox_DoubleClick(object sender, EventArgs e)
        {
            if (questionListBox.SelectedItem == null)
            {
                return;
            }

            selectedQuestion = (Questions)questionListBox.SelectedItem;

            updateForm = new QuestionDetails();

            updateForm.QuestionUpdated += new QuestionEventHandler(this.UpdateForm_QuestionUpdated);

            // takes this from the detailForm instance (QuestionDetails class) to populate data
            updateForm.PopulateData(selectedQuestion);

            // opens and shows the detail form upon a double click of a listbox item
            updateForm.Show();
        }
示例#2
0
        private void RandomQuestion()
        {
            Random randomNumber = new Random();

            triviaQuestionList = new BindingList <Questions>();

            for (int i = 0; i < 3;)
            {
                int       placement   = randomNumber.Next(0, questionList.Count);
                Questions tmpQuestion = questionList[placement];

                // the if is utilized to ensure no duplicate questions are added to the trivia list (which contains three questions)
                if (!triviaQuestionList.Contains(tmpQuestion))
                {
                    triviaQuestionList.Add(tmpQuestion);
                    i++;
                }
            }
        }
示例#3
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (questionListBox.SelectedItem == null)
            {
                MessageBox.Show("Add a question or load a file first");
                return;
            }


            selectedQuestion = (Questions)questionListBox.SelectedItem;

            updateForm = new QuestionDetails();

            updateForm.QuestionUpdated += new QuestionEventHandler(this.UpdateForm_QuestionUpdated);

            // takes this from the detailForm instance (QuestionDetails class) to populate data
            updateForm.PopulateData(selectedQuestion);

            // opens and shows the detail form upon a double click of a listbox item
            updateForm.Show();
        }
示例#4
0
        private void ShowQuestionInfo()
        {
            Questions quizQuestion = triviaQuestionList[questionNumber];

            questionLabel.Text     = quizQuestion.Question;
            choiceOneButton.Text   = quizQuestion.Answers[0];
            choiceTwoButton.Text   = quizQuestion.Answers[1];
            choiceThreeButton.Text = quizQuestion.Answers[2];
            choiceFourButton.Text  = quizQuestion.Answers[3];
            feedbackLabel.Text     = quizQuestion.Feedback;

            questionNumberLabel.Text = $"Question {questionNumber + 1} out of 3";
            scoreLabel.Text          = $"Total Score: {totalScore}";

            feedbackLabel.Visible      = false;
            correctWrongLabel.Visible  = false;
            nextQuestionButton.Visible = false;

            // enables the buttons
            choiceOneButton.Enabled   = true;
            choiceTwoButton.Enabled   = true;
            choiceThreeButton.Enabled = true;
            choiceFourButton.Enabled  = true;
        }
示例#5
0
 private void UpdateForm_QuestionUpdated(object sender, Questions q)
 {
     // reset the bindings so that the listbox updates
     // manual refresh
     questionList.ResetBindings();
 }
示例#6
0
 private void EntryForm_QuestionCreated(object sender, Questions q)
 {
     questionList.Add(q); // questions being added to the list
 }