public AddTestForm(User user, IEnumerable <HandbookTest> handbookTests, IEnumerable <HandbookSubjects> handbookSubjects, TestForm testForm) { if (!String.IsNullOrEmpty(Properties.Settings.Default.Language)) { // ВАЖНО: Устанавливать язык нужно до создания элементов формы! // Это можно сделать глобально, в рамках приложения в классе Program (см. файл Program.cs). System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language); System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language); } InitializeComponent(); cbSubjectAndGrade.DropDownStyle = ComboBoxStyle.DropDownList; this.user = user; this.testForm = testForm; foreach (var subject in handbookSubjects) { cbSubjectAndGrade.Items.Add(subject.Name + " " + subject.GradeNumber + subject.GradeName); } cbSubjectAndGrade.SelectionChangeCommitted += delegate { var index = cbSubjectAndGrade.SelectedIndex; var list = handbookSubjects.ToList(); subject = list[index]; }; }
public AddTestForm(User user, IEnumerable <HandbookTest> handbookTests, IEnumerable <HandbookSubjects> handbookSubjects, TestForm testForm, HandbookTest handbookTest) { InitializeComponent(); cbSubjectAndGrade.DropDownStyle = ComboBoxStyle.DropDownList; this.user = user; this.testForm = testForm; this.txtId.Text = handbookTest.Id.ToString(); this.txtSubjectId.Text = handbookTest.SubjectId.ToString(); this.txtName.Text = handbookTest.Name.ToString(); this.cbSubjectAndGrade.Text = handbookTest.SubjectName.ToString() + " " + handbookTest.GradeName.ToString(); this.txtQuantity.Text = handbookTest.Quantity.ToString(); this.txtQuantityPass.Text = handbookTest.QuantityPass.ToString(); subject = handbookSubjects.ToList().Where(s => s.Id == handbookTest.SubjectId).FirstOrDefault(); var indexOfIntegerValue = handbookSubjects.ToList().IndexOf(subject); foreach (var subject in handbookSubjects) { cbSubjectAndGrade.Items.Add(subject.Name + " " + subject.GradeNumber + subject.GradeName); } cbSubjectAndGrade.SelectionChangeCommitted += delegate { var index = cbSubjectAndGrade.SelectedIndex; var list = handbookSubjects.ToList(); subject = list[index]; }; cbSubjectAndGrade.SelectedItem = cbSubjectAndGrade.Items[indexOfIntegerValue]; }
private async void testsToolStripMenuItem_Click(object sender, EventArgs e) { ApplicationViewModel applicationViewModel = new ApplicationViewModel(); await applicationViewModel.GetTests(user.Login, user.Password); await applicationViewModel.GetSubjects(user.Login, user.Password); TestForm testForm = new TestForm(user, applicationViewModel.handbookTests, applicationViewModel.handbookSubjects); testForm.Show(); }