[2015/10/13] Since this article was written you should know that MSAGL has now been open-sourced. See: https://github.com/Microsoft/automatic-graph-layout.
Moving from GLEE to MSAGL
Microsoft Automatic Graph Layout (MSAGL) is the successor to GLEE and now I have received permission to use the MSAGL binaries in the sample code for VisioAutoExt. I’ve dropped GLEE support and moved completely over to MSAGL. The migration was straightforward, and I also improved the overall results of the topology being drawn. For example, now the connectors are one long Bezier curve in visio instead of multiple segments consisting of Bezier curves and line segments.
The new source is available on codeplex here: http://codeplex.com/visioautoext/
NOTE: You do *NOT* have to purchase a license to MSAGL to use this sample code in the project (which includes the MSAGL binaries).
A few words about Microsoft Automatic Graph Layout
- This is a tremendous piece of work by Lev Nachmanson in Microsoft Research. The results it produces are stellar and because its written as a .NET Framework library incorporating into my code has been very simple.
- If you are considering doing any graph layout, please check out MSAGL before you try to implement one yourself. You’ll save yourself a lot of work and produce far better looking results by letting geniuses like Lev do the heavy lifting for you. So if you plan on doing any graph layout for your own projects or products, I recommend going to Windows Marketplace and purchase a license.
Get the Code
You can find some sample in the VisioAutomation codeplex project in a VS project called TestVisioAutomation – search for a method called “Render_With_Dynamic_Connectors”
//------------------------ var vdom = new VA.DOM.AutoLayout.Drawing(); var n0 = vdom.AddShape("n0", "Untitled Node", "basflo_u.vss", "Decision"); n0.Size = new Isotope.Drawing.Size(3, 2); var n1 = vdom.AddShape("n1", "", "basflo_u.vss", "Decision"); n1.FillFormat = new FillFormat(); n1.FillFormat.FillForegnd.Value = "rgb(255,0,0)"; n1.FillFormat.FillBkgnd.Value = "rgb(255,255,0)"; n1.FillFormat.FillPattern.Value = 40; var n2 = vdom.AddShape("n2", "MailServer", "server_u.vss", "Email Server"); var n3 = vdom.AddShape("n3", null, "basflo_u.vss", "Data"); var n4 = vdom.AddShape("n4", "Alone", "basflo_u.vss", "Data"); var c0 = vdom.Connect("c0", n0, n1, null, VA.DOM.ConnectorType.Curved); var c1 = vdom.Connect("c1", n1, n2, "YES", VA.DOM.ConnectorType.RightAngle); var c3 = vdom.Connect("c2", n1, n0, "NO", VA.DOM.ConnectorType.Curved); var c4 = vdom.Connect("c3", n0, n2, null, VA.DOM.ConnectorType.Straight); var c5 = vdom.Connect("c4", n2, n3, null, VA.DOM.ConnectorType.Curved); var c6 = vdom.Connect("c5", n3, n0, null, VA.DOM.ConnectorType.Curved); var page1 = GetNewPage(StandardPageSize); var renderer = new VA.DOM.AutoLayout.Renderer(); renderer.RenderOptions.UseDynamicConnectors = true; var application = page1.Application; renderer.RenderToVisio(vdom, application, page1.Document, null); page1.ResizeToFitContents(); //------------------------