Hi,
You don't need any special algorithms for this, you can arrange the stacks using a simple nested loop:
var leftStacks = CreateTestStacks(2, 4, 1, 1);
var rightStacks = CreateTestStacks(4, 1, 0, 6);
double padding = 10, stackStart = 20, stacksPadding = 40;
for (int i = 0; i < 4; i++)
{
double yl = stackStart;
foreach (var node in leftStacks[i])
{
node.Move(20, yl);
yl += node.Bounds.Height + padding;
}
double yr = stackStart;
foreach (var node in rightStacks[i])
{
node.Move(80, yr);
yr += node.Bounds.Height + padding;
}
stackStart = Math.Max(yl, yr) + stacksPadding;
}
List<List<DiagramNode>> CreateTestStacks(params int[] stackSizes)
{
var stacks = new List<List<DiagramNode>>();
foreach (int size in stackSizes)
{
var stack = new List<DiagramNode>();
for (int i = 0; i < size; i++)
stack.Add(diagram.Factory.CreateShapeNode(defBounds));
stacks.Add(stack);
}
return stacks;
}
Rect defBounds = new Rect(0, 0, 30, 30);
You could add a lane-grid row at each iteration of the outer loop and set its height according to current Y positions. There's no associations between lane cells and nodes, but you can discover what lane nodes are dropped to and align nodes to lanes from some event handlers. For an example, see the Lanes and ProcessLayout sample projects.
I hope that helps,
Stoyan