void moveToWorker_DoWork(object sender, DoWorkEventArgs e) { if (BeforePaste != null) { BeforePaste(this, EventArgs.Empty); } DataTable moves = e.Argument as DataTable; Moves.DataTable.Clear(); Notations.NotationView.Clear(); bool b = Flags.IsEngineOn; Flags.IsEngineOn = false; AddMoves(moves); Flags.IsEngineOn = b; if (Flags.IsOffline) { CurrentMove = RootMove.Clone(); Clock.Reset(); Clock.Stop(); GameResult = GameResultE.InProgress; } }
public void SetMove(Move m) { if (m.Id == CurrentMove.Id) { return; } CurrentMove = m; Flags.IsMoveInProgress = true; Flags.IsClickedByUser = true; Clock.Stop(); Clock.SetClock(CurrentMove); Flags.IsRetracMove = false; Flags.IsMoveInProgress = false; Notations.Set(); Book.MoveTo(); SetFen(CurrentMove.Fen); //SetCapturedPiecesParameters(); //CapturedPieces.MoveTo(moveTo); }
public void Paste(DataTable moves) { if (BeforePaste != null) { BeforePaste(this, EventArgs.Empty); } Notations.Game.Moves.DataTable.Clear(); Notations.NotationView.Clear(); bool b = Flags.IsEngineOn; Flags.IsEngineOn = false; AddMoves(moves); Flags.IsEngineOn = b; if (Flags.IsOffline) { MoveTo(MoveToE.First); CurrentMove = null; Clock.Reset(); Clock.Stop(); GameResult = GameResultE.InProgress; } if (AfterPaste != null) { AfterPaste(this, EventArgs.Empty); } }
public void Pause() { if (Flags.IsPaused) { return; } Clock.Stop(); CurrentPlayer.PauseEngine(); Flags.IsPaused = true; }
public void SetFen(string fen) { if (string.IsNullOrEmpty(fen) || !GameValidator.IsValidFen(fen)) { return; } if (BeforeSetFen != null) { BeforeSetFen(this, EventArgs.Empty); } GameValidator = new GameW(fen); if (Flags.IsOffline) { if (Flags.IsClickedByUser) { if (IsSwapPlayersRequired) { SwapPlayers(); } } else { Clock.Reset(); Clock.Stop(); GameResult = GameResultE.InProgress; } Flags.EnPassant = SquareE.NoSquare; ResetCounters(); } if (AfterSetFen != null) { AfterSetFen(this, EventArgs.Empty); } }
public void Paste(DataTable moves) { if (BeforePaste != null) { BeforePaste(this, EventArgs.Empty); } Moves.DataTable.Clear(); Notations.NotationView.Clear(); AddMoves(moves); if (Flags.IsOffline) { // as now on paste, we set last move selected, // so currentMove points to that last move // and also clock is set by that move. //CurrentMove = RootMove.Clone(); //Clock.Reset(); Clock.Stop(); GameResult = GameResultE.InProgress; } else { Notations.GameFinished(); if (GameResult != GameResultE.InProgress) { Clock.Stop(); } } if (AfterPaste != null) { AfterPaste(this, EventArgs.Empty); } }
public void MoveTo(MoveToE moveTo) { Move m = null; switch (moveTo) { case MoveToE.First: m = Moves.First; //Notations.MoveTo(moveTo); break; case MoveToE.Last: m = Moves.Last; break; case MoveToE.Next: m = Moves.Next(CurrentMove); //Notations.MoveTo(moveTo); break; case MoveToE.Previous: m = Moves.Prev(CurrentMove); //Notations.MoveTo(moveTo); break; case MoveToE.Up: break; case MoveToE.Down: break; default: break; } if (m == null && moveTo == MoveToE.Previous) { return; } if (m == null) { Book.MoveTo(moveTo, true); return; } if (CurrentMove.Id == m.Id) { Book.MoveTo(moveTo, true); } else { CurrentMove = m.Clone(); Flags.IsMoveInProgress = true; Flags.IsClickedByUser = true; Clock.Stop(); Clock.SetClock(CurrentMove); Flags.IsRetracMove = false; Flags.IsMoveInProgress = false; Notations.Set(); Book.MoveTo(moveTo, false); SetCapturedPiecesParameters(); CapturedPieces.MoveTo(moveTo); SetFen(CurrentMove.Fen); } }