public async Task NotifyDownloaded(Version currentVersion, Version latestVersion, string changelog = null) { string message = $"An update has been downloaded. Would you like to install it now?\n\n" + $"Current version: {currentVersion}\n" + $"Downloaded version: {latestVersion}"; if (changelog != null) { message += $"\n\nChangelog:\n" + $"{changelog}"; } MessageDialogResult result = await MainWindow.ShowMessageAsync("Update downloaded", message, MessageDialogStyle.AffirmativeAndNegative); if (result == MessageDialogResult.Affirmative) { Settings.CurrentSettings.NotifyUpdates = true; Settings.CurrentSettings.Save(); Updater.InstallUpdate(); } else { Settings.CurrentSettings.NotifyUpdates = false; Settings.CurrentSettings.Save(); UpdateDownloaded = true; UpdateAvailable = false; MainWindow.buttonUpdate.Content = "Update downloaded"; } }
private async void CheckForUpdates() { try { if (Settings.CurrentSettings.CheckForUpdates) { Version version = await Updater.CheckForUpdatesAsync(); if (version.IsCurrentVersion) { Updater.DeleteUpdateFiles(); } } else if (Updater.IsUpdateDownloaded()) { UpdateDownloaded = true; MainWindow.buttonUpdate.Content = "Update downloaded"; } else { Updater.DeleteUpdateFiles(); } } catch (HttpRequestException) { } catch (Exception e) { if (string.Equals(e.Message, e.InnerException.Message)) { await MainWindow.ShowMessageAsync("Checking for updates failed", $"There was an error while checking for updates.\n\n" + $"Error:\n" + $"{e.Message}"); } else { await MainWindow.ShowMessageAsync("Checking for updates failed", $"There was an error while checking for updates.\n\n" + $"Error:\n" + $"{e.Message} ({e.InnerException.Message})"); } } }