Exemple #1
0
        private async void deleteLocalGameButton_Click(object sender, RoutedEventArgs e)
        {
            object selectedGame = localGameListBox.SelectedItem;

            if (selectedGame == null)
            {
                return;
            }
            string gameName = selectedGame.ToString();

            string message = "Delete " + gameName + " from local game list? (All cloud saves for "
                             + "this game will remain in the cloud, but you'll have to "
                             + "add this game to the local game list again to download "
                             + "or upload saves.)";
            ConfirmationDialog dialog = new ConfirmationDialog(message);
            bool?result = dialog.ShowDialog();

            if (result.HasValue && result.GetValueOrDefault())
            {
                StartOperation("Deleting game from local game list...");
                await SavegameSyncUtils.RunWithChecks(async() =>
                {
                    await savegameSync.DeleteLocalGame(gameName);
                });

                UpdateLocalGameList();
                await savegameListControl.SetGameAndUpdateAsync(null);

                UpdateLocalGameInfoDisplays(null);
                FinishOperation();
            }
        }
        private async void deleteAllFilesButton_Click(object sender, RoutedEventArgs e)
        {
            string             message = "Delete all files stored in the cloud?";
            ConfirmationDialog dialog  = new ConfirmationDialog(message);
            bool?result = dialog.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            string             message2 = "Are you sure you want to delete all files? (All your cloud saves will be lost!)";
            ConfirmationDialog dialog2  = new ConfirmationDialog(message2);
            bool?result2 = dialog2.ShowDialog();

            if (!result2.HasValue || !result2.Value)
            {
                return;
            }

            StartOperation();
            await SavegameSyncUtils.RunWithChecks(async() =>
            {
                await savegameSync.DeleteAllFilesAsync();
            });

            await UpdateOrphanedSaveList();
            await UpdateMissingEntriesListAsync();

            FinishOperation();
        }
        private async void downloadSaveButton_Click(object sender, RoutedEventArgs e)
        {
            object selection = orphanedSaveListBox.SelectedItem;

            if (selection == null)
            {
                return;
            }
            string saveFileName = selection.ToString();

            if (saveFileName == EMPTY_ORPHANED_LIST_MESSAGE)
            {
                return;
            }

            string message = "Download orphaned save file? (The zip file will be downloaded into"
                             + " the directory in which this app was launched.)";
            ConfirmationDialog dialog = new ConfirmationDialog(message);
            bool?result = dialog.ShowDialog();

            if (result.HasValue && result.GetValueOrDefault())
            {
                StartOperation();
                await SavegameSyncUtils.RunWithChecks(async() =>
                {
                    await savegameSync.DownloadOrphanedSaveFile(saveFileName);
                });

                FinishOperation();
            }
        }
        private async void downloadSaveButton_Click(object sender, RoutedEventArgs e)
        {
            object selection = cloudGameListBox.SelectedItem;

            if (selection == null)
            {
                return;
            }
            string gameName = selection.ToString();

            int saveIndex = savegameListControl.GetSelectedSaveIndex();

            if (saveIndex == -1)
            {
                return;
            }

            string downloadedFileName = savegameSync.GetSpecificSaveFileDownloadPath(gameName, saveIndex);
            string message            = "Download selected save? (The downloaded zip file will be downloaded"
                                        + " into the directory in which this app was launched and will be named \""
                                        + downloadedFileName + ".\")";
            ConfirmationDialog dialog = new ConfirmationDialog(message);
            bool?result = dialog.ShowDialog();

            if (result.HasValue && result.GetValueOrDefault())
            {
                StartOperation();
                await SavegameSyncUtils.RunWithChecks(async() =>
                {
                    await savegameSync.DownloadSpecificSaveFileAsync(gameName, saveIndex);
                });

                FinishOperation();
            }
        }
        private async void deleteGameButton_Click(object sender, RoutedEventArgs e)
        {
            if (cloudGameListBox.SelectedItem == null)
            {
                return;
            }
            string gameName = cloudGameListBox.SelectedItem.ToString();

            string message = "Delete all save files stored in the cloud for "
                             + gameName + "?";
            ConfirmationDialog dialog = new ConfirmationDialog(message);
            bool?result = dialog.ShowDialog();

            if (result.HasValue && result.GetValueOrDefault())
            {
                StartOperation();
                await SavegameSyncUtils.RunWithChecks(async() =>
                {
                    await savegameSync.DeleteGameFromCloud(gameName);
                });
                await UpdateCloudGameList();

                await savegameListControl.SetGameAndUpdateAsync(null);

                FinishOperation();
            }
        }
        private async void downloadAllFilesButton_Click(object sender, RoutedEventArgs e)
        {
            string directoryName = $"SavegameSync-all-files-{DateTime.Now.Day}-{DateTime.Now.Month}-{DateTime.Now.Year}-{DateTime.Now.Hour}-{DateTime.Now.Minute}-{DateTime.Now.Second}";

            string message = "Download all files? The files will be downloaded into a directory"
                             + " named " + directoryName + " located in the directory in which this"
                             + " app was launched.";

            ConfirmationDialog dialog = new ConfirmationDialog(message);
            bool?result = dialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                StartOperation();
                await SavegameSyncUtils.RunWithChecks(async() =>
                {
                    Directory.CreateDirectory(directoryName);
                    await savegameSync.DownloadAllFilesToDirectoryAsync(directoryName);
                });

                FinishOperation();
            }
        }