AxMapControl1 is the main map axMapControl2 is the EagleEye map
1 private void axmapcontrolpoliconextentupdated (object sender, IMapControlEvents2_OnExtentUpdatedEvent e) 2 {3 // Obtain the current range of the map (envelope) 4 IEnvelope pEnvelope = (IEnvelope) e. newEnvelope; 5 // Set the EagleEye map as a geographical container and then the activity View 6 IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer; 7 IActiveView pActiveView = pGraphicsContainer as IActiveView; 8 // clear any graphic element in the EagleEye map 9 pGraphicsContainer. deleteAllElements (); 10 // Set the rectangle range to 11 IRectangleElement pRectangeEle = new RectangleElementClass (); 12 IElement pElement = pRectangeEle as IElement; 13 pElement. geometry = pEnvelope; 14 15 // create the Red Line box in the EagleEye Chart 16 IRgbColor pColor = new RgbColor (); 17 pColor. red= 255; 18 pColor. blue = 0; 19 pColor. green = 0; 20 pColor. transparency = 255; 21 22 // create line symbol object 23 ILineSymbol pOutline = new SimpleLineSymbolClass (); 24 pOutline. width = 3; 25 pOutline. color = pColor; 26 27 // set the Color attribute 28 pColor = new RgbColorClass (); 29 pColor. red= 255; 30 pColor. blue = 0; 31 pColor. green = 0; 32 pColor. transparency = 0; 33 34 // Set the fill symbol 35 IFillSymbol pFillSymbol = new SimpleFillSymbolClass (); 36 pFillSymbol. color = pColor; 37 pFillSymbol. outline = pOutline; 38 39 IFillShapeElement pFillShapeEle = pElement as IFillShapeElement; 40 pFillShapeEle. symbol = pFillSymbol; 41 42 pGraphicsContainer. addElement (IElement) pFillShapeEle, 0); 43 pActiveView. partialRefresh (esriViewDrawPhase. esriViewGraphics, null, null); 44} 45 46 private void axmapcontrolpoliconmapreplaced (object sender, subject e) 47 {48 if (axMapControl1.LayerCount> 0) 49 {50 axMapControl2.Map = new MapClass (); 51 for (int I = 0; I <= axMapControl1.LayerCount-1; I ++) 52 {53 axMapControl2.Map. addLayer (axMapControl1.Map. get_Layer (I); 54} 55 axMapControl2.Extent = axMapControl1.Extent; 56 axMapControl2.Refresh (); 57} 58 // axMapControl2.LoadMxFile (axMapControl1.DocumentFilename); 59 // controls (); 60 // axMapControl2.Extent = axMapControl2.FullExtent; 61} 62 63 private void axMapControl2_OnMouseMove (object sender, IMapControlEvents2_OnMouseMoveEvent e) 64 {65 if (e. button = 1) 66 {67 IPoint pPoint = new PointClass (); 68 pPoint. putCoords (e. mapX, e. mapY); 69 axMapControl1.CenterAt (pPoint); 70 axMapControl1.ActiveView. partialRefresh (esriViewDrawPhase. esriViewGeography, null, null); 71} 72} 73 74 private void axMapControl2_OnMouseDown (object sender, IMapControlEvents2_OnMouseDownEvent e) 75 {76 if (axMapControl2.Map. layerCount> 0) 77 {78 if (e. button = 1) 79 {80 IPoint pPoint = new PointClass (); 81 pPoint. putCoords (e. mapX, e. mapY); 82 axMapControl1.CenterAt (pPoint); 83 axMapControl1.ActiveView. partialRefresh (esriViewDrawPhase. esriViewGeography, null, null); 84} 85 else86 {87 IEnvelope pEnv = axMapControl2.TrackRectangle (); 88 axMapControl1.Extent = pEnv; 89 axMapControl1.ActiveView. partialRefresh (esriViewDrawPhase. esriViewGeography, null, null); 90} 91 92} 93}
Add EagleEye to ArcGIS