Esempio n. 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;
                    }
            }
        }
Esempio n. 2
0
        public FormAbout()
        {
            InitializeComponent();
            _NO_TRANSLATE_labelProductName.Text = AppSettings.ApplicationName;
            InitializeComplete();

            environmentInfo.SetCopyButtonTooltip(_copyTooltip.Text);

            Color clrLink = SystemColors.Highlight;

            _NO_TRANSLATE_labelProductName.LinkColor = clrLink;
            _NO_TRANSLATE_ThanksTo.LinkColor         = clrLink;
            linkLabelIcons.LinkColor = clrLink;

            // Click handlers
            _NO_TRANSLATE_labelProductName.LinkClicked += delegate { OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions"); };
            _NO_TRANSLATE_ThanksTo.LinkClicked         += delegate { ShowContributorsForm(); };
            pictureDonate.Click        += delegate { OsShellUtil.OpenUrlInDefaultBrowser(FormDonate.DonationUrl); };
            linkLabelIcons.LinkClicked += delegate { OsShellUtil.OpenUrlInDefaultBrowser(@"http://p.yusukekamiyamane.com/"); };

            var contributorsList         = GetContributorList();
            var thanksToContributorsText = string.Format(_thanksToContributors.Text, contributorsList.Count);

            var random = new Random();

            thanksTimer.Tick    += delegate { ThankNextContributor(); };
            thanksTimer.Enabled  = true;
            thanksTimer.Interval = 1000;
            thanksTimer.Start();

            ThankNextContributor();

            return;

            void ShowContributorsForm()
            {
                using (var formContributors = new FormContributors())
                {
                    formContributors.ShowDialog(owner: this);
                }
            }

            void ThankNextContributor()
            {
                // Select a contributor at random
                var contributorName = contributorsList[random.Next(contributorsList.Count)].Trim();

                _NO_TRANSLATE_ThanksTo.Text = thanksToContributorsText + contributorName;
            }

            IReadOnlyList <string> GetContributorList()
            {
                return(new[] { Resources.Team, Resources.Coders, Resources.Translators, Resources.Designers }
                       .Select(c => c.Replace(Environment.NewLine, ""))
                       .SelectMany(line => line.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                       .Select(contributor => contributor.Trim())
                       .ToList());
            }
        }
            public void OpenRemoteUrlInBrowser()
            {
                if (!IsRemoteUrlUsingHttp)
                {
                    return;
                }

                OsShellUtil.OpenUrlInDefaultBrowser(_remote.FetchUrl);
            }
Esempio n. 4
0
        private void LaunchUrl(LaunchType launchType)
        {
            switch (launchType)
            {
            case LaunchType.ChangeLog:
                OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/blob/master/GitUI/Resources/ChangeLog.md");
                break;

            case LaunchType.DirectDownload:
                OsShellUtil.OpenUrlInDefaultBrowser(UpdateUrl);
                break;
            }
        }
        }                                            // for focusing

        public BuildReportTabPageExtension(Func <IGitModule> getModule, TabControl tabControl, string caption)
        {
            _getModule  = getModule;
            _tabControl = tabControl;
            _caption    = caption;

            _openReportLink.Click += (o, args) =>
            {
                if (!string.IsNullOrWhiteSpace(_url))
                {
                    OsShellUtil.OpenUrlInDefaultBrowser(_url);
                }
            };
            _openReportLink.Font = new Font(_openReportLink.Font.Name, 16F);
        }
Esempio n. 6
0
        private void _openGitupPageBtn_Click(object sender, EventArgs e)
        {
            if (CurrentySelectedGitRepo is null)
            {
                return;
            }

            string hp = CurrentySelectedGitRepo.Homepage;

            if (string.IsNullOrEmpty(hp) || (!hp.StartsWith("http://") && !hp.StartsWith("https://")))
            {
                MessageBox.Show(this, _strNoHomepageDefined.Text, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                OsShellUtil.OpenUrlInDefaultBrowser(CurrentySelectedGitRepo.Homepage);
            }
        }
Esempio n. 7
0
        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);
        }
    }
