Exemple #1
0
        private static bool LocateMissingGit()
        {
            int dialogResult = -1;

            using Microsoft.WindowsAPICodePack.Dialogs.TaskDialog dialog1 = new()
            {
                InstructionText = ResourceManager.TranslatedStrings.GitExecutableNotFound,
                Icon = TaskDialogStandardIcon.Error,
                StandardButtons = TaskDialogStandardButtons.Cancel,
                Cancelable = true,
            };
            TaskDialogCommandLink btnFindGitExecutable = new("FindGitExecutable", null, ResourceManager.TranslatedStrings.FindGitExecutable);
            btnFindGitExecutable.Click += (s, e) =>
            {
                dialogResult = 0;
                dialog1.Close();
            };
            TaskDialogCommandLink btnInstallGitInstructions = new("InstallGitInstructions", null, ResourceManager.TranslatedStrings.InstallGitInstructions);
            btnInstallGitInstructions.Click += (s, e) =>
            {
                dialogResult = 1;
                dialog1.Close();
            };
            dialog1.Controls.Add(btnFindGitExecutable);
            dialog1.Controls.Add(btnInstallGitInstructions);

            dialog1.Show();
            switch (dialogResult)
            {
                case 0:
                    {
                        using OpenFileDialog dialog = new()
                        {
                            Filter = @"git.exe|git.exe|git.cmd|git.cmd",
                        };
                        if (dialog.ShowDialog(null) == DialogResult.OK)
                        {
                            AppSettings.GitCommandValue = dialog.FileName;
                        }

                        if (CheckSettingsLogic.SolveGitCommand())
                        {
                            return true;
                        }

                        return false;
                    }

                case 1:
                    {
                        OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/wiki/Application-Dependencies#git");
                        return false;
                    }

                default:
                    {
                        return false;
                    }
            }
        }
Exemple #2
0
        private void GitFound_Click(object sender, EventArgs e)
        {
            if (!CheckSettingsLogic.SolveGitCommand())
            {
                MessageBox.Show(this, _solveGitCommandFailed.Text, _solveGitCommandFailedCaption.Text);

                PageHost.GotoPage(GitSettingsPage.GetPageReference());
                return;
            }

            MessageBox.Show(this, string.Format(_gitCanBeRun.Text, AppSettings.GitCommandValue), _gitCanBeRunCaption.Text);

            PageHost.GotoPage(GitSettingsPage.GetPageReference());
            SaveAndRescan_Click(null, null);
        }
Exemple #3
0
        private static bool LocateMissingGit()
        {
            int dialogResult = PSTaskDialog.cTaskDialog.ShowCommandBox(Title: "Error",
                                                                       MainInstruction: Strings.GitExecutableNotFound,
                                                                       Content: null,
                                                                       ExpandedInfo: null,
                                                                       Footer: null,
                                                                       VerificationText: null,
                                                                       CommandButtons: $"{Strings.FindGitExecutable}|{Strings.InstallGitInstructions}",
                                                                       ShowCancelButton: true,
                                                                       MainIcon: PSTaskDialog.eSysIcons.Error,
                                                                       FooterIcon: PSTaskDialog.eSysIcons.Warning);

            switch (dialogResult)
            {
            case 0:
            {
                using (var dialog = new OpenFileDialog
                    {
                        Filter = @"git.exe|git.exe|git.cmd|git.cmd",
                    })
                {
                    if (dialog.ShowDialog(null) == DialogResult.OK)
                    {
                        AppSettings.GitCommandValue = dialog.FileName;
                    }

                    if (CheckSettingsLogic.SolveGitCommand())
                    {
                        return(true);
                    }
                }

                return(false);
            }

            case 1:
            {
                Process.Start(@"https://github.com/gitextensions/gitextensions/wiki/Git");
                return(false);
            }

            default:
            {
                return(false);
            }
            }
        }
        private void BrowseGitPath_Click(object sender, EventArgs e)
        {
            CheckSettingsLogic.SolveGitCommand(GitPath.Text.Trim());

            using (var browseDialog = new OpenFileDialog
            {
                FileName = AppSettings.GitCommandValue,
                Filter = "Git.cmd (git.cmd)|git.cmd|Git.exe (git.exe)|git.exe|Git (git)|git"
            })
            {
                if (browseDialog.ShowDialog(this) == DialogResult.OK)
                {
                    GitPath.Text = browseDialog.FileName;
                }
            }
        }
        private static bool LocateMissingGit()
        {
            TaskDialogPage page = new()
            {
                Heading       = ResourceManager.TranslatedStrings.GitExecutableNotFound,
                Icon          = TaskDialogIcon.Error,
                Buttons       = { TaskDialogButton.Cancel },
                AllowCancel   = true,
                SizeToContent = true
            };
            TaskDialogCommandLinkButton btnFindGitExecutable      = new(ResourceManager.TranslatedStrings.FindGitExecutable);
            TaskDialogCommandLinkButton btnInstallGitInstructions = new(ResourceManager.TranslatedStrings.InstallGitInstructions);

            page.Buttons.Add(btnFindGitExecutable);
            page.Buttons.Add(btnInstallGitInstructions);

            TaskDialogButton result = TaskDialog.ShowDialog(page);

            if (result == btnFindGitExecutable)
            {
                using OpenFileDialog dialog = new() { Filter = @"git.exe|git.exe|git.cmd|git.cmd" };
                if (dialog.ShowDialog(null) == DialogResult.OK)
                {
                    AppSettings.GitCommandValue = dialog.FileName;
                }

                return(CheckSettingsLogic.SolveGitCommand());
            }

            if (result == btnInstallGitInstructions)
            {
                OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/wiki/Application-Dependencies#git");
                return(false);
            }

            return(false);
        }
    }
