private async void TabbedAnythingForm_VisibleChanged(object sender, EventArgs e) { LOG.DebugFormat("Visible Changed - Visible: {0}", this.Visible); if (this.Visible) { DateTime lastUpdatePromptTime = Settings.Default.LastUpdatePromptTime; DateTime now = DateTime.Now; TimeSpan difference = now - lastUpdatePromptTime; var inject = new { lastUpdatePromptTime = lastUpdatePromptTime, now = now, difference = difference }; LOG.DebugInject("Visible Changed - Last Update Prompt Time: {lastUpdatePromptTime} - Now: {now} - Difference: {difference}", inject); if (difference >= TimeSpan.FromDays(1)) { Version newestVersion = await TabbedAnythingUtil.IsUpToDate(); if (newestVersion != null) { LOG.DebugFormat("Newest Version: {0}", newestVersion); if (DialogResult.Yes == MessageBox.Show("A new version of Tabbed Anything is available. Update now?\n\nNote: This will exit Tabbed Anything.", "New Update", MessageBoxButtons.YesNo)) { LOG.Debug("Update Prompt: Yes"); Settings.Default.LastUpdatePromptTime = DateTime.MinValue; Settings.Default.Save(); if (await TabbedAnythingUtil.UpdateApplication(newestVersion)) { LOG.Debug("Update - Exiting Application"); Application.Exit(); } else { LOG.Debug("Update - Error occurred"); MessageBox.Show("There was an error updating Tabbed Anything. Try again later."); } } else { LOG.Debug("Update Prompt: No"); Settings.Default.LastUpdatePromptTime = now; Settings.Default.Save(); MessageBox.Show("To update Tabbed Anything at a later date, go to Options->About and click Update.", "New Update", MessageBoxButtons.OK); } } } } }
private async void AboutBox_Load(object sender, EventArgs e) { _newestVersion = await TabbedAnythingUtil.IsUpToDate(); if (_newestVersion != null) { LOG.DebugFormat("Newer Version Available - New: {0} - Current: {1}", _newestVersion, AssemblyVersion); UpdateCheckLabel.Text = "Version {0} is available.".XFormat(_newestVersion.ToString(3)); UpdateButton.Enabled = true; } else { UpdateCheckLabel.Text = AssemblyTitle + " is up to date."; LOG.DebugFormat("Update to Date - Version: {0}", AssemblyVersion); } }