CommandBars_FindBar( Microsoft.VisualStudio.CommandBars.CommandBars InBars, string InBarName) { Microsoft.VisualStudio.CommandBars.CommandBar foundBar = null; try { foundBar = InBars[InBarName]; } catch (System.Exception) { foundBar = null; } return(foundBar); }
public CommandBarCollectionNodeFactory(Microsoft.VisualStudio.CommandBars.CommandBars commandBars) { _commandBars = commandBars; }
/// <summary>Implements the OnStartupComplete method of the IDTExtensibility2 interface. Receives notification that the host application has completed loading.</summary> /// <param term='custom'>Array of parameters that are host application specific.</param> /// <seealso class='IDTExtensibility2' /> public void OnStartupComplete(ref Array custom) { object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)_applicationObject.Commands; Microsoft.VisualStudio.CommandBars.CommandBars _commandBars = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars); // add a top-level menu to stick some global options in { Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"]; int nenhancerPopupIndex = menuBarCommandBar.Controls.Count + 1; CommandBarPopup clangMenuRoot = menuBarCommandBar.Controls.Add( MsoControlType.msoControlPopup, Type.Missing, Type.Missing, nenhancerPopupIndex, true) as CommandBarPopup; clangMenuRoot.Caption = "Clang"; // open the settings dialog { _dteHelper.AddNamedCommand2( COMMAND_CLANG_SETTINGS_DLG, "Settings...", "Settings...", false, 0); Command commandToAdd = _applicationObject.Commands.Item(GetCommandFullName(COMMAND_CLANG_SETTINGS_DLG), 0); SettingsButton = commandToAdd.AddControl(clangMenuRoot.CommandBar, clangMenuRoot.CommandBar.Controls.Count + 1) as CommandBarButton; } // get active vcproj, rebuild it with Clang { _dteHelper.AddNamedCommand2( COMMAND_CLANG_REBUILD_ACTIVE, "Rebuild Active Project", "Rebuild Active Project", false, 0); Command commandToAdd = _applicationObject.Commands.Item(GetCommandFullName(COMMAND_CLANG_REBUILD_ACTIVE), 0); RebuildActiveProjectButton = commandToAdd.AddControl(clangMenuRoot.CommandBar, clangMenuRoot.CommandBar.Controls.Count + 1) as CommandBarButton; } { _dteHelper.AddNamedCommand2( COMMAND_CLANG_RELINK_ACTIVE, "Relink", "Relink", false, 0); Command commandToAdd = _applicationObject.Commands.Item(GetCommandFullName(COMMAND_CLANG_RELINK_ACTIVE), 0); RebuildActiveProjectButton = commandToAdd.AddControl(clangMenuRoot.CommandBar, clangMenuRoot.CommandBar.Controls.Count + 1) as CommandBarButton; } } // add a compile-this-file option to the editor window { Microsoft.VisualStudio.CommandBars.CommandBar codeWinCommandBar = _dteHelper.GetCommandBarByName("Code Window"); int pmPopupIndex = codeWinCommandBar.Controls.Count + 1; CommandBarPopup pmPopup = codeWinCommandBar.Controls.Add( MsoControlType.msoControlPopup, Type.Missing, Type.Missing, pmPopupIndex, true) as CommandBarPopup; pmPopup.Caption = "Clang Compiler"; CommandBarButton saveAndCompileCmd = _dteHelper.AddButtonToPopup( pmPopup, pmPopup.Controls.Count + 1, "Compile", "Compile"); CompileCmdEvent = _applicationObject.Events.get_CommandBarEvents(saveAndCompileCmd) as CommandBarEvents; CompileCmdEvent.Click += new _dispCommandBarControlEvents_ClickEventHandler(cvxCompileFile_menuop); CommandBarButton saveAndAnalyseCmd = _dteHelper.AddButtonToPopup( pmPopup, pmPopup.Controls.Count + 1, "Run Static Analysis", "Run Static Analysis"); AnalyseCmdEvent = _applicationObject.Events.get_CommandBarEvents(saveAndAnalyseCmd) as CommandBarEvents; AnalyseCmdEvent.Click += new _dispCommandBarControlEvents_ClickEventHandler(cvxAnalyseFile_menuop); CommandBarButton saveAndDasmCmd = _dteHelper.AddButtonToPopup( pmPopup, pmPopup.Controls.Count + 1, "View Disassembly (LLVM)", "View Disassembly (LLVM)"); DasmCmdEvent = _applicationObject.Events.get_CommandBarEvents(saveAndDasmCmd) as CommandBarEvents; DasmCmdEvent.Click += new _dispCommandBarControlEvents_ClickEventHandler(cvxDasmnFile_menuop); CommandBarButton dasmAndPreproCmd = _dteHelper.AddButtonToPopup( pmPopup, pmPopup.Controls.Count + 1, "View Preprocessor Result", "View Preprocessor Result"); PreproCmdEvent = _applicationObject.Events.get_CommandBarEvents(dasmAndPreproCmd) as CommandBarEvents; PreproCmdEvent.Click += new _dispCommandBarControlEvents_ClickEventHandler(cvxPreProFile_menuop); } }