示例#1
0
        void BindEditorItemToNode(HierarchyNode it)
        {
            var existingNode = FindTreeNode(it.Id);

            if (existingNode == null)
            {
                var parentNode = FindTreeNode(it.Parent.Id);
                var addTo      = (parentNode == null) ? treeControl.Nodes : parentNode.Nodes;
                var newNode    = addTo.Add(it.Id.ToString(), it.NodeDataAdapter.GetDisplayName());
                it.Changed += it_Changed;
                newNode.Tag = it;


                if (it.Commands.Count > 0)
                {
                    newNode.ContextMenu = new ContextMenu();
                    foreach (var cmd in it.Commands)
                    {
                        AddCommandToMenu(cmd, newNode.ContextMenu);
                    }
                }
                it.Commands.ItemAdded   += Commands_ItemAdded;
                it.Commands.ItemRemoved += Commands_ItemRemoved;

                foreach (var child in it.Nodes())
                {
                    BindEditorItemToNode(child);
                }
            }
        }