So there is a great open source tutorial on creating TreeNode class. It is great. But I wonder how to change its Arrange function to make it draw indented tree?
Here’s the function:
// Arrange the node and its children in the allowed area.
// Set xmin to indicate the right edge of our subtree.
// Set ymin to indicate the bottom edge of our subtree.
public void Arrange(Graphics gr, ref float xmin, ref float ymin)
{
// See how big this node is.
SizeF my_size = Data.GetSize(gr, MyFont);
// Recursively arrange our children,
// allowing room for this node.
float x = xmin;
float biggest_ymin = ymin + my_size.Height;
float subtree_ymin = ymin + my_size.Height + Voffset;
foreach (TreeNode<T> child in Children)
{
// Arrange this child's subtree.
float child_ymin = subtree_ymin;
child.Arrange(gr, ref x, ref child_ymin);
// See if this increases the biggest ymin value.
if (biggest_ymin < child_ymin) biggest_ymin = child_ymin;
// Allow room before the next sibling.
x += Hoffset;
}
// Remove the spacing after the last child.
if (Children.Count > 0) x -= Hoffset;
// See if this node is wider than the subtree under it.
float subtree_width = x - xmin;
if (my_size.Width > subtree_width)
{
// Center the subtree under this node.
// Make the children rearrange themselves
// moved to center their subtrees.
x = xmin + (my_size.Width - subtree_width) / 2;
foreach (TreeNode<T> child in Children)
{
// Arrange this child's subtree.
child.Arrange(gr, ref x, ref subtree_ymin);
// Allow room before the next sibling.
x += Hoffset;
}
// The subtree's width is this node's width.
subtree_width = my_size.Width;
}
// Set this node's center position.
Center = new PointF(
xmin + subtree_width / 2,
ymin + my_size.Height / 2);
// Increase xmin to allow room for
// the subtree before returning.
xmin += subtree_width;
// Set the return value for ymin.
ymin = biggest_ymin;
}
How it looks now:

How indented tree looks like ( image based on DmitryG s grate answer):

So.. How do I make it draw the graph in the indented form?
I have modified the TreeNode.Arrange() method for indented tree arrangement.
Now it looks like this:
Note, that the DrawSubtreLinks() method have also been modified: