ArcGISEngineC#实例开发教程代码

上传人:平*** 文档编号:11121730 上传时间:2017-10-12 格式:DOC 页数:134 大小:936.78KB
返回 下载 相关 举报
ArcGISEngineC#实例开发教程代码_第1页
第1页 / 共134页
ArcGISEngineC#实例开发教程代码_第2页
第2页 / 共134页
ArcGISEngineC#实例开发教程代码_第3页
第3页 / 共134页
ArcGISEngineC#实例开发教程代码_第4页
第4页 / 共134页
ArcGISEngineC#实例开发教程代码_第5页
第5页 / 共134页
点击查看更多>>
资源描述

《ArcGISEngineC#实例开发教程代码》由会员分享,可在线阅读,更多相关《ArcGISEngineC#实例开发教程代码(134页珍藏版)》请在金锄头文库上搜索。

1、Arcgis 二次开发常用源代码1.点上生成面的代码 if (m_pFeatureLayer.FeatureClass.ShapeType = esriGeometryType.esriGeometryPolygon) IPointCollection m_pPointCollection = new PolygonClass(); object missing = Type.Missing; int icount = newFeature.XLIST.Count; if (icount / Summary description for Form1. / public class SaveM

2、apDocument : System.Windows.Forms.Form public System.Windows.Forms.TextBox txtMapDocument; public System.Windows.Forms.Button cmdOpen; public System.Windows.Forms.Button cmdSave; public System.Windows.Forms.Button cmdSaveAs; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System

3、.Windows.Forms.SaveFileDialog saveFileDialog1; private IMapDocument m_MapDocument; private ESRI.ArcGIS.Controls.AxToolbarControl axToolbarControl1; private ESRI.ArcGIS.Controls.AxPageLayoutControl axPageLayoutControl1; private ESRI.ArcGIS.Controls.AxLicenseControl axLicenseControl1; private ESRI.Arc

4、GIS.Controls.AxTOCControl axTOCControl1; / / Required designer variable. / private System.ComponentModel.Container components = null; public SaveMapDocument() / / Required for Windows Form Designer support / InitializeComponent(); / / TODO: Add any constructor code after InitializeComponent call / /

5、 / Clean up any resources being used. / protected override void Dispose( bool disposing ) /Release COM objects ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown(); if( disposing ) if (components != null) components.Dispose(); base.Dispose( disposing ); #region Windows Form Designer generated code /

6、 / The main entry point for the application. / STAThread static void Main() Application.Run(new SaveMapDocument(); private void Form1_Load(object sender, System.EventArgs e) /Add toolbar definitions to the ToolbarControl axToolbarControl1.AddToolbarDef(esriControls.ControlsPageLayoutToolbar, -1, fal

7、se, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddToolbarDef(esriControls.ControlsGraphicElementToolbar, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); /Set buddy control axToolbarControl1.SetBuddyControl(axPageLayoutControl1); axTOCControl1.SetBuddyControl(axPageLa

8、youtControl1); cmdSave.Enabled = false; cmdSaveAs.Enabled = false; private void cmdOpen_Click(object sender, System.EventArgs e) /Open a file dialog for opening map documents openFileDialog1.Title = Open Map Document; openFileDialog1.Filter = Map Documents (*.mxd)|*.mxd; openFileDialog1.ShowDialog()

9、; / Exit if no map document is selected string sFilePath = openFileDialog1.FileName; if (sFilePath = ) return; /Open document OpenDocument(sFilePath); if (cmdSave.Enabled = false) cmdSave.Enabled = true; if (cmdSaveAs.Enabled = false) cmdSaveAs.Enabled = true; private void cmdSave_Click(object sende

10、r, System.EventArgs e) /Save changes to the current document SaveDocument(); private void cmdSaveAs_Click(object sender, System.EventArgs e) /Open a file dialog for saving map documents saveFileDialog1.Title = Save Map Document As; saveFileDialog1.Filter = Map Documents (*.mxd)|*.mxd; saveFileDialog

11、1.ShowDialog(); /Exit if no map document is selected string sFilePath = saveFileDialog1.FileName; if (sFilePath = ) return; if (sFilePath = m_MapDocument.DocumentFilename) /Save changes to the current document SaveDocument(); else /SaveAs a new document with relative paths m_MapDocument.SaveAs(sFile

12、Path, true, true); /Open document OpenDocument(sFilePath); MessageBox.Show(Document saved successfully!); private void OpenDocument(string sFilePath) if (m_MapDocument != null) m_MapDocument.Close(); /Create a new map document m_MapDocument = new MapDocumentClass(); /Open the map document selected m

13、_MapDocument.Open(sFilePath,); /Set the PageLayoutControl page layout to the map document page layout axPageLayoutControl1.PageLayout = m_MapDocument.PageLayout; txtMapDocument.Text = m_MapDocument.DocumentFilename; private void SaveDocument() /Check that the document is not read only if (m_MapDocum

14、ent.get_IsReadOnly(m_MapDocument.DocumentFilename) = true) MessageBox.Show(This map document is read only!); return; /Save with the current relative path setting m_MapDocument.Save(m_MapDocument.UsesRelativePaths,true); MessageBox.Show(Changes saved successfully!); 3.访问一个地图 static void OpenMXDViaMap

15、Document(string path) IMapDocument pMapDocument = new MapDocumentClass(); if (pMapDocument.get_IsMapDocument(path) pMapDocument.Open(path,null); IMap pMap; for (int i = 0; i / 新建地图命令 / / / private void New_Click(object sender, EventArgs e) / 本命令涉及到 MapControl 和 PageLayoutControl 同步问题,将在下一讲中实现 / / 打开地图文档 Mxd 命令 / / / private void Open_Click(object sender, EventArgs e) / 本命令涉及到 MapControl 和 PageLayoutControl 同步问题,将在下一讲中实现 / / 添加数据命令 / / / private void AddData_Click(object sender, EventArgs e) int currentLayerCount = this.axMapControl1.LayerCou

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

最新文档


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

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