Get coordinates from mouse up event in PDFViewWPF ?

Hi,

I need to capture the mouse coordinates of a mouse click in my open doc/page within the PDFViewWPF.

I need to use the coordinates in an effort to find a matching annotation from a list of annotations for the entire document (book). At the end of the day I need to capture the annotation the user clicked on, but I need to be in ToolType.e_text_highlight mode all the time so the user can create highlights at will, but so I can also capture a click on an existing highlight to run a custom method against the clicked annotation, to satisfy my business requirements.

Something like this:

private PDFViewWPF _pdfViewer;

.
.
.
//open doc in viewer etc.
//in highlight mode all the time, user adds a bunch of highlights
//need to capture when an existing highlight is clicked
.
.
.
_pdfViewer.MouseUp += _pdfViewer_MouseUp;

.
.
.

private void _pdfViewer_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{

//GET [CLICKED COORDINATES WITHIN PAGE], and then…

for (var i = 0; i < _allBookAnnotations.Count(); i++) {

Annot anAnnot = _allBookAnnotations[i];

if (anAnnot.GetPage().GetIndex() - 1 == [CLICKED COORDINATES WITHIN PAGE].pageIndex) {

var rect = {
x1: annot.GetLeft(),
y1: annot.GetTop(),
x2: annot.GetRight(),
y2: annot.GetBottom()
};
if (pageCoordinate.x >= rect.x1 && pageCoordinate.x <= rect.x2 && pageCoordinate.y >= rect.y1 && pageCoordinate.y <= rect.y2) {
WE HAVE A MATCHING ANNOTATION FOR CLICK;
}
}

}

}

Thanks,…Barry

Hi Barry. All the user interaction code for PDFViewWPF is in the PDFViewWPFTools project. You can either modify an existing tool, or create a new one based on an existing one.

Also PDFViewWPF has a method ConvScreenPtToPagePt, which you would use to convert the mouse click x,y to the x,y you can use to compare against annots.

Better yet, there is a method PDFViewWPF.GetAnnotationAt that will do all this for you, just pass in the mouse x,y.

Otherwise you look to be on the right track

This has the solution I cam up with:

https://groups.google.com/forum/#!topic/pdfnet-sdk/Ogd8hZSTI7s