Exemplo n.º 1
0
 /// <summary>
 /// Ensures that all real nodes are up-to-date with the virtual ones.
 /// </summary>
 private void Devirtualise(VirtualTreeNodeCollection nodes)
 {
     if (NodeCollectionRequiresUpdate(nodes.Owner))
     {
         nodes.Owner.RealNodes.Clear();
         nodes.Owner.RealNodes.AddRange(new List <VirtualTreeNode>(nodes).ToArray());
     }
 }
Exemplo n.º 2
0
        private void UpdateNodes(VirtualTreeNodeCollection oldNodes, IList <VirtualTreeNode> newNodes, ref bool doneBeginUpdate)
        {
            for (int i = 0; i < Math.Max(oldNodes.Count, newNodes.Count);)
            {
                if (oldNodes.Count > i && newNodes.Count > i)
                {
                    if (oldNodes[i].Nodes.Count > 0 && newNodes[i].Nodes.Count == 0 && oldNodes[i].IsExpanded)
                    {
                        // fix for issues CA-34486 and CA-36409
                        // see VirtualTreeViewTests.TestUpdateWhenRemoveAllChildNodesOfExandedParent

                        // When merging sets of tree-nodes using UpdateRootNodes, if you remove all of
                        // the child-nodes from a node, the node still remembers its IsExpanded state
                        // from before the nodes were removed regardless of whether you call Collapse()
                        // or Expand() after the nodes were removed.

                        // This causes problems for the Virtual treeview as it
                        // relies the BeforeExpanded event to convert DummyTreeNodes into VirtualTreeNodes
                        // on population.

                        oldNodes[i].Collapse();
                    }

                    UpdateNode(newNodes[i], oldNodes[i], ref doneBeginUpdate);
                    UpdateNodes(oldNodes[i].Nodes, newNodes[i].Nodes, ref doneBeginUpdate);
                    i++;
                }
                else if (oldNodes.Count <= i && newNodes.Count > i)
                {
                    LogTreeView("Adding node " + newNodes[i].Text);
                    DoBeginUpdateIfRequired(ref doneBeginUpdate);
                    oldNodes.Add(newNodes[i]);
                    UpdateNodes(oldNodes[i].Nodes, newNodes[i].Nodes, ref doneBeginUpdate);
                    i++;
                }
                else
                {
                    LogTreeView("Removing node " + oldNodes[i].Text);
                    DoBeginUpdateIfRequired(ref doneBeginUpdate);
                    oldNodes.RemoveAt(i);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualTreeView"/> class.
 /// </summary>
 public VirtualTreeView()
 {
     _nodes         = new VirtualTreeNodeCollection(this);
     _selectedNodes = new VirtualTreeSelectedNodeCollection(this);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualTreeView"/> class.
 /// </summary>
 public VirtualTreeView()
 {
     _nodes = new VirtualTreeNodeCollection(this);
     _selectedNodes = new VirtualTreeSelectedNodeCollection(this);
 }
Exemplo n.º 5
0
        private void UpdateNodes(VirtualTreeNodeCollection oldNodes, IList<VirtualTreeNode> newNodes, ref bool doneBeginUpdate)
        {
            for (int i = 0; i < Math.Max(oldNodes.Count, newNodes.Count); )
            {
                if (oldNodes.Count > i && newNodes.Count > i)
                {
                    if (oldNodes[i].Nodes.Count > 0 && newNodes[i].Nodes.Count == 0 && oldNodes[i].IsExpanded)
                    {
                        // fix for issues CA-34486 and CA-36409
                        // see VirtualTreeViewTests.TestUpdateWhenRemoveAllChildNodesOfExandedParent

                        // When merging sets of tree-nodes using UpdateRootNodes, if you remove all of
                        // the child-nodes from a node, the node still remembers its IsExpanded state
                        // from before the nodes were removed regardless of whether you call Collapse()
                        // or Expand() after the nodes were removed.

                        // This causes problems for the Virtual treeview as it
                        // relies the BeforeExpanded event to convert DummyTreeNodes into VirtualTreeNodes
                        // on population.

                        oldNodes[i].Collapse();
                    }

                    UpdateNode(newNodes[i], oldNodes[i], ref doneBeginUpdate);
                    UpdateNodes(oldNodes[i].Nodes, newNodes[i].Nodes, ref doneBeginUpdate);
                    i++;
                }
                else if (oldNodes.Count <= i && newNodes.Count > i)
                {
                    LogTreeView("Adding node " + newNodes[i].Text);
                    DoBeginUpdateIfRequired(ref doneBeginUpdate);
                    oldNodes.Add(newNodes[i]);
                    UpdateNodes(oldNodes[i].Nodes, newNodes[i].Nodes, ref doneBeginUpdate);
                    i++;
                }
                else
                {
                    LogTreeView("Removing node " + oldNodes[i].Text);
                    DoBeginUpdateIfRequired(ref doneBeginUpdate);
                    oldNodes.RemoveAt(i);
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Ensures that all real nodes are up-to-date with the virtual ones.
 /// </summary>
 private void Devirtualise(VirtualTreeNodeCollection nodes)
 {
     if (NodeCollectionRequiresUpdate(nodes.Owner))
     {
         nodes.Owner.RealNodes.Clear();
         nodes.Owner.RealNodes.AddRange(new List<VirtualTreeNode>(nodes).ToArray());
     }
 }