




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
ArcEngine 鹰眼的实现using System;using System.Collections.Generic;using System.Text;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.Display;namespace ArcEngineCommon.Controlspublic class MapMapControlEagle/记录层的内容以及次序(使用字典)private System.Collections.Generic.Dictionary _layerLog;/地图的主显示控件private AxMapControl _mapControlMain;/地图的鹰眼显示控件private AxMapControl _mapControlEagle;/Activeview操作对象private ActiveView _activeView;/渲染的样式private IFillSymbol _fillSymbol;/记录移动的个数,为移动过程中显示红框用。private int _moveCount = 0;/标识是否在拖动private bool _isTrackingSmallViewer = false;/红色的框范围private IEnvelope _envelope;/鹰眼小地图的红框private IMoveEnvelopeFeedback _smallViewerEnvelope;/拖动时鼠标落点private IPoint _smallViewerMouseDownPt;/ / 鹰眼显示程序/ / 主地图显示控件/ 鹰眼地图显示控件public MapMapControlEagle(AxMapControl pMapControlMain, AxMapControl pMapControlEagle)this._mapControlMain = pMapControlMain;this._mapControlEagle = pMapControlEagle;this._layerLog = new Dictionary();this._activeView = new ActiveView(this._mapControlEagle.ActiveView);/注册地图主控件视图范围更新事件this._mapControlMain .OnExtentUpdated +=new IMapControlEvents2_Ax_OnExtentUpdatedEventHandler(this.axMapControlMian_OnExtentUpdated);/注册地图主控件视图数据更新事件this._mapControlMain.OnAfterScreenDraw += new IMapControlEvents2_Ax_OnAfterScreenDrawEventHandler(this.axMapControl_OnAfterScreenDraw);/注册鹰眼地图控件的点击居中this._mapControlEagle .OnMouseDown +=new IMapControlEvents2_Ax_OnMouseDownEventHandler(this.axMapControl2_OnMouseDown);this._mapControlEagle .OnMouseMove +=new IMapControlEvents2_Ax_OnMouseMoveEventHandler(this.axMapControl2_OnMouseMove);this._mapControlEagle .OnMouseUp +=new IMapControlEvents2_Ax_OnMouseUpEventHandler(this.axMapControl2_OnMouseUp);/当地图主控件视图范围刷新时触发private void axMapControlMian_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)/得到地图主控件新的显示范围IEnvelope myEnvelope = e.newEnvelope as IEnvelope;/清除鹰眼地图显示控件上面的所有的元素this._mapControlEagle.ActiveView.GraphicsContainer.DeleteAllElements();/定义要画到鹰眼控件上面的元素对象IRectangleElement myRectangeElement = new RectangleElementClass();IElement myElemnet = myRectangeElement as IElement;myElemnet.Geometry = myEnvelope;this._envelope =myEnvelope ;/定义颜色IRgbColor myRgbColor = new RgbColorClass();myRgbColor.Red = 255;myRgbColor.Green = 0;myRgbColor.Blue = 0;/设置外边线ILineSymbol myLineSymbol = new SimpleLineSymbolClass();myLineSymbol.Color = myRgbColor as IColor;myLineSymbol.Width = 1.5;/设置矩形内部渲染样式IRgbColor myFillColor=new RgbColorClass ();myFillColor .Transparency =0;IFillSymbol myFillSymbol = new SimpleFillSymbolClass();myFillSymbol.Color = myFillColor as IColor;myFillSymbol.Outline = myLineSymbol;IFillShapeElement myFillShapeelment = myRectangeElement as IFillShapeElement;myFillShapeelment.Symbol = myFillSymbol;this._fillSymbol = myFillSymbol;/把设置好的元素添加到鹰眼地图上面this._mapControlEagle.ActiveView.GraphicsContainer.AddElement(myElemnet,0);this._mapControlEagle.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);/当mapControl数据发生变化重绘时触发(主要是用来判断层的添加,删除以及次序变化)private void axMapControl_OnAfterScreenDraw(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnAfterScreenDrawEvent e)/如果不一致,就刷新鹰眼地图if (!this.CompareLayers(this._layerLog, this._mapControlMain.ActiveView.FocusMap)/记录当前图层记录this.LogLayers(this._layerLog, this._mapControlMain.ActiveView.FocusMap);/刷新鹰眼层配置this._activeView.SetFocusMap(this._mapControlMain.ActiveView.FocusMap);/全图this._mapControlEagle.ActiveView.Extent = this._mapControlEagle.ActiveView.FullExtent;this._mapControlEagle.ActiveView.Refresh();/地图控件点击居中,主要是针对鹰眼地图设计private void axMapControl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)AxMapControl myAxMapControl = (AxMapControl)sender;IPoint myPoint = new PointClass();myPoint.X = e.mapX;myPoint.Y = e.mapY;myAxMapControl.CenterAt(myPoint);myAxMapControl.ActiveView.Refresh();/比较记录层和当前层是否一致private bool CompareLayers(System.Collections.Generic.Dictionary pLayerLog, IMap pMap)/先判断数量if (pLayerLog.Count != pMap.LayerCount)return false;/再判断对象是否一致,包括顺序for (int i = 0; i pMap.LayerCount; i+)ILayer myLogLayer = null;/如果找不到指定位置的层对象if (!pLayerLog.TryGetValue(i,out myLogLayer)return false;else/如果找到,就判断层引用是否指向的同一对象if (myLogLayer != pMap.get_Layer(i)return false;return true;/把层记录到层记录中,顺序好主地图顺序一致private void LogLayers(System.Collections.Generic.Dictionary pLayerLog, IMap pMap)pLayerLog .Clear ();for (int i = 0; i pMap.LayerCount; i+)pLayerLog.Add(i, pMap.get_Layer(i);/this._axMapControlEagle中的事件/鹰眼互动/鼠标在鹰眼上按下触发private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)this._smallViewerMouseDownPt = new PointClass();this._smallViewerMouseDownPt.PutCoords(e.mapX, e.mapY);this._mapControlMain.CenterAt(_smallViewerMouseDownPt);this._isTrackingSmallViewer = true;if (this._smallViewerEnvelope = null)this._smallViewerEnvelope = new MoveEnvelopeFeedbackClass();this._smallViewerEnvelope.Display = this._mapControlEagle.ActiveView.ScreenDisplay;this._smallViewerEnvelope.Symbol = (ISymbol)this._fillSymbol;this._smallViewerEnvelope.Start(_envelope, this._smallViewerMouseDownPt);/鼠标移动触发private void axMapControl2_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)if (this._isTrackingSmallViewer)this._moveCount+;if (this._moveCount % 5 = 0)this._mapControlEagle.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);this._smallViewerMouseDownPt.PutCoords(e.mapX, e.mapY);this._smallViewerEnvelope.MoveTo(this._smallViewerMouseDownPt);/鼠标按键弹起触发private void axMapControl2_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e)if (this._smallViewerEnvelope != null)this._envelope =this._smallViewerEnvelope.Stop();this._mapControlMain.Extent = _envelope;this._isTrackingSmallViewer = false;C#制作鹰眼全过程(带注释)axMapControl1是主控件,axMapControl2是鹰眼控件要看清楚事件响应1.鹰眼地图资源载入private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)/当主地图显示控件的地图更换时,鹰眼中的地图也跟随更换axMapControl2.LoadMxFile(axMapControl1.DocumentFilename);axMapControl2.Extent = axMapControl2.FullExtent;2.绘制鹰眼矩形框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 RectangleElementClass();IElement pEle = pRectangleEle as IElement;pEle.Geometry = pEnv;/设置鹰眼图中的红线框IRgbColor pColor = new RgbColorClass();pColor.Red = 255;pColor.Green = 0;pColor.Blue = 0;pColor.Transparency = 255;/产生一个线符号
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 延边大学《城市设计Ⅰ》2023-2024学年第二学期期末试卷
- 四川省成都经开区实验高级中学2025届高考模拟调研卷数学试题(一)含解析
- 江苏省盐城市东台实验中学2025年中考抽测语文试题样题(A卷)试卷含解析
- 武夷学院《细胞生物学实验》2023-2024学年第一学期期末试卷
- 辽宁省抚顺市清原县2025年数学三下期末统考试题含解析
- 上海市金山区金山中学2025届高三期末试题含解析
- 江苏省丹阳市2025年校初三4月考语文试题含解析
- 重庆第二师范学院《多媒体制作》2023-2024学年第一学期期末试卷
- 泰州学院《外科学各论》2023-2024学年第二学期期末试卷
- 闽南理工学院《隧道工程(B)》2023-2024学年第二学期期末试卷
- 《颈椎病的针灸治疗》课件
- 《木兰诗》历年中考古诗欣赏试题汇编(截至2024年)
- 2024年音乐节行业发展前景预测及投资策略研究报告
- 2024西部县域经济百强研究
- 2025-2030年中国IPTV产业行业发展趋势及前景调研分析报告
- 国企改革三年行动培训
- 医美诊所院感知识培训课件
- 上海市家庭居室装饰装修施工合同书
- 物联网技术及应用基础(第2版) -电子教案
- 新能源汽车租赁市场发展方案
- 货架回收合同范例
评论
0/150
提交评论