Beispiel #1
0
        /// <summary>
        /// Prompt the user if a newer version is available.
        /// </summary>
        /// <param name="flashMulti">An instance of the <see cref="FlashMulti"/> class.</param>
        public static async void DoCheck(FlashMulti flashMulti)
        {
            // Get check for the latest version on Github
            UpdateCheck check = new UpdateCheck();
            await Task.Run(() => { check = GetLatestVersion(); });

            // If the check completed successfully
            if (check.CheckSuccess)
            {
                // Get the current version
                Version currentVersion = Version.Parse(Application.ProductVersion);

                // Get the version available on Github
                Version latestVersion = check.LatestVersion;

                // Check if the current version is older than the latest Github release version
                if (currentVersion.CompareTo(latestVersion) == -1)
                {
                    // A newer version is available to show the user a prompt
                    Debug.WriteLine($"App version is older than latest version: {currentVersion} < {latestVersion}");
                    DialogResult showUpdate = MessageBox.Show(
                        $"A newer version of Flash Multi is available.\n\nYou have Flash Multi v{currentVersion.ToString()} and Flash Multi v{latestVersion.ToString()} is available.\n\nSee the latest release on Github?",
                        "Flash Multi Update Available",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Information);

                    // Show the Github release page for the new version if the user clicked Yes
                    if (showUpdate == DialogResult.Yes)
                    {
                        flashMulti.OpenLink(check.ReleaseUrl);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Prompt the user if a newer version is available.
        /// </summary>
        /// <param name="flashMulti">An instance of the <see cref="FlashMulti"/> class.</param>
        /// <param name="showNoUpdate">Indicate whether or not to show a message if there is no update.</param>
        public static async void DoCheck(FlashMulti flashMulti, bool showNoUpdate = false)
        {
            // Get check for the latest version on Github
            UpdateCheck check = new UpdateCheck();
            await Task.Run(() => { check = GetLatestVersion(); });

            // If the check completed successfully
            if (check.CheckSuccess)
            {
                // Get the current version
                Version currentVersion = Version.Parse(Application.ProductVersion);

                // Get the version available on Github
                Version latestVersion = check.LatestVersion;

                // Check if the current version is older than the latest Github release version
                if (currentVersion.CompareTo(latestVersion) == -1)
                {
                    // A newer version is available to show the user a prompt
                    Debug.WriteLine($"App version is older than latest version: {currentVersion} < {latestVersion}");

                    DialogResult showUpdate;
                    using (new CenterWinDialog(flashMulti))
                    {
                        showUpdate = MessageBox.Show(
                            $"{Strings.updatePromptPart1} v{currentVersion} {Strings.updatePromptPart2} v{latestVersion} {Strings.updatePromptPart3}",
                            Strings.dialogTitleUpdateCheck,
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Information);
                    }

                    // Show the Github release page for the new version if the user clicked Yes
                    if (showUpdate == DialogResult.Yes)
                    {
                        flashMulti.OpenLink(check.ReleaseUrl);
                    }
                }
                else
                {
                    if (showNoUpdate)
                    {
                        using (new CenterWinDialog(flashMulti))
                        {
                            MessageBox.Show(Strings.updateNoUpdate, Strings.dialogTitleUpdateCheck, MessageBoxButtons.OK);
                        }
                    }
                }
            }
            else
            {
                if (showNoUpdate)
                {
                    using (new CenterWinDialog(flashMulti))
                    {
                        MessageBox.Show(Strings.updateCheckFailed, Strings.dialogTitleUpdateCheck, MessageBoxButtons.OK);
                    }
                }
            }
        }