ArcGIS Engine開發模板及代碼

來源:互聯網
上載者:User

標籤:

       以下為AE開發軟體內建的模板及代碼,開發工具為VS 2012+ArcGIS Engine 10.2。


using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.IO;using System.Runtime.InteropServices;using ESRI.ArcGIS.esriSystem;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.ADF;using ESRI.ArcGIS.SystemUI;namespace MapControlApplication1{    public sealed partial class MainForm : Form    {        private IMapControl3 m_mapControl = null;        private string m_mapDocumentName = string.Empty;        public MainForm()        {            InitializeComponent();        }        private void MainForm_Load(object sender, EventArgs e)        {            //get the MapControl            m_mapControl = (IMapControl3)axMapControl1.Object;            //disable the Save menu (since there is no document yet)            menuSaveDoc.Enabled = false;        }        private void menuNewDoc_Click(object sender, EventArgs e)        {            //execute New Document command            ICommand command = new CreateNewDocument();            command.OnCreate(m_mapControl.Object);            command.OnClick();        }        private void menuOpenDoc_Click(object sender, EventArgs e)        {            //execute Open Document command            ICommand command = new ControlsOpenDocCommandClass();            command.OnCreate(m_mapControl.Object);            command.OnClick();        }        private void menuSaveDoc_Click(object sender, EventArgs e)        {            //execute Save Document command            if (m_mapControl.CheckMxFile(m_mapDocumentName))            {                //create a new instance of a MapDocument                IMapDocument mapDoc = new MapDocumentClass();                mapDoc.Open(m_mapDocumentName, string.Empty);                //Make sure that the MapDocument is not readonly                if (mapDoc.get_IsReadOnly(m_mapDocumentName))                {                    MessageBox.Show("Map document is read only!");                    mapDoc.Close();                    return;                }                //Replace its contents with the current map                mapDoc.ReplaceContents((IMxdContents)m_mapControl.Map);                //save the MapDocument in order to persist it                mapDoc.Save(mapDoc.UsesRelativePaths, false);                //close the MapDocument                mapDoc.Close();            }        }        private void menuSaveAs_Click(object sender, EventArgs e)        {            ICommand command = new ControlsSaveAsDocCommandClass();            command.OnCreate(m_mapControl.Object);            command.OnClick();        }        private void menuExitApp_Click(object sender, EventArgs e)        {            Application.Exit();        }        //listen to MapReplaced evant in order to update the statusbar and the Save menu        private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)        {            //get the current document name from the MapControl            m_mapDocumentName = m_mapControl.DocumentFilename;            //if there is no MapDocument, diable the Save menu and clear the statusbar            if (m_mapDocumentName == string.Empty)            {                menuSaveDoc.Enabled = false;                statusBarXY.Text = string.Empty;            }            else            {                //enable the Save manu and write the doc name to the statusbar                menuSaveDoc.Enabled = true;                statusBarXY.Text = Path.GetFileName(m_mapDocumentName);            }        }        private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)        {            statusBarXY.Text = string.Format("{0}, {1}  {2}", e.mapX.ToString("#######.##"), e.mapY.ToString("#######.##"), axMapControl1.MapUnits.ToString().Substring(4));        }    }}


ArcGIS Engine開發模板及代碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.