This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ESRI.ArcGIS.Snippets > Snippets > Zoom by Ratio Snippet (ArcObjects .NET 10.4 SDK) |
Zoom in ActiveView using a ratio of the current extent.
///<summary>Zoom in ActiveView using a ratio of the current extent.</summary> /// ///<param name="activeView">An IActiveView interface.</param> ///<param name="zoomRatio">A Double that is the ratio to zoom in. Less that 1 zooms in (Example: .75), greater than 1 zooms out (Example: 2).</param> /// ///<remarks>Both the width and height ratio of the zoomed area is preserved.</remarks> public void ZoomByRatio(ESRI.ArcGIS.Carto.IActiveView activeView, System.Double zoomRatio) { if(activeView == null || zoomRatio < 0) { return; } ESRI.ArcGIS.Geometry.IEnvelope envelope=activeView.Extent; envelope.Expand(zoomRatio, zoomRatio, true); activeView.Extent=envelope; activeView.Refresh(); }
'''<summary>Zoom in ActiveView using a ratio of the current extent.</summary> ''' '''<param name="activeView">An IActiveView interface.</param> '''<param name="zoomRatio">A Double that is the ratio to zoom in. Less that 1 zooms in (Example: .75), greater than 1 zooms out (Example: 2).</param> ''' '''<remarks>Both the width and height ratio of the zoomed area is preserved.</remarks> Public Sub ZoomByRatio(ByVal activeView As ESRI.ArcGIS.Carto.IActiveView, ByVal zoomRatio As System.Double) If activeView Is Nothing OrElse zoomRatio < 0 Then Return End If Dim envelope As ESRI.ArcGIS.Geometry.IEnvelope=activeView.Extent envelope.Expand(zoomRatio, zoomRatio, True) activeView.Extent=envelope activeView.Refresh() End Sub