' Name: View_SetMapExtent_SA
'
' Title: Set fixed map extent for repeatable plots (Whole SA)
'
' Topics: Views
'
' Description: Sets fixed map extents for South Africa -
'              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 = 1102
WinHeight = 863
'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
'Settings for all SA
'-734429.909255,-3815004.912361 1614489.819712,1421434.423280

x_ll = -734430
y_ll = -3815005
x_ur = x_ll+1614490
y_ur = y_ll+1421435
rext = Rect.MakeEmpty
rext = Rect.MakeXY(x_ll,y_ll,x_ur,y_ur)
theDisplay.SetExtent(rext)