Hello,
I am in the process of creating a toolbar containing nested menus with buttons and other menus for access of some custom functionality for end users.
For whatever reason, since the ArcMap addin templates do not seem to allow a toolbar contained menus with nested submenus, I turned to the non-addin approach of creating a BaseToolbar which has the ability to add commands (menus, buttons, etc.):
Code:
public MyToolbar()
{
this.AddItem(typeof(ButtonItem));
}
where ButtonItem is a class which inherits BaseCommand:
Code:
[Guid("2b3041ff-482c-4c36-aef3-2bf79546fb82")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("TestLib.ButtonItem")]
public class ButtonItem : BaseCommand
{
// ...
}
What I really want these buttons to do is have some non-ESRI functionality (which none of the examples provide), for example, when clicked, retrieves some id, name, or caption of this button, and traverses a directory on the file system to add a new layer to the map, or create a config .xml file somewhere on the file system.
However, there seems to be no room to add any custom methods or properties to ButtonItem, since the method AddItem() of the base toolbar does not take an instantiated object, but either a progid, or class type.
How can I handle the onClick method of this specific button to access class properties? There does not seem to be a clear indication of how/when the constructor and onCreate methods are executed.
Does anyone have experience utilizing this toolbar/menu style, or know how to dynamically add nested menu items to an add-in toolbar (loop over a directory, and add a menu item for a folder, or a button item for a file)?