public override void OnClick() { //Get the current extent of the active view IActiveView activeView = m_HookHelper.ActiveView; IEnvelope envelope = activeView.Extent; //Get the extension manager ExtensionManager extensionManager = new ExtensionManagerClass(); //Get the extension from the extension manager IExtension extension = extensionManager.FindExtension("Zoom Factor Extension"); //Get the zoom factor from the extension double zoomFactor = 1.1; if (extension != null) { IZoomExtension zoomExtension = (IZoomExtension)extension; zoomFactor = zoomExtension.ZoomFactor; } else { System.Windows.Forms.MessageBox.Show("The extension cannot be found!"); } //Update the current extent of the active view envelope.Expand((System.Convert.ToDouble(1.0) / zoomFactor), (System.Convert.ToDouble(1.0) / zoomFactor), true); activeView.Extent = envelope; activeView.Refresh(); }
public override void OnClick() { //Get the extension manager ExtensionManager extensionManager = new ExtensionManagerClass(); //Get the extension from the extension manager IExtension extension = extensionManager.FindExtension("Zoom Factor Extension"); IZoomExtension zoomExtension = (IZoomExtension)extension; double zoomFactor = zoomExtension.ZoomFactor; //Get a zoom factor from the user InputFormResult res = InputForm.ShowModal(null, "Enter a zoom factor", "ZoomExtension Sample", zoomExtension.ZoomFactor.ToString()); if (res.Result == DialogResult.Cancel) { return; } string zoomString = res.InputString; if (zoomString.Trim() == "") { return; } //Set the zoom factor if (System.Char.IsNumber(zoomString, 0) == true) { zoomExtension.ZoomFactor = System.Convert.ToDouble(zoomString); } }