using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.SystemUI;
namespace GIS_Demo1
{
public partial class MainFrm : Form
{
public IMapControl2 pMapControl;
public IMap pMap;
public MainFrm()
{
InitializeComponent();
}
private void MainFrm_Load(object sender, EventArgs e)
{
pMapControl = (IMapControl2)axMapControl1.Object;
}
private void Exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void axMapControl1_OnMapReplaced(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMapReplacedEvent e)
{
//當(dāng)主地圖中更換地圖時(shí),鷹眼中的地圖也更換
this.axMapControl2.Map = new MapClass();
//添加主地圖中的所有圖層到鷹眼地圖控件中
for (int i = 1; i <= axMapControl1.LayerCount; i++)
{
axMapControl2.AddLayer(this.axMapControl1.get_Layer(this.axMapControl1.LayerCount - i));
}
//設(shè)置鷹眼顯示范圍至數(shù)據(jù)的全局范圍
this.axMapControl2.Extent = axMapControl1.FullExtent;
//刷新鷹眼地圖控件
this.axMapControl2.Refresh();
}
private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
{
//得到新范圍
IEnvelope pEnv = (IEnvelope)e.newEnvelope;
IGraphicsContainer pGra = axMapControl2.Map as IGraphicsContainer;
IActiveView pAv = pGra as IActiveView;
//重新繪制前,清除之前繪制的圖形元素
pGra.DeleteAllElements();
IRectangleElement pRectangleEle = new RectangleElementClass();
IElement pEle = pRectangleEle as IElement;
pEle.Geometry = pEnv;
//設(shè)置鷹眼中的紅線(xiàn)框
IRgbColor pColor = new RgbColorClass();
pColor.Red = 255;
pColor.Green = 0;
pColor.Blue = 0;
pColor.Transparency = 255;
//產(chǎn)生一個(gè)線(xiàn)符號(hào)對(duì)象
ILineSymbol pOutline = new SimpleLineSymbolClass();
pOutline.Width = 2;
pOutline.Color = pColor;
//設(shè)置填充對(duì)象的顏色屬性
pColor = new RgbColorClass();