コード例 #1
0
        public void RecreateMenu(VBProject project)
        {
            int windowMenuId    = 30038;
            var menuBarControls = _app.IDE.CommandBars[1].Controls;
            var beforeIndex     = FindMenuInsertionIndex(menuBarControls, windowMenuId);

            if (_menu != null)
            {
                UnsubsribeCommandBarButtonClickEvents();
                beforeIndex = _menu.Index;
                _menu.Delete();
            }

            _menu         = menuBarControls.Add(MsoControlType.msoControlPopup, Before: beforeIndex, Temporary: true) as CommandBarPopup;
            _menu.Tag     = "VBAGit";
            _menu.Caption = VBAGitUI.VBAGitMenu;

            if (_app.GetVBProjectRepository(project) != null)
            {
                _gitSync   = AddButton(_menu, VBAGitUI.VBAGitMenu_Sync, false, OnGitSync, "git_sync");
                _gitCommit = AddButton(_menu, VBAGitUI.VBAGitMenu_Commit, false, OnGitCommit, "git_commit");
                _gitPull   = AddButton(_menu, VBAGitUI.VBAGitMenu_Pull, true, OnGitPull, "git_pull");
                _gitFetch  = AddButton(_menu, VBAGitUI.VBAGitMenu_Fecth, false, OnGitFetch, "git_pull");
                _gitPush   = AddButton(_menu, VBAGitUI.VBAGitMenu_Push, false, OnGitPush, "git_push");

                AddVBAGitMenu(true);
            }
            else
            {
                _gitCreate = AddButton(_menu, VBAGitUI.VBAGitMenu_Create, false, OnGitCreate, "create_repo");

                AddVBAGitMenu(false);
            }
        }
コード例 #2
0
ファイル: ContextMenu.cs プロジェクト: sanny32/VBAGit
        public void RecreateMenu(VBProject project)
        {
            RemoveButtons();

            var commandBar = _app.IDE.CommandBars["Project Window"];
            var beforeItem = commandBar.Controls.Cast <CommandBarControl>().First(control => control.Id == 2578).Index;

            if (_app.GetVBProjectRepository(project) != null)
            {
                _gitCommit = AddButton(commandBar, beforeItem, VBAGitUI.VBAGitMenu_Commit, true, _gitCommit_Click, "git_commit");
                _gitRevert = AddButton(commandBar, beforeItem + 1, VBAGitUI.VBAGitMenu_Revert, false, _gitRevert_Click, "VBAGit_revert");

                _selectedItem = _projectExplorer.GetSelectedItem();
                UpdateButtonsState(_selectedItem.Folder);
            }
        }