public void NodeChanged(AbstractFieldNode node) { TreeNode treeNode = GetTreeNode(node); if(treeNode == null) return; treeNode.Text = node.ToString(); for (int i = 0; i < node.Count; i++) { NodeChanged(node.GetChild(i)); } }
public void AddNode(AbstractFieldNode node) { AbstractFieldNode parent = node.Parent; if (parent == null) { if (m_nodeLookup.Count != 0) throw new InvalidOperationException("Cannot add a root node, a root already exists."); LinkedList<MenuItem> menuItems = new LinkedList<MenuItem>(); node.GetMenuCommands(menuItems); TreeNode treeNode = new TreeNode(node.ToString()); treeNode.ContextMenu = new ContextMenu(menuItems.ToArray()); treeNode.Tag = node; m_treeView.Nodes.Add(treeNode); m_treeNodeLookup.Add(node, treeNode); m_nodeLookup.Add(treeNode, node); } else { LinkedList<MenuItem> menuItems = new LinkedList<MenuItem>(); node.GetMenuCommands(menuItems); TreeNode treeNode = new TreeNode(node.ToString()); treeNode.ContextMenu = new ContextMenu(menuItems.ToArray()); treeNode.Tag = node; TreeNode parentTreeNode = GetTreeNode(parent); parentTreeNode.Nodes.Add(treeNode); parentTreeNode.Expand(); m_treeNodeLookup.Add(node, treeNode); m_nodeLookup.Add(treeNode, node); } }