private void CreateOrUpdateTaskBarButtons(bool validRepo) { if (EnvUtils.RunningOnWindows() && TaskbarManager.IsPlatformSupported) { if (!_toolbarButtonsCreated) { _commitButton = new ThumbnailToolBarButton(MakeIcon(toolStripButton1.Image, 48, true), toolStripButton1.Text); _commitButton.Click += ToolStripButton1Click; _pushButton = new ThumbnailToolBarButton(MakeIcon(toolStripButtonPush.Image, 48, true), toolStripButtonPush.Text); _pushButton.Click += PushToolStripMenuItemClick; _pullButton = new ThumbnailToolBarButton(MakeIcon(toolStripButtonPull.Image, 48, true), toolStripButtonPull.Text); _pullButton.Click += PullToolStripMenuItemClick; _toolbarButtonsCreated = true; ThumbnailToolBarButton[] buttons = new[] { _commitButton, _pullButton, _pushButton }; //Call this method using reflection. This is a workaround to *not* reference WPF libraries, becuase of how the WindowsAPICodePack was implimented. TaskbarManager.Instance.ThumbnailToolBars.AddButtons(Handle, buttons); } _commitButton.Enabled = validRepo; _pushButton.Enabled = validRepo; _pullButton.Enabled = validRepo; } }
/// <summary> /// Adds a tab with console interface to Git over the current working copy. Recreates the terminal on tab activation if user exits the shell. /// </summary> private void FillTerminalTab() { if (!EnvUtils.RunningOnWindows() || !Module.EffectiveSettings.Detailed.ShowConEmuTab.ValueOrDefault) return; // ConEmu only works on WinNT TabPage tabpage; string sImageKey = "Resources.IconConsole"; CommitInfoTabControl.ImageList.Images.Add(sImageKey, Resources.IconConsole); CommitInfoTabControl.Controls.Add(tabpage = new TabPage(_consoleTabCaption.Text)); tabpage.ImageKey = sImageKey; // After adding page // Delay-create the terminal window when the tab is first selected CommitInfoTabControl.Selecting += (sender, args) => { if (args.TabPage != tabpage) return; if (terminal == null) // Lazy-create on first opening the tab { tabpage.Controls.Clear(); tabpage.Controls.Add( terminal = new ConEmuControl() { Dock = DockStyle.Fill, AutoStartInfo = null, IsStatusbarVisible = false } ); } if (terminal.IsConsoleEmulatorOpen) // If user has typed "exit" in there, restart the shell; otherwise just return return; // Create the terminal var startinfo = new ConEmuStartInfo(); startinfo.StartupDirectory = Module.WorkingDir; startinfo.WhenConsoleProcessExits = WhenConsoleProcessExits.CloseConsoleEmulator; // Choose the console: bash from git with fallback to cmd string sJustBash = "bash.exe"; // Generic bash, should generally be in the git dir, less configured than the specific git-bash string sJustSh = "sh.exe"; // Fallback to SH string cmdPath = new[] { sJustBash, sJustSh }. Select(shell => { string shellPath; if (PathUtil.TryFindShellPath(shell, out shellPath)) return shellPath; return null; }). Where(shellPath => shellPath != null). FirstOrDefault(); if (cmdPath == null) { startinfo.ConsoleProcessCommandLine = ConEmuConstants.DefaultConsoleCommandLine; } else { startinfo.ConsoleProcessCommandLine = cmdPath + " --login -i"; } startinfo.ConsoleProcessExtraArgs = " -new_console:P:\"<Solarized Light>\""; // Set path to git in this window (actually, effective with CMD only) if (!string.IsNullOrEmpty(AppSettings.GitCommandValue)) { string dirGit = Path.GetDirectoryName(AppSettings.GitCommandValue); if (!string.IsNullOrEmpty(dirGit)) startinfo.SetEnv("PATH", dirGit + ";" + "%PATH%"); } terminal.Start(startinfo); }; }