I'm working on an add-in for ArcMap 10.0 that adds a toolbar to ArcMap. One command (OpenModelessDialogCommand) button on that toolbar opens a modeless WinForms dialog, from which a tool (MyTool) can be activated in order to e.g. select a feature on the map.
My Config.esriaddinx contains these command and toolbar declarations:
What I'm having problems with is activating MyTool in the form. All I've found on the internet is code samples along the lines of:
// get a reference to an instance of MyTool: ICommandItem myTool = ArcMap.Application.Document.CommandBars.Find("MyTool"); // activate MyTool: ArcMap.Application.CurrentTool = myTool; However, this apparently requires that MyTool actually appears in a command bar (e.g. toolbar) of my add-in. But that's not the case. So, I've tried this next:
ITool myTool = new MyTool(); ArcMap.Application.CurrentTool = myTool; // Type mismatch! An ICommandItem is expected. I've even looked into adding an invisible AxToolbarControl to my form and adding a button for MyTool there; but then I'm running into problems on how to connect that toolbar (via SetBuddyControl) to the opened document's map. I don't want the tool to function in a separate AxMapControl, I want it to work directly with the main map shown in ArcMap.
Question:
How do I activate a custom tool that is not added to any toolbar (or other command bar, for that matter)?
أكثر...
My Config.esriaddinx contains these command and toolbar declarations:
What I'm having problems with is activating MyTool in the form. All I've found on the internet is code samples along the lines of:
// get a reference to an instance of MyTool: ICommandItem myTool = ArcMap.Application.Document.CommandBars.Find("MyTool"); // activate MyTool: ArcMap.Application.CurrentTool = myTool; However, this apparently requires that MyTool actually appears in a command bar (e.g. toolbar) of my add-in. But that's not the case. So, I've tried this next:
ITool myTool = new MyTool(); ArcMap.Application.CurrentTool = myTool; // Type mismatch! An ICommandItem is expected. I've even looked into adding an invisible AxToolbarControl to my form and adding a button for MyTool there; but then I'm running into problems on how to connect that toolbar (via SetBuddyControl) to the opened document's map. I don't want the tool to function in a separate AxMapControl, I want it to work directly with the main map shown in ArcMap.
Question:
How do I activate a custom tool that is not added to any toolbar (or other command bar, for that matter)?
أكثر...