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


IEnvelope.CenterAt Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Geometry > ESRI.ArcGIS.Geometry > Interfaces > IE > IEnvelope Interface > IEnvelope.CenterAt Method
ArcGIS Developer Help

IEnvelope.CenterAt Method

Moves this envelope so it is centered at p.

[Visual Basic .NET]
Public Sub CenterAt ( _
    ByVal p As IPoint _
)
[C#]
public void CenterAt (
    IPoint p
);
[C++]
HRESULT CenterAt(
  IPoint* p
);
[C++]
Parameters
p 

p is a parameter of type IPoint*

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

Moves the Envelope so that the center point of the Envelope is at the given input point.  The Width, Height, and other properties of the Envelope remain unchanged (only the XMin, XMax, YMin, and YMax are altered).

Remarks

The Center Point occurs at: ((XMin + XMax) / 2, (YMin + YMax) / 2).

[C#]

private void ReCenterEnvelope()
{
    IEnvelope envelope = new EnvelopeClass();
    envelope.PutCoords(100, 100, 200, 200);

    String report1 = "Envelope: \n" +
                     "LowerLeft  X = " + envelope.LowerLeft.X + "\n" +
                     "LowerLeft  Y = " + envelope.LowerLeft.Y + "\n\n" +
                     "LowerRight X =  " + envelope.LowerRight.X + "\n" +
                     "LowerRight Y =  " + envelope.LowerRight.Y + "\n\n" +
                     "UpperLeft  X = " + envelope.UpperLeft.X + "\n" +
                     "UpperLeft  Y = " + envelope.UpperLeft.Y + "\n\n" +
                     "UpperRight X =  " + envelope.UpperRight.X + "\n" +
                     "UpperRight Y =  " + envelope.UpperRight.Y; System.Windows.Forms.MessageBox.Show(report1);

    //re-center
    IPoint centerPoint = new PointClass();
    centerPoint.PutCoords(0, 0);
    envelope.CenterAt(centerPoint);
    String report2 = "Re-cetered Envelope: \n" +
                     "LowerLeft  X = " + envelope.LowerLeft.X + "\n" +
                     "LowerLeft  Y = " + envelope.LowerLeft.Y + "\n\n" +
                     "LowerRight X =  " + envelope.LowerRight.X + "\n" +
                     "LowerRight Y =  " + envelope.LowerRight.Y + "\n\n" +
                     "UpperLeft  X = " + envelope.UpperLeft.X + "\n" +
                     "UpperLeft  Y = " + envelope.UpperLeft.Y + "\n\n" +
                     "UpperRight X =  " + envelope.UpperRight.X + "\n" +
                     "UpperRight Y =  " + envelope.UpperRight.Y; System.Windows.Forms.MessageBox.Show(report2);
}

[Visual Basic .NET]

    Public Sub t_EnvCenterAt()
        Dim pEnv1 As IEnvelope
        Dim pPoint As IPoint
        pEnv1 = New Envelope
        pPoint = New Point
        pEnv1.PutCoords(100, 100, 200, 200)
        pPoint.PutCoords(0, 0)

        pEnv1.CenterAt(pPoint)

        Dim dXmin As Double, dYmin As Double, dXmax As Double, dYmax As Double
        pEnv1.QueryCoords(dXmin, dYmin, dXmax, dYmax)

        If pEnv1.IsEmpty Then
            MsgBox("envelope is empty")
        Else
            MsgBox(dXmin & "," & dYmin & "," & dXmax & "," & dYmax)
        End If
    End Sub

See Also

IEnvelope Interface | IEnvelope.Union Method | IEnvelope.Intersect Method | IEnvelope.Expand Method | IEnvelope.Offset Method

.NET Samples

Dynamic biking RSS weather layer