public void repaint() { Dispatcher.Invoke(DispatcherPriority.Input, new ThreadStart(() => { String turn = Chess.WhosTurn(); Turn.Content = char.ToUpper(turn[0]) + turn.Substring(1) + "'s turn"; bool black = false; for (int y = 0; y < 8; ++y) { for (int x = 0; x < 8; ++x) { Label l = FindChild <Label>(ChessBoard, "board_" + x + y); if (l != null) { l.MouseLeftButtonDown -= showMoves; l.MouseLeftButtonDown -= move; l.MouseLeftButtonDown -= repaint; Piece current = Chess.board.at(new Position(x, y)); String type = current.visual(); l.Content = type; l.Background = black ? new SolidColorBrush(Color.FromArgb(150, 0, 0, 0)) : new SolidColorBrush(Color.FromArgb(205, 255, 255, 255)); if (current.getColor() == Chess.WhosTurn()) { if (current.getType() == "king") { if (Chess.IsChecked(Chess.WhosTurn())) { l.Background = Brushes.LightCoral; } } l.Cursor = Cursors.Hand; l.MouseLeftButtonDown += showMoves; } else { l.Cursor = Cursors.Arrow; } } black = !black; } black = !black; } ChessMove latestMove = Chess.computerMove; if (latestMove != null) { Label last = FindChild <Label>(ChessBoard, "board_" + latestMove.from.x + latestMove.from.y); last.Background = Brushes.GreenYellow; last = FindChild <Label>(ChessBoard, "board_" + latestMove.to.x + latestMove.to.y); last.Background = Brushes.GreenYellow; } })); }