Point screenPoint = new Point(e.X, e.Y); Point mousePosition = pictureBox1.PointToClient(screenPoint);
时间: 2024-05-13 15:05:36 浏览: 87
These two lines of code are used to convert the screen coordinates of the mouse cursor (represented by the Point object "screenPoint") to the coordinates relative to the top-left corner of the picture box control (represented by the Point object "mousePosition").
The first line creates a new Point object "screenPoint" with the X and Y coordinates of the mouse cursor obtained from the MouseEventArgs object "e".
The second line uses the PointToClient method of the pictureBox1 control to convert the screen coordinates to client coordinates. The method takes the screenPoint as a parameter and returns the converted coordinates as a Point object "mousePosition". The client coordinates are relative to the top-left corner of the control, which is the origin (0,0) point.
阅读全文