Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • 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.)

>Solution :

What the home button is doing is setting the Transform to null. So you can also do the same to reset the transform:

//Press home button:
gViewer1.Transform = null;
gViewer1.Invalidate();

Just in case that someone is interested to programmatically invoke the other buttons’ operations, here are the methods:

  • ZoomInPressed()
  • ZoomOutPressed()
  • BackwardButtonPressed()
  • ForwardButtonPressed()
  • SaveButtonPressed()
  • PrintButtonPressed()
  • OpenButtonPressed()
  • UndoButtonPressed()
  • RedoButtonPressed()
  • LayoutSettingsIsClicked()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading