public void GameStateChanged(BoardState state) { SquareView squareView = null; ResetBoardColor(); switch (state) { case BoardState.Normal: if (_lastChangedSquareView != null) { ResetSquareViewColor(_lastChangedSquareView); } break; case BoardState.WhiteCheck: squareView = SquareViews.First( x => (x.Square?.Piece?.Type == Type.King) && (x.Square?.Piece?.Color == Color.White)); squareView.SetResourceReference(BackgroundProperty, "ValidationBrush5"); break; case BoardState.BlackCheck: squareView = SquareViews.First( x => (x.Square?.Piece?.Type == Type.King) && (x.Square?.Piece?.Color == Color.Black)); squareView.SetResourceReference(BackgroundProperty, "ValidationBrush5"); break; case BoardState.BlackCheckMate: squareView = SquareViews.First( x => (x.Square?.Piece?.Type == Type.King) && (x.Square?.Piece?.Color == Color.Black)); squareView.SetResourceReference(BackgroundProperty, "TextBrush"); break; case BoardState.WhiteCheckMate: squareView = SquareViews.First( x => (x.Square?.Piece?.Type == Type.King) && (x.Square?.Piece?.Color == Color.White)); squareView.SetResourceReference(BackgroundProperty, "TextBrush"); break; case BoardState.BlackPat: squareView = SquareViews.First( x => (x.Square?.Piece?.Type == Type.King) && (x.Square?.Piece?.Color == Color.Black)); squareView.SetResourceReference(BackgroundProperty, "WhiteColorBrush"); break; case BoardState.WhitePat: squareView = SquareViews.First( x => (x.Square?.Piece?.Type == Type.King) && (x.Square?.Piece?.Color == Color.White)); squareView.SetResourceReference(BackgroundProperty, "WhiteColorBrush"); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } _lastChangedSquareView = squareView; }
public void GameStateChanged(BoardState state) { SquareView squareView = null; ResetBoardColor(); switch (state) { case BoardState.Normal: if (_lastChangedSquareView != null) { ResetSquareViewColor(_lastChangedSquareView); } break; case BoardState.WhiteCheck: squareView = SquareViews.First( x => x.Square?.Piece?.Type == Type.King && x.Square?.Piece?.Color == Color.White); squareView.SetResourceReference(BackgroundProperty, "MahApps.Brushes.Validation5"); break; case BoardState.BlackCheck: squareView = SquareViews.First( x => x.Square?.Piece?.Type == Type.King && x.Square?.Piece?.Color == Color.Black); squareView.SetResourceReference(BackgroundProperty, "MahApps.Brushes.Validation5"); break; case BoardState.BlackCheckMate: squareView = SquareViews.First( x => x.Square?.Piece?.Type == Type.King && x.Square?.Piece?.Color == Color.Black); squareView.SetResourceReference(BackgroundProperty, "MahApps.Brushes.Text"); break; case BoardState.WhiteCheckMate: squareView = SquareViews.First( x => x.Square?.Piece?.Type == Type.King && x.Square?.Piece?.Color == Color.White); squareView.SetResourceReference(BackgroundProperty, "MahApps.Brushes.Text"); break; case BoardState.BlackPat: squareView = SquareViews.First( x => x.Square?.Piece?.Type == Type.King && x.Square?.Piece?.Color == Color.Black); squareView.SetResourceReference(BackgroundProperty, "MahApps.Brushes.SystemControlForegroundChromeWhite"); break; case BoardState.WhitePat: squareView = SquareViews.First( x => x.Square?.Piece?.Type == Type.King && x.Square?.Piece?.Color == Color.White); squareView.SetResourceReference(BackgroundProperty, "MahApps.Brushes.SystemControlForegroundChromeWhite"); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } _lastChangedSquareView = squareView; }