IHookHelper怎么用? c#+ae二次开发 base tool中怎样应用hookhe...

vb\u4e2dihookhelper\u7c7b\u600e\u4e48\u663e\u793a\u672a\u5b9a\u4e49?

\u5728\u5de5\u5177\uff0c\u5f15\u7528\u4e2d\u6dfb\u52a0\u5bf9\u5b83\u7684\u5f15\u7528\u3002

IHookHelper \u4e3b\u8981\u5728\u7528\u5728\u81ea\u5b9a\u4e49\u7c7b\u578b\u4e8eAE\u5e26\u7684\u7684ICommand\u6216ITool\u7b49,
1.\u5b9e\u4f8b\u5316IHookHelper \u5bf9\u8c61\uff1a

IHookHelper m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = this.axMapControl1.Object ;\u8fd9\u6837\u5c31\u53ef\u4ee5\u628aAxMapControl\u4f20\u9012\u7ed9\u5176\u5b83\u8981\u7528\u5230\u7684\u5730\u65b9\u3002
2.\u901a\u8fc7IHookHelper\uff0c\u83b7\u53d6\u5730\u56fe\u63a7\u4ef6\u548c\u4e3b\u7a97\u4f53:
IntPtr pHandle = new IntPtr \uff08m_hookHelper.ActiveView.ScreenDisplay.hWnd);
axMapControl1 = System.Windows.Forms.Form.FromHandle(pHandle) as AxMapControl;//\u5bf9\u8fd9\u4e2a\u5730\u56fe\u63a7\u4ef6\u5bf9\u8c61\u64cd\u4f5c\uff0c\u4f1a\u76f4\u63a5\u53cd\u5e94\u5230\u4e3b\u7a97\u4f53\u7684\u5730\u56fe\u63a7\u4ef6\u4e0a

Form. MainForm. = Form.FromHandle(pHandle).FindForm();//\u8fd9\u91cc\u7684\u4e3b\u7a97\u4f53\u5bf9\u8c61\u4e4b\u540e\u8fd0\u884c\u65f6\u80fd\u8d77\u4f5c\u7528\uff0cMainForm. \u4e0d\u80fd\u76f4\u63a5\u8bbf\u95ee\u5230\u4e3b\u7a97\u4f53\u91cc\u7684\u53d8\u91cf\u3002
3.\u901a\u8fc7IHookHelper\uff0c\u83b7\u53d6IActiveView\u548cIMap\u5bf9\u8c61
\u518d\u901a\u8fc7IHookHelper.ActiveView\u548cIHookHelper.FocusMap\u5c5e\u6027\u6765\u83b7\u53d6IActiveView\u548cIMap\u5bf9\u8c61,\u901a\u8fc7\u8fd9\u4e24\u4e2a\u63a5\u53e3\u8fdb\u884c\u66f4\u4e00\u6b65\u7684\u64cd\u4f5c.

4.\u901a\u8fc7IHookHelper\uff0c\u64cd\u4f5c\u5730\u56fe
IHookActions hookActions= m_hookHelper as IHookHelper;
\u83b7\u53d6IHookActions,\u518d\u901a\u8fc7IHookActions\u8fdb\u884cFlash,Pan,ZoomTo\u64cd\u4f5c.


HOOK\u5b9e\u9645\u662f\u4e00\u4e2a\u5bf9\u8c61\u4f20\u51fa\u7684\u81ea\u8eab\u7684\u5f15\u7528\u6216\u8005\u53eb\u6307\u9488\u6216\u8005\u53eb\u53e5\u67c4\u3002
\u4f8b\u5982\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u52a0\u8f7d\u4e00\u4e2adll\u5185\u7684\u5bf9\u8c61\u65f6\u901a\u8fc7\u628aHook\u4f20\u9012\u7ed9\u8981\u8c03\u7528\u7684\u5bf9\u8c61\uff0c
\u8fd9\u6837dll\u5185\u7684\u5bf9\u8c61\u5c31\u5f97\u5230\u4e86\u5e94\u7528\u7a0b\u5e8f\u4f20\u9012\u7ed9\u4ed6\u7684\u8fd9\u4e2ahook\uff0c
\u5bf9\u8c61\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2ahook\u67e5\u770b\u7a0b\u5e8f\u5185\u90e8\u7684\u7ed3\u6784\u3002
\u5b9e\u9645\u5b9e\u73b0\u65f6\u5c31\u662f\u5bf9\u8c61\u95f4\u4f20\u9012\u6307\u5411\u81ea\u8eab\u7684\u6307\u9488\u4f20\u9012\u7ed9\u53e6\u4e00\u4e2a\u5bf9\u8c61\u3002


