Expose Linqpad's Automatic Graph Layout to Util
Hi. As Linqpad uses it internally it would be great to have MSAGL exposed to Util or some other class to draw graphs from script. Even it can be done via fluen interface:
gBulder
.PushGraph("NewGraph")
.ShowNodeIdOff()
.Text("x1","Reqest creation start")
.Circle("x2","Start")
.Command("x3","User creates request")
.PopGraph()
...
public GraphBuilder Circle(string id,string text){
return this
.PushNode(id)
.SetNodeLabel(text)
.SetNodeShape(Shape.Circle)
.SetNodeFill("#9999ff")
.WithNodeLabel(x=>x.FontName = "Calibri")
.WithNodeLabel(x=>x.FontSize = 10)
.PopNode()
;
}
As MSAGL has very cool layout functionality it can be used to draw graphs and activity-diagrams from code as diagram as code approach.
Is it possible to implement?
Comments
I'm not sure that anything new is required in LINQPad here. You can add a NuGet package reference to Microsoft.Msagl.GraphViewerGDI and then Dump a
GViewer
:In terms of a fluent interface, this sounds like it should be in library a that be used in other projects as well.
I already did, it's just an idea that came into my mind afrer I googled your post on stackoverflow that you forked your own version of MSAGL without Winforms dependancy especially for linqpad for net core. I played around with MSAGL for a while and wrote a small wrapper for fluent interface for MSAGL to implement a small graph describing DSL. But unfortunatly after I played with SVG writer class from MSAGL it turned out that it's only partly implemented and contains errors (doesn't write font attributed to svg).
I see. The story is that I forked MSAGL in 2019 to make it run on .NET Core (although the viewer still depends on WinForms). It was a very simple port - mainly to remove an unnecessary dependency on System.Data.SqlClient.
The fork is no longer necessary, because Microsoft released a .NET 6/7 compatible package in 2023.
Ok. Thanks for the reply.