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