Esempio n. 1
0
        private void DoDumpProgressToFile()
        {
            var dialog = new SaveFileDialog()
            {
                Filter          = "textFiles |*.txt",
                AddExtension    = true,
                CheckFileExists = false,
                OverwritePrompt = true,
                ValidateNames   = true,
                CheckPathExists = true,
                CreatePrompt    = false,
                Title           = Captions.PvB_DumpProgressFileDialogTitle
            };

            var result = dialog.ShowDialog();

            if (result.HasValue)
            {
                if (result.Value)
                {
                    var fileText = CreateProgressText.FromBoardState(gameService.CurrentBoardState);
                    File.WriteAllText(dialog.FileName, fileText);
                }
            }
        }
Esempio n. 2
0
        private async void ExecuteWinDialog(bool reportWinning, Player player, WinningReason winningReason, Move invalidMove)
        {
            var yesNoDialogViewModel = new YesNoDialogViewModel(GetWinningOrLoosingMessage(reportWinning, winningReason, invalidMove));

            var winningDialog = new YesNoDialog
            {
                DataContext = yesNoDialogViewModel
            };

            var dialogResult = await DialogHost.Show(winningDialog, "RootDialog");

            if ((bool)dialogResult)
            {
                var dialog = new SaveFileDialog()
                {
                    Filter          = "textFiles |*.txt",
                    AddExtension    = true,
                    CheckFileExists = false,
                    OverwritePrompt = true,
                    ValidateNames   = true,
                    CheckPathExists = true,
                    CreatePrompt    = false,
                    Title           = Captions.PvB_SaveGameProgressFileDialogTitle
                };

                var result = dialog.ShowDialog();

                if (result.HasValue)
                {
                    if (result.Value)
                    {
                        var fileText = CreateProgressText.FromBoardState(gameService.CurrentBoardState)
                                       .AndAppendWinnerAndReason(player, winningReason, invalidMove);

                        File.WriteAllText(dialog.FileName, fileText);
                    }
                }
            }

            yesNoDialogViewModel.Dispose();
        }