已经在屏幕上绘制了一些内容(作为其他所有内容的叠加)但是当我在绘图上移动某些内容时它会开始闪烁,我已经将DoubleBuffered设置为true 是他们用dll,函数,渲染来解决这个问题的方法吗?
private void button2_Click(object sender, EventArgs e)
{
DoubleBuffered = true;
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
Point midx = new Point(960, 960);
Point midy = new Point(540, 540);
Point LinksBoven = new Point(10, 10);
Point pt = Cursor.Position;
string letter = "drawing on";
float emSize = 12;
while (true)
{
using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
{
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(0, 200, 0));
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
if (cbCircel.Checked == true)
{
g.DrawEllipse(Pens.Black, midx.X - 10, midy.Y - 10, 20, 20);
}
if (cbKruis.Checked == true)
{
g.DrawLine(myPen, 940, 540, 980, 540);
g.DrawLine(myPen, 960, 560, 960, 520);
}
pt.X = 10;
pt.Y = 10;
g.DrawString(letter, new Font(FontFamily.GenericSansSerif, emSize, FontStyle.Regular), new SolidBrush(Color.Green), pt);
}
}
}