private void RaiseCommandsChanged() { GetHintCommand.RaiseCanExecuteChanged(); PassCommand.RaiseCanExecuteChanged(); PressedCommand.RaiseCanExecuteChanged(); ResignCommand.RaiseCanExecuteChanged(); UndoCommand.RaiseCanExecuteChanged(); }
protected void UpdateCanPassAndUndo() { if (IsTimelineInPast) { CanUndo = false; CanPass = false; return; } CanPass = (this.Game?.Controller?.TurnPlayer?.IsHuman ?? false) ? true : false; // TODO (future work) Petr this allows to undo before the beginning of the game and causes exception if (this.Game?.Controller?.GameTree == null) { // Game not yet initialized. CanUndo = false; } else if (this.Game.Controller.Players.Any(pl => pl.IsHuman)) { if (Game.Controller.GameTree.LastNode.Equals(Game.Controller.GameTree.GameTreeRoot)) { CanUndo = false; } else { bool undoPossible = this.Game.Controller.GameTree.PrimaryMoveTimeline.Any( move => { if (move.WhoMoves == StoneColor.None) { return(false); } return(this.Game.Controller.Players[move.WhoMoves].IsHuman); }); CanUndo = undoPossible; } } else { // No player is a local human. CanUndo = false; } PassCommand.RaiseCanExecuteChanged(); UndoCommand.RaiseCanExecuteChanged(); }