Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPointeur previousPointer = null; private class Pointeur { public Point StartPointL1 { get; set; } public Point EndPointL1 { get; set; } public Point StartPointL2 { get; set; } public Point EndPointL2 { get; set; } } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { Pointeur newPointer = new Pointeur(); newPointer.StartPointL1 = PointToScreen(new Point(pictureBox1.Location.X, pictureBox1.Location.Y + e.Y)); newPointer.EndPointL1 = PointToScreen(new Point(pictureBox1.Location.X + pictureBox1.Width, pictureBox1.Location.Y + e.Y)); newPointer.StartPointL2 = PointToScreen(new Point(pictureBox1.Location.X + e.X, pictureBox1.Location.Y)); newPointer.EndPointL2 = PointToScreen(new Point(pictureBox1.Location.X + e.X, pictureBox1.Location.Y + pictureBox1.Height)); if (previousPointer != null) { if (newPointer.StartPointL1.Y != previousPointer.StartPointL1.Y) { ControlPaint.DrawReversibleLine(previousPointer.StartPointL1, previousPointer.EndPointL1, Color.Red); ControlPaint.DrawReversibleLine(newPointer.StartPointL1, newPointer.EndPointL1, Color.Red); previousPointer.StartPointL1 = newPointer.StartPointL1; previousPointer.EndPointL1 = newPointer.EndPointL1; } if(newPointer.StartPointL2.X != previousPointer.StartPointL2.X) { ControlPaint.DrawReversibleLine(previousPointer.StartPointL2, previousPointer.EndPointL2, Color.Red); ControlPaint.DrawReversibleLine(newPointer.StartPointL2, newPointer.EndPointL2, Color.Red); previousPointer.StartPointL2 = newPointer.StartPointL2; previousPointer.EndPointL2 = newPointer.EndPointL2; } } else { ControlPaint.DrawReversibleLine(newPointer.StartPointL1, newPointer.EndPointL1, Color.Red); ControlPaint.DrawReversibleLine(newPointer.StartPointL2, newPointer.EndPointL2, Color.Red); previousPointer = newPointer; } }