Ejemplo n.º 1
0
        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++;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public CmdHelper(BuildCommandPackage package)
 {
     _package = package;
 }