GIS软件设计与实现程序说明组员:王兴平、邵瑞王平凯班级:测绘1103班指导老师:李光强2015/1/5一、小组成员表:姓名学号工作内容评分王平凯0145110616资料查找与程序测试,借阅AE组件开发的相关教程邵瑞0145110617软件功能设计,界面设计王兴平0145110620程序编写与调试二、程序功能概述本程序的功能有:1.实现一次加载多个shp文件;2.使用ITOCControl接口,对TOC控件中的图层显示顺序进行调整;3.实现鹰眼功能;以上为已经经过测试,实现了的功能,相关功能截图:1.软件设计界面2.加载shp文件3.图层顺序调整4.鹰眼功能程序相关代码:publicForm1(){InitializeComponent();}///summary///声明窗体层全局变量////summaryITOCControlmTOCControl;ILayerpMovelayer;//需要调整显示顺序的图层inttoIndex;//存放目标图层的索引///summary///实现同时加载多个shp文件////summary///paramname=sender/param///paramname=e/paramprivatevoidLoadFile_Click(objectsender,EventArgse){OpenFileDialogdlg=newOpenFileDialog();dlg.Filter=Shapefile(*.shp)|*.shp;dlg.Title=打开Shape数据文档;dlg.Multiselect=true;//定义存放打开IFeatureClass的字符串数组string[]FilePath;if(dlg.ShowDialog()==DialogResult.OK){FilePath=newstring[dlg.FileNames.Length];FilePath=dlg.FileNames;if(FilePath.Length0){stringWorkSpacePath=System.IO.Path.GetDirectoryName(FilePath[0]);string[]ShapeFilePath=newstring[FilePath.Length];//获得打开IFeatureClass的字符串数组for(inti=0;iFilePath.Length;i++){ShapeFilePath[i]=System.IO.Path.GetFileName(FilePath[i]);}IWorkspaceFactorypWorkspaceFactory=newShapefileWorkspaceFactoryClass();IWorkspacepWorkspace=pWorkspaceFactory.OpenFromFile(WorkSpacePath,0);IFeatureWorkspacepFeatureWorkspace=pWorkspaceasIFeatureWorkspace;for(inti=0;iShapeFilePath.Length;i++){IFeatureClasspFeatureClass=pFeatureWorkspace.OpenFeatureClass(ShapeFilePath[i]);IDatasetpDataset=pFeatureClassasIDataset;IFeatureLayerpFeatureLayer=newFeatureLayerClass();pFeatureLayer.FeatureClass=pFeatureClass;pFeatureLayer.Name=pDataset.Name;ILayerpLayer=pFeatureLayerasILayer;this.axMapControl1.Map.AddLayer(pLayer);this.axMapControl2.Map.AddLayer(pLayer);}}}}///summary///实现地图的鹰眼功能////summary///paramname=sender/param///paramname=e/paramprivatevoidaxMapControl1_OnMapReplaced(objectsender,ESRI.ArcGIS.Controls.IMapControlEvents2_OnMapReplacedEvente){IMappMap;pMap=axMapControl1.Map;for(inti=0;ipMap.LayerCount;i++){axMapControl2.Map.AddLayer(pMap.get_Layer(i));}axMapControl2.Extent=axMapControl2.FullExtent;}//在鹰眼中移动红色矩形框时,axMapControl2中的地图范围要发生相应的变化privatevoidaxMapControl2_OnMouseDown(objectsender,ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvente){if(e.button==1)//探测鼠标左键{IPointpPt=newPointClass();pPt.X=e.mapX;pPt.Y=e.mapY;IEnvelopepEnvelope=axMapControl1.ExtentasIEnvelope;pEnvelope.CenterAt(pPt);axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null);}elseif(e.button==2)//鼠标右键功能:范围显示{IEnvelopepEnvelope=axMapControl2.TrackRectangle();axMapControl1.Extent=pEnvelope;axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null);}}///summary///当主视图的显示范围发生变化时,会触发空间的OnExtentUpdated事件////summary///paramname=sender/param///paramname=e/paramprivatevoidaxMapControl2_OnMouseMove(objectsender,ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvente){if(e.button!=1)return;IPointpPt=newPointClass();pPt.X=e.mapX;pPt.Y=e.mapY;axMapControl1.CenterAt(pPt);axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null);}///summary///绘制鹰眼中红色矩形框////summary///paramname=sender/param///paramname=e/paramprivatevoidaxMapControl1_OnExtentUpdated(objectsender,ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvente){IGraphicsContainerpGraphicsContainer=axMapControl2.MapasIGraphicsContainer;IActiveViewpAv=pGraphicsContainerasIActiveView;//在绘制前,清除axMapControl2中的任何图形pGraphicsContainer.DeleteAllElements();IRectangleElementpRecElement=newRectangleElementClass();IElementpEle=pRecElementasIElement;IEnvelopepEnv;pEnv=e.newEnvelopeasIEnvelope;pEle.Geometry=pEnv;//设置颜色IRgbColorpColor=newRgbColorClass();pColor.Red=200;pColor.Green=0;pColor.Blue=0;pColor.Transparency=255;//产生一个线符号对象ILineSymbolpLineSymbol=newSimpleLineSymbolClass();pLineSymbol.Width=2;pLineSymbol.Color=pColor;//设置填充符号的属性IFillSymbolpFillSymbol=newSimpleFillSymbolClass();//设置透明颜色pColor.Transparency=0;pFillSymbol.Color=pColor;pFillSymbol.Outline=pLineSymbol;IFillShapeElementpFillShapeElement=pRecElementasIFillShapeElement;pFillShapeElement.Symbol=pFillSymbol;pGraphicsContainer.AddElement(pEle,0);axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null);}//在窗体Form1_Load事件中对mTOCControl进行实例化privatevoidForm1_Load(objectsender,EventArgse){mTOCControl=axTOCControl1.ObjectasITOCControl;}///summary///实现axTOCControl的图层显示顺序调整////summary///paramname=sender/param///paramname=e/paramprivatevoidaxTOCControl1_OnMouseDown(objectsender,ITOCControlEvents_OnMouseDownEvente){esriTOCControlItemitem=esriTOCControlItem.esriTOCControlItemNone;if(e.button==1){IBasicMapmap=null;ILayerlayer=null;objectother=null;objectindex=null;mTOCControl.HitTest(e.x,e.y,refitem,refmap,reflayer,refother,refindex);if(layerisIAnnotationSublayer)return;else{pMovelayer=layer;}}}//图层顺序的调整privatevoidaxTOCControl1_OnMouseUp(objectsender,ITOCControlEvents_OnMouseUpEvente){if(e.button==1){esriTOCControlItemitem=esriTOCControlItem.esriTOCControlItemNone;IB