private void GitPluginUISetupCommandBar() { // 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.DeleteGitCommandBar(); try { CommandBar commandBar = _gitPlugin.AddGitCommandBar(MsoBarPosition.msoBarTop); _gitPlugin.AddToolbarCommandWithText(commandBar, "Commit", "Commit", "Commit changes", 7, 1); _gitPlugin.AddToolbarCommand(commandBar, "Browse", "Browse", "Browse repository", 12, 2); _gitPlugin.AddToolbarCommand(commandBar, "Pull", "Pull", "Pull changes from remote repository", 9, 3); _gitPlugin.AddToolbarCommand(commandBar, "Push", "Push", "Push changes to remote repository", 8, 4); _gitPlugin.AddToolbarCommand(commandBar, "Stash", "Stash", "Stash changes", 3, 5); _gitPlugin.AddToolbarCommand(commandBar, "Settings", "Settings", "Settings", 2, 6); } catch (Exception ex) { _gitPlugin.OutputPane.OutputString("Error creating toolbar: " + ex); } }
private void GitPluginUISetup() { if (_gitPlugin == null) { return; } try { #if DEBUG this._gitPlugin.OutputPane.OutputString("Git Extensions plugin connected" + Environment.NewLine); #endif this.RegiserGitPluginCommand(); //Place the command on the tools menu. //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items: var menuBarCommandBar = _gitPlugin.GetMenuBar(); CommandBarControl toolsControl; CommandBarPopup toolsPopup = null; try { toolsControl = menuBarCommandBar.Controls["Git"]; } catch { toolsControl = null; } try { if (toolsControl == null) { toolsControl = menuBarCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 4, false); toolsControl.Caption = "&Git"; } toolsPopup = (CommandBarPopup)toolsControl; toolsPopup.Caption = "&Git"; } catch (Exception ex) { try { _gitPlugin.OutputPane.OutputString( "Error creating git menu (trying to add commands to tools menu): " + ex); if (toolsControl == null) { toolsControl = menuBarCommandBar.Controls[this.GetToolsMenuName()]; toolsPopup = (CommandBarPopup)toolsControl; } } catch (Exception ex2) { _gitPlugin.OutputPane.OutputString("Error menu: " + ex2); } } try { // add the toolbar and menu commands var commandBar = _gitPlugin.AddGitCommandBar(MsoBarPosition.msoBarTop); _gitPlugin.AddToolbarCommandWithText( commandBar, "GitExtensionsCommit", "Commit", "Commit changes", 7, 1); _gitPlugin.AddToolbarCommand(commandBar, "GitExtensionsBrowse", "Browse", "Browse repository", 12, 2); _gitPlugin.AddToolbarCommand(commandBar, "GitExtensionsPull", "Pull", "Pull changes from remote repository", 9, 3); _gitPlugin.AddToolbarCommand(commandBar, "GitExtensionsPush", "Push", "Push changes to remote repository", 8, 4); _gitPlugin.AddToolbarCommand(commandBar, "GitExtensionsStash", "Stash", "Stash changes", 3, 5); _gitPlugin.AddToolbarCommand(commandBar, "GitExtensionsSettings", "Settings", "Settings", 2, 6); } catch (Exception ex) { _gitPlugin.OutputPane.OutputString("Error creating toolbar: " + ex); } try { var n = 1; _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsApplyPatch", "&Apply patch", "Apply patch", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsBrowse", "&Browse", "Browse repository", 12, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsSwitchBranch", "Chec&kout branch", "Switch to branch", 10, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsCherryPick", "Cherry &pick", "Cherry pick commit", 11, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsCommit", "&Commit", "Commit changes", 7, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsCreateBranch", "Create bra&nch", "Create new branch", 10, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsClone", "Clone &repository", "Clone existing Git", 14, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsGitIgnore", "Edit &.gitignore", "Edit .gitignore file", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsFormatPatch", "&Format patch", "Format patch", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsBash", "&Git bash", "Start git bash", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsInitRepository", "Initialize new repositor&y", "Initialize new Git repository", 13, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsRemotes", "Manage rem&otes", "Manage remote repositories", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsMerge", "&Merge", "merge", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsPull", "P&ull", "Pull changes from remote repository", 9, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsPush", "Pu&sh", "Push changes to remote repository", 8, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsRebase", "R&ebase", "Rebase", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsSearchFile", "Search fi&le", "Search a file in the repository", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsSettings", "Se&ttings", "Settings", 2, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsSolveMergeConflicts", "Sol&ve mergeconflicts", "Solve mergeconflicts", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsStash", "Stas&h", "Stash changes", 3, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsDiff", "V&iew changes", "View commit change history", 0, n++); _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsAbout", "About Git E&xtensions", "About Git Extensions", 0, n++); } catch (Exception ex) { _gitPlugin.OutputPane.OutputString("Error creating contextmenu: " + ex); } AddContextMenuItemsToContextMenu("Web Item"); AddContextMenuItemsToContextMenu("Item"); AddContextMenuItemsToContextMenu("Easy MDI Document Window"); AddContextMenuItemsToContextMenu("Code Window"); AddContextMenuItemsToContextMenu("Script Context"); AddContextMenuItemsToContextMenu("ASPX Context"); /* * Uncomment the code block below to help find the name of commandbars in * visual studio. All commandbars (and context menu's) will get a new entry * with the name of that commandbar. * foreach (var commandBar in _gitPlugin.CommandBars) * { * _gitPlugin.OutputPane.OutputString(((CommandBar)commandBar).Name + Environment.NewLine); * }*/ } catch (Exception ex) { this._gitPlugin.OutputPane.OutputString("Error loading plugin: " + ex); } }