Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using ESRI. ArcGIS. CARTO;
Using ESRI. ArcGIS. display;
Using ESRI. ArcGIS. geometry;
Using ESRI. ArcGIS. controls;
/*
* The simple implementation of the eagleeye view is to display the area of the eagleeye view in the main view by dragging:
*/
Namespace Overview
{
Public partial class mainform: Form
{
# Region "interface initialization"
Public mainform ()
{
Initializecomponent ();
}
Private void mainform_load (Object sender, eventargs E)
{
Try
{
String strfilename = application. startuppath + @ "\ data \ Real Estate Planning Information System. mxd ";
// Load a map in the data view for query operations
If (axmapcontrol2.checkmxfile (strfilename ))
{
Axmapcontrol2.loadmxfile (strfilename );
}
Else
{
MessageBox. Show ("wrong data path:" + strfilename );
}
}
Catch (exception ex)
{
MessageBox. Show ("error01 in mainform. cs" + ex. Message );
}
}
# Endregion "interface initialization"
# Region "eagleeye map"
/* Implementation functions:
* 1. The eagleeye control generates a navigation field based on the view range of the Master Control.
* 2. Click the left button in the eagleeye control to move the widget. The red range will move with the mouse. The view range of the master control will move accordingly based on the location of the red range.
* 3. In the eagleeye control, you can right-click the mouse and drag it to generate a new red range to navigate
* The implementation steps are as follows (combined by multiple examples, write by Booker, 2008.4.12
*/
// 1. eagleeye map resource Loading
// When the data view document changes, load the document to the axmapcontrol1 map control of the eagleeye view.
Private void axmapcontrol2_onmapreplaced (Object sender, imapcontrolevents2_onmapreplacedevent E)
{
// Load the map document to mapcontrol
Axmapcontrol1.loadmxfile (axmapcontrol2.documentfilename, null, null );
// Set the display range of mapcontrol to the global range of data
Axmapcontrol1.extent = axmapcontrol1.fullextent;
}
// 2. Draw the eagleeye rectangle
Private void axmapcontrol2_onextentupdated (Object sender, ESRI. ArcGIS. Controls. imapcontrolevents2_onextentupdatedevent E)
{
// Get a new range
Ienvelope penv = (ienvelope) E. newenvelope;
Igraphicscontainer pgra = axmapcontrol1.map as igraphicscontainer;
Iactiveview pav = pgra as iactiveview;
// Clear any graphic elements in eagleeye axmapcontrol1 before painting
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 );
// Refresh
Pav. partialrefresh (esriviewdrawphase. esriviewgraphics, null, null );
}
// 3. Interaction
Private void axmapcontrolpoliconmousedown (Object sender, ESRI. ArcGIS. Controls. imapcontrolevents2_onmousedownevent E)
{
/*
Ipoint PPT = new pointclass ();
PPT. putcoords (E. MapX, E. mapy );
// Change the view range of the Main Control
Axmapcontrol2.centerat (PPT );
*/
If (E. Button = 1)
{
Ipoint PPT = new pointclass ();
PPT. x = E. MapX;
PPT. Y = E. mapy;
Ienvelope penvelope = This. axmapcontrol1.trackrectangle ();
This. axmapcontrol2.extent = penvelope;
}
}
Private void axmapcontrolpoliconmousemove (Object sender, ESRI. ArcGIS. Controls. imapcontrolevents2_onmousemoveevent E)
{
If (E. Button = 1)
{
Ipoint PPT = new pointclass ();
PPT. x = E. MapX;
PPT. Y = E. mapy;
//
Ienvelope penvelope = This. axmapcontrol2.extent as ienvelope;
Penvelope. centerat (PPT );
This. axmapcontrol2.extent = penvelope;
}
}
# Endregion "eagleeye map"
}
}