Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,075
Thanks: 6 times Was thanked: 124 time(s) in 121 post(s)
|
Question:How can I show the text of an annotation while moving the mouse, like acrobat reader? Answer:Please find code below that illustrates the idea. Code:
public class MyPdfViewer : PdfViewer
{
private ToolTip _tooltip = new ToolTip();
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (Document == null)
return;
int pageIndex = PointInPage(e.Location);
if (pageIndex < 0)
return;
var page = Document.Pages[pageIndex];
if (page.Annots == null)
return;
PointF pagePoint = ClientToPage(pageIndex, e.Location);
foreach (var annot in page.Annots)
{
if (!(annot is PdfTextAnnotation))
continue;
var rect = annot.Rectangle;
if(PointInRect(pagePoint, rect))
{
//any code showing annotation.
//Tooltip for example
_tooltip.Show(annot.Contents, this, e.Location);
return;
}
}
_tooltip.Hide(this);
}
public bool PointInRect(PointF point, FS_RECTF rect)
{
return !(point.X < rect.left || point.X > rect.right || point.Y < rect.bottom || point.Y > rect.top);
}
}
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close