示例#1
0
        private static async void CheckForUpdates(bool silentIfNoUpdateDetected)
        {
            try
            {
                var updateDetails = await UpdateUtils.CheckForUpdate();

                if (updateDetails.UpdateAvailable)
                {
                    if (MessageBox.Show(
                            string.Format(
                                Strings.UpdateAvailableFull,
                                updateDetails.CurrentVersion, updateDetails.LatestVersion),
                            Strings.NewVersionAvailable,
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1) == DialogResult.Yes
                        )
                    {
                        UrlUtils.OpenUrlInBrowser("https://github.com/Jonno12345/TileIconifier/releases");
                    }
                }
                else if (!silentIfNoUpdateDetected)
                {
                    MessageBox.Show(Strings.AlreadyLatest, Strings.UpToDate);
                }
            }
            catch
            {
                if (silentIfNoUpdateDetected)
                {
                    return;
                }

                if (MessageBox.Show(
                        string.Format(
                            Strings.UpdateAvailableError,
                            UpdateUtils
                            .CurrentVersion),
                        Strings.UnableToCheckServer,
                        MessageBoxButtons.OKCancel,
                        MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    UrlUtils.OpenUrlInBrowser("https://github.com/Jonno12345/TileIconifier/releases");
                }
            }
        }
示例#2
0
        private async void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var updateDetails = await UpdateUtils.CheckForUpdate();

                if (updateDetails.UpdateAvailable)
                {
                    if (MessageBox.Show(
                            $@"An update is available! Would you like to visit the releases page? (Your version: {
                            updateDetails
                                .CurrentVersion} - Latest version: {updateDetails.LatestVersion})",
                            @"New version available!",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1) == DialogResult.Yes
                        )
                    {
                        Process.Start("https://github.com/Jonno12345/TileIconifier/releases");
                    }
                }
                else
                {
                    MessageBox.Show(@"You are already on the latest version!", @"Up-to-date");
                }
            }
            catch
            {
                if (MessageBox.Show(
                        $@"An error occurred getting latest release information. Click Ok to visit the latest releases page to check manually. (Your version: {
                        UpdateUtils
                            .CurrentVersion})",
                        @"Unable to check server!",
                        MessageBoxButtons.OKCancel,
                        MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    Process.Start("https://github.com/Jonno12345/TileIconifier/releases");
                }
            }
        }