Главная / Создание Windows-приложений на основе Visual C# / Вы изучаете сборку графической программы, представленную в виде кода MSIL. При нажатии на кнопку btnCrop пользователь может вырезать часть выделенного изображения:.method private instance void btnCrop_Click(object sender, [mscorlib]System.EventArgs e) cil

Вы изучаете сборку графической программы, представленную в виде кода MSIL. При нажатии на кнопку btnCrop пользователь может вырезать часть выделенного изображения:.method private instance void btnCrop_Click(object sender, [mscorlib]System.EventArgs e) cil managed { // Code Size: 216 byte(s) .maxstack 6 .locals init ( [System.Drawing]System.Drawing.Bitmap bitmap1, [System.Drawing]System.Drawing.Graphics graphics1, [System.Drawing]System.Drawing.Rectangle rectangle1, [mscorlib]System.Exception exception1, [System.Drawing]System.Drawing.Rectangle rectangle2) L_0000: nop L_0001: nop L_0002: ldarg.0 L_0003: ldfld int32 cropImagesExtentedExample.frmMain::cropWidth L_0008: ldc.i4.1 L_0009: bge.s L_0024 L_000b: ldstr " Выделите область, перемещая курсор! " L_0010: ldstr " Нет области для выделения! " L_0015: ldc.i4.0 L_0016: ldc.i4.s 16 L_0018: call [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms. MessageBox::Show(string, string, [System.Windows.Forms] System.Windows.Forms.MessageBoxButtons, [System.Windows.Forms]System.Windows.Forms.MessageBoxIcon) L_001d: pop L_001e: nop L_001f: leave L_00d6 L_0024: nop L_0025: ldloca.s rectangle2 L_0027: ldarg.0 L_0028: ldfld int32 cropImagesExtentedExample.frmMain::cropX L_002d: ldarg.0 L_002e: ldfld int32 cropImagesExtentedExample.frmMain::cropY L_0033: ldarg.0 L_0034: ldfld int32 cropImagesExtentedExample.frmMain::cropWidth L_0039: ldarg.0 L_003a: ldfld int32 cropImagesExtentedExample.frmMain::cropHeight L_003f: call instance void [System.Drawing]System.Drawing.Rectangle::.ctor(int32, int32, int32, int32) L_0044: nop L_0045: ldloc.s rectangle2 L_0047: stloc.2 L_0048: ldarg.0 L_0049: callvirt instance [System.Windows.Forms]System.Windows.Forms.PictureBox cropImagesExtentedExample.frmMain::get_p() L_004e: callvirt instance [System.Drawing]System.Drawing.Image [System.Windows.Forms]System.Windows.Forms.PictureBox::get_Image() L_0053: ldarg.0 L_0054: callvirt instance [System.Windows.Forms]System.Windows.Forms.PictureBox cropImagesExtentedExample.frmMain::get_p() L_0059: callvirt instance int32 [System.Windows.Forms]System.Windows.Forms.Control::get_Width() L_005e: ldarg.0 L_005f: callvirt instance [System.Windows.Forms]System.Windows.Forms.PictureBox cropImagesExtentedExample.frmMain::get_p() L_0064: callvirt instance int32 [System.Windows.Forms]System.Windows.Forms.Control::get_Height() L_0069: newobj instance void [System.Drawing]System.Drawing.Bitmap::.ctor([System.Drawing]System.Drawing.Image, int32, int32) L_006e: stloc.0 L_006f: ldarg.0 L_0070: ldarg.0 L_0071: ldfld int32 cropImagesExtentedExample.frmMain::cropWidth L_0076: ldarg.0 L_0077: ldfld int32 cropImagesExtentedExample.frmMain::cropHeight L_007c: newobj instance void [System.Drawing]System.Drawing.Bitmap::.ctor(int32, int32) L_0081: stfld [System.Drawing]System.Drawing.Bitmap cropImagesExtentedExample.frmMain::cropBitmap L_0086: ldarg.0 L_0087: ldfld [System.Drawing]System.Drawing.Bitmap cropImagesExtentedExample.frmMain::cropBitmap L_008c: call [System.Drawing]System.Drawing.Graphics [System.Drawing]System.Drawing.Graphics::FromImage([System.Drawing]System.Drawing.Image) L_0091: stloc.1 L_0092: ldloc.1 L_0093: ldloc.0 L_0094: ldc.i4.0 L_0095: ldc.i4.0 L_0096: ldloc.2 L_0097: ldc.i4.2 L_0098: callvirt instance void [System.Drawing]System.Drawing. Graphics::DrawImage([System.Drawing]System.Drawing.Image, int32, int32, [System.Drawing]System.Drawing.Rectangle, [System.Drawing]System.Drawing.GraphicsUnit) L_009d: nop L_009e: ldarg.0 L_009f: callvirt instance [System.Windows.Forms]System.Windows.Forms.PictureBox cropImagesExtentedExample.frmMain::get_pbCrop() L_00a4: ldarg.0 L_00a5: ldfld [System.Drawing]System.Drawing.Bitmap cropImagesExtentedExample.frmMain::cropBitmap L_00aa: callvirt instance void [System.Windows.Forms]System.Windows.Forms.PictureBox::set_Image([System.Drawing]System.Drawing.Image) L_00af: nop L_00b0: leave.s L_00d5 L_00b2: dup L_00b3: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError([mscorlib]System.Exception) L_00b8: stloc.3 L_00b9: nop L_00ba: ldloc.3 L_00bb: callvirt instance string [mscorlib]System.Exception::get_Message() L_00c0: ldstr " Ошибка " L_00c5: ldc.i4.0 L_00c6: ldc.i4.s 16 L_00c8: call [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms. MessageBox::Show(string, string, [System.Windows.Forms] System.Windows.Forms.MessageBoxButtons, [System.Windows.Forms]System.Windows.Forms.MessageBoxIcon) L_00cd: pop L_00ce: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError() L_00d3: leave.s L_00d5 L_00d5: nop L_00d6: nop L_00d7: ret .try L_0002 to L_00b2 catch [mscorlib]System.Exception handler L_00b2 to L_00d5 }

Выберите правильный перевод этого фрагмента кода на языке 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 = 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(); } }
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(); } }
Сложность вопроса
85
Сложность курса: Создание Windows-приложений на основе Visual C#
77
Оценить вопрос
Очень сложно
Сложно
Средне
Легко
Очень легко
Комментарии:
Аноним
Кто ищет вот эти ответы с интуитом? Это же безумно легко
15 окт 2020
Аноним
Если бы не эти решения - я бы не смог решить c этими тестами intuit.
30 июн 2020
Аноним
Пишет вам сотрудник деканата! Срочно удалите сайт и ответы интуит. Пишу жалобу
18 мар 2016
Оставить комментарий
Другие ответы на вопросы из темы программирование интуит.