ArcEngine主要功能源码

上传人:平*** 文档编号:11121725 上传时间:2017-10-12 格式:DOCX 页数:53 大小:54.38KB
返回 下载 相关 举报
ArcEngine主要功能源码_第1页
第1页 / 共53页
ArcEngine主要功能源码_第2页
第2页 / 共53页
ArcEngine主要功能源码_第3页
第3页 / 共53页
ArcEngine主要功能源码_第4页
第4页 / 共53页
ArcEngine主要功能源码_第5页
第5页 / 共53页
点击查看更多>>
资源描述

《ArcEngine主要功能源码》由会员分享,可在线阅读,更多相关《ArcEngine主要功能源码(53页珍藏版)》请在金锄头文库上搜索。

1、using System;using System.IO;using System.Windows.Forms;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.DataSourcesFile;using ESRI.ArcGIS.DataSourcesGDB;using ESRI.ArcGIS.DataSourcesRaster;using ESRI.ArcGIS.Display;using ESRI.ArcGIS.esriSystem;using ESRI.ArcGIS.Geodatabase;using

2、 ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.SystemUI;namespace MapOperationpublic partial class FormMain : Form#region 变量定义/地图导出窗体private FormExportMap frmExpMap = null;/长度、面积量算private FormMeasureResult frmMeasureResult = null; /量算结果窗体private INewLineFeedback pNewLineFeedback; /追踪线对象private INewPolygonF

3、eedback pNewPolygonFeedback; /追踪面对象private IPoint pPointPt = null; /鼠标点击点private IPoint pMovePt = null; /鼠标移动时的当前点private double dToltalLength = 0; /量测总长度private double dSegmentLength = 0; /片段距离private IPointCollection pAreaPointCol = new MultipointClass() ; /面积量算时画的点进行存储; private string sMapUnits =

4、 未知单位; /地图单位变量private object missing = Type.Missing; /TOC菜单IFeatureLayer pTocFeatureLayer = null; /点击的要素图层private FormAtrribute frmAttribute = null; /图层属性窗体private ILayer pMoveLayer; /需要调整显示顺序的图层private int toIndex; /存放拖动图层移动到的索引号 /鹰眼同步private bool bCanDrag; /鹰眼地图上的矩形框可移动的标志private IPoint pMoveRectP

5、oint; /记录在移动鹰眼地图上的矩形框时鼠标的位置private IEnvelope pEnv; /记录数据视图的Extent#endregion#region 初始化public FormMain()InitializeComponent();axTOCControl.SetBuddyControl(mainMapControl);EagleEyeMapControl.Extent = mainMapControl.FullExtent;pEnv = EagleEyeMapControl.Extent;DrawRectangle(pEnv);#endregion#region 数据加载

6、#region LoadMxFile方法加载地图文档文件private void btnLoadMxFile_Click(object sender, EventArgs e)/加载数据前如果有数据则清空tryOpenFileDialog pOpenFileDialog = new OpenFileDialog();pOpenFileDialog.CheckFileExists = true;pOpenFileDialog.Title = 打开地图文档;pOpenFileDialog.Filter = ArcMap文档(*.mxd)|*.mxd;|ArcMap模板(*.mxt)|*.mxt|发

7、布地图文件(*.pmf)|*.pmf|所有地图格式(*.mxd;*.mxt;*.pmf)|*.mxd;*.mxt;*.pmf;pOpenFileDialog.Multiselect = false; /不允许多个文件同时选择pOpenFileDialog.RestoreDirectory = true; /存储打开的文件路径if (pOpenFileDialog.ShowDialog() = DialogResult.OK)string pFileName = pOpenFileDialog.FileName;if (pFileName = )return;if (mainMapControl

8、.CheckMxFile(pFileName) /检查地图文档有效性ClearAllData();mainMapControl.LoadMxFile(pFileName);elseMessageBox.Show(pFileName + 是无效的地图文档!, 信息提示);return;catch (Exception ex) MessageBox.Show(打开地图文档失败 + ex.Message);#endregion#region IMapDocument方法加载Mxd文档文件private void btnIMapDocument_Click(object sender, EventAr

9、gs e)tryOpenFileDialog pOpenFileDialog = new OpenFileDialog();pOpenFileDialog.CheckFileExists = true;pOpenFileDialog.Title = 打开地图文档;pOpenFileDialog.Filter = ArcMap文档(*.mxd)|*.mxd;|ArcMap模板(*.mxt)|*.mxt|发布地图文件(*.pmf)|*.pmf|所有地图格式(*.mxd;*.mxt;*.pmf)|*.mxd;*.mxt;*.pmf;pOpenFileDialog.Multiselect = fals

10、e;pOpenFileDialog.RestoreDirectory = true;if (pOpenFileDialog.ShowDialog() = DialogResult.OK)string pFileName = pOpenFileDialog.FileName;if (pFileName = )return;if (mainMapControl.CheckMxFile(pFileName) /检查地图文档有效性/将数据载入pMapDocument并与Map控件关联IMapDocument pMapDocument = new MapDocument();/using ESRI.Ar

11、cGIS.Carto;pMapDocument.Open(pFileName, );/获取Map中激活的地图文档mainMapControl.Map = pMapDocument.ActiveView.FocusMap;mainMapControl.ActiveView.Refresh();else MessageBox.Show(pFileName + 是无效的地图文档!, 信息提示);return;catch (Exception ex)MessageBox.Show(打开地图文档失败 + ex.Message);#endregion#region ControlsOpenDocComma

12、ndClass加载地图private void btncontrolsOpenDocCommandClass_Click(object sender, EventArgs e)ICommand command = new ControlsOpenDocCommandClass();command.OnCreate(mainMapControl.Object);command.OnClick();#endregion#region 加载Shape文件private void btnAddShapefile_Click(object sender, EventArgs e)/ClearAllDat

13、a();tryOpenFileDialog pOpenFileDialog = new OpenFileDialog();pOpenFileDialog.CheckFileExists = true;pOpenFileDialog.Title = 打开Shape文件;pOpenFileDialog.Filter = Shape文件(*.shp)|*.shp;pOpenFileDialog.ShowDialog();/获取文件路径/FileInfo pFileInfo = new FileInfo(pOpenFileDialog.FileName); /string pPath = pOpenF

14、ileDialog.FileName.Substring(0, pOpenFileDialog.FileName.Length - pFileInfo.Name.Length);/mainMapControl.AddShapeFile(pPath, pFileInfo.Name);IWorkspaceFactory pWorkspaceFactory;IFeatureWorkspace pFeatureWorkspace;IFeatureLayer pFeatureLayer;string pFullPath = pOpenFileDialog.FileName;if (pFullPath =

15、 ) return;int pIndex = pFullPath.LastIndexOf();string pFilePath = pFullPath.Substring(0, pIndex); /文件路径string pFileName = pFullPath.Substring(pIndex + 1); /文件名/实例化ShapefileWorkspaceFactory工作空间,打开Shape文件pWorkspaceFactory = new ShapefileWorkspaceFactory();pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(pFilePath, 0);/创建并实例化要素集IFeatureClass pFeatureClass

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号