private void nextQuestionButton_Click(object sender, EventArgs e)
        {
            // If this isn't the first question, validate the answer
            if (questionIndex > -1)
            {
                validateAnswer();
            }

            // Select next question
            questionIndex++;

            // If we've gone through all questions, end the quiz
            if (questionIndex == quiz.Questions.Count)
            {
                endQuiz();
                return;
            }

            // Load the current question
            currentQuestion = quiz.Questions[questionOrder[questionIndex]];

            // If the question is a text question hide the picture box and update the question text label
            if (currentQuestion.Type == QuestionType.TEXT)
            {
                questionTextLabel.Text = currentQuestion.Text;
                questionPictureBox.Visible = false;
            }
            // Otherwise show the questions image, and set the label to indicate that this is a picture question
            else
            {
                questionTextLabel.Text = StringResources.MISC_PICTURE_QUESTION_LABEL;
                questionPictureBox.Visible = true;
                questionPictureBox.Image = quiz.Images[currentQuestion.ImageIndex];
            }

            // Update answers
            answersComboBox.DataSource = currentQuestion.Answers;

            // Ask windows to re-render everything
            Refresh();
        }
        /// <summary>
        /// Sets up a new quiz and adds a blank question to it
        /// </summary>
        private void setupNewQuiz()
        {
            SelectedQuiz = new Quiz();
            SelectedQuestion = SelectedQuiz.AddQuestion();

            updateQuestionList();
            selectQuestion(0);
        }
        private void removeQuestionButton_Click(object sender, EventArgs e)
        {
            // Remove the selected question when the remove question button is clicked
            SelectedQuiz.RemoveQuestion(SelectedQuestion);
            SelectedQuestion = null;

            updateQuestionList();
        }
 private void questionListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     // If the sanity check passes, select the new question.
     // If not, select the previously selected question
     if (doSanityChecks())
     {
         SelectedQuestion = (Question)questionListBox.SelectedItem;
     }
     else
     {
         selectQuestion(questionListBox.Items.IndexOf(SelectedQuestion));
     }
 }
 /// <summary>
 /// Removes a question from the quiz
 /// </summary>
 /// <param name="question">The question to remove</param>
 public void RemoveQuestion(Question question)
 {
     Questions.Remove(question);
 }
        /// <summary>
        /// Adds a new question to the quiz
        /// </summary>
        /// <returns>The newly created and added question</returns>
        public Question AddQuestion()
        {
            Question question = new Question();
            question.QuestionId = String.Format(StringResources.MISC_QUESTION_ID, Questions.Count);

            Questions.Add(question);

            return question;
        }
 /// <summary>
 /// Saves a question to a zip archive
 /// </summary>
 /// <param name="question">The question to save</param>
 /// <param name="archive">The archive to save to</param>
 public void SaveQuestion(Question question, ZipArchive archive)
 {
     // Create file in zip
     ZipArchiveEntry questionEntry = archive.CreateEntry(StringResources.PATH_QUESTION_DIR + Path);
     using (Stream stream = questionEntry.Open())
     {
         // Serialize the question
         XmlSerializer x = new XmlSerializer(typeof(Question));
         x.Serialize(stream, question);
     }
 }