private async void AboutBox_Load(object?sender, EventArgs e)
        {
            _newestVersion = await TTG.IsUpToDate();

            if (_newestVersion != null)
            {
                LOG.Debug($"Newer Version Available - New: {_newestVersion} - Current: {AssemblyVersion}");

                UpdateCheckLabel.Text = $"Version {_newestVersion.ToString( 3 )} is available.";
                UpdateButton.Enabled  = true;
            }
            else
            {
                UpdateCheckLabel.Text = AssemblyTitle + " is up to date.";
                LOG.Debug($"Update to Date - Version: {AssemblyVersion}");
            }
        }
        static int Main(String[] args)
        {
            LOG.Debug($"Application Startup - Args: {String.Join( ", ", args )}");
            LOG.Debug($"Version: {Assembly.GetExecutingAssembly().GetName().Version}");

            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            if (!TTG.VerifyAssemblyVersions())
            {
                return(1);
            }

            Parser.Default.ParseArguments <CommitInstallArguments, DefaultArguments>(args)
            .WithParsed <CommitInstallArguments>((args) =>
            {
                var exe = TTG.GetExe();
                LOG.Debug($"Starting application after install: {exe}");
                Process.Start(exe);
            })
            .WithParsed <DefaultArguments>((a) =>
            {
                if (_mutex.WaitOne(TimeSpan.Zero, true))
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    LOG.Debug("Starting Tabbed TortoiseGit");
                    Application.Run(ProgramForm.Create(a.Startup));
                    _mutex.ReleaseMutex();
                }
                else
                {
                    LOG.Debug("Tabbed TortoiseGit instance already exists");
                    Native.PostMessage((IntPtr)Native.HWND_BROADCAST, ProgramForm.WM_SHOWME, IntPtr.Zero, IntPtr.Zero);
                }
            })
            .WithNotParsed((errors) =>
            {
                LOG.Error("Invalid command line arguments:" + String.Join("", errors.Select((e) => $"\n\t{e}: {e.Tag}")));
            });

            LOG.Debug("Application End");
            return(0);
        }
 private async void UpdateButton_Click(object?sender, EventArgs e)
 {
     LOG.Debug($"{nameof( UpdateButton_Click )} - Newest Version: {_newestVersion!.ToString( 3 )}");
     if (DialogResult.Yes == MessageBox.Show("This will exit Tabbed TortoiseGit. Continue?", "New Update", MessageBoxButtons.YesNo))
     {
         LOG.Debug("Update Prompt - OK");
         if (await TTG.UpdateApplication(_newestVersion))
         {
             LOG.Debug("Update - Exiting Application");
             Application.Exit();
         }
         else
         {
             LOG.Debug("Update - Error occurred");
             MessageBox.Show("There was an error updating Tabbed TortoiseGit. Try again later.");
         }
     }
 }
Esempio n. 4
0
        private async void TabbedTortoiseGitForm_Shown(object?sender, EventArgs e)
        {
            LOG.Debug($"{nameof( TabbedTortoiseGitForm_Shown )}");

            if (!_skipUpdateCheck)
            {
                DateTime lastUpdatePromptTime = Settings.Default.LastUpdatePromptTime;
                DateTime now        = DateTime.Now;
                TimeSpan difference = now - lastUpdatePromptTime;
                LOG.Debug($"{nameof( TabbedTortoiseGitForm_Shown )} - Last Update Prompt Time: {lastUpdatePromptTime} - Now: {now} - Difference: {difference}");
                if (difference >= TimeSpan.FromDays(1))
                {
                    Version?newestVersion = await TTG.IsUpToDate();

                    if (newestVersion != null)
                    {
                        LOG.Debug($"Newest Version: {newestVersion}");

                        if (DialogResult.Yes == MessageBox.Show($"Version {newestVersion} of Tabbed TortoiseGit is available. Update now?\n\nNote: This will exit Tabbed TortoiseGit.", "New Update", MessageBoxButtons.YesNo))
                        {
                            LOG.Debug("Update Prompt: Yes");
                            Settings.Default.LastUpdatePromptTime = DateTime.MinValue;
                            Settings.Default.Save();

                            if (await TTG.UpdateApplication(newestVersion))
                            {
                                LOG.Debug("Update - Exiting Application");
                                Application.Exit();
                            }
                            else
                            {
                                LOG.Debug("Update - Error occurred");
                                MessageBox.Show("There was an error updating Tabbed TortoiseGit. Try again later.");
                            }
                        }
                        else
                        {
                            LOG.Debug("Update Prompt: No");
                            Settings.Default.LastUpdatePromptTime = now;
                            Settings.Default.Save();

                            MessageBox.Show("To update Tabbed TortoiseGit at a later date, go to Options->About and click Update.", "New Update", MessageBoxButtons.OK);
                        }
                    }
                }
            }

            if (Settings.Default.CheckTortoiseGitOnPath)
            {
                if (!(await GitAction.CanAccessTortoiseGit()))
                {
                    using ConfirmationDialog dialog = new ConfirmationDialog("Cannot access TortoiseGit", "TortoiseGit does not appear to be on PATH (this will prevent Tabbed TortoiseGit from being able to open logs). Update PATH environment variable to include directory for TortoiseGitProc.exe.");
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        if (dialog.DoNotAskAgain)
                        {
                            Settings.Default.CheckTortoiseGitOnPath = false;
                            Settings.Default.Save();
                        }
                    }
                }
            }

            if (_showStartUpRepos)
            {
                await OpenStartupRepos();
            }

            if (Settings.Default.ShouldShowChangelog)
            {
                Settings.Default.ShouldShowChangelog = false;

                if (Settings.Default.ShowChangelogOnUpdate)
                {
                    ChangelogDialog.ShowChangelog();
                }
            }
        }