Example #1
0
        private void QuestionListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (last_question_index >= 0)
            {
                SaveLastAnswer(last_question_index, pack.GetQuestions()[last_question_index]);
            }
            last_question_index = QuestionListBox.SelectedIndex;
            Question q = pack.GetQuestions()[QuestionListBox.SelectedIndex];

            foreach (var elem in sets.GetPriorities())
            {
                int counter = 0;
                if (elem.Equals("text"))
                {
                    if (q.GetQuestionText() != "")
                    {
                        webBrowser.DocumentText = q.GetQuestionText();
                        break;
                    }
                }
                else if (elem.Equals("html"))
                {
                    if (q.GetHTML() != "")
                    {
                        webBrowser.DocumentText = q.GetHTML();
                        break;
                    }
                }
                else if (elem.Equals("image"))
                {
                    if (q.GetQuestionImageEncoded() != "")
                    {
                        webBrowser.DocumentText = EmbedIMG(q.GetQuestionImageEncoded());
                        break;
                    }
                }
                counter++;
                if (counter == 2)
                {
                    webBrowser.DocumentText = q.GetQuestionText();
                    break;
                }
            }
            List <Answer> a = q.getAnswers();

            for (var i = 0; i < 4; i++)
            {
                answerCheckBoxes[i].Text = a[i].GetText();
                CA[answerCheckBoxes[i]]  = a[i];
                if (a[i].IsChosen())
                {
                    answerCheckBoxes[i].Checked = true;
                }
                else
                {
                    answerCheckBoxes[i].Checked = false;
                }
            }
        }
Example #2
0
        public Form1()
        {
            InitializeComponent();
            mainControls = new List <Control>()
            {
                QuestionListBox,
                webBrowser,
                AnswerACheckBox,
                AnswerBCheckBox,
                AnswerCCheckBox,
                AnswerDCheckBox,
                FinishButton
            };
            nameControls = new List <Control>()
            {
                Namelabel,
                NametextBox,
                StartButton
            };

            foreach (var elem in mainControls)
            {
                elem.Visible = false;
            }

            pack = jsonSender.GetPack(false);
            sets = pack.GetSettings();
            if (sets.GetPriorities().Count != 3)
            {
                sets.SetPriorities(jsonSender.GetConfig().InPriority);
            }
            answerCheckBoxes = new CheckBox[] { AnswerACheckBox, AnswerBCheckBox, AnswerCCheckBox, AnswerDCheckBox };

            foreach (var elem in answerCheckBoxes)
            {
                CA[elem] = null;
            }

            for (int i = 1; i < pack.GetQuestions().Count + 1; i++)
            {
                QuestionListBox.Items.Add(i);
            }

            QuestionListBox.SelectedIndex = 0;
        }