asdp
路人甲
路人甲
  • 注册日期2004-10-20
  • 发帖数11
  • QQ
  • 铜币151枚
  • 威望0点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
阅读:2074回复:6

[求助]请问如何在自定义的工具栏中使用engine提供的内建命令(c#)

楼主#
更多 发布于:2005-09-02 17:09
<P>代码如下  </P>
<P>private void Form1_Load(object sender, System.EventArgs e)<BR>  {<BR>   ToolbarControlClass axToolbarControl1 = new ToolbarControlClass();<BR>   IToolbarControl toolBar1;<BR>   toolBar1 = axToolbarControl1;<BR>   toolBar1.SetBuddyControl(axMapControl1);<BR>  <BR>  } <BR>  private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)<BR>  {<BR>   <BR>   if (e.Button == toolBarButton1)<BR>   {<BR>    ICommand command = new ControlsMapPanToolClass();<BR>    command.OnCreate(axMapControl1.Object);<BR>    axMapControl1.CurrentTool = command as ITool;<BR>      }</P>
<P>   if (e.Button == toolBarButton2)<BR>   { <BR>    ICommand command = new ControlsMapFullExtentCommandClass();<BR>    command.OnCreate(axMapControl1.Object);<BR>    axMapControl1.CurrentTool = command as ITool;<BR>     }<BR>现在只有button1可用,button2不行,不知是何原因,请指教,谢谢</P>
喜欢0 评分0
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2005-09-02 17:24
俺是用VB滴!~
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
kisssy
卧底
卧底
  • 注册日期2004-04-18
  • 发帖数235
  • QQ
  • 铜币614枚
  • 威望2点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2005-09-02 19:51
<P>当然不行啊!</P>
<P>要注意Tool和Command的区别</P>
<P>通俗的说:</P>
<P>Command是在工具栏一点击,就出效果。如FullExtent,Refresh;</P>
<P>而Tool在工具栏点击后并无直接反映,而是等到你在地图上点击或移动后,产生效果,如Zoomin,Zoomout,Pan,Identify等等</P>
<P>具体哪些是Tool,哪些是Command,可以参照相关OMD。</P>
<P>Tool使用类似你的Button1;</P>
<P>而Command应该: </P>
<P>if (e.Button == toolBarButton2)<br>   { <br>    ICommand command = new ControlsMapFullExtentCommandClass();<br>    command.OnCreate(axMapControl1.Object);<br>    command.OnClick();<br>     }</P><br>
[此贴子已经被作者于2005-9-2 19:53:08编辑过]
个人专栏: https://zhuanlan.zhihu.com/c_165676639
举报 回复(0) 喜欢(0)     评分
wzhipeng0117
路人甲
路人甲
  • 注册日期2005-05-05
  • 发帖数53
  • QQ
  • 铜币317枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2005-09-02 22:42
<P>两者的区别也是最近刚搞明白</P>
举报 回复(0) 喜欢(0)     评分
asdp
路人甲
路人甲
  • 注册日期2004-10-20
  • 发帖数11
  • QQ
  • 铜币151枚
  • 威望0点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
4楼#
发布于:2005-09-03 13:37
<P>谢谢<STRONG><FONT face=Verdana color=#da2549>kisssy,我是没搞清楚tool和command的区别,另外我想问问commandpool和hookhelp,我看了help,有些例子是vb的,我不懂vb</FONT></STRONG></P>
<P><STRONG><FONT face=Verdana color=#da2549>谢谢!!</FONT></STRONG></P><img src="images/post/smile/dvbbs/em12.gif" />
举报 回复(0) 喜欢(0)     评分
kisssy
卧底
卧底
  • 注册日期2004-04-18
  • 发帖数235
  • QQ
  • 铜币614枚
  • 威望2点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2005-09-03 16:11
<P>commandpool:说白了就是Command Collection</P>
<P>hookhelper:一般在你自己写一个Command类模块的时候用,用法可以看例子,概括的讲:</P>
<P>1、Class_Initialize中:<FONT color=#0000ff>Set</FONT> m_pHookHelper = <CODE><FONT color=#0000ff>New</FONT></CODE> HookHelper<BR>2、ICommand_OnCreate(<CODE><FONT color=#0000ff>ByVal</FONT></CODE> hook <CODE><FONT color=#0000ff>As Object</FONT></CODE>)中:<FONT color=#0000ff>Set</FONT> m_pHookHelper.hook = hook<BR>3、ICommand_OnClick()中就可以通过m_pHookHelper得到:<a href="ms-its:E:\ArcGIS\DeveloperKit\Help\COM\VB\esriControls.chm::/ctrl_IHookHelper_ActiveView.htm" target="_blank" ><STRONG>ActiveView</STRONG></A>、<a href="ms-its:E:\ArcGIS\DeveloperKit\Help\COM\VB\esriControls.chm::/ctrl_IHookHelper_FocusMap.htm" target="_blank" ><STRONG>FocusMap</STRONG></A>、<a href="ms-its:E:\ArcGIS\DeveloperKit\Help\COM\VB\esriControls.chm::/ctrl_IHookHelper_PageLayout.htm" target="_blank" ><STRONG>PageLayout</STRONG></A>(如在OnCreate中传入PageLayoutControl)。<BR><BR></P>
个人专栏: https://zhuanlan.zhihu.com/c_165676639
举报 回复(0) 喜欢(0)     评分
asdp
路人甲
路人甲
  • 注册日期2004-10-20
  • 发帖数11
  • QQ
  • 铜币151枚
  • 威望0点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
6楼#
发布于:2005-09-07 15:01
谢谢<STRONG><FONT face=Verdana color=#da2549>kisssy</FONT></STRONG><img src="images/post/smile/dvbbs/em02.gif" />
举报 回复(0) 喜欢(0)     评分
游客

返回顶部