private void OnNewDesign(DesignData design) { bool match = false; treeView1.BeginUpdate(); foreach (CategoryNode node in treeView1.Nodes) { if (node.Text.ToLower() == design.Category.ToLower()) { node.AddDesign(design); match = true; break; } } if (!match) { CategoryNode node = new CategoryNode(design.Category); node.AddDesign(design); treeView1.Nodes.Add(node); } treeView1.EndUpdate(); }
private void OnSaved() { string oldCategory = this.Parent.Parent.Text.ToLower(); string oldSubsection = this.Parent.Text.ToLower(); string newCategory = _design.Category.ToLower(); string newSubsection = _design.Subsection.ToLower(); if (oldCategory == newCategory) { if (oldSubsection == newSubsection) { this.Text = _design.Name; } else { CategoryNode category = (CategoryNode)this.Parent.Parent; (this.Parent as SubsectionNode).RemoveNode(this.Index); category.AddDesign(_design); } } else { int index = FindCategoryNode(_design.Category.ToLower()); CategoryNode category = null; if (index != -1) { category = (CategoryNode)this.TreeView.Nodes[index]; } else { category = new CategoryNode(_design.Category); this.TreeView.Nodes.Add(category); } category.AddDesign(_design); (this.Parent as SubsectionNode).RemoveNode(this.Index); } }