In top of form1 I did:
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();
Then in pictureBox1 move event I did:
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();
}
And the pictureBox2 paint event:
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);
}
}
What I did is that when I click mouse left button press without leave it then drag the mouse around pictureBox1 its drawing a line in pictureBox2 in green and every 10 locations(pixels) its creating a red point automatic.
The problem is when I move the mouse fast or fast movements then the red points are not in the same distance of 10 locations(pixels) if I move the mouse very very slow the red points are too close to each other if I move the mouse regular more or less it seems that the points distance between each other are ok and if I move the mouse fast/very fast the distance between every red point is large more then 10 pixels.
How can I fix/solve this mouse movements problem ?