How to position the results of nested layouts with both Horizontal and Vertical in one Diagram with a MuiltiLayout.
I moved your post from the GoDiagram forum to this, the GoXam forum.
If I understand you correctly, you just need to override IDiagramModel.DoLayout to do what you want.
To help you implement what you want, here’s the definition of MultiLayout.DoLayout:
public void DoLayout(IEnumerable<Node> nodes, IEnumerable<Link> links) {
Diagram diagram = this.Diagram;
LayoutManager mgr = diagram.LayoutManager;
Northwoods.GoXam.Tool.DraggingTool tool = diagram.DraggingTool;
Point pos = this.ArrangementOrigin;
foreach (IDiagramLayout layout in this.Layouts) {
bool invalidlayout = !layout.ValidLayout;
if (invalidlayout || this.Arrangement != MultiArrangement.None) {
IEnumerable<Node> subnodes = nodes.Where(n => mgr.CanLayoutPart(n, layout));
IEnumerable<Link> sublinks = links.Where(l => mgr.CanLayoutPart(l, layout));
if (invalidlayout) {
DiagramLayout dlay = layout as DiagramLayout;
if (dlay != null) dlay.ArrangementOrigin = pos;
layout.DoLayout(subnodes, sublinks);
}
Rect b = diagram.Panel.ComputeBounds(subnodes.OfType<Part>());
if (!invalidlayout && !b.IsEmpty) {
var dict = tool.ComputeEffectiveCollection(subnodes.OfType<Part>());
tool.MoveParts(dict, new Point(pos.X-b.X, pos.Y-b.Y));
}
switch (this.Arrangement) {
case MultiArrangement.None: break;
case MultiArrangement.Horizontal:
if (b.Width > 0) {
pos.X += b.Width;
pos.X += this.ArrangementSpacing.Width;
}
break;
case MultiArrangement.Vertical:
if (b.Height > 0) {
pos.Y += b.Height;
pos.Y += this.ArrangementSpacing.Height;
}
break;
}
}
}
}