public CSAUSBTool(IReadOnlyList <string> args) { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; InitializeComponent(); if (args.Count >= 1) { Console.Out.WriteLine(args[0]); seasons["FRC9999"] = new FIRSTSeason(9999, FIRSTProgram.FRC); } ValidSeasons().ForEach(year => { if (!Enum.TryParse(year.Substring(0, 3), true, out FIRSTProgram program)) { return; } seasons[year] = new FIRSTSeason(int.Parse(year.Substring(3)), program); }); // Bind year objects to the selector. yearSelection.DataSource = new BindingSource(seasons, null); yearSelection.DisplayMember = "Key"; yearSelection.ValueMember = "Value"; SelectedSeason = seasons[ValidSeasons().ElementAt(0)]; // Clear the selected software to ensure blank slate. SelectedSoftware.Clear(); ResetSelectedSoftware(); // Bind software for the year to the listbox. SelectedItems.DataSource = new BindingSource(SelectedSoftware, null); SelectedItems.DisplayMember = "Key"; SelectedItems.ValueMember = "Value"; downloadFolder.Text = $@"{Directory.GetCurrentDirectory()}\\{SelectedYear}\\"; }
private void yearSelection_SelectedIndexChanged(object sender, EventArgs e) { if (yearSelection.SelectedItem.ToString().Equals("")) { return; } // Reset the selections var selected = (KeyValuePair <string, FIRSTSeason>)yearSelection.SelectedItem; SelectedYear = selected.Key; SelectedSeason = seasons[SelectedYear]; downloadFolder.Text = $@"{Directory.GetCurrentDirectory()}\\{SelectedYear}\\"; SelectedSoftware.Clear(); ResetSelectedSoftware(); // Bind software again to ensure it gets updated. SelectedItems.DataSource = new BindingSource(SelectedSoftware, null); SelectedItems.DisplayMember = "Key"; SelectedItems.ValueMember = "Value"; }