コード例 #1
0
        static SharpTreeNode ConcatTrees(SharpTreeNode first, SharpTreeNode second)
        {
            SharpTreeNode tmp = first;

            while (tmp.right != null)
            {
                tmp = tmp.right;
            }
            InsertNodeAfter(tmp, second);
            return(tmp.GetListRoot());
        }
コード例 #2
0
        public int IndexOf(object item)
        {
            SharpTreeNode node = item as SharpTreeNode;

            if (node != null && node.IsVisible && node.GetListRoot() == root)
            {
                if (includeRoot)
                {
                    return(SharpTreeNode.GetVisibleIndexForNode(node));
                }
                else
                {
                    return(SharpTreeNode.GetVisibleIndexForNode(node) - 1);
                }
            }
            else
            {
                return(-1);
            }
        }
コード例 #3
0
 static void InsertNodeAfter(SharpTreeNode pos, SharpTreeNode newNode)
 {
     // newNode might be the model root of a whole subtree, so go to the list root of that subtree:
     newNode = newNode.GetListRoot();
     if (pos.right == null)
     {
         pos.right          = newNode;
         newNode.listParent = pos;
     }
     else
     {
         // insert before pos.right's leftmost:
         pos = pos.right;
         while (pos.left != null)
         {
             pos = pos.left;
         }
         Debug.Assert(pos.left == null);
         pos.left           = newNode;
         newNode.listParent = pos;
     }
     RebalanceUntilRoot(pos);
 }
コード例 #4
0
 static void DumpTree(SharpTreeNode node)
 {
     node.GetListRoot().DumpTree();
 }