Exemplo n.º 1
0
        private void GitPluginUISetupMainMenu()
        {
            // Try to delete the commandbar if it exists from a previous execution,
            // because the /resetaddin command-line switch of VS 2005 (or higher) add-in
            // projects only resets commands and buttons, not commandbars
            _gitPlugin.DeleteOldGitExtMainMenuBar();
            _gitPlugin.DeleteGitExtMainMenuBar();

            try
            {
                // Add a new commandbar popup
                CommandBar      mainMenuBar   = _gitPlugin.AddGitExtMainMenuBar(GetToolsMenuName());
                CommandBarPopup mainMenuPopup = (CommandBarPopup)mainMenuBar.Parent;

                var n = 1;

                // Add commands
                {
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Browse", "&Browse", "Browse repository", 12, n++, true);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Clone", "Clone &repository", "Clone existing Git", 14, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "CreateNewRepository", "Create new repositor&y", "Create new Git repository", 13, n++);
                }

                // Working with changes
                {
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Commit", "&Commit", "Commit changes", 7, n++, true);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Pull", "P&ull", "Pull changes from remote repository", 9, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Push", "Pu&sh", "Push changes to remote repository", 8, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Stash", "Stas&h", "Stash changes", 3, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Remotes", "Manage rem&otes", "Manage remote repositories", 17, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "GitIgnore", "Edit &.gitignore", "Edit .gitignore file", 22, n++);
                }

                // Patch
                {
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "ApplyPatch", "&Apply patch", "Apply patch", 0, n++, true);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "FormatPatch", "&Format patch", "Format patch", 0, n++);
                }

                {
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "ViewChanges", "V&iew changes", "View commit change history", 0, n++, true);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "FindFile", "Find fi&le", "Search for a file in the repository", 23, n++);
                }

                // Branch manipulations
                {
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "SwitchBranch", "Chec&kout branch", "Switch to branch", 16, n++, true);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "CreateBranch", "Create bra&nch", "Create new branch", 10, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Merge", "&Merge", "merge", 18, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Rebase", "R&ebase", "Rebase", 19, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "SolveMergeConflicts", "Sol&ve mergeconflicts", "Solve mergeconflicts", 0, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "CherryPick", "Cherry &pick", "Cherry pick commit", 15, n++);
                }

                {
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Bash", "&Git bash", "Start git bash", 21, n++, true);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "Settings", "Se&ttings", "Settings", 2, n++);
                    _gitPlugin.AddPopupCommand(mainMenuPopup, "About", "About Git E&xtensions", "About Git Extensions", 20, n);
                }
            }
            catch (Exception ex)
            {
                _gitPlugin.OutputPane.OutputString("Error creating contextmenu: " + ex);
            }
        }