IHookHelper m_hookHelper=new HookHelperClass();
m_hookHelper.Hook=axMapControl1.Object;
//\u8fd9\u6837\u5c31\u83b7\u5f97\u4e86axMapControl1\u63a7\u4ef6\u7684\u4e00\u4e2a\u5f15\u7528
\u7136\u540e\u901a\u8fc7m_hookHelper.ActiveView\u53ef\u4ee5\u83b7\u5f97\u539faxMapControl1\u7684ActiveView\u9879\uff0c
\u7528m_hookHelper.FocusMap\u53ef\u4ee5\u83b7\u5f97IMap\u5bf9\u8c61

HOOK实际是一个对象传出的自身的引用或者叫指针或者叫句柄。 例如一个程序,加载一个dll内的对象时通过把Hook传递给要调用的对象,这样dll内的对象就得到了应用程序传递给他的这个hook,对象可以通过这个hook查看程序内部的结构。 实际实现时就是对象间传递指向自身的指针传递给另一个对象。
IHookHelper m_hookHelper=new HookHelperClass();
m_hookHelper.Hook=axMapControl1.Object; //这样就获得了axMapControl1控件的一个引用
然后通过m_hookHelper.ActiveView可以获得原axMapControl1的ActiveView项,用m_hookHelper.FocusMap可以获得IMap对象
例如在实现一个BaseCommand重写其OnCreate()和OnClick()方法时
private IHookHelper m_hookHelper = null;
public override void OnCreate(object hook)
{
if (m_hookHelper == null)
m_hookHelper = new HookHelperClass();

m_hookHelper.Hook = hook;
}
public override void OnClick()
{
IMapControl3 mapControl = null;

//get the MapControl from the hook in case the container is a ToolbatControl
if (m_hookHelper.Hook is IToolbarControl)
{
mapControl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
}
//In case the container is MapControl
else if (m_hookHelper.Hook is IMapControl3)
{
mapControl = (IMapControl3)m_hookHelper.Hook;
}
else
{
MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}

//allow the user to save the current document
DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (res == DialogResult.Yes)
{
//launch the save command (why work hard!?)
ICommand command = new ControlsSaveAsDocCommandClass();
command.OnCreate(m_hookHelper.Hook);
command.OnClick();
}

//craete a new Map
IMap map = new MapClass();
map.Name = "Map";

//assign the new map to the MapControl
mapControl.DocumentFilename = string.Empty;
mapControl.Map = map;
}
在调用时:command.OnCreate(m_mapControl.Object);//这样就把MapControl传递进去了。

HOOK实际是一个对象传出的自身的引用或者叫指针或者叫句柄。 例如一个程序,加载一个dll内的对象时通过把Hook传递给要调用的对象,这样dll内的对象就得到了应用程序传递给他的这个hook,对象可以通过这个hook查看程序内部的结构。 实际实现时就是对象间传递指向自身的指针传递给另一个对象。
IHookHelper m_hookHelper=new HookHelperClass();
m_hookHelper.Hook=axMapControl1.Object; //这样就获得了axMapControl1控件的一个引用
然后通过m_hookHelper.ActiveView可以获得原axMapControl1的ActiveView项,用m_hookHelper.FocusMap可以获得IMap对象
例如在实现一个BaseCommand重写其OnCreate()和OnClick()方法时
private IHookHelper m_hookHelper = null;
public override void OnCreate(object hook)
{
if (m_hookHelper == null)
m_hookHelper = new HookHelperClass();

m_hookHelper.Hook = hook;
}
public override void OnClick()
{
IMapControl3 mapControl = null;

//get the MapControl from the hook in case the container is a ToolbatControl
if (m_hookHelper.Hook is IToolbarControl)
{
mapControl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
}
//In case the container is MapControl
else if (m_hookHelper.Hook is IMapControl3)
{
mapControl = (IMapControl3)m_hookHelper.Hook;
}
else
{
MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}

//allow the user to save the current document
DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (res == DialogResult.Yes)
{
//launch the save command (why work hard!?)
ICommand command = new ControlsSaveAsDocCommandClass();
command.OnCreate(m_hookHelper.Hook);
command.OnClick();
}

//craete a new Map
IMap map = new MapClass();
map.Name = "Map";

//assign the new map to the MapControl
mapControl.DocumentFilename = string.Empty;
mapControl.Map = map;
}
在调用时:command.OnCreate(m_mapControl.Object);//这样就把MapControl传递进去了
另外参考http://gisfire.blog.163.com/blog/static/139077132201211942026566/

