Удаление класса Delegate, создание вместо него Action. Исправление ошибок. Сдана Lab5

This commit is contained in:
malimova 2023-11-13 12:40:58 +04:00
parent ede63a0ae5
commit 32ff4df6d8
4 changed files with 26 additions and 51 deletions

View File

@ -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);
}

View File

@ -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("Не удалось добавить объект");
}
}
/// <summary>
/// Удаление объекта из набора
/// </summary>
@ -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("Не удалось добавить объект");
}
}
}
}

View File

@ -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

View File

@ -19,8 +19,8 @@ namespace AirBomber
/// <summary>
/// Делегат для передачи объекта-автомобиля
/// </summary>
/// <param name="car"></param>
private event AirPlaneDelegate? EventAddPlane;
/// <param name="plane"></param>
private event Action<DrawningAirPlane>? EventAddPlane;
/// <summary>
/// Конструктор
/// </summary>
@ -53,7 +53,7 @@ namespace AirBomber
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(AirPlaneDelegate ev)
public void AddEvent(Action<DrawningAirPlane> ev)
{
if (EventAddPlane == null)
{