在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移動事件
然後我做:
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像素。
我該如何修復/解決這個鼠標移動問題?