This document is archived and information here might be outdated.  Recommended version.


Set Max Extent On Spatial Domain Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Set Max Extent On Spatial Domain Snippet

Set the extent of the ActiveView to be the maximum extent of a SpatialDomain.

[C#]
///<summary>
///Set the extent of the ActiveView to be the maximum extent of a SpatialDomain. 
///</summary>
///<param name="spatialReference">An ESRI.ArcGIS.Geometry.ISpatialReference interface that is the input SpatialDomain.</param>
///<param name="activeView">An ESRI.ArcGIS.Carto.IActiveView interface that is the ActiveView for which to recieve the new extent.</param>
///<remarks></remarks>
public void SetMaxExtentOnSpatialDomain(ESRI.ArcGIS.Geometry.ISpatialReference spatialReference, ESRI.ArcGIS.Carto.IActiveView activeView)
{

  System.Double xMin=0;
  System.Double xMax=0;
  System.Double yMin=0;
  System.Double yMax=0;
  spatialReference.GetDomain(out xMin, out xMax, out yMin, out yMax);

  ESRI.ArcGIS.Geometry.IEnvelope envelope=new ESRI.ArcGIS.Geometry.EnvelopeClass();
  envelope.XMax=xMax;
  envelope.XMin=xMin;
  envelope.YMax=yMax;
  envelope.YMin=yMin;

  activeView.Extent=envelope;

}
[Visual Basic .NET]
'''<summary>
'''Set the extent of the ActiveView to be the maximum extent of a SpatialDomain. 
'''</summary>
'''<param name="spatialReference">An ESRI.ArcGIS.Geometry.ISpatialReference interface that is the input SpatialDomain.</param>
'''<param name="activeView">An ESRI.ArcGIS.Carto.IActiveView interface that is the ActiveView for which to recieve the new extent.</param>
'''<remarks></remarks>
Public Sub SetMaxExtentOnSpatialDomain(ByVal spatialReference As ESRI.ArcGIS.Geometry.ISpatialReference, ByVal activeView As ESRI.ArcGIS.Carto.IActiveView)

  Dim xMin As System.Double
  Dim xMax As System.Double
  Dim yMin As System.Double
  Dim yMax As System.Double
  spatialReference.GetDomain(xMin, xMax, yMin, yMax)

  Dim envelope As ESRI.ArcGIS.Geometry.IEnvelope=New ESRI.ArcGIS.Geometry.EnvelopeClass
  envelope.XMax=xMax
  envelope.XMin=xMin
  envelope.YMax=yMax
  envelope.YMin=yMin

  activeView.Extent=envelope

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Carto
  • ESRI.ArcGIS.Geometry
  • ESRI.ArcGIS.System