AxMapControl1 is the main control and axMapControl2 is the eagleeye control.
Clear Event Response
1. eagleeye map resource Loading
Copy codeThe Code is as follows: privatevoid axmapcontrolpoliconmapreplaced (object sender, IMapControlEvents2_OnMapReplacedEvent e)
{
// When the map of the master Map Display Control is changed, the map in the eagleeye will also be changed.
AxMapControl2.LoadMxFile (axMapControl1.DocumentFilename );
AxMapControl2.Extent = axMapControl2.FullExtent;
}
2. Draw an eagleeye rectangleCopy codeThe Code is as follows: private void axmapcontrolpoliconextentupdated (object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
{
// Get a new range
IEnvelope pEnv = (IEnvelope) e. newEnvelope;
IGraphicsContainer pGra = axMapControl2.Map as IGraphicsContainer;
IActiveView pAv = pGra as IActiveView;
// Clear any graphic elements in axMapControl2 before drawing
PGra. DeleteAllElements ();
IRectangleElement pRectangleEle = new RectangleElementClass ();
IElement pEle = pRectangleEle as IElement;
PEle. Geometry = pEnv;
// Set the red line in the eagleeye chart
IRgbColor pColor = new RgbColorClass ();
PColor. red= 255;
PColor. Green = 0;
PColor. Blue = 0;
PColor. Transparency = 255;
// Generate a line symbol object
ILineSymbol pOutline = new SimpleLineSymbolClass ();
POutline. Width = 2;
POutline. Color = pColor;
// Set the color attribute
PColor = new RgbColorClass ();
PColor. red= 255;
PColor. Green = 0;
PColor. Blue = 0;
PColor. Transparency = 0;
// Set the attributes of the fill symbol
IFillSymbol pFillSymbol = new SimpleFillSymbolClass ();
PFillSymbol. Color = pColor;
PFillSymbol. Outline = pOutline;
IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;
PFillShapeEle. Symbol = pFillSymbol;
PGra. AddElement (IElement) pFillShapeEle, 0 );
PAv. PartialRefresh (esriViewDrawPhase. esriViewGraphics, null, null );
}
3. InteractionCopy codeThe Code is as follows: private void axMapControl2_OnMouseDown (object sender, IMapControlEvents2_OnMouseDownEvent e)
{
IPoint pPt = new PointClass ();
PPt. PutCoords (e. mapX, e. mapY );
// Change the view range of the Main Control
AxMapControl1. CenterAt (pPt );
}