public CreateEditQuestion(Editor parent, List <string> sections) { InitializeComponent(); this.parent = parent; comboBoxType.SelectedIndex = 0; _answer = new SingleQuestionAnswer(); foreach (var section in sections) { comboBoxSection.Items.Add(section); } comboBoxSection.SelectedIndex = 0; infoEdit = new SimpleInfoEditControl(); panelInfo.Controls.Add(infoEdit as UserControl); }
public CreateEditQuestion(Editor parent, List <string> sections, IQuestion questionToChange) { InitializeComponent(); this.parent = parent; textBoxName.Enabled = false; _isChangeQuestionState = true; textBoxName.Text = questionToChange.Name; infoEdit = InfoEditableControlFactory.GetInfoEditableControl(questionToChange.QuestionInfo); panelInfo.Controls.Add(infoEdit as UserControl); if (questionToChange.QuestionAnswer is SingleQuestionAnswer) { comboBoxType.SelectedIndex = 0; _answer = new SingleQuestionAnswer(questionToChange.QuestionAnswer as SingleQuestionAnswer); } else if (questionToChange.QuestionAnswer is AlternativeQuestionAnswer) { comboBoxType.SelectedIndex = 1; _answer = new AlternativeQuestionAnswer(questionToChange.QuestionAnswer as AlternativeQuestionAnswer); } else if (questionToChange.QuestionAnswer is AccordanceQuestionAnswer) { comboBoxType.SelectedIndex = 2; _answer = new AccordanceQuestionAnswer(questionToChange.QuestionAnswer as AccordanceQuestionAnswer); } else if (questionToChange.QuestionAnswer is SequenceQuestionAnswer) { comboBoxType.SelectedIndex = 3; _answer = new SequenceQuestionAnswer(questionToChange.QuestionAnswer as SequenceQuestionAnswer); } else if (questionToChange.QuestionAnswer is FreeStatementQuestionAnswer) { comboBoxType.SelectedIndex = 4; _answer = new FreeStatementQuestionAnswer(questionToChange.QuestionAnswer as FreeStatementQuestionAnswer); } else if (questionToChange.QuestionAnswer is MultiQuestionAnswer) { comboBoxType.SelectedIndex = 5; _answer = new MultiQuestionAnswer(questionToChange.QuestionAnswer as MultiQuestionAnswer); } else { throw new ArgumentException("Поле comboBoxType не содержит определения для данного типа QuestionAnswer"); } foreach (var section in sections) { comboBoxSection.Items.Add(section); } if (questionToChange.Section == null) { comboBoxSection.SelectedIndex = 0; } else { comboBoxSection.SelectedIndex = comboBoxSection.Items.IndexOf(questionToChange.Section); } numericUpDownScore.Value = questionToChange.QuestionAnswer.QuestionScore < 1 ? 1 : questionToChange.QuestionAnswer.QuestionScore; }