string tree = BuildTreeRecursive(root, 1);
{
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;
}