示例#1
0
        internal void AttachNode(Node node, ControlNode parentNode)
        {
            node.NodeSelectionChanged += NodeSelectionChanged;
            node.NodeDirtyChanged     += NodeDirtyChanged;

            if (parentNode != null)
            {
                parentNode.AddChild(node);
            }
            else if (_rootNode == null)
            {
                _rootNode = node;
                Dirty     = true;
            }
            else
            {
                throw new InvalidOperationException("Can't attach orphaned node.");
            }
        }
示例#2
0
        internal void DetachNode(Node node, ControlNode parentNode)
        {
            node.Selected = false;

            node.NodeSelectionChanged -= NodeSelectionChanged;
            node.NodeDirtyChanged     -= NodeDirtyChanged;

            if (parentNode != null)
            {
                parentNode.RemoveChild(node);
            }
            else if (_rootNode == node)
            {
                _rootNode = null;
                Dirty     = true;
            }
            else
            {
                throw new InvalidOperationException("Can't detach orphaned node.");
            }
        }