skyline 递归查找信息树中所有节点

  int root = sgworld.ProjectTree.GetNextItem(0, ItemCode.ROOT);
            string tree = BuildTreeRecursive(root, 1);
private string BuildTreeRecursive( int current, int indent) //递归函数,模糊查找
                {
                         string padding = "";
                         for ( int i = 0; i < indent * 3; i++)
                                padding += "-";    
                         string result = "";
                         // iterate over all siblings of current node
                         while (current > 0)
                        {
                             // append node name to the tree string
                                 string currentName = sgworld.ProjectTree.GetItemName(current);
                                result += padding + currentName + "\r\n";
                                 // if current node is group, recursively build tree from its first child;
                                 if (sgworld.ProjectTree.IsGroup(current))
                                {
                                         int child = sgworld.ProjectTree.GetNextItem(current, ItemCode.CHILD);
                                        result += BuildTreeRecursive(child, indent + 1);
                                }
                                current = sgworld.ProjectTree.GetNextItem(current,ItemCode.NEXT);
                                 // move to next sibling                                
                        }
                         return result;
                }

你可能感兴趣的:(skyline,信息树)