private async void SavePGNExecuted(object obj) { var savePicker = new FileSavePicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, SuggestedFileName = "My Game" }; savePicker.FileTypeChoices.Add("PGN File", new List <string>() { ".pgn" }); savePicker.FileTypeChoices.Add("FEN File", new List <string>() { ".fen" }); var file = await savePicker.PickSaveFileAsync(); if (file != null) { BoardSerializationType serializationType = BoardSerializationType.PGN; string fileType = file.FileType; if (fileType.ToLower().Equals(".pgn")) { serializationType = BoardSerializationType.PGN; } else if (fileType.ToLower().Equals(".fen")) { serializationType = BoardSerializationType.FEN; } else { var dialog = new MessageDialog(String.Format("Unsupported file format {0}.\nPlease provide a .pgn or .fen file!" + fileType)); dialog.Commands.Add(new UICommand { Label = "Ok", Id = 0 }); await dialog.ShowAsync(); return; } await FileIO.WriteTextAsync(file, boardService.Serialize(serializationType, false)); } }
public PositionLoadOptions GetPositionLoadOptions(BoardSerializationType serializationType, bool stopOnCurrent = true) { PositionLoadOptions result = new PositionLoadOptions() { SerializedBoard = boardService.Serialize(serializationType, stopOnCurrent), SerializationType = serializationType, Perspective = BoardViewModel.Perspective, }; MoveData currentMove = boardService.GetCurrentMove(); if (currentMove != null) { result.CurrentMoveIndex = currentMove.Index; } return(result); }
public string Serialize(BoardSerializationType type, bool stopOnCurrent = true) { return(chessBoard.Serialize((int)type, stopOnCurrent)); }