public ucOneAnswerTest(OneAnswerQuestion question = null) { InitializeComponent(); this.question = question; tbQuestion.Text = question.Text; numericUpDown.Value = question.Answers.Count; UpdateRadioButtons(); if (question.Answers.Count > 0) { radioButtons[question.CorrectAnswerIndex].Checked = true; } }
private void ViewShown(IQuestionControlView sender) { currentOneAnswerQuestion = Argument.MainView.CurrentQuestion as OneAnswerQuestion; if (currentOneAnswerQuestion == null) { View.Hide(); return; } if (Argument.Client.Mixing) { MixAnswers(currentOneAnswerQuestion.QuestionContent.Answers); } View.Answers = currentOneAnswerQuestion.QuestionContent.Answers; View.Answer = currentOneAnswerQuestion.Answer; View.Devider = currentOneAnswerQuestion.QuestionContent.Devider; View.Letters = currentOneAnswerQuestion.QuestionContent.Letters; View.QuestionText = currentOneAnswerQuestion.QuestionContent.Text; }
public ucOneAnswerTest(OneAnswerQuestion question) { InitializeComponent(); this.question = question; lbQuestion.Text = question.Text; lbQuestion.Left = (this.Width - lbQuestion.Width) / 2; int answersCount = question.Answers.Count; int margin = 20; int rbFirstTop = lbQuestion.Top + lbQuestion.Height + margin; int lastTop = lbQuestion.Top + lbQuestion.Height + margin; for (int ind = 0; ind < answersCount; ind++) { int i = ind; var radioButton = new RadioButton { Text = question.Answers[i], AutoSize = true, Left = 20, Top = lastTop }; radioButton.CheckedChanged += (s, e) => { if ((s as RadioButton).Checked) { index = i; } }; lastTop += radioButton.Height; this.Controls.Add(radioButton); if (i == answersCount - 1) { var width = this.ClientSize.Width; var height = radioButton.Top + radioButton.Height;// + margin; this.ClientSize = new System.Drawing.Size(width, height); } } }