internal Form_header(Test TEST) { InitializeComponent(); Design_for_Form_header(); button_create.Click += new EventHandler(Button_create_Click); Show(); test_name_textbox.Text = TEST._Header.Name; description_textBox.Text = TEST._Header.Description; if (TEST._Header.Verifier == VerificationDescriptors._NO_LIMITS) { NL_checkBox.Checked = true; } else if (TEST._Header.Verifier == VerificationDescriptors._AT_LEAST_ONE) { AO_checkBox.Checked = true; } else if (TEST._Header.Verifier == VerificationDescriptors._ONLY_ONE) { OO_checkBox.Checked = true; } void Button_create_Click(object sender, EventArgs e) { if (test_name_textbox.Text.Trim() != "" && !test_name_textbox.Text.Contains('<') && !test_name_textbox.Text.Contains('>')) { TEST._Header.Name = test_name_textbox.Text.Trim(); } else { MessageBox.Show("Ошибка: имя пусто или содержит символы \"<>\""); return; } if (!description_textBox.Text.Contains('<') && !description_textBox.Text.Contains('>')) { TEST._Header.Description = description_textBox.Text.Trim(); } else { MessageBox.Show("Ошибка: описание содержит символы \"<>\""); return; } if (NL_checkBox.Checked) { TEST._Header.Verifier = VerificationDescriptors._NO_LIMITS; } else if (AO_checkBox.Checked) { TEST._Header.Verifier = VerificationDescriptors._AT_LEAST_ONE; } else if (OO_checkBox.Checked) { TEST._Header.Verifier = VerificationDescriptors._ONLY_ONE; } else { MessageBox.Show("Ошибка: вы не выбрали вариант валидации"); return; } Form_Questions FQ = new Form_Questions(TEST); this.Close(); } }
internal Form_Keys(Test TEST) { InitializeComponent(); Design_for_Form_Keys(); Show(); CoKey_textbox.Text = Convert.ToString(TEST._Keys.Count); CoKey_textbox.KeyPress += new KeyPressEventHandler(TextBox_KeyPress_integers); button_add_row.Click += new EventHandler(button_add_row_click); button_remove_row.Click += new EventHandler(button_remove_row_click); button_left.Click += new EventHandler(button_left_click); button_right.Click += new EventHandler(button_right_click); button_create.Click += new EventHandler(button_create_click); button_next.Click += new EventHandler(button_next_click); button_back.Click += new EventHandler(button_back_click); if (TEST._Keys.Count > 0) { Create_Key(TEST); } void button_add_row_click(object sender, EventArgs e) { TEST._Keys[Key_number].Add(new Element()); Questions_form.Add(new TextBox()); Answers_form.Add(new TextBox()); Points_form.Add(new TextBox()); Create_row(TEST, TEST._Keys[Key_number].Count - 1); } void button_remove_row_click(object sender, EventArgs e) { if (TEST._Keys[Key_number].Count <= 0) { return; } Delete_last_row_on_panel(); TEST._Keys[Key_number].RemoveAt(TEST._Keys[Key_number].Count - 1); Questions_form.RemoveAt(Questions_form.Count - 1); Answers_form.RemoveAt(Answers_form.Count - 1); Points_form.RemoveAt(Points_form.Count - 1); C_Row_label.Text = $"Количество строк {Convert.ToString(TEST._Keys[Key_number].Count)}"; } void button_create_click(object sender, EventArgs e) { try { int tmp = Convert.ToInt32(CoKey_textbox.Text); if (tmp > 0) { if (tmp > TEST._Keys.Count) { for (int i = TEST._Keys.Count; i < tmp; i++) { TEST._Keys.Add(new Key()); } Create_Key(TEST); } if (tmp < TEST._Keys.Count) { for (int i = TEST._Keys.Count - 1; i >= tmp; i--) { TEST._Keys.RemoveAt(i); } if (Key_number >= TEST._Keys.Count) { Key_number = TEST._Keys.Count - 1; } Create_Key(TEST); } } } catch { MessageBox.Show("Ошибка: некорректно задано количество ключей"); } } void button_left_click(object sender, EventArgs e) { if (Key_number <= 0) { return; } Key_number--; Clear_panel(); Questions_form = new List <TextBox>(); Answers_form = new List <TextBox>(); Points_form = new List <TextBox>(); Create_Key(TEST); } void button_right_click(object sender, EventArgs e) { try { if (Questions_form.Count == 0) { MessageBox.Show("Ошибка: ключ должен иметь хотя бы одну строку"); return; } for (int i = 0; i < Questions_form.Count; i++) { if (Convert.ToInt32(Questions_form[i].Text.Trim()) <= 0 || Convert.ToInt32(Answers_form[i].Text.Trim()) <= 0 || Convert.ToSingle(Points_form[i].Text.Trim()) <= 0) { MessageBox.Show("Ошибка: значения в строках заданы неверно"); return; } } for (int i = 0; i < Questions_form.Count; i++) { TEST._Keys[Key_number][i] = new Element(Convert.ToInt32(Questions_form[i].Text.Trim()), Convert.ToInt32(Answers_form[i].Text.Trim()), Convert.ToSingle(Points_form[i].Text.Trim())); } //check for the last question if (Key_number >= TEST._Keys.Count - 1) { MessageBox.Show("Добавлен последний ключ"); return; } //update and add text box on the panel Key_number++; Clear_panel(); Create_Key(TEST); } catch { MessageBox.Show("Ошибка: значения в строках заданы неверно GE"); return; } } void button_next_click(object sender, EventArgs e) { if (TEST._Keys.Count > 0 && TEST._Keys[TEST._Keys.Count - 1].Count > 0 && TEST._Keys[TEST._Keys.Count - 1][TEST._Keys[TEST._Keys.Count - 1].Count - 1].Point != 0) { this.Close(); Form_Scales FS = new Form_Scales(TEST); } else { MessageBox.Show("Ошибка: не все ключи заданы"); } } void button_back_click(object sender, EventArgs e) { this.Close(); Form_Questions FQ = new Form_Questions(TEST); } }