From 32ff4df6d89f9e1f643200e3bb59b932703c33fa Mon Sep 17 00:00:00 2001 From: malimova Date: Mon, 13 Nov 2023 12:40:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20Delegate,=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=BC?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=BE=20=D0=BD=D0=B5=D0=B3=D0=BE=20Action.?= =?UTF-8?q?=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA.=20=D0=A1=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B0=20Lab5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AirPlaneDelegate.cs | 10 ----- AirBomber/AirBomber/FormPlaneCollection.cs | 45 ++++++++++--------- .../AirBomber/FormPlaneConfig.Designer.cs | 16 ------- AirBomber/AirBomber/FormPlaneConfig.cs | 6 +-- 4 files changed, 26 insertions(+), 51 deletions(-) delete mode 100644 AirBomber/AirBomber/AirPlaneDelegate.cs diff --git a/AirBomber/AirBomber/AirPlaneDelegate.cs b/AirBomber/AirBomber/AirPlaneDelegate.cs deleted file mode 100644 index e912336..0000000 --- a/AirBomber/AirBomber/AirPlaneDelegate.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AirBomber -{ - public delegate void AirPlaneDelegate(DrawningAirPlane plane); -} diff --git a/AirBomber/AirBomber/FormPlaneCollection.cs b/AirBomber/AirBomber/FormPlaneCollection.cs index 2d5b92a..6ed5627 100644 --- a/AirBomber/AirBomber/FormPlaneCollection.cs +++ b/AirBomber/AirBomber/FormPlaneCollection.cs @@ -63,6 +63,28 @@ namespace AirBomber formPlaneConfig.AddEvent(AddPlane); formPlaneConfig.Show(); } + private void AddPlane(DrawningAirPlane plane) + { + plane._pictureWidth = pictureBoxCollection.Width; + plane._pictureHeight = pictureBoxCollection.Height; + + if (listBoxStorages.SelectedIndex == -1) return; + + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + if (obj + plane > -1) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowPlanes(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } /// /// Удаление объекта из набора /// @@ -140,27 +162,6 @@ namespace AirBomber ReloadObjects(); } } - private void AddPlane(DrawningAirPlane plane) - { - plane._pictureWidth = pictureBoxCollection.Width; - plane._pictureHeight = pictureBoxCollection.Height; - - if (listBoxStorages.SelectedIndex == -1) return; - - var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; - if (obj == null) - { - return; - } - if (obj + plane > -1) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowPlanes(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + } } diff --git a/AirBomber/AirBomber/FormPlaneConfig.Designer.cs b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs index 70e2b0c..dbf6319 100644 --- a/AirBomber/AirBomber/FormPlaneConfig.Designer.cs +++ b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs @@ -126,8 +126,6 @@ panelPurple.Name = "panelPurple"; panelPurple.Size = new Size(54, 54); panelPurple.TabIndex = 1; - panelPurple.DragDrop += PanelObject_DragDrop; - panelPurple.DragEnter += PanelObject_DragEnter; panelPurple.MouseDown += panelColor_MouseDown; // // panelBlack @@ -137,8 +135,6 @@ panelBlack.Name = "panelBlack"; panelBlack.Size = new Size(54, 54); panelBlack.TabIndex = 1; - panelBlack.DragDrop += PanelObject_DragDrop; - panelBlack.DragEnter += PanelObject_DragEnter; panelBlack.MouseDown += panelColor_MouseDown; // // panelGray @@ -148,8 +144,6 @@ panelGray.Name = "panelGray"; panelGray.Size = new Size(54, 54); panelGray.TabIndex = 1; - panelGray.DragDrop += PanelObject_DragDrop; - panelGray.DragEnter += PanelObject_DragEnter; panelGray.MouseDown += panelColor_MouseDown; // // panelWhite @@ -159,8 +153,6 @@ panelWhite.Name = "panelWhite"; panelWhite.Size = new Size(54, 54); panelWhite.TabIndex = 1; - panelWhite.DragDrop += PanelObject_DragDrop; - panelWhite.DragEnter += PanelObject_DragEnter; panelWhite.MouseDown += panelColor_MouseDown; // // panelYellow @@ -170,8 +162,6 @@ panelYellow.Name = "panelYellow"; panelYellow.Size = new Size(54, 54); panelYellow.TabIndex = 1; - panelYellow.DragDrop += PanelObject_DragDrop; - panelYellow.DragEnter += PanelObject_DragEnter; panelYellow.MouseDown += panelColor_MouseDown; // // panelBlue @@ -181,8 +171,6 @@ panelBlue.Name = "panelBlue"; panelBlue.Size = new Size(54, 54); panelBlue.TabIndex = 1; - panelBlue.DragDrop += PanelObject_DragDrop; - panelBlue.DragEnter += PanelObject_DragEnter; panelBlue.MouseDown += panelColor_MouseDown; // // panelGreen @@ -192,8 +180,6 @@ panelGreen.Name = "panelGreen"; panelGreen.Size = new Size(54, 54); panelGreen.TabIndex = 1; - panelGreen.DragDrop += PanelObject_DragDrop; - panelGreen.DragEnter += PanelObject_DragEnter; panelGreen.MouseDown += panelColor_MouseDown; // // panelRed @@ -203,8 +189,6 @@ panelRed.Name = "panelRed"; panelRed.Size = new Size(54, 54); panelRed.TabIndex = 0; - panelRed.DragDrop += PanelObject_DragDrop; - panelRed.DragEnter += PanelObject_DragEnter; panelRed.MouseDown += panelColor_MouseDown; // // checkBoxFuelTanks diff --git a/AirBomber/AirBomber/FormPlaneConfig.cs b/AirBomber/AirBomber/FormPlaneConfig.cs index b00e861..b41872a 100644 --- a/AirBomber/AirBomber/FormPlaneConfig.cs +++ b/AirBomber/AirBomber/FormPlaneConfig.cs @@ -19,8 +19,8 @@ namespace AirBomber /// /// Делегат для передачи объекта-автомобиля /// - /// - private event AirPlaneDelegate? EventAddPlane; + /// + private event Action? EventAddPlane; /// /// Конструктор /// @@ -53,7 +53,7 @@ namespace AirBomber /// Добавление события /// /// Привязанный метод - public void AddEvent(AirPlaneDelegate ev) + public void AddEvent(Action ev) { if (EventAddPlane == null) {