Esempio n. 8
0
        private void SendAndQuitButton_Click(object sender, EventArgs e)
        {
            var hasUserText = CheckContainsInfo(descriptionTextBox.Text);

            if (!hasUserText)
            {
                MessageBox.Show(this, _noReproStepsSuppliedErrorMessage.Text, _title.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                descriptionTextBox.Focus();
                return;
            }

            if (MessageBox.Show(this, _submitGitHubMessage.Text, _title.Text,
                                MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
            {
                return;
            }

            string url = UrlBuilder.Build("https://github.com/gitextensions/gitextensions/issues/new", _lastException.OriginalException, _environmentInfo, descriptionTextBox.Text);

            OsShellUtil.OpenUrlInDefaultBrowser(url);

            DialogResult = DialogResult.Abort;
            Close();
        }
Esempio n. 9
0
 private static void DonateItem_Click(object sender, EventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(FormDonate.DonationUrl);
 }
        private void OpenManual()
        {
            string url = GetUrl();

            OsShellUtil.OpenUrlInDefaultBrowser(url);
        }
Esempio n. 11
0
 private void LlblTelemetryPrivacyLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/blob/master/PrivacyPolicy.md");
 }
 private void GcmDetectedFix_Click(object sender, EventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/wiki/How-To:-fix-GitCredentialWinStore-missing");
 }
Esempio n. 13
0
 private void lnkGitIgnoreGenerate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://www.gitignore.io/");
 }
Esempio n. 14
0
        private static CommandStatus RunScriptInternal(IWin32Window owner, IGitModule module, string?scriptKey, IGitUICommands uiCommands, RevisionGridControl?revisionGrid)
        {
            if (Strings.IsNullOrEmpty(scriptKey))
            {
                return(false);
            }

            ScriptInfo?scriptInfo = ScriptManager.GetScript(scriptKey);

            if (scriptInfo is null)
            {
                ThreadHelper.AssertOnUIThread();
                throw new UserExternalOperationException($"{TranslatedStrings.ScriptErrorCantFind}: '{scriptKey}'",
                                                         new ExternalOperationException(command: null, arguments: null, module.WorkingDir, innerException: null));
            }

            if (Strings.IsNullOrEmpty(scriptInfo.Command))
            {
                return(false);
            }

            string?arguments = scriptInfo.Arguments;

            if (!Strings.IsNullOrEmpty(arguments) && revisionGrid is null)
            {
                string?optionDependingOnSelectedRevision
                    = ScriptOptionsParser.Options.FirstOrDefault(option => ScriptOptionsParser.DependsOnSelectedRevision(option) &&
                                                                 ScriptOptionsParser.Contains(arguments, option));
                if (optionDependingOnSelectedRevision is not null)
                {
                    ThreadHelper.AssertOnUIThread();
                    throw new UserExternalOperationException($"{TranslatedStrings.ScriptText}: '{scriptKey}'{Environment.NewLine}'{optionDependingOnSelectedRevision}' {TranslatedStrings.ScriptErrorOptionWithoutRevisionGridText}",
                                                             new ExternalOperationException(scriptInfo.Command, arguments, module.WorkingDir, innerException: null));
                }
            }

            if (scriptInfo.AskConfirmation &&
                MessageBox.Show(owner, $"{TranslatedStrings.ScriptConfirmExecute}: '{scriptInfo.Name}'?", TranslatedStrings.ScriptText,
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return(false);
            }

            string?originalCommand = scriptInfo.Command;

            (string?argument, bool abort) = ScriptOptionsParser.Parse(scriptInfo.Arguments, module, owner, revisionGrid);
            if (abort)
            {
                ThreadHelper.AssertOnUIThread();
                throw new UserExternalOperationException($"{TranslatedStrings.ScriptText}: '{scriptKey}'{Environment.NewLine}{TranslatedStrings.ScriptErrorOptionWithoutRevisionText}",
                                                         new ExternalOperationException(scriptInfo.Command, arguments, module.WorkingDir, innerException: null));
            }

            Validates.NotNull(argument);

            string command = OverrideCommandWhenNecessary(originalCommand);

            command = ExpandCommandVariables(command, module);

            if (scriptInfo.IsPowerShell)
            {
                PowerShellHelper.RunPowerShell(command, argument, module.WorkingDir, scriptInfo.RunInBackground);

                // 'RunPowerShell' always runs the script detached (yet).
                // Hence currently, it does not make sense to set 'needsGridRefresh' to '!scriptInfo.RunInBackground'.
                return(new CommandStatus(executed: true, needsGridRefresh: false));
            }

            if (command.StartsWith(PluginPrefix))
            {
                command = command.Replace(PluginPrefix, string.Empty);

                lock (PluginRegistry.Plugins)
                {
                    foreach (var plugin in PluginRegistry.Plugins)
                    {
                        if (string.Equals(plugin.Name, command, StringComparison.CurrentCultureIgnoreCase))
                        {
                            var eventArgs = new GitUIEventArgs(owner, uiCommands);
                            return(new CommandStatus(executed: true, needsGridRefresh: plugin.Execute(eventArgs)));
                        }
                    }
                }

                return(false);
            }

            if (command.StartsWith(NavigateToPrefix))
            {
                if (revisionGrid is null)
                {
                    return(false);
                }

                command = command.Replace(NavigateToPrefix, string.Empty);
                if (!Strings.IsNullOrEmpty(command))
                {
                    var revisionRef = new Executable(command, module.WorkingDir).GetOutputLines(argument).FirstOrDefault();

                    if (revisionRef is not null)
                    {
                        revisionGrid.GoToRef(revisionRef, true);
                    }
                }

                return(new CommandStatus(executed: true, needsGridRefresh: false));
            }

            if (!scriptInfo.RunInBackground)
            {
                bool success = FormProcess.ShowDialog(owner, command, argument, module.WorkingDir, null, true);
                if (!success)
                {
                    return(false);
                }
            }
            else
            {
                if (originalCommand.Equals("{openurl}", StringComparison.CurrentCultureIgnoreCase))
                {
                    OsShellUtil.OpenUrlInDefaultBrowser(argument);
                }
                else
                {
                    // It is totally valid to have a command without an argument, e.g.:
                    //    Command  : myscript.cmd
                    //    Arguments: <blank>
                    new Executable(command, module.WorkingDir).Start(argument ?? string.Empty);
                }
            }

            return(new CommandStatus(executed: true, needsGridRefresh: !scriptInfo.RunInBackground));
        }
Esempio n. 15
0
 private void downloadGitForWindows_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/wiki/Application-Dependencies#git");
 }
Esempio n. 16
0
 private void lnkGitIgnorePatterns_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/github/gitignore");
 }
Esempio n. 17
0
 private void helpTranslate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/wiki/Translations");
 }
Esempio n. 18
0
 private static void IssuesItem_Click(object sender, EventArgs e)
 {
     UserEnvironmentInformation.CopyInformation();
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/issues");
 }
Esempio n. 19
0
 private void downloadDictionary_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/wiki/Spelling");
 }
Esempio n. 20
0
 private void pictureAvatarHelp_Click(object sender, EventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"http://en.gravatar.com/site/implement/images#default-image");
 }
Esempio n. 21
0
 private void PictureBox1Click(object sender, EventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(DonationUrl);
 }
Esempio n. 22
0
 private void linkGitRevParse_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://git-scm.com/docs/git-rev-parse#_specifying_revisions");
 }
Esempio n. 23
0
 private static void GitHubItem_Click(object sender, EventArgs e)
 {
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions");
 }