Exemple #1
0
        public void DoVersionTextUpdate()
        {
            string strLatestVersion = LatestVersion.Trim().TrimStart("Nightly-v");

            lblUpdaterStatus.Left = lblUpdaterStatusLabel.Left + lblUpdaterStatusLabel.Width + 6;
            if (strLatestVersion == LanguageManager.GetString("String_No_Update_Found").Trim())
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("Warning_Update_CouldNotConnect");
                cmdUpdate.Enabled     = false;
                return;
            }
            Version.TryParse(strLatestVersion, out Version objLatestVersion);
            int intResult = objLatestVersion?.CompareTo(_objCurrentVersion) ?? 0;

            if (intResult > 0)
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("String_Update_Available").Replace("{0}", strLatestVersion).Replace("{1}", _strCurrentVersion);
            }
            else
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("String_Up_To_Date").Replace("{0}", _strCurrentVersion).Replace("{1}", LanguageManager.GetString(_blnPreferNightly ? "String_Nightly" : "String_Stable")).Replace("{2}", strLatestVersion);
                if (intResult < 0)
                {
                    cmdRestart.Text    = LanguageManager.GetString("Button_Up_To_Date");
                    cmdRestart.Enabled = false;
                }
                cmdUpdate.Text = LanguageManager.GetString("Button_Redownload");
            }
            if (_blnPreferNightly)
            {
                lblUpdaterStatus.Text += " " + LanguageManager.GetString("String_Nightly_Changelog_Warning");
            }
        }
Exemple #2
0
        public void DoVersionTextUpdate()
        {
            string strLatestVersion = LatestVersion.Trim();

            lblUpdaterStatus.Left = lblUpdaterStatusLabel.Left + lblUpdaterStatusLabel.Width + 6;
            if (strLatestVersion == LanguageManager.GetString("String_No_Update_Found").Trim())
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("Warning_Update_CouldNotConnect");
                cmdUpdate.Enabled     = false;
                return;
            }

            string strCurrentVersion = CurrentVersion.Trim().TrimStart("Nightly-v");

            string[] strCurrentVersionNumbers = strCurrentVersion.Split('.');
            strLatestVersion = strLatestVersion.TrimStart("Nightly-v");
            string[] strLatestVersionNumbers = strLatestVersion.Split('.');

            bool blnNeedsUpdate = false;
            int  intLatestTemp  = 0;
            int  intCurrentTemp = 0;
            // Note: this value only matters if blnNeedsUpdate is false, otherwise the relevant code will not run anyway
            bool blnDisableDownloadButton = true;

            for (int i = 0; i < strLatestVersionNumbers.Length; ++i)
            {
                if (strCurrentVersion.Length <= i)
                {
                    blnNeedsUpdate = true;
                    break;
                }
                if (int.TryParse(strLatestVersionNumbers[i], out intLatestTemp) && int.TryParse(strCurrentVersionNumbers[i], out intCurrentTemp))
                {
                    if (intLatestTemp != intCurrentTemp)
                    {
                        if (intLatestTemp > intCurrentTemp)
                        {
                            blnNeedsUpdate = true;
                        }
                        else
                        {
                            blnDisableDownloadButton = false;
                        }
                        break;
                    }
                }
            }

            if (blnNeedsUpdate)
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("String_Update_Available").Replace("{0}", strLatestVersion).Replace("{1}", strCurrentVersion);
            }
            else
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("String_Up_To_Date").Replace("{0}", strCurrentVersion).Replace("{1}", LanguageManager.GetString(_blnPreferNightly ? "String_Nightly" : "String_Stable")).Replace("{2}", strLatestVersion);
                if (blnDisableDownloadButton)
                {
                    cmdUpdate.Text    = LanguageManager.GetString("Button_Up_To_Date");
                    cmdUpdate.Enabled = false;
                }
                else
                {
                    cmdUpdate.Text = LanguageManager.GetString("Button_Redownload");
                }
            }
            if (_blnPreferNightly)
            {
                lblUpdaterStatus.Text += " " + LanguageManager.GetString("String_Nightly_Changelog_Warning");
            }
        }