/// <summary> /// Обработка нажатия кнопок управления /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonMove_Click(object sender, EventArgs e) { //получаем имя кнопки string name = (sender as Button).Name; switch (name) { case "buttonUp": _car?.MoveTransport(Direction.Up); break; case "buttonDown": _car?.MoveTransport(Direction.Down); break; case "buttonLeft": _car?.MoveTransport(Direction.Left); break; case "buttonRight": _car?.MoveTransport(Direction.Right); break; } Draw(); }