What version of the control are you using? Here is the C# code from latest:
public Window1()
{
InitializeComponent();
dirDiagram.ModificationStart = ModificationStart.AutoHandles;
dirDiagram.Font.Size = 10.75;
dirDiagram.ShowAnchors = ShowAnchors.Never;
folderAnchors = new AnchorPattern(new[]
{
new AnchorPoint(10, 100, false, true),
new AnchorPoint(0, 50, true, false)
},
"FolderAnchors");
// set folder-like polygonal shape as default for nodes
byte[] folderShape = { 0, 0, 40, 0, 55, 20, 100, 20, 100, 100, 0, 100 };
dirDiagram.DefaultShape = new Shape(folderShape);
dirDiagram.ShapeBrush = new LinearGradientBrush(new GradientStopCollection {
new GradientStop(Colors.White, 0),
new GradientStop(Colors.Yellow, 0.7),
new GradientStop(Colors.Orange, 1)
}, 10);
Brush penBrush = new LinearGradientBrush(Colors.Bisque, Colors.OrangeRed, 0);
dirDiagram.ShapePen = new Pen(penBrush, 1);
// allow hierarchical expand/collapse
dirDiagram.NodesExpandable = true;
// all arrows should start with vertical segment
dirDiagram.LinkCascadeOrientation = Orientation.Vertical;
dirDiagram.LinkHeadShape = ArrowHeads.BowArrow;
dirDiagram.LinkHeadShapeSize = 3;
dirDiagram.LinkPen = new Pen(Brushes.Black, 0.41);
// read some directories
BuildTree();
}
int height = 0;
AnchorPattern folderAnchors;
private void BuildTree()
{
// create a box that will be a root in our hierarchy
ShapeNode root = new ShapeNode(dirDiagram);
root.AnchorPattern = folderAnchors;
root.Bounds = new RectangleF(23.04, 23.04, 99.84, 46.08);
root.Text = "root";
dirDiagram.Nodes.Add(root);
height = 20;
// read directories of all drives
string[] drives = Environment.GetLogicalDrives();
int skip = 0;
if (drives.Length >= 2)
{
if (drives[0][0] == 'A') skip++;
if (drives[1][0] == 'B') skip++;
}
DirectoryInfo[] di = new DirectoryInfo[drives.Length - skip];
for (int i = 0; i < di.GetLength(0); ++i)
{
di[i] = new DirectoryInfo(drives[i + skip]);
}
BuildSubDirs(root, di, 1);
LayoutTree();
// after the whole tree is built adjust the document extents
// to be as big as needed
dirDiagram.ResizeToFitItems(5, true);
}
private void LayoutTree()
{
TreeLayout tl = new TreeLayout();
tl.Root = null; // automatically select root
tl.Type = TreeLayoutType.Cascading;
tl.Direction = TreeLayoutDirections.LeftToRight;
tl.LinkStyle = TreeLayoutLinkType.Cascading2;
tl.LevelDistance = -40;
tl.NodeDistance = 15;
tl.KeepRootPosition = true;
tl.ReversedLinks = false;
tl.Anchoring = Anchoring.Keep;
tl.Arrange(dirDiagram);
}
private void BuildSubDirs(ShapeNode root, DirectoryInfo[] dirs, int level)
{
foreach (DirectoryInfo dir in dirs)
{
// create a node for the subfolder
ShapeNode folder = dirDiagram.Factory.CreateShapeNode(6 + level * 76.8, height, 99.84, 46.08);
folder.AnchorPattern = folderAnchors;
...