Hi, what im trying to do is to zoom 2 times, with 3 seconds pause between zooms. public void ZoomToLayerInTOC(ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument)
{
if (mxDocument == null)
{
return;
}
ESRI.ArcGIS.Carto.IActiveView activeView = mxDocument.ActiveView;
// Get the TOC
ESRI.ArcGIS.ArcMapUI.IContentsView IContentsView = mxDocument.CurrentContentsView;
ESRI.ArcGIS.Geometry.IEnvelope envelope = activeView.Extent;
// ESRI.ArcGIS.Geometry.IEnvelope envelope = activeView.Extent;
envelope.Expand(0.75, 0.75, true);
activeView.Extent = envelope;
activeView.Refresh();
System.Threading.Thread.Sleep(3000);
envelope.Expand(0.75, 0.75, true);
activeView.Extent = envelope;
activeView.Refresh();
System.Threading.Thread.Sleep(3000);
// Get the selected layer
System.Object selectedItem = IContentsView.SelectedItem;
if (!(selectedItem is ESRI.ArcGIS.Carto.ILayer))
{
return;
}
ESRI.ArcGIS.Carto.ILayer layer = selectedItem as ESRI.ArcGIS.Carto.ILayer;
// Zoom to the extent of the layer and refresh the map
activeView.Extent = layer.AreaOfInterest;
activeView.Refresh();
}
And after clicking button i get zoomed in after 6 seconds. Like there's no refresh after first zoom, although map scrollbars gets smaller.