为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

利用C#进行AO开发--实现地图文件的打开、保存和另存为功能 (

2011-06-12 4页 doc 27KB 33阅读

用户头像

is_503807

暂无简介

举报
利用C#进行AO开发--实现地图文件的打开、保存和另存为功能 (利用C#进行AO开发--实现地图文件的打开、保存和另存为功能 (2007-10-27 08:51:26) 利用C#进行AO开发--实现地图文件的打开、保存和另存为功能 (2007-10-27 08:51:26)   由于C#继承了VB界面开发的友好性,所以完全可以利用C#提供的友好界面开发功能来实现winform的程序开发,在安装好了ArcEngine以后就可以利用其提供的控件进行GIS的二次开发,在form窗体上添加MapControl控件,MenuStrip控件(File(Open、Save、SaveAs、Exit)),s...
利用C#进行AO开发--实现地图文件的打开、保存和另存为功能 (
利用C#进行AO开发--实现地图文件的打开、保存和另存为功能 (2007-10-27 08:51:26) 利用C#进行AO开发--实现地图文件的打开、保存和另存为功能 (2007-10-27 08:51:26)   由于C#继承了VB界面开发的友好性,所以完全可以利用C#提供的友好界面开发功能来实现winform的程序开发,在安装好了ArcEngine以后就可以利用其提供的控件进行GIS的二次开发,在form窗体上添加MapControl控件,MenuStrip控件(File(Open、Save、SaveAs、Exit)),saveFileDialog控件之后就可以进行编写代码,调试后的代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.Display; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Output; namespace openDocu {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         IMapDocument m_MapDcument;         //openFileDialog         private void LoadMapDocument()         {             m_MapDcument = new MapDocumentClass();             try             {                 //打开文件对话框选取MXD文件                 OpenFileDialog openFileDialog2;                 openFileDialog2 = new OpenFileDialog();                 openFileDialog2.Title = "Open Map Document";                 openFileDialog2.Filter = "Map Documents(*.mxd)|*.mxd";                 openFileDialog2.ShowDialog();                 string sFilePath = openFileDialog2.FileName;                 //将数据载入pMapDocument并与map控件联系起来                 m_MapDcument.Open(sFilePath, "");                 int i;                 for (i = 0; i <= m_MapDcument.MapCount - 1; i++)                 {                     //一个IMapDocument对象中可能有多个Map对象,遍历每个map对象                     axMapControl1.Map = m_MapDcument.get_Map(i);                 }                 //刷新地图                 axMapControl1.Refresh();             }             catch (Exception ex)             {                 MessageBox.Show(ex.ToString());             }                    }         //save map         private void SaveDocument()         {             //check that the document is not read only             if (m_MapDcument.get_IsReadOnly(m_MapDcument.DocumentFilename) == true)             {                 MessageBox.Show("The map document is read only!");                 return;             }             //save with the current relative path setting             m_MapDcument.Save(m_MapDcument.UsesRelativePaths,true);             MessageBox.Show("Change saved successfully!");                         }         //saveas         private void SaveAsDocument()         {             //open a file dialog for saving map document             saveFileDialog1.Title = "Sava Map Document As";             saveFileDialog1.Filter = "Map Documents(*.mxd)|*.mxd";             saveFileDialog1.ShowDialog();             //Exit if no map document is select             string sFilePath = saveFileDialog1.FileName;             if (sFilePath == "")             {                 return;             }             if (sFilePath == m_MapDcument.DocumentFilename)             {                 //Save change to the current document                 SaveDocument();             }             else             {                 //SaveAs a new docuemnt with relative paths                 m_MapDcument.SaveAs(sFilePath, true, true);                 //open document                 MessageBox.Show("Documnet saved successfully!");             }         }         private void openToolStripMenuItem_Click(object sender, EventArgs e)         {             LoadMapDocument();         }         private void exitToolStripMenuItem_Click(object sender, EventArgs e)         {             this.Close();         }         private void saveToolStripMenuItem_Click(object sender, EventArgs e)         {             SaveDocument();         }         private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)         {             SaveAsDocument();         }            } }
/
本文档为【利用C#进行AO开发--实现地图文件的打开、保存和另存为功能 (】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索