Exemplo n.º 1
0
        public static DialogResult CheckForUpdates(bool silently)
        {
            // Checking version mentioned in "version" file on GitHub
            latestStringVersion = DownloadString(EXE_VERSION_TEXT_URL);

            int          latestVersion;
            bool         showMessageBox;
            string       message;
            string       title;
            DialogResult result;

            if (latestStringVersion.Length == 0)
            {
                showMessageBox = true;
                message        = "There is no data in \"version\" file on GitHub!";
                title          = "Warning!";
                result         = DialogResult.Abort;
                goto SHOW_MESSAGEBOX;
            }

            try
            {
                latestVersion = Convert.ToInt32(latestStringVersion.Replace(".", ""));
            }
            catch (Exception ex)
            {
                showMessageBox = true;
                message        = "There is something wrong with version number in \"version\" file on GitHub!\n" + ex.Message;
                title          = "Warning!";
                result         = DialogResult.Abort;
                goto SHOW_MESSAGEBOX;
            }

            if (currentVersion < latestVersion)
            {
                return(ThemedDialogueBox.Show($"The new DoW Mod Manager v{latestStringVersion} is available. Do you wish to update now?", "New update available", exeORmods: "exe"));
            }
            else
            {
                showMessageBox = true;
                message        = "You have the latest version!";
                title          = "Good news!";
                result         = DialogResult.Cancel;
            }

SHOW_MESSAGEBOX:

            if (!silently)
            {
                if (showMessageBox)
                {
                    ThemedMessageBox.Show(message, title);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        // TODO: It looks very similar to CheckForUpdates()
        public static DialogResult CheckForNewModlist(bool silently)
        {
            // Checking version mentioned in "version" file on GitHub
            latestStringVersion = DownloadString(MODLIST_VERSION_TEXT_URL);

            int          latestModlistVersion;
            bool         showMessageBox;
            string       message;
            string       title;
            DialogResult result;

            if (latestStringVersion.Length == 0)
            {
                showMessageBox = true;
                message        = "There is no data in \"version\" file on GitHub!";
                title          = "Warning!";
                result         = DialogResult.Abort;
                goto SHOW_MESSAGEBOX;
            }

            try
            {
                latestModlistVersion = Convert.ToInt32(latestStringVersion.Replace(".", ""));
            }
            catch (Exception ex)
            {
                showMessageBox = true;
                message        = "There is something wrong with version number in \"version\" file on GitHub!\n" + ex.Message;
                title          = "Warning!";
                result         = DialogResult.Abort;
                goto SHOW_MESSAGEBOX;
            }

            // Check for version string in Modlist file
            int modlistVersion = 0;

            using (StreamReader file = new StreamReader(currentDir + "\\" + ModDownloaderForm.MODLIST_FILE))
            {
                string line;

                if ((line = file.ReadLine()) != null)
                {
                    try
                    {
                        modlistVersion = Convert.ToInt32(line.Replace(".", ""));
                    }
                    catch (Exception ex)
                    {
                        showMessageBox = true;
                        message        = $"There is something wrong with version number in {ModDownloaderForm.MODLIST_FILE}\n" + ex.Message;
                        title          = "Warning!";
                        result         = DialogResult.Abort;
                        goto SHOW_MESSAGEBOX;
                    }
                }
            }

            if (modlistVersion < latestModlistVersion)
            {
                return(ThemedDialogueBox.Show($"The new Modlist v{latestStringVersion} is available. Do you wish to update now?", "New update available", exeORmods: "mods"));
            }
            else
            {
                showMessageBox = true;
                message        = "You have the latest version!";
                title          = "Good news!";
                result         = DialogResult.Cancel;
            }

SHOW_MESSAGEBOX:

            if (!silently)
            {
                if (showMessageBox)
                {
                    ThemedMessageBox.Show(message, title);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public static DialogResult CheckForUpdates(bool silently)
        {
            // That fixes problem in Windows 7
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            // Checking version mentioned in "version" file on GitHub
            latestStringVersion = DownloadString(EXE_VERSION_TEXT_URL);

            Version      latestVersion;
            bool         showMessageBox;
            string       message;
            string       title;
            DialogResult result;

            if (latestStringVersion.Length == 0)
            {
                showMessageBox = true;
                message        = "There is no data in \"version\" file on GitHub!";
                title          = "Warning!";
                result         = DialogResult.Abort;
                goto SHOW_MESSAGEBOX;
            }

            try
            {
                latestVersion = new Version(latestStringVersion);
            }
            catch (Exception ex)
            {
                showMessageBox = true;
                message        = "There is something wrong with version number in \"version\" file on GitHub!\n" + ex.Message;
                title          = "Warning!";
                result         = DialogResult.Abort;
                goto SHOW_MESSAGEBOX;
            }

            if (currentVersion < latestVersion)
            {
                return(ThemedDialogueBox.Show($"The new DoW Mod Manager v{latestStringVersion} is available. Do you wish to update now?", "New update available", exeORmods: "exe"));
            }
            else
            {
                showMessageBox = true;
                message        = "You have the latest version!";
                title          = "Good news!";
                result         = DialogResult.Cancel;
            }

SHOW_MESSAGEBOX:

            if (!silently)
            {
                if (showMessageBox)
                {
                    ThemedMessageBox.Show(message, title);
                }
            }

            return(result);
        }