ArcEngine开发之自定义工具
1.在项目中添加基于Base Command等的类,可改变命名空间名称。
2.引用:命名空间.类名称;
实例:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Resources;
using System.Reflection;
using System.Drawing;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;
namespace CSharpMyFullExtent
{
/// <summary>
/// Command that works in ArcMap/Map/PageLayout
/// </summary>
[Guid("4f4e73b1-40c3-44a5-8729-d403b7b3d779")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("CSharpMyFullExtent.MyFullExtentCommand")]
public sealed class MyFullExtentCommand : BaseCommand
{
#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType);
//
// TODO: Add any COM registration code here
//
}
[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType);
//
// TODO: Add any COM unregistration code here
//
}
#region ArcGIS Component Category Registrar generated code
/// <summary>
/// Required method for ArcGIS Component Category registration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryRegistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Register(regKey);
ControlsCommands.Register(regKey);
}
/// <summary>
/// Required method for ArcGIS Component Category unregistration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryUnregistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Unregister(regKey);
ControlsCommands.Unregister(regKey);
}
#endregion
#endregion
private IHookHelper m_hookHelper = null;
public MyFullExtentCommand()
{
//
// TODO: Define values for the public properties
//
base.m_category = "CustomCommands"; //localizable text
base.m_caption = "My Full Extent"; //localizable text
base.m_message = "My Full Extent"; //localizable text
base.m_toolTip = "My Full Extent"; //localizable text
base.m_name = "MyCommands_MyFullExtent"; //unique id, non-localizable (e.g. "MyCategory_MyCommand")
//As part of your deployment strategy you must register the name of the WinHelp file (*.hlp)
//as a new string value in: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Help
//or provide the full path name.
base.m_helpFile = "MyHelpFile.hlp";
//The Context Help ID as defined when compiling the RTF file into the HelpFile
base.m_helpID = 1234;
ResourceManager rm = new ResourceManager("CSharpMyFullExtent.Resources", Assembly.GetExecutingAssembly());
base.m_bitmap = (System.Drawing.Bitmap)rm.GetObject("CommandImage");
}
#region Overriden Class Methods
/// <summary>
/// Occurs when this command is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
if (hook == null)
return;
try
{
m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = hook;
if (m_hookHelper.ActiveView == null)
m_hookHelper = null;
}
catch
{
m_hookHelper = null;
}
if (m_hookHelper == null)
base.m_enabled = false;
else
base.m_enabled = true;
}
/// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
//Get IActiveView interface
IActiveView pActiveView = m_hookHelper.FocusMap as IActiveView;
//Set the extent to the full extent
pActiveView.Extent = pActiveView.FullExtent;
//Refresh the active view
pActiveView.Refresh();
}
#endregion
}
}
引用:
axToolbarControl1.AddItem("CSharpMyFullExtent.MyFullExtentCommand", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
转载于:https://www.cnblogs.com/jinqier/archive/2013/01/22/2871148.html
ArcEngine开发之自定义工具相关推荐
- Navisworks API 简单二次开发 (自定义工具条)
在Navisworks软件运行的时候界面右侧有个工具条.比较方便.但是在二次开发的时候我不知道在Api那里调用.如果有网友知道请告诉我.谢谢. 我用就自己设置一个工具.界面比较丑!没有美工. 代码: ...
- t4b代码生成_T4+VSIX 打造Visual Studio 2010 中的Entity代码生成自定义工具
首先简单介绍下T4(Code Generation and Text Templates),也就是有一些文本模板和控制逻辑组成的混合体,可以使用这些模板生成程序中的部分源代码. 在Visual Stu ...
- 【小米手环7】使用 Zeus + 表盘自定义工具 为小米手环7开发和安装小程序
有关 Zepp OS Zepp OS 是华米开发的一个 RTOS,运行在手表.手环等设备上. 最新发布的小米手环7 / 7NFC 搭载的就是由华米研发的 Zepp OS.相比与之前小米手环搭载的 RT ...
- 【开发随机】JAVA+POI+自定义注解+反射构建自定义工具类实现快捷简便的Excel模板化导出(附demo代码)
220907更新 项目UAT期间,用户反映了一个问题,数据量稍大的情况下,会出现"从某一行开始,往下所有行设置的字体和字体大小不生效"的BUG. 经过排查,发现原因是:POI的XS ...
- Polyworks脚本开发学习笔记(十七)-制作宏脚本自定义工具条
Polyworks脚本开发学习笔记(十七)-制作宏脚本自定义工具条 做好的宏脚本程序,每次打开脚本加载程序太多麻烦,为了方便的调用脚本做各种操作,可以使用系统的自定义工具条功能将脚本加载到工具条上. ...
- 用PHP开发命令行工具
介绍 用过laravel开发过项目的都应该用过artisan,通过artisan我们可以在命令行中创建控制器类,Eloquent类等,今天我们将通过php来开发命令行工具 开发环境与工具 使用vagr ...
- php 自定义菜单 openid,微信公众平台开发(99) 自定义菜单获取OpenID
关键字 微信公众平台 自定义菜单 OpenID 作者:方倍工作室 原文:http://www.cnblogs.com/txw1958/p/weixin-menu-get-openid.html 在这篇 ...
- 12个便于web设计及开发的在线工具
请不要低估这些小工具,他们极其的方便并且能节省很多的时间和工作,下面就是这些在线工具的列表,挑几款来试试吧. 我还是比较喜欢Ajax Load和Web 20 Badges Generator的,你们呢 ...
- mac json格式化工具_一个在 MAC 上 iOS/Flutter 开发的辅助工具
大家好,我是章鱼猫. 今天给大家推荐的这个开源项目,是来自于我们公众号读者的投稿,这个东西还挺好的. 如果你作为读者,也有自己的开源项目或者你也有想推荐的开源项目,都可以向我们投稿,我们就是致力于帮助 ...
最新文章
- 联想 k2450 温度、耗电试验
- 华为SNS2224巡检
- Python 标准化 - 使用logging
- 删除数据文件—启动不了数据库--恢复数据库—启动数据库
- WPF将数据库和GridView绑定并更改GridView模板
- 透视前端工程化之 Webpack 基本介绍【文末有彩蛋~】
- 网络攻防实验(五)——201521460003王浩洋
- 3D移动translate3d(CSS3)
- 海康监控设备如何修改IP地址
- charset参数 sqluldr2_sqluldr2 oracle直接导出数据为文本的小工具使用
- 软件测试 _ 基础知识
- java-se-包装类
- docker insecure-registry
- iOS 安装包瘦身(下篇)
- 网络攻防“三剑客”正式加盟墨者安全 担任首席安全顾问...
- erlang中的ets和dets
- html tbody增加行,实现所有行变色,所有行删除。给出的结构中少了tbody,加上就可以了。...
- SaaS到底是什么?如何做?
- max pooling 和 average pooling
- SQL语句 操作实例
热门文章
- android 自定义水波纹点击效果Button
- 单例设计模式八种写法
- Oracle和Mysql中的字符串的拼接
- [lct] Luogu P4219 大融合
- redhat7.3安装yum源 基于外网的http服务
- asp.net的处理机制(.ashx/.aspx)
- Hibernate 学习-1
- C# DataTable的Distinct解决方案及表的复制
- 来自官方文档的Ubuntu 16.04 + tensorflow-GPU 配置
- php2个数字拼接,PHP合并2个数字键数组值示例详解