private async void buttonDownload_Click(object sender, RoutedEventArgs e) { var selectedGame = await DownloadGameData.SelectGame(); if (selectedGame == null) { return; } var filePicker = new Microsoft.Win32.SaveFileDialog(); filePicker.AddExtension = true; filePicker.DefaultExt = ".zip"; filePicker.Filter = "ZIP (*.zip)|*.zip"; filePicker.Title = "Download Saved Game"; var result = filePicker.ShowDialog(); if (result != true) { return; } Utilities.ShowStatus("Downloading game files...", Colors.Green); var response = await Services.GetGame(selectedGame); if (response == null) { return; } var byteRemoteGame = await response.Content.ReadAsByteArrayAsync(); File.WriteAllBytes(filePicker.FileName, byteRemoteGame); Utilities.ShowStatus("Done.", Colors.Green); }
public static async Task <SyncedGame> SelectGame() { var win = new DownloadGameData(); win.Owner = Options.Current; win.Show(); while (win.IsVisible && win.SelectedGame == null) { await Task.Delay(5); } win.Close(); return(win?.SelectedGame); }