/// <summary> /// Carga un juego /// </summary> private void LoadGame(string fileName) { if (ChessGameViewModel.Load(fileName, out string error)) { // Limpia el último movimiento ClearMovementPanel(); // Guarda el archivo en la configuración Properties.Settings.Default.Game = fileName; Properties.Settings.Default.Save(); } else { MessageBox.Show(error); } }
/// <summary> /// Muestra el movimiento siguiente / anterior /// </summary> private void ShowMovement(bool back, bool showAnimation) { if (ChessGameViewModel.ChessGame != null) { MovementFigureModel movement = ChessGameViewModel.GetMovement(back); // Limpia el panel ClearMovementPanel(); // Obtiene el siguiente movimiento if (ChessGameViewModel.MovementsList.ActualMovement != null) { lblMovement.Text = ChessGameViewModel.MovementsList.ActualMovement.Text; imgMovement.Source = udtBoard.LoadImage(ChessGameViewModel.MovementsList.ActualMovement.Color, ChessGameViewModel.MovementsList.ActualMovement.Piece); udtBoard.ShowMovement(movement, back, showAnimation); } } }
/// <summary> /// Inicializa el formulario /// </summary> private void InitForm() { // Inicializa el tablero ChessGameViewModel.Init(); ChessGameViewModel.ShowNextMovement += (sender, evntArgs) => ShowMovement(false, evntArgs.ShowAnimation); udtBoard.Init(ChessGameViewModel); // Carga el archivo inicial if (!string.IsNullOrEmpty(Properties.Settings.Default.Game)) { LoadGame(Properties.Settings.Default.Game); } // Inicia los directorios de imágenes if (!string.IsNullOrEmpty(Properties.Settings.Default.PathBoardImages)) { ChessGameViewModel.ComboPathBoard.SelectedPath = Properties.Settings.Default.PathBoardImages; } if (!string.IsNullOrEmpty(Properties.Settings.Default.PathPieceImages)) { ChessGameViewModel.ComboPathPieces.SelectedPath = Properties.Settings.Default.PathPieceImages; } // Asigna el resto de las propiedades ChessGameViewModel.ShowVariations = Properties.Settings.Default.ShowVariations; ChessGameViewModel.MustShowAnimation = Properties.Settings.Default.MustShowAnimations; }