static public Category xml2Category(XmlNode xml) { Category info = new Category(); info.name = xml.SelectSingleNode("Name").InnerText; info.id = int.Parse(xml.Attributes.GetNamedItem("ID").InnerText); info.ownerId = int.Parse(xml.SelectSingleNode("OwnerId").InnerText); return info; }
private void updateCategoriesListBox() { Program.allCategories = Program.fetcher.getCategories(); Category noneCat = new Category(); noneCat.name = "None"; noneCat.id = 0; noneCat.ownerId = 0; listViewCategories.Clear(); comboBoxCategory.Items.Clear(); comboBoxCategory.Items.Add(noneCat); comboBoxCategory.SelectedItem = noneCat; foreach( Category cat in Program.allCategories.Values ) { ListViewItem item = new ListViewItem(cat.name); item.Tag = cat.id.ToString(); if (!Program.isSuperAdmin && (cat.ownerId != Program.UserId)) { item.ForeColor = Color.LightGray; } listViewCategories.Items.Add(item); comboBoxCategory.Items.Add(cat); } }