^^ 偶也是AE开发的... 不过目前也是在摸索期。。

对desktop算是有点了解,呵呵0_0

加油学吧,总会学会的。多逛逛论坛,比如 ESRI北京 论坛

  • IHookHelper鎬庝箞鐢?
    绛旓細鐒跺悗閫氳繃m_hookHelper.ActiveView鍙互鑾峰緱鍘焌xMapControl1鐨凙ctiveView椤癸紝鐢╩_hookHelper.FocusMap鍙互鑾峰緱IMap瀵硅薄 渚嬪鍦ㄥ疄鐜颁竴涓狟aseCommand閲嶅啓鍏禣nCreate锛堬級鍜孫nClick锛堬級鏂规硶鏃 private IHookHelper m_hookHelper = null;public override void OnCreate(object hook){ if (m_hookHelper == null)m_h...
  • c#+ae浜屾寮鍙 base tool涓鎬庢牱搴旂敤hookhelper
    绛旓細瀹為檯瀹炵幇鏃跺氨鏄璞¢棿浼犻掓寚鍚戣嚜韬殑鎸囬拡浼犻掔粰鍙︿竴涓璞°IHookHelper m_hookHelper=new HookHelperClass();m_hookHelper.Hook=axMapControl1.Object;//杩欐牱灏辫幏寰椾簡axMapControl1鎺т欢鐨勪竴涓紩鐢 鐒跺悗閫氳繃m_hookHelper.ActiveView鍙互鑾峰緱鍘焌xMapControl1鐨凙ctiveView椤癸紝鐢╩_hookHelper.FocusMap鍙互鑾峰緱IM...
  • c#arcengine鐨刣ocument鍦ㄥ摢
    绛旓細private IHookHelper m_hookHelper;private ControlsSynchronizer m_controlsSynchronizer = null;private string m_sDocumentPath = string.Empty;public OpenNewMapDocument(ControlsSynchronizer controlsSynchronizer){ base.m_category = ".NET Samples";base.m_caption = "Open Map Document";base.m_message =...
  • 濡備綍浣跨敤ArcGIS涓殑鍔ㄦ佹樉绀烘妧鏈
    绛旓細IDynamicMapEvents.AfterDynamicDraw;3.3.1 缁樺浘鏂瑰紡鐨勪袱绉嶉夋嫨(浜嬪疄鏄湰璐ㄧ殑draw閮芥槸OpenGL鏂规硶)(1)浣跨敤AO鐨凙PI (2)鐩存帴璋冪敤OpenGL鐨凙PI 榛樿鎯呭喌涓婳penGL鐨勭汗鐞(texture)鍙敤銆傞渶瑕佹敞鎰忕殑鏄紝鍦ㄦ渶鍒濋渶瑕佸紑濮嬪埄鐢∣penGL鐨勬柟娉曟椂锛岃姹傚叧闂璒penGL 2D texture flag銆3.4缁樺浘鏂瑰紡閲囩敤浣跨敤AO鐨凙PI [C#]//...
  • 扩展阅读:support.apple.com ... iherb购物官网 ... shopify官网入口 ... prosettings.net ... iherb海淘官网 ... mrantifun修改器怎么用 ... www.example.com ... imperialharem触发3次 ... iherb中国app下载 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网