自定义的工具栏中使用engine提供的内建命令
来源:互联网 发布:笔记本可以开淘宝店吗 编辑:程序博客网 时间:2024/05/21 10:10
代码如下
private void Form1_Load(object sender, System.EventArgs e)
{
ToolbarControlClass axToolbarControl1 = new ToolbarControlClass();
IToolbarControl toolBar1;
toolBar1 = axToolbarControl1;
toolBar1.SetBuddyControl(axMapControl1);
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if (e.Button == toolBarButton1)
{
ICommand command = new ControlsMapPanToolClass();
command.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = command as ITool;
}
if (e.Button == toolBarButton2)
{
ICommand command = new ControlsMapFullExtentCommandClass();
command.OnCreate(axMapControl1.Object);
axMapControl1.CurrentTool = command as ITool;
}
现在只有button1可用,button2不行,不知是何原因,请指教,谢谢
当然不行啊!
要注意Tool和Command的区别
通俗的说:
Command是在工具栏一点击,就出效果。如FullExtent,Refresh;
而Tool在工具栏点击后并无直接反映,而是等到你在地图上点击或移动后,产生效果,如Zoomin,Zoomout,Pan,Identify等等
具体哪些是Tool,哪些是Command,可以参照相关OMD。
Tool使用类似你的Button1;
而Command应该:
if (e.Button == toolBarButton2)
{
ICommand command = new ControlsMapFullExtentCommandClass();
command.OnCreate(axMapControl1.Object);
command.OnClick();
}
commandpool:说白了就是Command Collection
hookhelper:一般在你自己写一个Command类模块的时候用,用法可以看例子,概括的讲:
1、Class_Initialize中:Set m_pHookHelper = New
HookHelper
2、ICommand_OnCreate(ByVal
hook As Object
)中:Set m_pHookHelper.hook = hook
3、ICommand_OnClick()中就可以通过m_pHookHelper得到:ActiveView、FocusMap、PageLayout(如在OnCreate中传入PageLayoutControl)。
- 自定义的工具栏中使用engine提供的内建命令
- 使用ArcGIS Engine提供的命令和工具(ICommond,ITool)实现MapView操作
- Android中添加自定义工具栏的方法
- 自定义myeclipse的工具栏
- 创建自定义的工具栏
- MFC中添加工具栏的使用总结
- MFC 工具栏的自定义创建
- Fckeditor jsp使用实例,自定义Fckeditor的工具栏
- GAWK命令内建变量的使用
- 工具栏的使用
- 01--工具栏的使用
- MFC 工具栏的使用
- UIToolBar工具栏的使用
- MFC工具栏的使用
- 工具栏ToolBar的使用
- ArcGIS Engine 中多线程的使用
- ArcGIS Engine中关于Cursor的使用
- 如何使用XE2及更高版本中提供的自定义皮肤(样式)功能
- 通过WMI获得硬件信息
- 页面执行时间
- 使用 NetBeans IDE 5.5 创建漂亮的 GUI
- 将人民币的数字表示转化成大写表示
- ASP.net 验证码(C#)
- 自定义的工具栏中使用engine提供的内建命令
- 一个功能齐全的DataGrid分页例子
- Asp.NET常用函数
- 您可能不知道的.Net2.0小技巧
- 在Tomcat中配置DataSource
- 牛市炒股
- 在java中取得当前的系统时间并且转化成自己想要的格式
- 精妙SQL语句学习
- 关于CMD.EXE的问题