Главная / Создание Windows-приложений на основе Visual C# / Вы изучаете сборку графической программы, написанной на языке VisualBasic. При нажатии на кнопку btnCrop пользователь может вырезать часть выделенного изображения: Private Sub btnCrop_Click(ByVal sender As Object, ByVal e As EventArgs) Try If (Me.cropWidt

Вы изучаете сборку графической программы, написанной на языке VisualBasic. При нажатии на кнопку btnCrop пользователь может вырезать часть выделенного изображения: Private Sub btnCrop_Click(ByVal sender As Object, ByVal e As EventArgs) Try If (Me.cropWidth < 1) Then MessageBox.Show("Выделите область, перемещая курсор!", "Нет области для выделения!", MessageBoxButtons.OK, MessageBoxIcon.Hand) Else Dim rectangle2 As New Rectangle(Me.cropX, Me.cropY, Me.cropWidth, Me.cropHeight) Dim rectangle1 As Rectangle = rectangle2 Dim bitmap1 As New Bitmap(Me.p.Image, Me.p.Width, Me.p.Height) Me.cropBitmap = New Bitmap(Me.cropWidth, Me.cropHeight) Dim graphics1 As Graphics = Graphics.FromImage(Me.cropBitmap) graphics1.DrawImage(bitmap1, 0, 0, rectangle1, GraphicsUnit.Pixel) Me.pbCrop.Image = Me.cropBitmap End If Catch exception2 As Exception ProjectData.SetProjectError(exception2) Dim exception1 As Exception = exception2 MessageBox.Show(exception1.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand) ProjectData.ClearProjectError End Try End Sub

Выберите правильный перевод этого фрагмента кода на языке C#:

вопрос

Правильный ответ:

private void btnCrop_Click(object sender, EventArgs e) { try { if (this.cropWidth < 1) { MessageBox.Show("Выделите область, перемещая курсор!", " Нет области для выделения!", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { Rectangle rectangle2 = new Rectangle(this.cropX, this.cropY, this.cropWidth, this.cropHeight); Rectangle rectangle1 = rectangle2; Bitmap bitmap1 = new Bitmap(this.p.Image, this.p.Width, this.p.Height); this.cropBitmap = new Bitmap(this.cropWidth, this.cropHeight); Graphics graphics1 = Graphics.FromImage(this.cropBitmap); graphics1.DrawImage(bitmap1, 0, 0, rectangle1, GraphicsUnit.Pixel); this.pbCrop.Image = this.cropBitmap; } } catch (Exception exception2) { ProjectData.SetProjectError(exception2); Exception exception1 = exception2; MessageBox.Show(exception1.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand); ProjectData.ClearProjectError(); } }
private void btnCrop_Click(object sender, EventArgs e) { try { if (this.cropWidth < 1) { MessageBox.Show("Выделите область, перемещая курсор!", " Нет области для выделения!", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { Rectangle rectangle2 = new Rectangle(this.cropX, this.cropY, this.cropWidth, this.cropHeight); Rectangle rectangle1 = rectangle2; Bitmap bitmap1 = new Bitmap(this.p.Image, this.p.Width, this.p.Height); this.cropBitmap = bitmap1(this.cropWidth, this.cropHeight); Graphics graphics1 = Graphics.FromImage(this.cropBitmap); graphics1.DrawImage(bitmap1, 0, 0, rectangle1, GraphicsUnit.Pixel); this.pbCrop.Image = this.cropBitmap; } } catch (Exception exception2) { ProjectData.SetProjectError(exception2); Exception exception1 = exception2; MessageBox.Show(exception1.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand); ProjectData.ClearProjectError(); } }
private void btnCrop_Click(object sender, EventArgs e) { try { if (this.cropWidth < 1) { MessageBox.Show("Выделите область, перемещая курсор!", " Нет области для выделения!", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { Rectangle rectangle2 = new Rectangle(this.cropX, this.cropY, this.cropWidth, this.cropHeight); Rectangle rectangle1 = rectangle2; Bitmap bitmap1 = new Bitmap(this.p.Image, this.p.Width, this.p.Height); this.cropBitmap = bitmap1(this.p.Image, this.cropWidth, this.cropHeight); Graphics graphics1 = Graphics.FromImage(this.cropBitmap); graphics1.DrawImage(bitmap1, 0, 0, rectangle1, GraphicsUnit.Pixel); this.pbCrop.Image = this.cropBitmap; } } catch (Exception exception2) { ProjectData.SetProjectError(exception2); Exception exception1 = exception2; MessageBox.Show(exception1.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand); ProjectData.ClearProjectError(); } }
private void btnCrop_Click(object sender, EventArgs e) { try { if (this.cropWidth < 1) { MessageBox.Show("Выделите область, перемещая курсор!", " Нет области для выделения!", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { Rectangle rectangle2 = new Rectangle(this.cropX, this.cropY, this.cropWidth, this.cropHeight); Rectangle rectangle1 = rectangle2; Bitmap bitmap1 = new Bitmap(this.p.Image, this.p.Width, this.p.Height); this.cropBitmap = bitmap1(this.p.Image); Graphics graphics1 = Graphics.FromImage(this.cropBitmap); graphics1.DrawImage(bitmap1, 0, 0, rectangle1, GraphicsUnit.Pixel); this.pbCrop.Image = this.cropBitmap; } } catch (Exception exception2) { ProjectData.SetProjectError(exception2); Exception exception1 = exception2; MessageBox.Show(exception1.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand); ProjectData.ClearProjectError(); } }
Сложность вопроса
79
Сложность курса: Создание Windows-приложений на основе Visual C#
77
Оценить вопрос
Очень сложно
Сложно
Средне
Легко
Очень легко
Комментарии:
Аноним
Спасибо за гдз по intuit.
03 дек 2018
Аноним
Если бы не данные ответы - я бы не справился c этими тестами intuit.
03 июн 2016
Оставить комментарий
Другие ответы на вопросы из темы программирование интуит.