Hi guys
Using VS2017 on Windows 10 Professional with version 16.3460.0.21 of the PDF Controls. In the code below PDFViewerEx is the name of the form and ViewerCtl is a PdfViewer.PdfDocumentView.
I am trying to make the control zoom with the user using the mousewheel and control key and whilst it is working, I have found what I believe to be a bug. Code follows.
The bug I believe is only in the zoom up functionality - the control move up a page on each scroll and I cater for that by adjusting the page back - that of course is an issue. Can you confirm my code is correct and confirm that there is a bug?
..
enum ZoomDirection { None, Up, Down };
private void PDFViewerEx_KeyDown(object sender, KeyEventArgs e)
{
CtrlIsDown = e.Control;
}
private void PDFViewerEx_MouseWheel(object sender, MouseEventArgs e)
{
//check if control is being held down
int page = ViewerCtl.CurrentPageIndex;
Debug.WriteLine("In mousewhereel event - Zoom Up - page " + ViewerCtl.CurrentPageIndex.ToString());
if (CtrlIsDown)
{
//evaluate the delta's sign and call the appropriate zoom command
int i = Math.Sign(e.Delta);
if (i < 0)
{
Zoom(ZoomDirection.Down);
}
else if (i > 0)
{
Zoom(ZoomDirection.Up);
Debug.WriteLine("In mousewhereel event - Zoom Up1 - page " + ViewerCtl.CurrentPageIndex.ToString());
if (page > 1)
ViewerCtl.GoToPageAtIndex(page + 1);
else
ViewerCtl.GoToPageAtIndex(page);
Debug.WriteLine("In mousewhereel event - Zoom Up2 - page " + ViewerCtl.CurrentPageIndex.ToString());
}
}
}
void Zoom(ZoomDirection zd)
{
int ZoomLevel = ViewerCtl.ZoomPercentage;
//Debug.WriteLine("In Zoom event " + ZoomLevel.ToString());
switch (zd)
{
case ZoomDirection.Up:
ViewerCtl.ZoomTo(ZoomLevel + 2);
break;
case ZoomDirection.Down:
ViewerCtl.ZoomTo(ZoomLevel - 2);
break;
case ZoomDirection.None:
ViewerCtl.ZoomTo(ZoomLevel);
break;
}
//Debug.WriteLine("After Zoom event " + ViewerCtl.ZoomPercentage.ToString());
CtrlIsDown = false;
}
private void ViewerCtl_KeyDown(object sender, KeyEventArgs e)
{
CtrlIsDown = e.Control;
}
private void ViewerCtl_ZoomChanged(object sender, int zoomFactor)
{
Debug.WriteLine("In ViewerCtl_ZoomChanged event");
}