在欢乐合唱团上画线

时间:2019-06-28 09:14:19

标签: c# drawing

我正在使用 Microsoft.Glee 中的库。我尝试在C#的pictureBox中绘制图形(而非图表)。在此图中,我想绘制节点ID,它们只是字符串。     我使用此功能:

graphics.DrawString(n.Id, new Font("Times New Roman", 12, FontStyle.Bold),
           Brushes.Black, (float)n.BBox.Left, (float)n.BBox.Bottom);    

问题在于字符串在镜像中显示,并且认为问题出自MSAGL库中的CalculateLayout()方法。

关于如何解决这个问题的任何想法?

public void DrawNode(Node n, Pen pen, Graphics graphics)
{
    ICurve curve = n.MovedBoundaryCurve;
    Ellipse el = curve as Ellipse;
    if (el != null)
    {
        RectangleF rF = new RectangleF((float)el.BBox.Left, (float)el.BBox.Bottom, (float)el.BBox.Width, (float)el.BBox.Height);
        graphics.DrawEllipse(pen, rF);
        graphics.FillEllipse(pen.Brush, rF);
        //graphics.DrawString(n.Id, new Font("Times New Roman", 12, FontStyle.Bold), Brushes.Black,(float)el.BBox.Left, (float)el.BBox.Bottom);
        graphics.DrawString(n.Id, new Font("Times New Roman", 12, FontStyle.Bold), Brushes.Black, (float)n.BBox.Left, (float)n.BBox.Bottom);
    }
    else
    {
        Curve c = curve as Curve;
        foreach (ICurve seg in c.Segs)
        {
            LineSeg l = seg as LineSeg;
            if (l != null)
                graphics.DrawLine(pen, GleePointToDrawingPoint(l.Start), GleePointToDrawingPoint(l.End));
        }
    }
}

enter image description here

0 个答案:

没有答案