private void UpdateItemInfo() { var items = itemDTOs.Select ( item => new { Key = item.m_ID + ": " + _translations.Where(t => t.Key == "ITEM_" + item.m_ID + "_NAME").FirstOrDefault()?.Element.m_Translations[activeLanguage], Value = item } ).ToList(); ItemListBox.SelectedIndexChanged -= ItemListBox_SelectedIndexChanged; ItemListBox.DataSource = items; ItemListBox.DisplayMember = "Key"; ItemListBox.ValueMember = "Value"; ItemListBox.ClearSelected(); ItemListBox.SelectedIndexChanged += ItemListBox_SelectedIndexChanged; UpdateAbilityInfo(); UpdateModifierInfo(); }
public ItemBrowser() { SRMapper.LanguageMapper(); InitializeComponent(); ItemListBox.ClearSelected(); _translations = FileManager.LoadTranslationsXML("Translations.xml", FileManager.ExecPath).ToList(); itemDTOs = FileManager.LoadItemDataXML("ItemData.xml", FileManager.ExecPath).OrderBy(i => i.m_ID).ToList(); UpdateItemInfo(); ItemSlotTypeDropDown.DataSource = Enum.GetValues(typeof(ItemSlotTypes)).Cast <ItemSlotTypes>().ToList().Take(8).ToList(); GearSubTypeDropDown.DataSource = Enum.GetValues(typeof(ItemSubCategories)); //.Cast<ItemSubCategories>().ToList().Take(8).ToList(); WeaponTypeDropDown.DataSource = Enum.GetValues(typeof(WeaponType)).Cast <WeaponType>().ToList().Take(29).ToList(); abilities = _translations.Where(t => t.Key.StartsWith("ABILITY_") && t.Key.EndsWith("_NAME")).Select(a => { int id = int.Parse(a.Key.Replace("ABILITY_", "").Replace("_NAME", "")); LocElement desc = null; if (_translations.Where(t => t.Key == "ABILITY_" + id + "_DESC").Any()) { desc = _translations.Where(t => t.Key == "ABILITY_" + id + "_DESC").First().Element; } return(new Models.Ability() { Id = id, LocName = a.Element, LocDesc = desc }); }).ToList(); AbilityDropdown.DataSource = abilities; AbilityDropdown.DisplayMember = "Name"; AbilityDropdown.ValueMember = "Desc"; ModifierDropdown.DataSource = Enum.GetValues(typeof(ModifierType)).Cast <ModifierType>().ToList().Skip(1).ToList(); //MultiplierTypeDropDown.DataSource = Enum.GetValues(typeof(ModifierType)).Cast<ModifierType>().ToList(); }