我正在使用 aNodeBoundaryDelegate
来绘制我的节点。
是否可以中和 DrawNodeDelegate 中的图形变换,以便此所有者绘图始终可以从相关区域的左上角为 0,0 开始?
Msagl.Drawing.Node
的坐标系是正-y-is-north。Winforms 是正向的。
在我的图表中(大约 100 个节点,从左到右布置得非常宽),最左边的 Msagl.Drawing.Node 对象通常以 -10,000、-3000 等坐标结束。
g.ClipBounds
以 {X = -10019.999 Y = -1716.70862 Width = 9519.998 Height = 3755.74536} 之类的范围结束。
到代码到达DrawNode
时,g.Transform 已经在某个(对我来说不直观)非零范围内,例如:
[0] 0.0612394959
[1] 0
[2] 0
[3] 0.0612394959
[4] 613.619751
[5] 224.130356
以防万一,我还使用NodeBoundaryDelegate
将所有节点大小硬编码为 500x50 的固定大小。
private bool DrawNode(Microsoft.Msagl.Drawing.Node node, object graphics)
{
Graphics g = (Graphics)graphics;
// some kind of g.Transform wizardry here?
g.DrawString("nodename", Font, Brushes.Red, 0, 0); // 0,0 should be perfectly aligned
// at top left corner of drawn node
}