コード例 #1
0
        /// <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);
        }
コード例 #2
0
 /// <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);
         }
     }
 }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        /// <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);
            }
        }
コード例 #6
0
        /// <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();
        }
コード例 #7
0
 public NodeEventArgs(BindableTreeNode node)
 {
     Node = node;
 }