private void m_BindingList_ListChanged(object sender, ListChangedEventArgs e) { if (m_Sorted) { if (e.ListChangedType == ListChangedType.ItemAdded) { SortListItem item = new SortListItem(m_SortBy.GetValue(m_List[e.NewIndex]), m_List[e.NewIndex]); if (m_SortDirection == ListSortDirection.Ascending) { m_SortedList.Add(item); } else { m_SortedList.Insert(0, item); } } else { this.DoSort(); } } else { ListChanged(this, e); } }
public static List <Skill> GetSkillList(Character c, FilterOptions filter, string strName = "") { //TODO less retarded way please List <Skill> b = new List <Skill>(); // Load the Skills information. XmlDocument objXmlDocument = XmlManager.Load("skills.xml"); // Populate the Skills list. XmlNodeList objXmlSkillList = objXmlDocument.SelectNodes("/chummer/skills/skill[not(exotic) and (" + c.Options.BookXPath() + ")" + SkillFilter(filter, strName) + "]"); // First pass, build up a list of all of the Skills so we can sort them in alphabetical order for the current language. Dictionary <string, Skill> dicSkills = new Dictionary <string, Skill>(objXmlSkillList.Count); List <ListItem> lstSkillOrder = new List <ListItem>(); foreach (XmlNode objXmlSkill in objXmlSkillList) { ListItem objSkillItem = new ListItem(); objSkillItem.Value = objXmlSkill["name"]?.InnerText; objSkillItem.Name = objXmlSkill["translate"]?.InnerText ?? objSkillItem.Value; lstSkillOrder.Add(objSkillItem); //TODO: read from backup Skill objSkill = Skill.FromData(objXmlSkill, c); dicSkills.Add(objSkillItem.Value, objSkill); } SortListItem objSort = new SortListItem(); lstSkillOrder.Sort(objSort.Compare); // Second pass, retrieve the Skills in the order they're presented in the list. foreach (ListItem objItem in lstSkillOrder) { b.Add(dicSkills[objItem.Value]); } return(b); }
private void LoadSuggestedSpecializations(string name) { if (s_NameCategoryMap.TryGetValue(name, out string strNameValue)) { SuggestedSpecializations.Clear(); XmlNodeList list = XmlManager.Load("skills.xml").SelectNodes($"chummer/knowledgeskills/skill[name = \"{name}\"]/specs/spec"); foreach (XmlNode node in list) { string strInnerText = node.InnerText; SuggestedSpecializations.Add(new ListItem(strInnerText, node.Attributes?["translate"]?.InnerText ?? strInnerText)); } SortListItem objSort = new SortListItem(); SuggestedSpecializations.Sort(objSort.Compare); OnPropertyChanged(nameof(CGLSpecializations)); } }
private static IEnumerable <Skill> GetSkillList(Character c, FilterOptions filter) { //TODO less retarded way please List <Skill> b = new List <Skill>(); // Load the Skills information. XmlDocument objXmlDocument = XmlManager.Instance.Load("skills.xml"); // Populate the Skills list. XmlNodeList objXmlSkillList = objXmlDocument.SelectNodes("/chummer/skills/skill[not(exotic) and (" + c.Options.BookXPath() + ")" + SkillFilter(filter) + "]"); // First pass, build up a list of all of the Skills so we can sort them in alphabetical order for the current language. List <ListItem> lstSkillOrder = new List <ListItem>(); foreach (XmlNode objXmlSkill in objXmlSkillList) { ListItem objSkill = new ListItem(); objSkill.Value = objXmlSkill["name"].InnerText; if (objXmlSkill["translate"] != null) { objSkill.Name = objXmlSkill["translate"].InnerText; } else { objSkill.Name = objXmlSkill["name"].InnerText; } lstSkillOrder.Add(objSkill); } SortListItem objSort = new SortListItem(); lstSkillOrder.Sort(objSort.Compare); // Second pass, retrieve the Skills in the order they're presented in the list. foreach (ListItem objItem in lstSkillOrder) { XmlNode objXmlSkill = objXmlDocument.SelectSingleNode("/chummer/skills/skill[name = \"" + objItem.Value + "\"]"); //TODO: read from backup Skill objSkill = Skill.FromData(objXmlSkill, c); b.Add(objSkill); } return(b); }