|
I want my add-in to create a new menu item in the View menu and then call some code in my add-in when the user clicks on the menu item. |
The Existing Workbench MenuThe SoapBox.Core Workbench already comes with the following menu structure:
However, menu items without any children won't show up, so you may not see all of them. Example: Adding an Item to the View MenuAssumes you've already created an Add-In and created a Pad. This View Menu Item will show that pad when the menu item is clicked.
(Please see Appendix A below...) Advanced Menu ItemsAdding an IconYou can add an Icon to your menu item easily if you have a bitmap stored in a resource file. Just call this in your menu item's constructor:
The framework will take care of changing the image to grayscale when the command can't be executed. CheckableYou can make this a checkable menu item with the following changes: Add this to your constructor: IsCheckable = true; IsChecked = true; // default value Add this in your class: protected override void OnIsCheckedChanged()
{
base.OnIsCheckedChanged();
// take an action on the check being changed here
}
Make it a Menu Item SeparatorEasily enough, in the constructor, do this:
Add a Sub MenuMenu items can have submenus. Not only that, but these submenus are extension points just like the main menu items. The easiest way to explain how this works is to show you the File Menu Item:
Calling extensionService.Sort(...) makes sure that all of the imported sub menu items are ordered according to the InsertRelativeTo and BeforeOrAfter properties. |
Appendix A:(I had some problems with code formatting and had to move it down here.)
I believe the line --> private MyPad myPad { get; set; } should be --> private Lazy<mypad> myPad { get; set; }
(07 Sep '11, 23:28)
granthes
|