我想在图像上移动一条线。事实上,我正在使用一个循环。当我画一条新线时,前一条线应该被删除。但我不知道如何删除前一行。我尝试使用invalidate和dispose方法,但不起作用。我的代码是:
int xinc = 0, yinc = 0;
for (int loop = 0; loop <= 363; loop++)
{
Thread.Sleep(200);
MethodInvoker actionimage1 = delegate
{
Graphics g = pictureBox1.CreateGraphics();
if (loop <= 117)
{
Pen p = new Pen(Color.Red, 4.0f);
g.DrawLine(p, 0, xinc, 363, xinc);
g.Clear(this.BackColor);
this.Dispose();
this.Invalidate();
xinc++;
}
if (loop <= 363)
{
Pen p = new Pen(Color.Red, 4.0f);
g.DrawLine(p, yinc, 0, yinc, 117);
g.Clear(this.BackColor);
this.Dispose(); // I need here to remove the line,
such that when loop starts again the
sholud be on next coordinate.
this.Invalidate();
yinc++;
}
};
pictureBox1.BeginInvoke(actionimage1);
}发布于 2013-07-10 18:11:21
目前还不清楚您使用的是canvas还是其他技术。无论如何,下面是通用的答案
像修改对象位置一样的线,因为一切都是像素的。
只是好奇地想知道,你想实现什么目标?--
https://stackoverflow.com/questions/17567528
复制相似问题