private void go_click_firstQuestion() { var list = new ArrayList(); quesIDList = quesIDList_init(); var q = new Question(); list = q.GetQuestion(quesIDList[ques_idx], path); if (list.Count > 1)// the description of the problem is the list[0] { var num = 1; quesTextLabel.Text = list[0].ToString(); foreach (Control control in optionsGrpBox.Controls) { var radio = control as RadioButton; radio.Visible = false; radio.Enabled = false; radio.Text = ""; if (num <= list.Count - 1) { radio.Visible = true; radio.Enabled = true; radio.Text = list[num].ToString(); num++; } } } else { SubmitButton.Enabled = false; NextButton.Enabled = false; } //NextButton.PerformClick(); }
private void NextButton_Click(object sender, EventArgs e) { //explain.Visible = false; ExplainPictureBox.Image = null; foreach (Control control in optionsGrpBox.Controls) { var radio = control as RadioButton; radio.Checked = false; } NextButton.Enabled = false; SubmitButton.Enabled = true; optionsGrpBox.Enabled = true; optionsGrpBox.Refresh(); var q = new Question(); var list = new ArrayList(); if (ques_idx < no_ques) { list = q.GetQuestion(quesIDList[ques_idx], path); var num = 1; if (list.Count > 1) { quesTextLabel.Text = list[0].ToString(); foreach (Control control in optionsGrpBox.Controls) { var radio = control as RadioButton; radio.Visible = false; radio.Enabled = false; radio.Text = " "; if (num <= list.Count - 1) { radio.Visible = true; radio.Enabled = true; radio.Text = list[num].ToString(); num++; } } } else { SubmitButton.Enabled = false; NextButton.Enabled = false; } } else { var file = "image\\icon\\finish.png"; ExplainPictureBox.Image = Image.FromFile(file); //MessageBox.Show("You have successfully completed the quiz and scored " + points + " points"); SubmitButton.Enabled = false; foreach (Control control in optionsGrpBox.Controls) { var radio = control as RadioButton; radio.Enabled = false; } } }
public QuestionViewer(Question q) { question = q; text = question.GetQuestion(); Dock = DockStyle.Fill; StyleApplier.ApplyColors(this); textLabel = new Label { TextAlign = ContentAlignment.MiddleCenter, Dock = DockStyle.Fill, Text = text, Font = new Font("Callbri", 11, FontStyle.Bold), }; if (question is ImageQuestion) { var splitContainer = new SplitContainer { IsSplitterFixed = true }; splitContainer.Orientation = Orientation.Horizontal; splitContainer.Dock = DockStyle.Fill; splitContainer.SizeChanged += (s, ea) => splitContainer.SplitterDistance = 100; splitContainer.Panel1.Controls.Add(textLabel); splitContainer.Panel1.Controls.Add(new Button { Text = "" }); //now the spliter does not catch focus splitContainer.Panel1.AutoScroll = true; splitContainer.Panel2.Controls.Add(new PictureBox { Image = (question as ImageQuestion).Image, Dock = DockStyle.Fill, SizeMode = PictureBoxSizeMode.Zoom }); this.Controls.Add(splitContainer); } else if (question is SoundQuestion) { var playButton = new Button { Width = 120, Height = 40, Text = "Play sound", BackColor = Color.Green, Font = new Font("Callbri", 12, FontStyle.Bold), FlatStyle = FlatStyle.Popup, ForeColor = Color.Black }; var stopButton = new Button { Width = 120, Height = 40, Text = "Stop", BackColor = Color.Red, Font = new Font("Callbri", 12, FontStyle.Bold), FlatStyle = FlatStyle.Popup, ForeColor = Color.Black }; playButton.Click += (s, ea) => (question as SoundQuestion).Play(); stopButton.Click += (s, ea) => (question as SoundQuestion).Stop(); var splitContainer = new SplitContainer { IsSplitterFixed = true }; splitContainer.Orientation = Orientation.Horizontal; splitContainer.Dock = DockStyle.Fill; splitContainer.SizeChanged += (s, ea) => splitContainer.SplitterDistance = 80; splitContainer.Panel1.Controls.Add(playButton); splitContainer.Panel1.Controls.Add(stopButton); splitContainer.Panel1.SizeChanged += (s, ea) => { playButton.Left = (splitContainer.Panel1.Width) / 2 - playButton.Width - 10; playButton.Top = (splitContainer.Panel1.Height - playButton.Height) / 2; stopButton.Left = (splitContainer.Panel1.Width) / 2 + 10; stopButton.Top = (splitContainer.Panel1.Height - stopButton.Height) / 2; }; splitContainer.Panel2.Controls.Add(textLabel); splitContainer.Panel2.AutoScroll = true; this.Controls.Add(splitContainer); } else { this.Controls.Add(textLabel); } }