我在窗口上有 cairo 的问题,我不知道为什么它无法在我的面板上绘制当我使用 GDI 时一切正常,但是当我使用 cairo 时我无法绘制,请帮助。谢谢。
包裹开罗来画画
using System;
using Cairo;
using Gtk;
namespace BT.LibExtend
{
public class CairoExt : BTGraphicLibExt
{
Surface s;
Context c;
public CairoExt(IntPtr hdc)
{
s = new Win32Surface(hdc);
c = new Context(s);
}
public override void DrawLine(double x1, double y1, double x2, double y2)
{
c.MoveTo(x1, y1);
c.LineTo(x2, y2);
c.Stroke();
}
}
}
这是我的表格
public partial class FigureDraw : Form
{
GraphicLibExt glip;
public FigureDraw()
{
InitializeComponent();
glip = new CairoExt(pnMainDraw.CreateGraphics().GetHdc());
}
private void btnLine_Click(object sender, EventArgs e)
{
glip.DrawLine(20, 20, 100, 100);
}
}