public override void DoMouseInput(MouseEventArgs e, MouseEventCategory met) { Point thisPt = new Point(e.X, e.Y); switch (met) { case MouseEventCategory.MouseButtonDown: if (e.Button == MouseButtons.Left) { previousPt = thisPt; Cursor.Clip = bound.RectangleToScreen(new Rectangle(new Point(), bound.Size)); } break; case MouseEventCategory.MouseMove: if (e.Button == MouseButtons.Left) { surface.DrawLine(drawPen, previousPt, thisPt); previousPt = new Point(e.X, e.Y); bound.Invalidate(); } break; case MouseEventCategory.MouseButtonUp: //release the mouse Cursor.Clip = Rectangle.Empty; break; } }
public override void DoMouseInput(MouseEventArgs e, MouseEventCategory met) { Point thisPt = new Point(e.X, e.Y); switch (met) { case MouseEventCategory.MouseButtonDown: if (e.Button == MouseButtons.Left) { previousPt = originPt = thisPt; Cursor.Clip = bound.RectangleToScreen(new Rectangle(new Point(), bound.Size)); isInitialized = true; } break; case MouseEventCategory.MouseMove: if (e.Button == MouseButtons.Left) { ControlPaint.DrawReversibleLine(bound.PointToScreen(originPt), bound.PointToScreen(previousPt), Color.White); ControlPaint.DrawReversibleLine(bound.PointToScreen(originPt), bound.PointToScreen(thisPt), Color.White); previousPt = thisPt; } break; case MouseEventCategory.MouseButtonUp: if (isInitialized) { surface.DrawLine(drawPen, originPt, thisPt); //release the mouse Cursor.Clip = Rectangle.Empty; bound.Invalidate(); } break; } }