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; } }
public WinGui() { InitializeComponent(); MessageBox.MainForm = this; GuiEventLoop.MainForm = this; GuiEventLoop.ResetHistory(new ChessState()); GuiEventLoop.PollGuiOnce(); chessBoardControl.PieceMovedByHuman += PieceMovedByHuman_Changed; chessBoardControl.SetChessFlagCombo(this.cmbChessFlags); }
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(); } }
public GuiEvent(GuiEventLoop.ObjectParameterCallback eventCallback, params object[] eventArgs) { EventCallback = eventCallback; EventArgs = eventArgs; }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { GuiEventLoop.SaveSelectedStateToDisk(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { GuiEventLoop.OpenStateFromDisk(); }
public void PieceMovedByHuman_Changed(ChessMove move) { GuiEventLoop.UpdateBoardBasedOnMove((ChessState)this.lstHistory.SelectedItem, move, this.radWhite.Checked); }
private void WinGui_FormClosing(object sender, FormClosingEventArgs e) { GuiEventLoop.ShutdownGuiEventLoop(); }
private void viewDecisionTreeToolStripMenuItem_Click(object sender, EventArgs e) { GuiEventLoop.ShowDecisionTree(); }
private void btnSaveBlacksLog_Click(object sender, EventArgs e) { GuiEventLoop.SaveBlacksLogToDisk(); }
private void btnClearBlacksLog_Click(object sender, EventArgs e) { GuiEventLoop.ClearBlacksLog(); }
private void lstHistory_SelectedIndexChanged(object sender, EventArgs e) { GuiEventLoop.UpdateBoardBasedOnLstHistory((ChessState)this.lstHistory.SelectedItem); }
private void cmbBlack_SelectedIndexChanged(object sender, EventArgs e) { GuiEventLoop.UpdateBlacksName(this.cmbBlack.SelectedItem.ToString()); }
private void cmbWhite_SelectedIndexChanged(object sender, EventArgs e) { GuiEventLoop.UpdateWhitesName(this.cmbWhite.SelectedItem.ToString()); }
private void clearHistoryToolStripMenuItem_Click(object sender, EventArgs e) { GuiEventLoop.ResetHistory(new ChessState()); }
private void stopToolStripMenuItem_Click(object sender, EventArgs e) { GuiEventLoop.StopGame(); }