private void Form1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 'w') { ClearBoard(); //костыль, чтобы не работал разворот, когда он невозможен из-за того, //что фигура вылазит за пределы доски try { currentFigure.ChangePosition(); if (board[currentFigure.PosFirstX, currentFigure.PosFirstY] == 1 || board[currentFigure.PosSecondX, currentFigure.PosSecondY] == 1 || board[currentFigure.PosThirdX, currentFigure.PosThirdY] == 1 || board[currentFigure.PosQuadrupleX, currentFigure.PosQuadrupleY] == 1) { throw new Exception(); } else { FillBoard(); } } catch { ClearBoard(); currentFigure.ChangePosition(); currentFigure.ChangePosition(); currentFigure.ChangePosition(); FillBoard(); } pictureBox1.Invalidate(); } if (e.KeyChar == 'a') { ClearBoard(); GetLeft(); FillBoard(); pictureBox1.Invalidate(); } if (e.KeyChar == 'd') { ClearBoard(); GetRight(); FillBoard(); pictureBox1.Invalidate(); } if (e.KeyChar == 's') { ClearBoard(); GetLower(); FillBoard(); pictureBox1.Invalidate(); } }