private void historyToolStripMenuItem_Click(object sender, EventArgs e) { if (_historyForm != null) { _historyForm.Activate(); return; } _historyForm = new HistoryForm(); _historyForm.FormClosed += history_Closed; _historyForm.Top = this.Top; _historyForm.Left = this.Right; _historyForm.SelectedPlyChanged += historyForm_SelectedPlyChanged; var screenBounds = Screen.GetBounds(this._boardView); if (_historyForm.Right >= screenBounds.Right) { _historyForm.Left = this.Left - _historyForm.Width; } if (_historyForm.Left < 0) { _historyForm.Left = 0; } _historyForm.Owner = this; foreach (var move in _gameRecord.MoveNotations) { _historyForm.AddPly(move.Text); } _historyForm.Show(); }
void AddMoveToGameRecord(IMove move) { TakEngine.Notation.MoveNotation notated; if (!TakEngine.Notation.MoveNotation.TryParse(move.Notate(), out notated)) { throw new ApplicationException("Critical movement error"); // this shouldn't ever happen } _gameRecord.MoveNotations.Add(notated); _navigating = true; if (_historyForm != null) { _historyForm.AddPly(notated.Text); } _navigating = false; _movesOfNotation[notated] = move; }
void ProcessMove(IMove move = null, TakEngine.Notation.MoveNotation notation = null, bool alreadyExecuted = false) { if (move == null && notation == null) { throw new ArgumentException("move and notation cannot both be null"); } if (notation == null) { if (!TakEngine.Notation.MoveNotation.TryParse(move.Notate(), out notation)) { throw new ApplicationException("Critical move error"); } } else if (move == null) { _tempMoveList.Clear(); Helper.EnumerateMoves(_tempMoveList, _game, _ai.NormalPositions); move = notation.MatchLegalMove(_tempMoveList); if (move == null) { throw new ApplicationException("Illegal move: " + notation.Text); } } if (!alreadyExecuted) { move.MakeMove(_game); } if (!_gameRecord.MoveNotations.Contains(notation)) // if opening an existing game file then we may have already loaded the notation { _gameRecord.MoveNotations.Add(notation); } _navigating = true; if (_historyForm != null) { _historyForm.AddPly(notation.Text); } _navigating = false; _movesOfNotation[notation] = move; _game.Ply++; _boardView.InvalidateRender(); }