【问题标题】:C# MSAGL - How to create: Title, Subtitle on nodes and Tooltip on edgeC# MSAGL - 如何创建:节点上的标题、副标题和边缘上的工具提示
【发布时间】:2017-05-31 17:26:06
【问题描述】:

我正在尝试构建一个表示数据库关系的图表,因此我希望每个节点都有一个 标题与表名子标题,这将代表不同的键表格边缘有这样关系的字符串 如:“每个table1可能有很多table2”。

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

谢谢。

【问题讨论】:

    标签: c# sql-server winforms msagl


    【解决方案1】:

    我是这样做的:

            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...
            }
    

    【讨论】:

    • 我必须非常注意命名空间冲突,因为我自己的代码有一个 Node 类,MSAGL 也有。
    猜你喜欢
    • 2021-09-27
    • 2021-06-22
    • 2017-07-16
    • 2018-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-14
    • 1970-01-01
    相关资源
    最近更新 更多