【发布时间】:2013-12-07 23:32:18
【问题描述】:
在 form1 的顶部我做了:
private int pixelscounter;
private int counter;
private float xFactor, yFactor;
List<PointF> points = new List<PointF>();
double increment = 1.25;
double factor = 1.0;
Image img;
private Point startingPoint = Point.Empty;
private Point movingPoint = Point.Empty;
private bool panning = false;
GraphicsPath gp = new GraphicsPath();
GraphicsPath redgp = new GraphicsPath();
然后在 pictureBox1 move 事件中我做了:
if (checkBox2.Checked && e.Button == MouseButtons.Left)
{
gp.AddLine(e.X * xFactor, e.Y * yFactor, e.X * xFactor, e.Y * yFactor);
pixelscounter += 1;
if (pixelscounter == 10)
{
redgp.AddEllipse((e.X) * xFactor, (e.Y) * yFactor, 3f, 3f);
pixelscounter = 0;
}
p = e.Location;
pictureBox2.Invalidate();
}
还有pictureBox2的绘制事件:
if (checkBox2.Checked)
{
using (Pen pp = new Pen(Color.Green, 2f))
{
pp.StartCap = pp.EndCap = LineCap.Round;
pp.LineJoin = LineJoin.Round;
e.Graphics.DrawPath(pp, gp);
}
using (Pen pp = new Pen(Color.Red, 2f))
{
pp.StartCap = pp.EndCap = LineCap.Round;
pp.LineJoin = LineJoin.Round;
e.Graphics.DrawPath(pp, redgp);
}
}
我所做的是,当我单击鼠标左键时,按下鼠标左键,然后在pictureBox1周围拖动鼠标,它在pictureBox2中以绿色绘制一条线,每10个位置(像素)自动创建一个红点。
问题是当我快速或快速移动鼠标时,如果我移动鼠标非常非常慢,红点与 10 个位置(像素)的距离不同,如果我移动鼠标,红点彼此太近或多或少地移动鼠标,似乎彼此之间的点距离还可以,如果我快速/非常快速地移动鼠标,每个红点之间的距离都会大于 10 像素。
如何修复/解决此鼠标移动问题?
【问题讨论】: