解决方法
GitHub上有
VisioAutomation.如果安装了Visio,它可以自动生成图表.如果您可以将您想要的图表建模为有向图,那么它可以自动为您绘制图形(使用MSAGL).
以下是创建有向图的基本示例
using VACONNECT = VisioAutomation.Shapes.Connections; var d = new VisioAutomation.Models.DirectedGraph.Drawing(); var basic_stencil = "basic_u.vss"; var n0 = d.AddShape("n0","Node 0",basic_stencil,"Rectangle"); n0.Size = new VA.Drawing.Size(3,2); var n1 = d.AddShape("n1","Node 1","Rectangle"); var n2 = d.AddShape("n2","Node 2","Rectangle"); var n3 = d.AddShape("n3","Node 3","Rectangle"); var n4 = d.AddShape("n4","Node 4\nUnconnected","Rectangle"); var c0 = d.AddConnection("c0",n0,n1,"0 -> 1",VACONNECT.ConnectorType.Curved); var c1 = d.AddConnection("c1",n2,"1 -> 2",VACONNECT.ConnectorType.RightAngle); var c2 = d.AddConnection("c2",VACONNECT.ConnectorType.Curved); var c3 = d.AddConnection("c3","0 -> 2",VACONNECT.ConnectorType.Straight); var c4 = d.AddConnection("c4",n3,"2 -> 3",VACONNECT.ConnectorType.Curved); var c5 = d.AddConnection("c5","3 -> 0",VACONNECT.ConnectorType.Curved);
然后绘制它:
var options = new VisioAutomation.Models.DirectedGraph.MsaglLayoutOptions(); var page = visio_app.ActivePage; d.Render(page,options);