private void InitMenuItems(BuildCommandPackage package, OleMenuCommandService mcs) { this.package = package; LoadCustomCommand(); foreach (var menuHierarchy in _hierarchy2BaseCmdId.Keys) { int menuIdx = 0; for (int j = 0; j < _customMenu.Count; j++) { CustomMenuItem item = _customMenu[j]; if (item.hierarchy == menuHierarchy) { int baseCmdId = getMenuId(item); if (baseCmdId != 0) { var cmdID = new CommandID(CommandSet, baseCmdId + menuIdx); var mc = new OleMenuCommand(new EventHandler(OnCommandExec), cmdID); mc.BeforeQueryStatus += new EventHandler(OnBeforeQueryStatus); mcs.AddCommand(mc); _cmdId2MenuItem[cmdID.ID] = item; menuIdx++; } } } } }
public static async Task InitializeAsync(BuildCommandPackage package) { // Switch to the main thread - the call to AddCommand in BuildCommand's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); OleMenuCommandService commandService = await package.GetServiceAsync((typeof(IMenuCommandService))) as OleMenuCommandService; var instance = new CustomCommands(); instance.InitMenuItems(package, commandService); }
public CmdHelper(BuildCommandPackage package) { _package = package; }