Nevron Forum

Control.MousePosition (Point) To Document Coords (NPointF) ?

https://www.nevron.com/Forum/Topic2841.aspx

By michal bandrowski - Friday, December 11, 2009

Hi,

How can I translate mouse position Point(int, int) to document coords NPointF(float, float)?

Thanks in advance,
Michal
By Ivo Milanov - Monday, December 14, 2009

Hi,

Client coordinates for the drawing view can be converted to scene coordinates (document) with the help of the drawingView.SceneToDevice transformation. For example: if you have a point in client coordinates (e.g. relative to the drawing view control) you can convert to document coordinates like this:

NPointF pt = new NPointF(clientX, clientY);
pt = nDrawingView1.SceneToDevice.InvertPoint(pt);

If the mouse coordinates are in screen coordinates you have to first convert them to control client coordinates like this:

Point pt = new Point(screenX, screenY);
pt = nDrawingView1.PointToClient(pt);

Hope this helps...

Best regards,
Ivo