• C#+arcengine10.0+SP5实现鹰眼(加载的是mdb数据库中的数据)


    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.Controls;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.Geodatabase;
    using ESRI.ArcGIS.DataSourcesRaster;
    using DevComponents.DotNetBar;
    
    using System.Runtime.InteropServices;
    using ESRI.ArcGIS.ADF.BaseClasses;
    using ESRI.ArcGIS.ADF.CATIDs;
    using ESRI.ArcGIS.Carto;
    using ESRI.ArcGIS.Geometry;
    using ESRI.ArcGIS.Output;
    using ESRI.ArcGIS.SystemUI;
    using ESRI.ArcGIS.Display;
      private void btAddMdb_Click_1(object sender, EventArgs e)     //添加mdb数据库打开数据
            {
                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();   //加入地图到鹰眼里
                axMap.Refresh();
            }
    

      

     private void axMap_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)
            {        
                #region 添加鹰眼   载入地图到鹰眼控件
                AddLayerToOverViewMap();
                #endregion                   
            }
      #region 鹰眼功能
            /// <summary>
            /// 把地图加到鹰眼里的方法,
    ///该段代码摘自http://www.cnblogs.com/zya-gis/archive/2009/04/17/1438033.html,非常好用,解决了我鹰眼一直不能显示的问题
    /// </summary> private void AddLayerToOverViewMap() { axMapSmall.ClearLayers(); for (int i = 0; i < axMap.LayerCount; i++) { IObjectCopy objectcopy = new ObjectCopyClass(); object toCopyLayer = axMap.get_Layer(i); object copiedLayer = objectcopy.Copy(toCopyLayer); ILayer C = (new FeatureLayerClass()) as ILayer; object toOverwriteLayer = C; objectcopy.Overwrite(copiedLayer, ref toOverwriteLayer); axMapSmall.AddLayer(C, i); } } private void axMap_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) //绘制鹰眼矩形框 { try { //得到范围 IEnvelope pEnv = e.newEnvelope as IEnvelope; IGraphicsContainer pGraphicsContainer = axMapSmall.Map as IGraphicsContainer; IActiveView pActiveView = pGraphicsContainer as IActiveView; //在绘制新的矩形框前,清楚、清除Map对象中的任何图形元素 pGraphicsContainer.DeleteAllElements(); IRectangleElement pRectangleEle = new RectangleElementClass(); IElement pEle = pRectangleEle as IElement; pEle.Geometry = pEnv; IRgbColor pColor = new RgbColorClass(); pColor.RGB = 255; pColor.Transparency = 255; //产生一个线符号对象 ILineSymbol pOutLine = new SimpleLineSymbolClass(); pOutLine.Width = 1; pOutLine.Color = pColor; //设置颜色属性 pColor.RGB = 255; pColor.Transparency = 0; //设置填充符号的属性 IFillSymbol pFillsymbol = new SimpleFillSymbolClass(); pFillsymbol.Color = pColor; pFillsymbol.Outline = pOutLine; IFillShapeElement pFillshapEle; pFillshapEle = pEle as IFillShapeElement; pFillshapEle.Symbol = pFillsymbol; pEle = pFillshapEle as IElement; pGraphicsContainer.AddElement(pEle, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } catch (Exception ey) { } } private void axMapSmall_OnMouseDown(object sender, AxESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) //鹰眼与主 Map 控件互动 { if (this.axMapSmall.Map.LayerCount != 0) { // 按下鼠标左键移动矩形框 if (e.button == 1) { IPoint pPoint = new PointClass(); 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); } // 按下鼠标右键绘制矩形框 else if (e.button == 2) { IEnvelope pEnvelop = this.axMapSmall.TrackRectangle(); this.axMap.Extent = pEnvelop; this.axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } } } private void axMapSmall_OnMouseMove(object sender, AxESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e) //按下鼠标左键的时候移动矩形框,同时也改变主的图控件的显示范围 { // 如果不是左键按下就直接返回 if (e.button != 1) return; IPoint pPoint = new PointClass(); pPoint.PutCoords(e.mapX, e.mapY); this.axMap.CenterAt(pPoint); this.axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } #endregion 鹰眼功能完结

    放效果图一张:

  • 相关阅读:
    PAIP.MYSQL数据库比较
    paip.验证码识别----判断汉字还是英文
    SQLServer2008客户端软件
    paip.多个TOMCAT共存在一台主机上配置方法
    paip.银行卡号的发卡行归属地查询
    paip.获取当前实际北京时间API
    PAIP.HIBERNATE ORA02289 sequence does not exist的解决
    C51与汇编语言混合编程之一
    KEIL C51高级编程之二
    可重入函数与不可重入函数(转)
  • 原文地址:https://www.cnblogs.com/smilepeter/p/4608875.html
Copyright © 2020-2023  润新知