usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingESRI. Arcgis.controls;usingESRI. Arcgis.esrisystem;usingESRI. Arcgis.geodatabase;usingESRI. Arcgis.datasourcesraster;usingDevcomponents.dotnetbar;usingSystem.Runtime.InteropServices;usingESRI. ArcGIS.ADF.BaseClasses;usingESRI. ArcGIS.ADF.CATIDs;usingESRI. Arcgis.carto;usingESRI. Arcgis.geometry;usingESRI. Arcgis.output;usingESRI. Arcgis.systemui;usingESRI. Arcgis.display;
private void Btaddmdb_click_1 (object sender, EventArgs e) //Add MDB database Open Data { OpenFileDialog dlg = new OpenFileDialog (); Dlg. Filter = "Personal geodatabase (*.mdb) |*.mdb| All Files (*. *) |*.* "; Dlg. Title = "Open persongeodatabase file"; if (dlg. ShowDialog ()! = DialogResult.OK) return; Commonfun.load_mdb (dlg. FileName, axmap); Addlayertooverviewmap (); Add map to Eagle Eye Axmap.refresh (); }
Private void axmap_onmapreplaced (object sender, imapcontrolevents2_onmapreplacedevent e) { #region add Hawkeye to load the map into the Eagle Eye control addlayertooverviewmap () ; #endregion }
#regionEagle Eye function/// <summary> ///The way to add a map to the Eagle's eye,
//// This code is from http://www.cnblogs.com/zya-gis/archive/2009/04/17/1438033.html, very easy to use, solved my eagle eye has been unable to display the problem /// </summary> Private voidAddlayertooverviewmap () {axmapsmall.clearlayers (); for(inti =0; i < Axmap.layercount; i++) {iobjectcopy objectcopy=NewObjectcopyclass (); ObjectTocopylayer =Axmap.get_layer (i); ObjectCopiedlayer =objectcopy. Copy (Tocopylayer); ILayer C= (NewFeaturelayerclass ()) asILayer; ObjectTooverwritelayer =C; Objectcopy. Overwrite (Copiedlayer,refTooverwritelayer); Axmapsmall.addlayer (C, i); } } Private voidAxmap_onextentupdated (Objectsender, Imapcontrolevents2_onextentupdatedevent e)//draw the Eagle's eye rectangular box { Try { //Get RangeIenvelope penv = E.newenvelope asIenvelope; Igraphicscontainer Pgraphicscontainer= Axmapsmall.map asIgraphicscontainer; Iactiveview Pactiveview= Pgraphicscontainer asIactiveview; //clear and clear any graphic elements in the Map object before you draw a new rectangular boxpgraphicscontainer.deleteallelements (); Irectangleelement Prectangleele=NewRectangleelementclass (); IElement PEle= Prectangleele asielement; Pele.geometry=penv; Irgbcolor Pcolor=NewRgbcolorclass (); Pcolor.rgb=255; Pcolor.transparency=255; //produces a line symbol objectIlinesymbol Poutline =NewSimplelinesymbolclass (); Poutline.width=1; Poutline.color=Pcolor; //Set color PropertiesPcolor.rgb =255; Pcolor.transparency =0; //set the properties of a fill symbolIfillsymbol Pfillsymbol =NewSimplefillsymbolclass (); Pfillsymbol.color=Pcolor; Pfillsymbol.outline=Poutline; Ifillshapeelement Pfillshapele; Pfillshapele= PEle asifillshapeelement; Pfillshapele.symbol=Pfillsymbol; PEle= Pfillshapele asielement; Pgraphicscontainer.addelement (PEle,0); Pactiveview.partialrefresh (Esriviewdrawphase.esriviewgraphics,NULL,NULL); } Catch(Exception ey) {}}Private voidAxmapsmall_onmousedown (Objectsender, AxESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)//Eagle Eye interacts with the master Map control { if( This. axMapSmall.Map.LayerCount! =0) { //press the left mouse button to move the rectangle box if(E.button = =1) {IPoint ppoint=NewPointclass (); Ppoint.putcoords (E.MAPX, e.mapy); Ienvelope Penvelope= This. axmap.extent; Penvelope.centerat (PPoint); This. axmap.extent =Penvelope; This. AxMap.ActiveView.PartialRefresh (Esriviewdrawphase.esriviewgeography,NULL,NULL); } //Press the right mouse button to draw a rectangular box Else if(E.button = =2) {Ienvelope penvelop= This. Axmapsmall.trackrectangle (); This. axmap.extent =Penvelop; This. AxMap.ActiveView.PartialRefresh (Esriviewdrawphase.esriviewgeography,NULL,NULL); } } } Private voidAxmapsmall_onmousemove (Objectsender, AxESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e)//move the rectangle when the left mouse button is pressed, and also change the display range of the master graph control { //if it is not left-click, return directly if(E.button! =1)return; IPoint PPoint=NewPointclass (); Ppoint.putcoords (E.MAPX, e.mapy); This. Axmap.centerat (PPoint); This. AxMap.ActiveView.PartialRefresh (Esriviewdrawphase.esriviewgeography,NULL,NULL); } #endregionEagle Eye Function ends
Put a picture:
C#+ARCENGINE10.0+SP5 Implementation Eagle Eye (loading data from MDB database)