C # create detailed entire process (with comments) of eagleeye instance code

Source: Internet
Author: User

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 );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.