c# - How do you find and modify existing menu commands in Visual Studio extension -


i'm writing plugin/extension visual studio , i'd able find existing menu command , hide it. specifically, want find rebuild commands in context menus , hide or disable them. looks have access command ids: https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.vsconstants.vsstd2kcmdid(v=vs.140).aspx

and using olemenucommandservice there findcommand returns null. here i'm trying:

olemenucommandservice mcs = getservice(typeof(imenucommandservice)) olemenucommandservice; if ( null != mcs ) {     menucommand rebuildcommand = mcs.findcommand(new commandid(         microsoft.visualstudio.vsconstants.uicontext_solutionhassingleproject,         (int)microsoft.visualstudio.vsconstants.vsstd97cmdid.rebuildctx) );      // rebuildcommand null } 

any ideas on way this?

unfortunately, appears impossible existing visual studio command using findcommand method. can see more detailed information on msdn forum.

also, think it's not idea make existing visual studio features unavailable in extension. instead, can subscribe commandevents.beforeexecute , commandevents.afterexecute events. here's how it:

using envdte; using envdte80; using microsoft.visualstudio.shell;  ...  dte2 ide = serviceprovider.globalprovider.getservice(typeof(dte)) dte2); commandevents commandevents = ide.events.commandevents; commandevents.beforeexecute += onbeforeexecute; commandevents.afterexecute += onafterexecute;  ...  private void onbeforeexecute(string guid, int id, object customin, object customout, ref bool canceldefault) {     if (id == (int)vsconstants.vsstd97cmdid.rebuildctx)     {         //     } }  private void onafterexecute(string guid, int id, object customin, object customout, ref bool canceldefault) {     if (id == (int)vsconstants.vsstd97cmdid.rebuildctx)     {         //     } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -