/// <summary> /// Do a move /// </summary> /// <param name="move"> Move to be done</param> private void DoMove(SrcChess2.MoveExt move) { int iIncrementTimeInSec; int iMoveCount; TimeSpan span; SrcChess2.ChessBoard.PlayerE ePlayer; lock (m_chessBoard) { ePlayer = ChessBoardCtl.NextMoveColor; ChessBoardCtl.DoMove(move); if (m_spanOriginalMaxTime.HasValue && Game.IncTimeInSec != 0) { iMoveCount = ChessBoardCtl.Board.MovePosStack.Count + 1 / 2; iIncrementTimeInSec = Game.IncTimeInSec * iMoveCount; span = m_spanOriginalMaxTime.Value + TimeSpan.FromSeconds(iIncrementTimeInSec); if (ePlayer == SrcChess2.ChessBoard.PlayerE.Black) { ChessBoardCtl.GameTimer.MaxBlackPlayTime = span; } else { ChessBoardCtl.GameTimer.MaxWhitePlayTime = span; } } if (!ChessBoardCtl.SignalActionDone.WaitOne(0)) { ChessBoardCtl.SignalActionDone.WaitOne(); } } }
/// <summary> /// Set the board content /// </summary> private void SetBoardControl() { Action del; del = () => { ChessBoardCtl.CreateGameFromMove(null /*chessBoardStarting*/, m_listInitialMoves, m_chessBoard.CurrentPlayer, Game.WhitePlayer, Game.BlackPlayer, SrcChess2.PlayerTypeE.Human, SrcChess2.PlayerTypeE.Human, TimeSpan.Zero, TimeSpan.Zero); ChessBoardCtl.GameTimer.ResetTo(Game.NextMovePlayer, Game.WhiteTimeSpan.Ticks, Game.BlackTimeSpan.Ticks); ChessBoardCtl.Refresh(); }; ChessBoardCtl.Dispatcher.Invoke(del); }
/// <summary> /// Send an error to the chess board control /// </summary> /// <param name="strError"> Error string</param> public virtual void ShowError(string strError) { ChessBoardCtl.Dispatcher.Invoke((Action)(() => { ChessBoardCtl.ShowError(strError); })); }
/// <summary> /// Send a message to the chess board control /// </summary> /// <param name="strMsg"> Message string</param> protected virtual void ShowMessage(string strMsg) { ChessBoardCtl.Dispatcher.Invoke((Action)(() => { ChessBoardCtl.ShowMessage(strMsg); })); }