private void OnMenuLayoutDiagram(object sender, EventArgs e) { EFModelDiagram diagram = CurrentSelection.Cast <EFModelDiagram>().FirstOrDefault(); if (diagram != null) { using (Transaction tx = diagram.Store.TransactionManager.BeginTransaction("ModelAutoLayout")) { diagram.AutoLayoutShapeElements(diagram.NestedChildShapes, Microsoft.VisualStudio.Modeling.Diagrams.GraphObject.VGRoutingStyle.VGRouteStraight, Microsoft.VisualStudio.Modeling.Diagrams.GraphObject.PlacementValueStyle.VGPlaceSN, false); tx.Commit(); } } }
private static void DoStandardLayout(List <BinaryLinkShape> linkShapes, EFModelDiagram diagram) { // first we need to mark all the connectors as dirty so they'll route. Easiest way is to flip their 'ManuallyRouted' flag foreach (BinaryLinkShape linkShape in linkShapes) { linkShape.ManuallyRouted = !linkShape.ManuallyRouted; } // now let the layout mechanism route the connectors by setting 'ManuallyRouted' to false, regardless of what it was before foreach (BinaryLinkShape linkShape in linkShapes) { linkShape.ManuallyRouted = false; } diagram.AutoLayoutShapeElements(diagram.NestedChildShapes.Where(s => s.IsVisible).ToList(), VGRoutingStyle.VGRouteStraight, PlacementValueStyle.VGPlaceSN, true); }