/// <summary> /// Creates a node from the specified item. /// </summary> /// <param name="item">The item.</param> /// <returns>The node.</returns> private BindableTreeNode CreateNodeFromItem(object item) { BindableTreeNode node = new BindableTreeNode(); node.DataBinding += Node_DataBinding; node.DataBound += Node_DataBound; node.DataSource = item; return(node); }
/// <summary> /// Gets the expande state of each child node in the specified node. /// </summary> /// <param name="node">The node.</param> /// <param name="expandedState">The expanded state of each node.</param> private void GetExpandedState(BindableTreeNode node, Dictionary <Guid, bool> expandedState) { foreach (BindableTreeNode childNode in node.Nodes) { if (!expandedState.ContainsKey(childNode.ID) && childNode.Nodes.Count > 0) { expandedState.Add(childNode.ID, node.IsExpanded); } } }
/// <summary> /// Finds a node with the specified ID within the specified node. /// </summary> /// <param name="node">The node to search.</param> /// <param name="id">The ID to find.</param> private BindableTreeNode Find(BindableTreeNode node, Guid id) { BindableTreeNode foundNode = node.ID == id ? node : default(BindableTreeNode); for (int nodeIndex = 0; nodeIndex < node?.Nodes.Count && foundNode == default(BindableTreeNode); nodeIndex++) { foundNode = Find((BindableTreeNode)node.Nodes[nodeIndex], id); } return(foundNode); }
/// <summary> /// Finds a node with the specified ID. /// </summary> /// <param name="id">The ID to find.</param> public BindableTreeNode Find(Guid id) { BindableTreeNode node = default(BindableTreeNode); for (int nodeIndex = 0; nodeIndex < Nodes.Count && node == default(BindableTreeNode); nodeIndex++) { node = Find((BindableTreeNode)Nodes[nodeIndex], id); } return(node); }
/// <summary> /// Sets the expanded state of each child node in the specified node. /// </summary> /// <param name="node">The node.</param> /// <param name="expandedState">The expanded state of each node.</param> private void SetExpandedState(BindableTreeNode node, Dictionary <Guid, bool> expandedState) { if (expandedState.ContainsKey(node.ID)) { if (expandedState[node.ID] && !node.IsExpanded) { node.Expand(); } else if (expandedState[node.ID] && node.IsExpanded) { node.Collapse(); } } foreach (BindableTreeNode childNode in node.Nodes) { SetExpandedState(childNode, expandedState); } }
/// <summary> /// Creates nodes for each item in the DataMember list. /// </summary> private void CreateNodes() { Dictionary <Guid, bool> initialState = GetExpandedState(); BeginUpdate(); Nodes.Clear(); foreach (object item in currencyManager.List) { BindableTreeNode node = new BindableTreeNode(); node.DataBinding += Node_DataBinding; node.DataBound += Node_DataBound; node.DataSource = item; Nodes.Add(node); } SetExpandedState(initialState); EndUpdate(); }
public NodeEventArgs(BindableTreeNode node) { Node = node; }