private static void Actually_StopGame(params object[] eventArgs) { if (_isInGameMode) { _isInGameMode = false; _mainGame.StopGameEarly(); // Remove the ChessGame from the GuiChessBoard updates MainForm.chessBoardControl.PieceMovedByHuman -= _mainGame.WhitePlayer_HumanMovedPieceEvent; MainForm.chessBoardControl.PieceMovedByHuman -= _mainGame.BlackPlayer_HumanMovedPieceEvent; // Remove WinGui from the ChessGame updates event //_mainGame.Updated -= OnChessGameUpdated; _mainGame.UpdatedState -= GuiEventLoop.AddToHistory; _mainGame.SetGuiChessBoard_IsLocked -= GuiEventLoop.SetGuiChessBoard_IsLocked; // Remove WinGui from the DeclareResults event _mainGame.DeclareResults -= GuiEventLoop.DeclareResults; _mainGame.SetDecisionTree -= GuiEventLoop.SetDecisionTree; // Add WinGui to the GuiChessBoard updates MainForm.chessBoardControl.PieceMovedByHuman += MainForm.PieceMovedByHuman_Changed; Actually_EnableMenuItemsAfterPlay(); Actually_EnableRadioBtnsAndComboBoxes(); Actually_EnableHistoryWindowClicking(); GuiEventLoop.Actually_SetGuiChessBoard_IsLocked(new object[] { false }); _mainGame = null; } }
private static void Actually_StartGame(params object[] eventArgs) { if (!_isInGameMode) { _isInGameMode = true; UvsChess.Framework.ChessState item = Actually_GetUpdated_LstHistory_SelectedItem(); _mainGame = new UvsChess.Framework.ChessGame(item, GuiEventLoop.WhitePlayerName, GuiEventLoop.BlackPlayerName); // Remove WinGui from the GuiChessBoard updates MainForm.chessBoardControl.PieceMovedByHuman -= MainForm.PieceMovedByHuman_Changed; // Add the ChessGame to the GuiChessBoard updates MainForm.chessBoardControl.PieceMovedByHuman += _mainGame.WhitePlayer_HumanMovedPieceEvent; MainForm.chessBoardControl.PieceMovedByHuman += _mainGame.BlackPlayer_HumanMovedPieceEvent; // Add WinGui to the ChessGame updates event _mainGame.UpdatedState += GuiEventLoop.AddToHistory; _mainGame.SetGuiChessBoard_IsLocked += GuiEventLoop.SetGuiChessBoard_IsLocked; // Add WinGui to the DeclareResults event _mainGame.DeclareResults += GuiEventLoop.DeclareResults; _mainGame.SetDecisionTree += GuiEventLoop.SetDecisionTree; Actually_RemoveHistoryAfterSelected(); Actually_DisableMenuItemsDuringPlay(); Actually_DisableRadioBtnsAndComboBoxes(); Actually_DisableHistoryWindowClicking(); GuiEventLoop.Actually_SetGuiChessBoard_IsLocked(new object[] { true }); _mainGame.StartGame(); } }