Get X and Y position of mouse click on GDViewer
Get X and Y position of mouse click on GDViewer
Hi,
i have displayed one PDF file inside gdviewer control. gdviewer zmoo mode is selected by user it may be 100%, fixtowidth,fittiviewer etc.. it is not hardcode, any user can change zoom mode of GdViewer control.
i need to draw a line in displayed pdf of gdviewer. so i need exact starting position of mouse wit point and ending position of mouse with point to draw line.
Please provide me the detail and example of this problem.
i have displayed one PDF file inside gdviewer control. gdviewer zmoo mode is selected by user it may be 100%, fixtowidth,fittiviewer etc.. it is not hardcode, any user can change zoom mode of GdViewer control.
i need to draw a line in displayed pdf of gdviewer. so i need exact starting position of mouse wit point and ending position of mouse with point to draw line.
Please provide me the detail and example of this problem.
Re: Get X and Y position of mouse click on GDViewer
Hello,
- Catch X & Y in the mouse event. This will be viewer coordinates.
- Then translate viewer coordinates to document coordinates by using the CoordViewerToDocument method.
Kind regards,
Loïc
- Catch X & Y in the mouse event. This will be viewer coordinates.
- Then translate viewer coordinates to document coordinates by using the CoordViewerToDocument method.
Kind regards,
Loïc
Re: Get X and Y position of mouse click on GDViewer
Thanks Loic,Loïc wrote:Hello,
- Catch X & Y in the mouse event. This will be viewer coordinates.
- Then translate viewer coordinates to document coordinates by using the CoordViewerToDocument method.
Kind regards,
Loïc
Can you please give me one sample code for this i have below code but it is not working.
Code: Select all
private void GdViewer1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isDrag = true;
int a = 0, b = 0;
GdViewer1.CoordDocumentToViewer(e.X, e.Y, ref a, ref b);
startPoint = new Point(a, b);
}
}
Thanks
Re: Get X and Y position of mouse click on GDViewer
I was talking about CoordViewerToDocument , not CoordDocumentToViewer.
Also, if you are dealing with PDF coordinates I will suggest you to convert them to inches:
Hope this helps!
Loïc
Also, if you are dealing with PDF coordinates I will suggest you to convert them to inches:
Code: Select all
int docXPix = 0, docYPix = 0;
GdViewer1.CoordViewerToDocument(e.X, e.Y, ref docXPix, ref docYPix);
double doXInches = docXPix / GdViewer1.HorizontalResolution ;
double doYInches = docYPix / GdViewer1.VerticalResolution;
Loïc
Re: Get X and Y position of mouse click on GDViewer
Loïc wrote:I was talking about CoordViewerToDocument , not CoordDocumentToViewer.
Also, if you are dealing with PDF coordinates I will suggest you to convert them to inches:
Hope this helps!Code: Select all
int docXPix = 0, docYPix = 0; GdViewer1.CoordViewerToDocument(e.X, e.Y, ref docXPix, ref docYPix); double doXInches = docXPix / GdViewer1.HorizontalResolution ; double doYInches = docYPix / GdViewer1.VerticalResolution;
Loïc
Thanks, it is working.
my main goal is to draw line on GDViewer using "AddLineAnnotation()" of GDPicture pdf class. but i have some problem in that. i have posted one thread on GDPicture forum. link is below. please help me to solve that problem also.
viewtopic.php?t=3844
Thanks
-
- Posts: 352
- Joined: Tue Sep 27, 2011 11:47 am
Re: Get X and Y position of mouse click on GDViewer
Hi,
It has been answered. Please do not refer to other tickets in the forum in your posts. Your threads will be answered in due time.
Best Regards,
Sami
It has been answered. Please do not refer to other tickets in the forum in your posts. Your threads will be answered in due time.
Best Regards,
Sami
Who is online
Users browsing this forum: No registered users and 1 guest