private void CheckProgramVersion() { LOG.Debug("CheckProgramVersion()-RandomizerVersion: " + Application.ProductVersion); ProgramVersion versionInfo = WGAPI.GetProgramVersion(); ChangeLog = versionInfo.ChangeLog; RandomizerVersion = versionInfo.Version; DateTime updateDate = new DateTime(); updateDate = DateTime.Parse(versionInfo.Updated); if (!versionInfo.Version.Equals(Application.ProductVersion)) { LOG.Debug("New version available."); string cc = Properties.Settings.Default.Locale; string msg = "The new version " + RandomizerVersion + " is available as per " + Commons.ConvertDateToLocalFormat(updateDate, cc) + "\nDo You want to download it now?"; var userInput = MessageBox.Show(msg, "New version of the WoWs Randomizer available!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (userInput == DialogResult.Yes) { LOG.Debug("User requested download of new Randomizer version"); string downloadsPath = KnownFolders.GetPath(KnownFolder.Downloads); string fileName = downloadsPath + "\\" + Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location); using (WebClient wc = new WebClient()) { wc.DownloadFile(versionInfo.URL, fileName); MessageBox.Show("The new version has been downloaded to Your download folder.\n(" + fileName + ")\nClose this program and replace the EXE-file in this folder with the downloaded one.", "New version downloaded", MessageBoxButtons.OK, MessageBoxIcon.Information); LOG.Debug("Download complete."); } } } }
private void HelpAbout_Load(object sender, EventArgs e) { String jsonFile = Commons.GetCurrentDirectory() + "/randomizer.json"; ProgramVersion versionInfo; if (File.Exists(jsonFile)) { string jsonText = File.ReadAllText(jsonFile); versionInfo = JsonConvert.DeserializeObject <ProgramVersion>(jsonText); } else { versionInfo = WGAPI.GetProgramVersion(); } programVersion.Text = versionInfo.Version; updateTime.Text = versionInfo.Updated; Settings settings = Commons.GetSettings(); gameVersion.Text = settings.GameVersion; string cc = Properties.Settings.Default.Locale; string dt = Commons.ConvertDateToLocalFormat(settings.GameUpdated, cc); gameDate.Text = dt; string cinfo = (settings.ConsumablesInfoVersion == null || settings.ConsumablesInfoVersion.Equals("")) ? "": settings.ConsumablesInfoVersion; lblConsumablesInfoVer.Text = cinfo; }