Arcengine编辑代码
- 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 Demo2
- {
- public sealed partial class MainForm : Form
- {
- #region private members
- private IMapControl3 m_mapControl = null;
- private string m_mapDocumentName = string.Empty;
- private IToolbarMenu m_toolbarMenu;
- #endregion
- #region class constructor
- public MainForm()
- {
- InitializeComponent();
- }
- #endregion
- private void MainForm_Load(object sender, EventArgs e)
- {
- m_mapControl = (IMapControl3) axMapControl1.Object;
- //Load the Data into the MapControl1
- string sFilePath = @"C:ConferenceDataDemo Editing.mxd";
- if (m_mapControl.CheckMxFile(sFilePath))
- {
- m_mapControl.LoadMxFile(sFilePath, null, null);
- }
- else
- MessageBox.Show(sFilePath + " is not a valid ArcMap document");
- #region setup toolbar visibility
- menuSaveDoc.Enabled = false;
- editingToolStripMenuItem.Checked = true;
- inkToolStripMenuItem.Checked = false;
- GenericToolStripMenuItem.Checked = false;
- navigationToolStripMenuItem.Checked = true;
- axEditorToolbar.Visible = true;
- axNavigationToolbar.Visible = true;
- axExtraEditorToolbar.Visible = false;
- axInkToolbar.Visible = false;
- #endregion
- //EditorToolbar
- axEditorToolbar.AddItem("esriControls.ControlsEditingEditorMenu", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axEditorToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axEditorToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axEditorToolbar.AddItem("esriControls.ControlsEditingTargetToolControl", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axEditorToolbar.AddItem("esriControls.ControlsEditingTaskToolControl", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axEditorToolbar.AddItem("esriControls.ControlsEditingAttributeCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axEditorToolbar.AddItem("esriControls.ControlsEditingSketchPropertiesCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axEditorToolbar.AddItem("esriControls.ControlsUndoCommand", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axEditorToolbar.AddItem("esriControls.ControlsRedoCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- //ExtraEditorToolbar
- axExtraEditorToolbar.AddItem(new EditPropertiesCmd(), 0, -1, false, 0, esriCommandStyles.esriCommandStyleTextOnly);
- axExtraEditorToolbar.AddItem("esriControls.ControlsUndoCommand", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axExtraEditorToolbar.AddItem("esriControls.ControlsRedoCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axExtraEditorToolbar.AddItem("esriControls.ControlsEditingCutCommand", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axExtraEditorToolbar.AddItem("esriControls.ControlsEditingPasteCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axExtraEditorToolbar.AddItem("esriControls.ControlsEditingCopyCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- axExtraEditorToolbar.AddItem("esriControls.ControlsEditingClearCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
- //Create a popup menu
- m_toolbarMenu = new ToolbarMenuClass();
- m_toolbarMenu.AddItem("esriControls.ControlsEditingSketchContextMenu", 0, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
- //Share the Command Pool
- m_toolbarMenu.CommandPool = axEditorToolbar.CommandPool;
- }
- #region Main Menu event handlers
- 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)
- {
- //execute SaveAs Document command
- ICommand command = new ControlsSaveAsDocCommandClass();
- command.OnCreate(m_mapControl.Object);
- command.OnClick();
- }
- private void menuExitApp_Click(object sender, EventArgs e)
- {
- //exit the application
- Application.Exit();
- }
- #endregion
- //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));
- }
- private void editingToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (axEditorToolbar.Visible == false)
- {
- axEditorToolbar.Visible = true;
- editingToolStripMenuItem.Checked = true;
- }
- else
- {
- axEditorToolbar.Visible = false;
- editingToolStripMenuItem.Checked = false;
- }
- }
- private void inkToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (axInkToolbar.Visible == false)
- axInkToolbar.Visible = true;
- else
- axInkToolbar.Visible = false;
- }
- private void navigationToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (axNavigationToolbar.Visible == false)
- axNavigationToolbar.Visible = true;
- else
- axNavigationToolbar.Visible = false;
- }
- private void bookmarksToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (axExtraEditorToolbar.Visible == false)
- axExtraEditorToolbar.Visible = true;
- else
- axExtraEditorToolbar.Visible = false;
- }
- private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
- {
- if (e.button == 2) m_toolbarMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);
- }
- }
- }
Arcengine编辑代码的更多相关文章
- VS2010在运行状态下编辑代码
在VS2010环境下,当程序处于调试运行状态时,编辑代码会出现下图提示框: 这就给边编辑代码边查看程序运行效果带来不便. 解决方法:在程序没有运行的时候,打开菜单“工具”——>“选项”——> ...
- 如何让 Drupal 使用 Wordpress 形式的编辑代码?
如果你曾有过将 Wordpress 网站迁移到 Drupal 的经验,很可能客户会问的第一件事就是如何为 Drupal 添加编辑代码. Wordpress 中的 Shortcodes 插件让使用者可以 ...
- VS编辑代码的时候,都会自动在资源浏览器里将文件所在项目展开
如何设置VS编辑代码的时候,都会自动在资源浏览器里将文件所在项目展开 工具-选项-项目和解决方案-常规-在解决方案资源管理器中跟踪活动项(C)
- 在线编辑代码[django]版本
再国内,做什么都这么吃力.连aliyun 的ssh 都被封这是什么世道,所以做一个在线编辑代码的忙忙碌碌有点粗糙.大家见谅1. [代码]views.py #-*- coding:utf-8 -*- ...
- 【01】在 Github 上编辑代码
[01]在 Github 上编辑代码 当你使用 GitHub,看一些文件(任何的文本文件或者仓库),能看到一个顶部右侧有一个小铅笔图标.点击即可编辑文档. 完成后,按照提示点击「Propose fil ...
- 用vscode编辑代码
本教程只适用于用vs code编辑代码,并不是用vs code调试,调试还是老实用keil吧,干货开始.... 废话不多说 第一步:去微软下载一个vs code,顺带百度了解一下vs code强大的功 ...
- 安装Pycharm(方便编辑代码的IDE(编辑器))以及 使用Pycharm新建项目
安装Pycharm(方便编辑代码的IDE(编辑器))以及 使用Pycharm新建项目 一.下载安装Pycharm 首先要下载Pycharm这个软件,官网的下载地址是: http://www.jetbr ...
- Eclipse里编辑代码,进度条出现“Remote System Explorer Operation”解决方法
Eclipse里编辑代码,进度条出现"Remote System Explorer Operation",导致Eclipse有卡顿. 解决方法: Eclipse -> Pre ...
- ArcEngine编辑保存错误:Unable to create logfile system tables
通过ArcEngine对多个SDE中多个图层进行批量编辑处理,其中有部分图层在结束编辑的时候出现错误提示(部分图层可以,只有两个数据较多的图层保存失败). 错误信息:Unable to create ...
随机推荐
- linux下shell脚本执行方法及exec和source命令
exec和source都属于bash内部命令(builtins commands),在bash下输入man exec或man source可以查看所有的内部命令信息. bash shell的命令分为两 ...
- C++的开源跨平台日志库glog学习研究(一)
作为C++领域中为数不多的好用.高效的.跨平台的日志工具,Google的开源日志库glog也算是凤毛麟角了.glog 是一个C++实现的应用级日志记录框架,提供了C++风格的流操作. 恰巧趁着五一我也 ...
- python strip()函数的用法
函数原型 声明:s为字符串,rm为要删除的字符序列 s.strip(rm) 删除s字符串中开头.结尾处,位于 rm删除序列的字符 s.lstrip(rm) 删除s字符串中 ...
- JVM-压缩指针
什么是压缩指针: 通常64位JVM消耗的内存会比32位的最多会多用1.5倍,这是因为对象指针在64位架构下,对象指针长度会翻倍. 对于那些将要从32位平台移植到64位的应用来说,平白无辜多了1/2的内 ...
- [转]你真的了解 console 吗
原文:https://segmentfault.com/a/1190000000481884 对于前端开发者来说,在开发过程中需要监控某些表达式或变量的值的时候,用 debugger 会显得过于笨重, ...
- wordpress 固定链接 404错误
一开始我是用本机服务器做测试,写文章,发现固定链接模式在非默认情况下,都是404错误页面,具体如下: 方法一,.htaccess要开放写权限,这样在自定义wp的永久链接时,wp会自动重写.htacce ...
- SearchView去掉下划线
SearchView calSearchView = (SearchView) findViewById(R.id.sv_search_text); if (calSearchView != null ...
- ELK日志系统之通用应用程序日志接入方案
前边有两篇ELK的文章分别介绍了MySQL慢日志收集和Nginx访问日志收集,那么各种不同类型应用程序的日志该如何方便的进行收集呢?且看本文我们是如何高效处理这个问题的 日志规范 规范的日志存放路径和 ...
- ubuntu 16.04 安装PhpMyAdmin
首先,安装mysql $ sudo apt-get install mysql-server $ sudo apt-get install mysql-client 安装时输出root用户的密码 然后 ...
- 3-nginx.conf参数配置
–#定义Nginx运行的用户和用户组 –user www www; –#nginx进程数,建议设置为等于CPU总核心数. –worker_processes8; –#全局错误日志定义类型,[ debu ...