internal static List<ComboItem> getVariedCBList(string[] inStrings, int[] stringNum, int[] stringVal) { // Set up List<ComboItem> newlist = new List<ComboItem>(); for (int i = 4; i > 1; i--) // add 4,3,2 { // First 3 Balls are always first ComboItem ncbi = new ComboItem { Text = inStrings[i], Value = i }; newlist.Add(ncbi); } // Sort the Rest based on String Name string[] ballnames = new string[stringNum.Length]; for (int i = 0; i < stringNum.Length; i++) ballnames[i] = inStrings[stringNum[i]]; string[] sortedballs = new string[stringNum.Length]; Array.Copy(ballnames, sortedballs, ballnames.Length); Array.Sort(sortedballs); // Add the rest of the balls newlist.AddRange(sortedballs.Select(s => new ComboItem { Text = s, Value = stringVal[Array.IndexOf(ballnames, s)] })); return newlist; }
private void populateComboBoxes() { // Set the Text CB_HeldItem.DisplayMember = CB_Species.DisplayMember = CB_Ability.DisplayMember = CB_Nature.DisplayMember = CB_GameOrigin.DisplayMember = CB_HPType.DisplayMember = "Text"; // Set the Value CB_HeldItem.ValueMember = CB_Species.ValueMember = CB_Ability.ValueMember = CB_Nature.ValueMember = CB_GameOrigin.ValueMember = CB_HPType.ValueMember = "Value"; var Any = new ComboItem {Text = "Any", Value = -1}; var DS_Species = new List<ComboItem>(GameInfo.SpeciesDataSource); DS_Species.RemoveAt(0); DS_Species.Insert(0, Any); CB_Species.DataSource = DS_Species; var DS_Item = new List<ComboItem>(GameInfo.ItemDataSource); DS_Item.Insert(0, Any); CB_HeldItem.DataSource = DS_Item; var DS_Nature = new List<ComboItem>(GameInfo.NatureDataSource); DS_Nature.Insert(0, Any); CB_Nature.DataSource = DS_Nature; var DS_Ability = new List<ComboItem>(GameInfo.AbilityDataSource); DS_Ability.Insert(0, Any); CB_Ability.DataSource = DS_Ability; var DS_Version = new List<ComboItem>(GameInfo.VersionDataSource); DS_Version.Insert(0, Any); CB_GameOrigin.DataSource = DS_Version; string[] hptypes = new string[Main.GameStrings.types.Length - 2]; Array.Copy(Main.GameStrings.types, 1, hptypes, 0, hptypes.Length); var DS_Type = Util.getCBList(hptypes, null); DS_Type.Insert(0, Any); CB_HPType.DataSource = DS_Type; // Set the Move ComboBoxes too.. var DS_Move = new List<ComboItem>(GameInfo.MoveDataSource); DS_Move.RemoveAt(0); DS_Move.Insert(0, Any); { foreach (ComboBox cb in new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 }) { cb.DisplayMember = "Text"; cb.ValueMember = "Value"; cb.DataSource = new BindingSource(DS_Move, null); } } // Trigger a Reset resetFilters(null, null); }
internal static List<ComboItem> getUnsortedCBList(string textfile) { // Set up List<ComboItem> cbList = new List<ComboItem>(); string[] inputCSV = getStringList(textfile); // Gather our data from the input file for (int i = 1; i < inputCSV.Length; i++) { string[] inputData = inputCSV[i].Split(','); ComboItem ncbi = new ComboItem { Text = inputData[1], Value = Convert.ToInt32(inputData[0]) }; cbList.Add(ncbi); } return cbList; }
private void populateComboBoxes() { // Set the Text CB_HeldItem.DisplayMember = CB_Species.DisplayMember = "Text"; // Set the Value CB_HeldItem.ValueMember = CB_Species.ValueMember = "Value"; var Any = new ComboItem {Text = "Any", Value = -1}; var DS_Species = new List<ComboItem>(GameInfo.SpeciesDataSource); DS_Species.RemoveAt(0); var filteredSpecies = DS_Species.Where(spec => RawDB.Any(mg => mg.Species == spec.Value)).ToList(); filteredSpecies.Insert(0, Any); CB_Species.DataSource = filteredSpecies; var DS_Item = new List<ComboItem>(GameInfo.ItemDataSource); DS_Item.Insert(0, Any); CB_HeldItem.DataSource = DS_Item; // Set the Move ComboBoxes too.. var DS_Move = new List<ComboItem>(GameInfo.MoveDataSource); DS_Move.RemoveAt(0); DS_Move.Insert(0, Any); { foreach (ComboBox cb in new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 }) { cb.DisplayMember = "Text"; cb.ValueMember = "Value"; cb.DataSource = new BindingSource(DS_Move, null); } } // Trigger a Reset resetFilters(null, null); }