AE二次开发C#语言鹰眼图的实现

28 篇文章 16 订阅
24 篇文章 44 订阅

AE二次开发C#语言鹰眼图的实现

我的开发环境为ArcGIS Engine 10.2与Visual studio2010,主地图名称为axMapControl1,鹰眼图名称为axMapControl2。如果名称变动则需要修改(注意相关事件的添加与动态链接库的导入)!界面设计
实现代码:

private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e) 
{ 
	// 当主地图显示控件的地图更换时,鹰眼中的地图也跟随更换 
	this.axMapControl2.Map = new Map (); 
	// 添加主地图控件中的所有图层到鹰眼控件中 
    for (int i = 1; i <= this.axMapControl1.LayerCount; i++) 
    { 
        axMapControl2.AddLayer(axMapControl1.get_Layer(this.axMapControl1.LayerCount - i)); 
    } 
	// 设置 MapControl 显示范围至数据的全局范围 
	axMapControl2.Extent = axMapControl1.FullExtent; 
	// 刷新鹰眼控件地图 
	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;
            // 在绘制前,清除 axMapControl2 中的任何图形元素 
            pGra.DeleteAllElements();
            IRectangleElement pRectangleEle = new RectangleElement() as IRectangleElement;
            IElement pEle = pRectangleEle as IElement;
            pEle.Geometry = pEnv;
            // 设置鹰眼图中的红线框 
            IRgbColor pColor = new RgbColor();
            pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0;
            pColor.Transparency = 255;
            // 产生一个线符号对象 
            ILineSymbol pOutline = new SimpleLineSymbol();
            pOutline.Width = 2;
            pOutline.Color = pColor;
            // 设置颜色属性 
            pColor = new RgbColor();
            pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0;
            pColor.Transparency = 0;
            // 设置填充符号的属性 
            IFillSymbol pFillSymbol = new SimpleFillSymbol();
            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);

}

private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) 
{ 
    if (this.axMapControl2.Map.LayerCount != 0) 
    { 
        // 按下鼠标左键移动矩形框 
        if (e.button == 1) 
        { 
        IPoint pPoint = new ESRI.ArcGIS.Geometry.Point(); 
        pPoint.PutCoords(e.mapX, e.mapY); 
        IEnvelope pEnvelope = this.axMapControl1.Extent; 
        pEnvelope.CenterAt(pPoint); 
        this.axMapControl1.Extent = pEnvelope; 
        // PartialRefresh() 局部刷新以减少闪烁
        this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); 
    } 
    // 按下鼠标右键绘制矩形框 
    else if (e.button == 2) 
    { 
        IEnvelope pEnvelop = this.axMapControl2.TrackRectangle(); 
        this.axMapControl1.Extent = pEnvelop; 
        this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); 
    } 
} 
}

private void axMapControl2_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) 
{ 
    // 如果不是左键按下就直接返回 
    if (e.button != 1) return; 
    IPoint pPoint = new ESRI.ArcGIS.Geometry.Point (); 
    pPoint.PutCoords(e.mapX, e.mapY); 
    this.axMapControl1.CenterAt(pPoint); 
    this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); 
}

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值