' Name: View_SetMapExtent_Olifants
'
' Title: Set fixed map extent for repeatable plots (Olifants drainage)
'
' Topics: Views
'
' Description: Sets fixed map extents for water management areas -
'              smaller margin than the automatic limits
'
' Author: Michael Silberbauer 2001-10-10
' Institute for Water Quality Studies, Department of Water and Sanitation
' Private Bag X313 PRETORIA South Africa 0001
' SilberbauerM@dwaf.gov.za
'
' Requires: A View
'
' Self:
'
' Results:
' -----------------------------------------------------------------------------

theView = av.GetActiveDoc
theDisplay = theView.GetDisplay
thePrj = theView.GetProjection
'MsgBox.Info( thePrj.asString, "Projection" )
' Get the GraphicList for the View...

theGraphics = theView.GetGraphics

'Set the legend (TOC) width of the View to a constant value and fix it so we
' dont have to worry about it further:

theView.SetTOCUnResizable(false)
theView.SetTOCWidth(142)
theView.SetTOCWidth(219)
theView.SetTOCUnResizable(true)

' Return the extent (the enclosing rectangle) of the View:

theMapExtent = theView.GetDisplay.ReturnVisExtent
MsgBox.Report(theMapExtent.AsString,"VisExtent")
aWindow = theView.GetWin
aWinPixSize = aWindow.ReturnExtent
MsgBox.Report(aWinPixSize.AsString,"Window size, pixels")
WinWidth = 800
WinHeight = 550
'WinWidth  = 1234
'WinHeight =  848

aWindow.Resize(WinWidth,WinHeight)

' Settings for Olifants drainage region:

pt_ll = (28.26500@(-26.56461)).ReturnProjected(thePrj)
pt_ur = (31.93353@(-23.69139)).ReturnProjected(thePrj)
x_ll = pt_ll.GetX
y_ll = pt_ll.GetY
x_ur = pt_ur.GetX
y_ur = pt_ur.GetY
rext = Rect.MakeEmpty
rext = Rect.MakeXY(421854,-2892760,804010,-2582960)
'rext = Rect.MakeXY( 423000, -2895000, 802000, -2585000 )
'rext = Rect.MakeXY( x_ll, y_ll, x_ur, y_ur )

theDisplay.SetExtent(rext)