'MSAGL: GraphViewerGdi: How to programmatically reset the zoom (or programmatically press the Home button to reset it)?

I want to right click on a node to zoom into that node, then right click again to completely reset the zoom and pan to its starting state. Furthermore, I may in future wish to hide the viewer's built-in toolbar and perform the zoom-out with a hotkey. So "just press the existing Home button" is not a solution for my use case.

I already have the zoom-in working using ShowBBox().

I cannot find a way to programmatically zoom out exactly like the Home button would do.

  • The viewer has no ResetZoom(), HomeButtonPressed(), or any such method that I can find.
  • Setting .ZoomF back to 1.0 is not sufficient because it does not simultaneous center the panning (and Pan(0,0) does not center the pan either.)
  • gvMain.ShowBBox(gvMain.Graph.BoundingBox) does not work (the zoom changes very slightly, but not to a fully reset state akin to the Home button.)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source