private void FireRemovingChild(TreeNodeEventArgs e) { if (RemovingChild != null) RemovingChild(this, e); }
private void FireChildRemoved(TreeNodeEventArgs e) { if (RemovedChild != null) RemovedChild(this, e); FireChildrenChanged(); }
private void FireChildAdded(TreeNodeEventArgs e) { if (AddedChild != null) AddedChild(this, e); FireChildrenChanged(); }
private void FireAddingChild(TreeNodeEventArgs e) { if (AddingChild != null) AddingChild(this, e); }
public void RemoveChild(ITreeNode node) { // Ignore if the node has already been added. if (!Contains(node)) return; // Fire pre-event. TreeNodeEventArgs args = new TreeNodeEventArgs(node, NullIndex); FireRemovingChild(args); // Remove the child. ChildList.Remove(node); // Unwire events. node.SelectionChanged -= OnChildSelectionChanged; // De-register this as the nodes parent. if (node.Parent == this) SetParent(node, null); // Fire post-event. FireChildRemoved(args); }
public void InsertChild(int index, ITreeNode node) { // Setup initial conditions. if (node == null) return; if (Contains(node)) return; // Ignore if the node has already been added. if (index < 0) index = ChildCount; // Fire pre-event. TreeNodeEventArgs args = new TreeNodeEventArgs(node, index); FireAddingChild(args); // Store the node. ChildList.Insert(index, node); // Wire up events. node.SelectionChanged += OnChildSelectionChanged; // Ensure the parent node is set to this. if (node.Parent != this) SetParent(node, this); // Fire post-event. FireChildAdded(args); }