Reputation: 112
I'm trying to add an item to the context menu in the Visual Studio 2010 Form Designer.
So far I have an Addin project which retrieves the IDesignerHost, IDesigner etc. representations of the Form Designer. None of these interfaces seem to expose anything related to context menus. I've also tried retrieving the IMenuEditorService for the designer Site, but this doesn't have any items associated with it.
I've also tried iterating through all the CommandBar items in the window DTE (as seen Visual Studio 2010 Plug-in - Adding a context-menu to the Editor Window), again, none of these seem to represent the Form Designer context menu.
Is there an easy way to do this?
Thanks
Upvotes: 2
Views: 449
Reputation: 2817
Verbs appear in designer menu and control properties. If adding verb to designer would be sufficient to you, then that is how you can make it:
DesignerVerb _verb;
_verb = new DesignerVerb("Do something", OnConvertClick);
var designer = _designerHost.GetDesigner(comp);
if (!designer.Verbs.Contains(_verb))
designer.Verbs.Add(_verb);
void OnConvertClick(object sender, EventArgs e)
{
MessageBox.Show("Hello world!");
}
Upvotes: 3