The following code example sets up a world file for a given IExport passed in as docExport. It assumes that a HookHelper object has been set up to obtain the active view. If the docExport is not coming from IExportFileDialog, the mapWorldFileSettings.OutputWorldFile parameter must be set to true for a world file to be output.
[C#]
privatevoid InitWorldFile(IExport docExport)
{
IWorldFileSettings mapWorldFileSettings;
IWorldFileSettings2 mapWorldFileSettings2;
//Use the new IWorldFileSettings2 interface to write the rotation to the world file.if (docExport is IExportImage && m_pHookHelper.ActiveView is IMap)
{
//Cast these two world file settings variables to docExport.
mapWorldFileSettings = docExport as IWorldFileSettings;
mapWorldFileSettings2 = docExport as IWorldFileSettings2;
//The mapWorldFileSettings.OutputWorldFile is set by the dialog.
mapWorldFileSettings.MapExtent = m_GraphicsExtentEnv;
//The mapWorldFileSettings2.MapRotation must be copied for the world file to properly reflect rotation.
mapWorldFileSettings2.MapRotation = m_ActiveView.ScreenDisplay.DisplayTransformation.Rotation;
}
}
[VB.NET]
PrivateSub InitWorldFile(ByVal docExport As IExport)
Dim mapWorldFileSettings As IWorldFileSettings
Dim mapWorldFileSettings2 As IWorldFileSettings2
'Use the new IWorldFileSettings2 interface to write the rotation to the world file.IfTypeOf docExport Is IExportImage And m_pHookHelper.ActiveView Is IMap Then'Cast these two world file settings variables to docExport.
mapWorldFileSettings = docExport
mapWorldFileSettings2 = docExport
'The mapWorldFileSettings.OutputWorldFile is set by the dialog.
mapWorldFileSettings.MapExtent = m_GraphicsExtentEnv
'The mapWorldFileSettings2.MapRotation must be copied for the world file to properly reflect rotation.
mapWorldFileSettings2.MapRotation = m_ActiveView.ScreenDisplay.DisplayTransformation.Rotation
EndIfEndSub