Exemplo n.º 1
0
        public static async Task RunAutoUpdater(UpdaterOptions options, TinyIoCContainer container, bool manualCheck = false)
        {
            return;

            // Only check once per day.
            if (!manualCheck && options.lastCheck != null && (DateTime.Now - options.lastCheck) < options.checkInterval)
            {
                return;
            }

            bool    newVersion;
            Version remoteVersion;
            string  releaseNotes;
            string  downloadUrl;

            if (options.repo != null)
            {
                (newVersion, remoteVersion, releaseNotes, downloadUrl) = await CheckForGitHubUpdate(options, container);
            }
            else
            {
                (newVersion, remoteVersion, releaseNotes, downloadUrl) = await CheckForManifestUpdate(options);
            }

            if (remoteVersion != null)
            {
                options.lastCheck = DateTime.Now;
            }

            if (newVersion)
            {
                // Make sure we open the UpdateQuestionForm on a UI thread.
                await(Task) ActGlobals.oFormActMain.Invoke((Func <Task>)(() =>
                {
                    var dialog = new UpdateQuestionForm(options, releaseNotes);
                    var result = dialog.ShowDialog();
                    dialog.Dispose();

                    if (result == DialogResult.Yes)
                    {
                        return(InstallUpdate(downloadUrl, options));
                    }

                    return(Task.CompletedTask);
                }));
            }
            else if (manualCheck && remoteVersion != null)
            {
                ActGlobals.oFormActMain.Invoke((Action)(() =>
                {
                    MessageBox.Show(
                        Resources.UpdateAlreadyLatest,
                        string.Format(Resources.UpdateTitle, options.project),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );
                }));
            }
        }
Exemplo n.º 2
0
        public static async void PerformUpdateIfNecessary(string pluginDirectory, bool alwaysTalk = false)
        {
            var(newVersion, remoteVersion, releaseNotes) = await CheckForUpdate();

            if (newVersion)
            {
                var dialog = new UpdateQuestionForm(releaseNotes);
                var result = dialog.ShowDialog();
                dialog.Dispose();

                if (result == DialogResult.Yes)
                {
                    await InstallUpdate(remoteVersion, pluginDirectory);
                }
            }
            else if (alwaysTalk)
            {
                MessageBox.Show("You are already on the latest version.", "OverlayPlugin", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 3
0
        public static async void PerformUpdateIfNecessary(Control parent, string pluginDirectory, bool manualCheck = false)
        {
            var config = Registry.Resolve <IPluginConfig>();

            // Only check once per day.
            if (!manualCheck && config.LastUpdateCheck != null && (DateTime.Now - config.LastUpdateCheck).TotalDays < 1)
            {
                return;
            }

            var(newVersion, remoteVersion, releaseNotes) = await CheckForUpdate(parent);

            if (remoteVersion != null)
            {
                config.LastUpdateCheck = DateTime.Now;
            }

            if (newVersion)
            {
                // Make sure we open the UpdateQuestionForm on a UI thread.
                parent.Invoke((Action)(async() =>
                {
                    var dialog = new UpdateQuestionForm(releaseNotes);
                    var result = dialog.ShowDialog();
                    dialog.Dispose();

                    if (result == DialogResult.Yes)
                    {
                        await InstallUpdate(remoteVersion, pluginDirectory);
                    }
                }));
            }
            else if (manualCheck && remoteVersion != null)
            {
                parent.Invoke((Action)(() =>
                {
                    MessageBox.Show(Resources.UpdateAlreadyLatest, Resources.UpdateTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }));
            }
        }