private void Proceed(object sender, EventArgs e) { settings = new Settings(); settings.CandidateName = txt_candidate_name.Text; if (chk_enable_timer.Checked) { settings.TimeLimit = (int)num_time_limit.Value; } else { settings.TimeLimit = exam.Properties.TimeLimit; } // if (rdb_selected_sections.Checked) { settings.Sections = clb_section_options.CheckedItems.Cast <Section>().ToList(); foreach (var section in settings.Sections) { settings.Questions.AddRange(section.Questions.ToArray()); } } // if (rdb_fixed_number_questions.Checked) { int numOfQuestions = (int)num_questions.Value; int sum = 0; foreach (Section section in exam.Sections) { if (sum + section.Questions.Count < numOfQuestions) { settings.Sections.Add(section); settings.Questions.AddRange(section.Questions.ToArray()); sum += section.Questions.Count; } else if (sum + section.Questions.Count == numOfQuestions) { settings.Sections.Add(section); settings.Questions.AddRange(section.Questions.ToArray()); break; } else { int difference = numOfQuestions - sum; settings.Sections.Add(section); settings.Questions.AddRange(section.Questions.GetRange(0, difference).ToArray()); break; } } } // Exam_UI ui = new Exam_UI(exam, settings); this.Hide(); ui.ShowDialog(); this.Close(); }
private void btn_ok_Click(object sender, EventArgs e) { Properties.Settings.Default.SelectedSections = new System.Collections.Specialized.StringCollection(); if (rdb_selected_sections.Checked) { for (int i =0; i < clb_section_options.CheckedItems.Count; i++) { Properties.Settings.Default.SelectedSections.Add(clb_section_options.CheckedItems[i].ToString()); } } else { for (int i = 0; i < clb_section_options.Items.Count; i++) { Properties.Settings.Default.SelectedSections.Add(clb_section_options.Items[i].ToString()); } } Properties.Settings.Default.Name = txt_candidate_name.Text; Properties.Settings.Default.ExamType = examType.ToString(); Properties.Settings.Default.NumOfQuestions = Convert.ToInt32(num_exam_number.Value); Properties.Settings.Default.TimerChosen = chk_enable_timer.Checked; if (chk_enable_timer.Checked) { Properties.Settings.Default.TimerValue = Convert.ToInt32(num_time_limit.Value); } else { Properties.Settings.Default.TimerValue = defaultExamDuration; } Properties.Settings.Default.Save(); Form exam = new Exam_UI(filename); this.Hide(); exam.ShowDialog(); this.Close(); }
private void btn_ok_Click(object sender, EventArgs e) { if (rdb_selected_sections.Checked) { for (int i =0; i < clb_section_options.CheckedItems.Count; i++) { this.selectedSections += ("," + clb_section_options.CheckedItems[i].ToString()); } } else { for (int i = 0; i < clb_section_options.Items.Count; i++) { this.selectedSections += ("," + clb_section_options.Items[i].ToString()); } } if (rdb_fixed_number_questions.Checked) { this.examType = 2; } else { this.examType = 1; } Properties.Settings.Default.CandidatesName = txt_candidaate_name.Text; Properties.Settings.Default.ExamType = this.examType; Properties.Settings.Default.NumberOfQuestions = Convert.ToInt32(num_exam_number.Value); Properties.Settings.Default.SelectedSections = selectedSections; Properties.Settings.Default.TimerEnabled = chk_enable_timer.Checked; if (chk_enable_timer.Checked) { Properties.Settings.Default.TimerValue = Convert.ToInt32(num_time_limit.Value); } else { Properties.Settings.Default.TimerValue = defaultExamDuration; } Properties.Settings.Default.Save(); Form exam = new Exam_UI(filename); this.Hide(); exam.ShowDialog(); this.Close(); }