Esempio n. 1
0
        public static void CheckForUpdates(bool silent = false)
        {
            Version currentVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Version latestVersion  = GitHubApi.GetLatestReleaseVersion();

            if (latestVersion == null)
            {
                if (!silent)
                {
                    var dialogResult = MessageBox.Show("Couldn't fetch latest release info. Do you want to check manually?", Config.ApplicationName, MessageBoxButtons.YesNo);

                    if (dialogResult == DialogResult.Yes)
                    {
                        OpenBrowser(Config.RepositoryReleasesUrl);
                    }
                }

                return;
            }

            int versionDifference = latestVersion.CompareTo(currentVersion);

            if (versionDifference > 0)
            {
                var dialogResult = MessageBox.Show("New version available. Do you want to open the releases page?", Config.ApplicationName, MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    OpenBrowser(Config.RepositoryReleasesUrl);
                }

                return;
            }
            ;

            if (!silent)
            {
                MessageBox.Show("You are running the latest version.", Config.ApplicationName);
            }
        }