1

我正在尝试构建一个表示数据库关系的图表,所以我希望每个节点都有一个带有表名子标题的标题,这将代表表的不同键,并且在边缘有一个带有关系的字符串, 例如:"每个 table1 可能有很多 table2"。

有可能吗?如果可以,怎么办?

谢谢。

4

1 回答 1

0

我是这样做的:

        Microsoft.Msagl.Drawing.Node visnode = new Microsoft.Msagl.Drawing.Node($"{n.NodeId}: {n.NodeName}") { UserData = n };
        visnode.NodeBoundaryDelegate    = GetNodeBoundary;
        visnode.DrawNodeDelegate        = DrawNode;
        ICurve GetNodeBoundary(Microsoft.Msagl.Drawing.Node node) {
            return CurveFactory.CreateRectangle(500, 50, new Microsoft.Msagl.Core.Geometry.Point(0,0) );
        }

        private bool DrawNode(Microsoft.Msagl.Drawing.Node node, object graphics)
        {
            Graphics g = (Graphics)graphics;
            Node n = (Node)node.UserData;

            // fiddle with g.transform (this took a ton of trial and error, and cribbing from 
            // the NodesWithImages sample code from MSAGL)
            // see also https://stackoverflow.com/q/70855662/2112855
            // g.FillRectangle, g.DrawString...
        }
于 2022-01-26T16:18:35.440 回答