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 />

2. Create a new function called CreateOverviewSymbol. This is where you will<br />

create the symbol used in the MapControl to represent the extent of the data<br />

in the focus map of the PageLayoutControl. Add the following code to the<br />

function.<br />

private void CreateOverviewSymbol()<br />

{<br />

// Get the IRgbColor interface.<br />

IRgbColor color = new RgbColor();<br />

// Set the color properties.<br />

color.RGB = 255;<br />

// Get the ILine symbol interface.<br />

ILineSymbol outline = new SimpleLineSymbol();<br />

// Set the line symbol properties.<br />

outline.Width = 1.5;<br />

outline.Color = color;<br />

// Get the IFillSymbol interface.<br />

ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();<br />

// Set the fill symbol properties.<br />

simpleFillSymbol.Outline = outline;<br />

simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;<br />

m_FillSymbol = simpleFillSymbol;<br />

}<br />

3. Call the CreateOverviewSymbol function from the Form_Load event before<br />

the TOCControl label editing code.<br />

private void Form1_Load(object sender, System.EventArgs e)<br />

{<br />

// Create symbol used on the MapControl.<br />

CreateOverviewSymbol();<br />

}<br />

// Set label editing to manual…<br />

4. Add the following OnVisibleBoundsUpdated function. This function will be<br />

linked to an event raised whenever the extent of the map is changed and is<br />

used to set the envelope to the new visible bounds of the map. By refreshing<br />

the MapControl you force it to redraw the shape on its display.<br />

private void OnVisibleBoundsUpdated(IDisplayTransformation sender, bool<br />

sizeChanged)<br />

{<br />

// Set the extent to the new visible extent.<br />

m_Envelope = sender.VisibleBounds;<br />

// Refresh the MapControl's foreground phase.<br />

axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.<br />

esriViewForeground, null, null);<br />

}<br />

5. The default event interface of the PageLayoutControl is the<br />

IPageLayoutControlEvents. These events do not tell you when the extent of<br />

the map within the data frame changes. To enable this functionality you will<br />

Chapter 6 • <strong>Developer</strong> scenarios • 345

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

Saved successfully!

Ooh no, something went wrong!