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."); } }
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."); } }