private void AddCategory(object sender, EventArgs e) { EditCategoryForm ecf = new EditCategoryForm(); if (ecf.ShowDialog() == DialogResult.OK) { // create category Guid guid = Guid.NewGuid(); Category category = new Category(ecf.CategoryName, true, ecf.CategoryColor); qcData.Categories[guid] = category; // update tree TreeNode node = copyTree.Nodes.Add(guid.ToString(), category.Name); node.BackColor = category.Color; node.ContextMenu = categoryMenu; } }
private void EditCategory(object sender, EventArgs e) { string categoryGuid = copyTree.SelectedNode.Name; Category category = qcData.Categories[Guid.Parse(categoryGuid)]; EditCategoryForm ecf = new EditCategoryForm(category.Name, category.Color); if (ecf.ShowDialog() == DialogResult.OK) { // update category category.Name = ecf.CategoryName; category.Color = ecf.CategoryColor; // update tree TreeNode node = copyTree.Nodes[categoryGuid]; node.Text = category.Name; node.BackColor = category.Color; } }
private void EditMenuItem_Click(object sender, EventArgs e) { if (copyTree.SelectedNode.Level == 1) { string categoryGuid = copyTree.SelectedNode.Parent.Name; string itemGuid = copyTree.SelectedNode.Name; Item item = qcData.Categories[Guid.Parse(categoryGuid)].Items[Guid.Parse(itemGuid)]; EditItemForm eif = new EditItemForm(item.Name, item.Content, item.Color); if (eif.ShowDialog() == DialogResult.OK) { // update item item.Name = eif.ItemName; item.Content = eif.ItemContent; item.Color = eif.ItemColor; // update tree TreeNode node = copyTree.Nodes[categoryGuid].Nodes[itemGuid]; node.Text = item.Name; node.BackColor = item.Color; } } else if (copyTree.SelectedNode.Level == 0) { string categoryGuid = copyTree.SelectedNode.Name; Category category = qcData.Categories[Guid.Parse(categoryGuid)]; EditCategoryForm ecf = new EditCategoryForm(category.Name, category.Color); if (ecf.ShowDialog() == DialogResult.OK) { // update category category.Name = ecf.CategoryName; category.Color = ecf.CategoryColor; // update tree TreeNode node = copyTree.Nodes[categoryGuid]; node.Text = category.Name; node.BackColor = category.Color; } } }