First: calling ZoomIN followed by ZoomOUT should leave the view unchanged. Well it doesn't. The view is a little bit zoomed out compared to the starting point. So ZoomOUT seems to be using a larger factor than ZoomIN.
Second: centering at the mouse does not work. There is this thread and the ZoomCenterAtMousePosition property, but none of them work. I should add that the code provided by Loïc in the linked thread is terribly slow.
This is all somewhat disappointing. So I went about implementing it all myself, here is what I've come up with (code in the MouseDown event):
Code: Select all
Dim x = viewer.GetMouseLeftInDocument
Dim y = viewer.GetMouseTopInDocument
If e.Button = Windows.Forms.MouseButtons.Left Then
viewer.Zoom = viewer.Zoom * 1.25
ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
viewer.Zoom = viewer.Zoom / 1.25
End If
viewer.SetRectCoordinatesOnDocument(x, y, 2, 2)
viewer.CenterOnRect()
viewer.ClearRect()