橡皮擦技术画线程序-C#版

Point originalPoint = new Point(); Point lastPoint = new Point(); bool mouseIsDown; private void Form1_MouseDown(object sender, MouseEventArgs e) { mouseIsDown = true; originalPoint.X = e.X; originalPoint.Y = e.Y; lastPoint.X = -1; lastPoint.Y = -1; } private void MyDrawReversibleLine(Point point1, Point point2) { point1 = PointToScreen(point1); point2 = PointToScreen(point2); ControlPaint.DrawReversibleLine(point1, point2, Color.Yellow); } private void Form1_MouseUp(object sender, MouseEventArgs e) { mouseIsDown = false; if (lastPoint.X != -1) { Point currentPoint = new Point(e.X, e.Y); MyDrawReversibleLine(originalPoint, lastPoint); } lastPoint.X = -1; lastPoint.Y = -1; originalPoint.X = -1; originalPoint.Y = -1; } private void Form1_MouseMove(object sender, MouseEventArgs e) { Point currentPoint = new Point(e.X, e.Y); if (mouseIsDown) { if (lastPoint.X != -1) { MyDrawReversibleLine(originalPoint, lastPoint); } lastPoint = currentPoint; MyDrawReversibleLine(originalPoint, currentPoint); } }

你可能感兴趣的:(object)