18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING APPLICATIONS WITH WINDOWS CONTROLS<br />

use the ITransformEvents interface of the PageLayoutControl focus map. Add<br />

the following code to the PageLayoutControl_OnPageLayoutReplaced event<br />

handler directly above the load document code.<br />

private void axPageLayoutControl1_OnPageLayoutReplaced(object sender,<br />

ESRI.<strong>ArcGIS</strong>.PageLayoutControl.IPageLayoutControlEvents_OnPageLayoutReplacedEvent<br />

e)<br />

{<br />

// Get the IActiveView of the focus map in the PageLayoutControl.<br />

IActiveView activeView = (IActiveView)<br />

axPageLayoutControl1.ActiveView.FocusMap;<br />

// Trap the ITransformEvents of the PageLayoutControl's focus map.<br />

visBoundsUpdatedE = new<br />

ITransformEvents_VisibleBoundsUpdatedEventHandler(OnVisibleBoundsUpdated);<br />

((ITransformEvents_Event)activeView.ScreenDisplay.<br />

DisplayTransformation).VisibleBoundsUpdated += visBoundsUpdatedE;<br />

// Get the extent of the focus map.<br />

m_Envelope = activeView.Extent;<br />

// Load the same preauthored map document into the MapControl.<br />

axMapControl1.LoadMxFile(axPageLayoutControl1.DocumentFilename,null,<br />

null);<br />

// Set the extent of the MapControl to the full extent of the data.<br />

axMapControl1.Extent = axMapControl1.FullExtent;<br />

}<br />

6. Display the form in design mode and select axMapControl1 from the Properties<br />

window and display the axMapControl events. Double-click<br />

OnAfterDraw to add an event handler to the code window.<br />

7. Add the following code to the axMapControl_OnAfterDraw event handler to<br />

draw the envelope with the symbol you created earlier onto the MapControl’s<br />

display.<br />

private void axMapControl1_OnAfterDraw(object sender,<br />

ESRI.<strong>ArcGIS</strong>.MapControl.IMapControlEvents2_OnAfterDrawEvent e)<br />

{<br />

if (m_Envelope == null)<br />

{<br />

return;<br />

}<br />

// If the foreground phase has drawn<br />

esriViewDrawPhase viewDrawPhase = (esriViewDrawPhase) e.viewDrawPhase;<br />

if (viewDrawPhase == esriViewDrawPhase.esriViewForeground)<br />

{<br />

IGeometry geometry = m_Envelope;<br />

axMapControl1.DrawShape(geometry, ref m_FillSymbol);<br />

}<br />

}<br />

346 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!