|
|
What's wrong with this code? It works great for me. The only one thing to consider is that the controls of the field can be placed on a several pages.
|
|
|
Hi Great product, I'm loving using it and how customizable it can be! I'm trying to determine if the first control on a field is currently visible in the viewer. I'm using the current code in an extended PdfViewer (WPF) class. There's definitely something wrong with it. Was hoping you could please point me in the right direction. I think what I have is completely wrong, even though it works sometimes. Thanks for your help Code:
private Rect GetControlDimensions(PdfControl ctrl, int pageIndex)
{
Point pt1 = PageToClient(pageIndex, new Point(ctrl.BoundRect.left, ctrl.BoundRect.top));
Point pt2 = PageToClient(pageIndex, new Point(ctrl.BoundRect.right, ctrl.BoundRect.bottom));
//The page may be rotated, so we must take it into account
int left = (int)Math.Min(pt1.X, pt2.X);
int top = (int)Math.Min(pt1.Y, pt2.Y);
int right = (int)Math.Max(pt1.X, pt2.X);
int bottom = (int)Math.Max(pt1.Y, pt2.Y);
return new Rect(left, top, right - left, bottom - top);
}
private bool IsFieldVisible(PdfField field)
{
PdfControl ctrl = field.Controls.FirstOrDefault();
if (ctrl != null)
{
Rect dimensions = GetControlDimensions(ctrl, CurrentIndex);
if (dimensions.Top > 0 && dimensions.Bottom < ViewportHeight)
{
return true;
}
}
return false;
}
|
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