private void AddCategoriesToNode(TreeNode node, Category cat) { foreach (Category temp in cat.Categories) { TreeNode tnode = node.Nodes.Add(temp.Name); tnode.Tag = temp; tnode.Checked = temp.Selected; AddCategoriesToNode(tnode, temp); } }
public void Load(Category[] categories) { BeginUpdate(); Nodes.Clear(); foreach (Category cat in categories) { TreeNode node = Nodes.Add(cat.Name); node.Tag = cat; node.Checked = cat.Selected; AddCategoriesToNode(node, cat); } EndUpdate(); }
internal string GetCategorieName(Category cat, int p) { foreach (Category tcat in cat.Categories) { if (tcat.ID == p) return tcat.Name; string name = GetCategorieName(tcat, p); if (name != null) return name; } return null; }
private bool LoadFurtherCategories(XmlNode root, Category cat) { foreach (XmlNode node in root.SelectNodes("subcategories/category")) { Category temp = new Category(node.SelectSingleNode("name/text()").Value); temp.ID = int.Parse(node.SelectSingleNode("id/text()").Value); cat.AddCategory(temp); LoadFurtherCategories(node, temp); } return true; }
/// <summary> /// "Business Method" - searchs for the given keywords in the given categories /// </summary> /// <param name="keywords">String containing the query</param> /// <param name="categories">Array of categories. if null or length == 0 all /// categories will be searched</param> public void Search(string keywords, Category[] categories) { StringBuilder builder = new StringBuilder(); Category[] searchin = (categories.Length > 0 ? categories : Categories); foreach (Category cat in searchin) { builder.Append("&category="); builder.Append(cat.ID); } string categoryString = builder.ToString(); string url = GetBaseUrl("search"); url += "&keyword=" + keywords + categoryString; //Response document XmlDocument doc = SendRequest(url); if (doc == null) return; if (!CheckResult(doc)) return; SetCategoryCounter(doc); if (SearchComplete != null) SearchComplete(this, new SearchEventArgs(url, doc)); }
/// <summary> /// Loads all categories from server /// </summary> /// <returns></returns> public Category[] LoadCategories(int project) { string url = GetBaseUrl("getcategories"); url += "&projectid=" + project; XmlDocument doc = SendRequest(url); if (!CheckResult(doc)) return new Category[0]; List<Category> categories = new List<Category>(); XmlNode firstCat = doc.SelectSingleNode("//category"); if (firstCat == null) return new Category[0]; while (firstCat != null) { Category cat = new Category(firstCat.SelectSingleNode("name/text()").Value); cat.ID = int.Parse(firstCat.SelectSingleNode("id/text()").Value); categories.Add(cat); LoadFurtherCategories(firstCat, cat); firstCat = firstCat.NextSibling; } SetCategoryCounter(doc); return categories.ToArray(); }
public void AddCategory(Category category) { string newCatName = null; string newCatdescription = null; using (FrmAddCategory frmCategory = new FrmAddCategory()) { DialogResult res = frmCategory.ShowDialog(); if (res != DialogResult.OK) return; newCatName = frmCategory.CategoryName; newCatdescription = frmCategory.CategoryDescription; } DialogResult question = MessageBox.Show(string.Format("Möchten Sie die Kategorie: [{0}] als Unterkategorie von: [{1}] dem aktuellen Projekt hinzufügen!", newCatName, category.Name), "Frage", MessageBoxButtons.YesNo); if (question != DialogResult.Yes) return; string url = GetBaseUrl("addcategory"); url += "&name=" + newCatName + "&description=" + newCatdescription + "&subcategoryof=" + category.ID; XmlDocument doc = SendRequest(url); if (!CheckResult(doc)) return; MessageBox.Show("Kategorie erfolgreich angelegt!"); categories = LoadCategories(project.ID); }
public CategoryMenuItem(string name, Category category) : base(name) { _category = category; }
public void AddCategory(Category category) { categories.Add(category); }