Exemple #6
0
        private static void RunApplication()
        {
            string[] args = Environment.GetCommandLineArgs();

            // This form created to obtain UI synchronization context only
            using (new Form())
            {
                // Store the shared JoinableTaskContext
                ThreadHelper.JoinableTaskContext = new JoinableTaskContext();
            }

            AppSettings.LoadSettings();
            if (EnvUtils.RunningOnWindows())
            {
                WebBrowserEmulationMode.SetBrowserFeatureControl();
                FormFixHome.CheckHomePath();
            }

            if (string.IsNullOrEmpty(AppSettings.Translation))
            {
                using (var formChoose = new FormChooseTranslation())
                {
                    formChoose.ShowDialog();
                }
            }

            try
            {
                // Ensure we can find the git command to execute,
                // unless we are being instructed to uninstall,
                // or AppSettings.CheckSettings is set to false.
                if (!(args.Length >= 2 && args[1] == "uninstall"))
                {
                    if (!CheckSettingsLogic.SolveGitCommand())
                    {
                        if (!LocateMissingGit())
                        {
                            Environment.Exit(-1);
                            return;
                        }
                    }

                    if (AppSettings.CheckSettings)
                    {
                        var uiCommands         = new GitUICommands("");
                        var commonLogic        = new CommonLogic(uiCommands.Module);
                        var checkSettingsLogic = new CheckSettingsLogic(commonLogic);
                        var fakePageHost       = new SettingsPageHostMock(checkSettingsLogic);
                        using (var checklistSettingsPage = SettingsPageBase.Create <ChecklistSettingsPage>(fakePageHost))
                        {
                            if (!checklistSettingsPage.CheckSettings())
                            {
                                if (!checkSettingsLogic.AutoSolveAllSettings())
                                {
                                    uiCommands.StartSettingsDialog();
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                // TODO: remove catch-all
            }

            if (EnvUtils.RunningOnWindows())
            {
                MouseWheelRedirector.Active = true;
            }

            var commands = new GitUICommands(GetWorkingDir(args));

            if (args.Length <= 1)
            {
                commands.StartBrowseDialog();
            }
            else
            {
                // if we are here args.Length > 1
                commands.RunCommand(args);
            }

            AppSettings.SaveSettings();
        }
Exemple #7
0
        private static void RunApplication()
        {
            string[] args = Environment.GetCommandLineArgs();

            // This form created to obtain UI synchronization context only
            using (new Form())
            {
                // Store the shared JoinableTaskContext
                ThreadHelper.JoinableTaskContext = new JoinableTaskContext();
            }

            AppSettings.LoadSettings();

            if (EnvUtils.RunningOnWindows())
            {
                WebBrowserEmulationMode.SetBrowserFeatureControl();
                FormFixHome.CheckHomePath();
            }

            if (string.IsNullOrEmpty(AppSettings.Translation))
            {
                using (var formChoose = new FormChooseTranslation())
                {
                    formChoose.ShowDialog();
                }
            }

            if (!AppSettings.TelemetryEnabled.HasValue)
            {
                AppSettings.TelemetryEnabled = MessageBox.Show(null, Strings.TelemetryPermissionMessage,
                                                               Strings.TelemetryPermissionCaption, MessageBoxButtons.YesNo,
                                                               MessageBoxIcon.Question) == DialogResult.Yes;
            }

            try
            {
                // Ensure we can find the git command to execute,
                // unless we are being instructed to uninstall,
                // or AppSettings.CheckSettings is set to false.
                if (!(args.Length >= 2 && args[1] == "uninstall"))
                {
                    if (!CheckSettingsLogic.SolveGitCommand())
                    {
                        if (!LocateMissingGit())
                        {
                            Environment.Exit(-1);
                            return;
                        }
                    }

                    if (AppSettings.CheckSettings)
                    {
                        var uiCommands         = new GitUICommands("");
                        var commonLogic        = new CommonLogic(uiCommands.Module);
                        var checkSettingsLogic = new CheckSettingsLogic(commonLogic);
                        var fakePageHost       = new SettingsPageHostMock(checkSettingsLogic);
                        using (var checklistSettingsPage = SettingsPageBase.Create <ChecklistSettingsPage>(fakePageHost))
                        {
                            if (!checklistSettingsPage.CheckSettings())
                            {
                                if (!checkSettingsLogic.AutoSolveAllSettings())
                                {
                                    uiCommands.StartSettingsDialog();
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                // TODO: remove catch-all
            }

            if (EnvUtils.RunningOnWindows())
            {
                MouseWheelRedirector.Active = true;
            }

            var commands = new GitUICommands(GetWorkingDir(args));

            if (args.Length <= 1)
            {
                commands.StartBrowseDialog();
            }
            else
            {
                // if we are here args.Length > 1

                // Avoid replacing the ExitCode eventually set while parsing arguments,
                // i.e. assume -1 and afterwards, only set it to 0 if no error is indicated.
                Environment.ExitCode = -1;
                if (commands.RunCommand(args))
                {
                    Environment.ExitCode = 0;
                }
            }

            AppSettings.SaveSettings();
        }
 private void GitPath_TextChanged(object sender, EventArgs e)
 {
     // If user pastes text or types in the box be sure to validate and save in the settings.
     CheckSettingsLogic.SolveGitCommand(GitPath.Text.Trim());
 }
Exemple #9
0
        private static bool LocateMissingGit()
        {
            int dialogResult = -1;

            using var dialog1 = new TaskDialog
                  {
                      InstructionText = ResourceManager.Strings.GitExecutableNotFound,
                      Icon            = TaskDialogStandardIcon.Error,
                      StandardButtons = TaskDialogStandardButtons.Cancel,
                      Cancelable      = true,
                  };
            var btnFindGitExecutable = new TaskDialogCommandLink("FindGitExecutable", null, ResourceManager.Strings.FindGitExecutable);

            btnFindGitExecutable.Click += (s, e) =>
            {
                dialogResult = 0;
                dialog1.Close();
            };
            var btnInstallGitInstructions = new TaskDialogCommandLink("InstallGitInstructions", null, ResourceManager.Strings.InstallGitInstructions);

            btnInstallGitInstructions.Click += (s, e) =>
            {
                dialogResult = 1;
                dialog1.Close();
            };
            dialog1.Controls.Add(btnFindGitExecutable);
            dialog1.Controls.Add(btnInstallGitInstructions);

            dialog1.Show();
            switch (dialogResult)
            {
            case 0:
            {
                using (var dialog = new OpenFileDialog
                    {
                        Filter = @"git.exe|git.exe|git.cmd|git.cmd",
                    })
                {
                    if (dialog.ShowDialog(null) == DialogResult.OK)
                    {
                        AppSettings.GitCommandValue = dialog.FileName;
                    }

                    if (CheckSettingsLogic.SolveGitCommand())
                    {
                        return(true);
                    }
                }

                return(false);
            }

            case 1:
            {
                Process.Start(@"https://github.com/gitextensions/gitextensions/wiki/Application-Dependencies#git");
                return(false);
            }

            default:
            {
                return(false);
            }
            }
        }