public Main(Login loginForm, ClientController ctrl) { this.loginForm = loginForm; this.ctrl = ctrl; InitializeComponent(); ChallengesDataGridView.DataSource = ctrl.GetAllChallenges(); ChildrenDataGridView.DataSource = ctrl.GetAllChildren(); SecondChallengeBox.Visible = false; DeleteSecondChallengeLabel.Visible = false; ctrl.updateEvent += userUpdate; }
private void FirstChallengeComboBox_DropDown(object sender, EventArgs e) { string ageText = AgeTextBox.Text; FirstChallengeComboBox.Items.Clear(); SecondChallengeComboBox.Items.Clear(); try { int age = Int32.Parse(ageText); IDictionary <string, ChallengeDTO> challengesDictionary = new Dictionary <string, ChallengeDTO>(); List <ChallengeDTO> challenges = ctrl.GetAllChallenges().ToList(); List <ChallengeDTO> filtered = new List <ChallengeDTO>(); foreach (ChallengeDTO challenge in challenges) { if (challenge.MinimumAge <= age && challenge.MaximumAge >= age) { filtered.Add(challenge); } } foreach (ChallengeDTO challenge in filtered) { challengesDictionary[challenge.Name] = challenge; } foreach (KeyValuePair <string, ChallengeDTO> entry in challengesDictionary) { FirstChallengeComboBox.Items.Add(entry.Key); } RegisterButton.Enabled = true; } catch (IOException exception) { Console.WriteLine(exception.StackTrace); RegisterButton.Enabled = false; } }