private void UpdateCurrentProfile(GitHubRelease onlineRelease) { switch (MessageBox.Show(string.Format(LocalizationUI.GetString("UpdateAvailable"), CurrentProfile.Version, onlineRelease.Version), LocalizationUI.GetString("UpdateAvailableTitle"), MessageBoxButtons.YesNo)) { case DialogResult.Yes: using (var directUpdater = new ReleaseDownloaderForm(onlineRelease.ReleaseAsset, CurrentProfile.Folder)) directUpdater.ShowDialog(); break; case DialogResult.No: return; /* * case DialogResult.Yes: * //MessageBox.Show(LocalizationUI.GetString("UpdateDisabled"), LocalizationUI.GetString("UpdateDisabledTitle"), MessageBoxButtons.OK); * if (Settings.SelectedDL != null && !string.IsNullOrEmpty(Settings.SelectedDL.AbsolutePath)) * //using (var customUpdater = new PerFileUpdaterForm(onlineRelease.UpdateInfoAsset, CurrentProfile.Folder, new Uri(Settings.SelectedDL, $"{onlineRelease.Version}/"))) * // customUpdater.ShowDialog(); * ; * else * MessageBox.Show(LocalizationUI.GetString("DLNotSelected"), LocalizationUI.GetString("DLNotSelectedTitle"), MessageBoxButtons.OK); * break; * * case DialogResult.No: * //case DialogResult.Cancel: * using (var directUpdater = new ReleaseDownloaderForm(onlineRelease.ReleaseAsset, CurrentProfile.Folder)) * directUpdater.ShowDialog(); * break; * * case DialogResult.Cancel: * //case DialogResult.No: * return; */ } }
private async Task <bool> DownloadCurrentProfileAsync() { var gameReleases = await CurrentProfile.GetAvailableReleasesAsync(); if (gameReleases.Any()) { var onlineRelease = gameReleases.First(release => release.Version == CurrentProfile.Version); switch (MessageBox.Show(string.Format(LocalizationUI.GetString("NotDownloaded"), CurrentProfile.Name), LocalizationUI.GetString("NotDownloadedTitle"), MessageBoxButtons.YesNo)) { case DialogResult.Yes: using (var directUpdater = new ReleaseDownloaderForm(onlineRelease.ReleaseAsset, CurrentProfile.Folder)) { var state = directUpdater.ShowDialog(); return(state != DialogResult.Abort && state != DialogResult.Cancel); } } } return(false); }
private async Task CheckLauncherForUpdateAsync() { var launcherVersion = Assembly.GetExecutingAssembly().GetName().Version; Log($"Launcher version: [{launcherVersion}]."); Log("Checking Launcher for updates..."); var launcherReleases = await GitHub.GetAllLauncherReleasesAsync(); if (launcherReleases.Any()) { var latestRelease = launcherReleases.First(); if (launcherVersion < latestRelease.Version) { Log($"Found a new Launcher version [{latestRelease.Version}]!"); switch (MessageBox.Show(LocalizationUI.GetString("LauncherUpdateAvailable"), LocalizationUI.GetString("LauncherUpdateAvailableTitle"), MessageBoxButtons.YesNo)) { case DialogResult.Yes: using (var directUpdater = new ReleaseDownloaderForm(latestRelease.ReleaseAsset, new UpdateFolder())) directUpdater.ShowDialog(); Program.ActionsBeforeExit.Add(() => new UpdaterFile().Start(createNoWindow: true)); Close(); break; default: return; } } else { Log("Launcher is up to date."); } } else { Log("Error while checking Launcher for updates. Is Internet available?"); MessageBox.Show(LocalizationUI.GetString("NoInternet"), LocalizationUI.GetString("NoInternetTitle"), MessageBoxButtons.OK); } }