public BoardControl(IBoardStyle boardStyle, int bitmapWidth, int bitmapHeight) { this.boardStyle = boardStyle; this.bitmapWidth = bitmapWidth; this.bitmapHeight = bitmapHeight; chessBoard = new DataGridView(); Controls.Add(chessBoard); chessBoard.CellClick += (sender, args) => CellClick?.Invoke(ChessUtils.GetPosition(args.RowIndex, args.ColumnIndex, chessBoard.Rows.Count)); }
/* * Этот класс должен расположить все элементы на экране: * 1. Поле для шахмат. * 2. Историю. * 3. Сообщения игрокам. */ public ChessForm(ChessApp app, IBoardStyle boardStyle, ICellBitmapSelector <ChessPiece> bitmapSelector, IMessageSelector <ChessGame> messageSelector) { this.app = app; this.bitmapSelector = bitmapSelector; this.messageSelector = messageSelector; board = new BoardControl(boardStyle, bitmapSelector.BitmapWidth, bitmapSelector.BitmapHeight); board.CellClick += app.ClickAt; app.StateChanged += Invalidate; // need some layout }