public void AddCategory() { Expand(); ConfigCategory cat = new ConfigCategory(); int n = 1; string nameBase = "Category"; cat.CategoryName = nameBase + n.ToString(); bool b = true; while (b) { b = false; for (int i = 0; i < Nodes.Count; i++) { TreeNodeCategory cn = Nodes[i] as TreeNodeCategory; if (cn != null) { ConfigCategory c = cn.Category; if (string.Compare(cat.CategoryName, c.CategoryName, StringComparison.OrdinalIgnoreCase) == 0) { n++; cat.CategoryName = nameBase + n.ToString(); b = true; } } } } TreeNodeCategory tc = new TreeNodeCategory(cat, false); Nodes.Add(tc); this.Expand(); this.TreeView.SelectedNode = tc; }
private void nameChanging(object sender, EventArgs e) { TreeNode changedNode = null; EventArgvNameChange en = (EventArgvNameChange)e; TreeNodeCategory tc = (TreeNodeCategory)Parent; for (int i = 0; i < tc.Nodes.Count; i++) { TreeNodeConfigProperty tp = tc.Nodes[i] as TreeNodeConfigProperty; if (tp != null) { if (string.CompareOrdinal(en.OldName, tp.Property.DataName) != 0) { if (string.CompareOrdinal(en.NewName, tp.Property.DataName) == 0) { MessageBox.Show(this.TreeView.FindForm(), "The name is in use", "Application Configuration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); en.Cancel = true; break; } } else { changedNode = tc.Nodes[i]; } } } if (!en.Cancel) { if (changedNode != null) { changedNode.Text = en.NewName; } } }
private void toolStripButtonDelCat_Click(object sender, EventArgs e) { TreeNodeCategory tc = treeView1.SelectedNode as TreeNodeCategory; if (tc != null) { tc.Delete(); } }
public override void LoadNextLevel(TreeNodeCat parent) { TreeNodeCategory tc = (TreeNodeCategory)parent; foreach (ConfigProperty p in tc._cat.Properties.Properties) { TreeNodeConfigProperty tp = new TreeNodeConfigProperty(p, parent.IsDataOnly); parent.Nodes.Add(tp); } }
public override void LoadNextLevel(TreeNodeCat parent) { TreeNodeAppConfig ta = (TreeNodeAppConfig)parent; foreach (ConfigCategory cat in ta._list.Categories) { TreeNodeCategory tc = new TreeNodeCategory(cat, parent.IsDataOnly); parent.Nodes.Add(tc); } }
private void toolStripButtonAddProperty_Click(object sender, EventArgs e) { TreeNodeCategory tc = treeView1.SelectedNode as TreeNodeCategory; if (tc == null) { if (treeView1.SelectedNode != null) { tc = treeView1.SelectedNode.Parent as TreeNodeCategory; } } if (tc != null) { tc.AddProperty(); } }
private void nameChanging(object sender, EventArgs e) { TreeNodeCategory changedNode = null; EventArgvNameChange en = (EventArgvNameChange)e; if (ApplicationConfiguration.IsReservedWord(en.NewName)) { MessageBox.Show(this.TreeView.FindForm(), "The name is reserved", "Application Configuration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); en.Cancel = true; } else { for (int i = 0; i < Parent.Nodes.Count; i++) { TreeNodeCategory tp = Parent.Nodes[i] as TreeNodeCategory; if (tp != null) { if (string.CompareOrdinal(en.OldName, tp.Category.CategoryName) != 0) { if (string.CompareOrdinal(en.NewName, tp.Category.CategoryName) == 0) { MessageBox.Show(this.TreeView.FindForm(), "The name is in use", "Application Configuration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); en.Cancel = true; break; } } else { changedNode = tp; } } } } if (!en.Cancel) { if (changedNode != null) { changedNode.Text = en.NewName; } } }
private void toolStripButtonOK_Click(object sender, EventArgs e) { Ret = new CategoryList(); TreeNodeAppConfig ta = null; for (int i = 0; i < treeView1.Nodes.Count; i++) { ta = treeView1.Nodes[i] as TreeNodeAppConfig; if (ta != null) { break; } } if (ta != null) { for (int i = 0; i < ta.Nodes.Count; i++) { TreeNodeCategory tc = ta.Nodes[i] as TreeNodeCategory; if (tc != null) { ConfigCategory cat = tc.Category; cat.Properties.Properties.Clear(); Ret.Categories.Add(cat); for (int j = 0; j < tc.Nodes.Count; j++) { TreeNodeConfigProperty tp = tc.Nodes[j] as TreeNodeConfigProperty; if (tp != null) { cat.Properties.Properties.Add(tp.Property); } } } } } this.DialogResult = DialogResult.OK; }