diff --git a/ProjectBomber/ProjectBomber/CollectionGenericObject/AbstractCompany.cs b/ProjectBomber/ProjectBomber/CollectionGenericObject/AbstractCompany.cs
new file mode 100644
index 0000000..725d58b
--- /dev/null
+++ b/ProjectBomber/ProjectBomber/CollectionGenericObject/AbstractCompany.cs
@@ -0,0 +1,105 @@
+using ProjectAirBomber.CollectionGenericObject;
+using ProjectAirBomber.Drawnings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirBomber.CollectionGenericObject;
+
+public abstract class AbstractCompany
+{
+ ///
+ /// Размер места (ширина)
+ ///
+ protected readonly int _placeSizeWidth = 180;
+ ///
+ /// Размер места (высота)
+ ///
+ protected readonly int _placeSizeHeight = 170;
+ ///
+ /// Ширина окна
+ ///
+ protected readonly int _pictureWidth;
+ ///
+ /// Высота окна
+ ///
+ protected readonly int _pictureHeight;
+ ///
+ /// Коллекция автомобилей
+ ///
+ protected ICollectionGenericObject? _collection = null;
+ ///
+ /// Вычисление максимального количества элементов, который можно разместить в окне
+ ///
+ private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
+ ///
+ /// Конструктор
+ ///
+ /// Ширина окна
+ /// Высота окна
+ /// Коллекция автомобилей
+ public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObject collection)
+ {
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _collection = collection;
+ _collection.SetMaxCount = GetMaxCount;
+ }
+ ///
+ /// Перегрузка оператора сложения для класса
+ ///
+ /// Компания
+ /// Добавляемый объект
+ ///
+ public static int? operator +(AbstractCompany company, DrawningPlane plane)
+ {
+ return company._collection?.Insert(plane);
+ }
+ ///
+ /// Перегрузка оператора удаления для класса
+ ///
+ /// Компания
+ /// Номер удаляемого объекта
+ ///
+ public static DrawningPlane operator -(AbstractCompany company, int position)
+ {
+ return company._collection?.Remove(position);
+ }
+ ///
+ /// Получение случайного объекта из коллекции
+ ///
+ ///
+ public DrawningPlane? GetRandomObject()
+ {
+ Random rnd = new();
+ return _collection?.Get(rnd.Next(GetMaxCount));
+ }
+ ///
+ /// Вывод всей коллекции
+ ///
+ ///
+ public Bitmap? Show()
+ {
+ Bitmap bitmap = new(_pictureWidth, _pictureHeight);
+ Graphics graphics = Graphics.FromImage(bitmap);
+ DrawBackgound(graphics);
+ SetObjectsPosition();
+ for (int i = 0; i < (_collection?.Count ?? 0); ++i)
+ {
+ DrawningPlane? obj = _collection?.Get(i);
+ obj?.DrawPlane(graphics);
+ }
+ return bitmap;
+ }
+ ///
+ /// Вывод заднего фона
+ ///
+ ///
+ protected abstract void DrawBackgound(Graphics g);
+ ///
+ /// Расстановка объектов
+ ///
+ protected abstract void SetObjectsPosition();
+}
\ No newline at end of file
diff --git a/ProjectBomber/ProjectBomber/CollectionGenericObject/ICollectionGenericObject.cs b/ProjectBomber/ProjectBomber/CollectionGenericObject/ICollectionGenericObject.cs
index bc55e51..8edcb0c 100644
--- a/ProjectBomber/ProjectBomber/CollectionGenericObject/ICollectionGenericObject.cs
+++ b/ProjectBomber/ProjectBomber/CollectionGenericObject/ICollectionGenericObject.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace ProjectAirBomber.CollectionGenericObject;
-public interface ICollectionGenericObjects
+public interface ICollectionGenericObject
where T : class
{
///
@@ -22,7 +22,7 @@ where T : class
///
/// Добавляемый объект
/// true - вставка прошла удачно, false - вставка не удалась
- bool Insert(T obj);
+ int Insert(T obj);
///
/// Добавление объекта в коллекцию на конкретную позицию
///
diff --git a/ProjectBomber/ProjectBomber/CollectionGenericObject/MassivegenericObjects.cs b/ProjectBomber/ProjectBomber/CollectionGenericObject/MassiveGenericObject.cs
similarity index 91%
rename from ProjectBomber/ProjectBomber/CollectionGenericObject/MassivegenericObjects.cs
rename to ProjectBomber/ProjectBomber/CollectionGenericObject/MassiveGenericObject.cs
index 638c7ff..c39a285 100644
--- a/ProjectBomber/ProjectBomber/CollectionGenericObject/MassivegenericObjects.cs
+++ b/ProjectBomber/ProjectBomber/CollectionGenericObject/MassiveGenericObject.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace ProjectAirBomber.CollectionGenericObject;
-public class MassiveGenericObjects : ICollectionGenericObjects
+public class MassiveGenericObject : ICollectionGenericObject
where T : class
{
///
@@ -34,7 +34,7 @@ where T : class
///
/// Конструктор
///
- public MassiveGenericObjects()
+ public MassiveGenericObject()
{
_collection = Array.Empty();
}
@@ -44,17 +44,17 @@ where T : class
return null;
return _collection[position];
}
- public bool Insert(T obj) // вставка объекта на свободное место
+ public int Insert(T obj) // вставка объекта на свободное место
{
for (int i = 0; i < _collection.Length; ++i)
{
if (_collection[i] == null)
{
_collection[i] = obj;
- return true;
+ return i;
}
}
- return false;
+ return -1;
}
public bool? Insert(T obj, int position) // вставка объекта на место
{
diff --git a/ProjectBomber/ProjectBomber/CollectionGenericObject/PlaneHangar.cs b/ProjectBomber/ProjectBomber/CollectionGenericObject/PlaneHangar.cs
new file mode 100644
index 0000000..6fa38b6
--- /dev/null
+++ b/ProjectBomber/ProjectBomber/CollectionGenericObject/PlaneHangar.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ProjectAirBomber.Drawnings;
+
+namespace ProjectAirBomber.CollectionGenericObject;
+
+public class PlaneHangar : AbstractCompany
+{
+ ///
+ /// Конструктор
+ ///
+ ///
+ ///
+ ///
+ public PlaneHangar(int picWidth, int picHeight, ICollectionGenericObject collection) : base(picWidth, picHeight, collection) { }
+ protected override void DrawBackgound(Graphics g)
+ {
+ Pen pen = new(Color.Black, 3);
+ int posX = 0;
+ for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
+ {
+ int posY = 0;
+ g.DrawLine(pen, posX, posY, posX, posY + _placeSizeHeight * (_pictureHeight / _placeSizeHeight));
+ for (int j = 0; j <= _pictureHeight / _placeSizeHeight; j++)
+ {
+ g.DrawLine(pen, posX, posY, posX + _placeSizeWidth - 30, posY);
+ posY += _placeSizeHeight;
+ }
+ posX += _placeSizeWidth;
+
+ }
+ }
+ protected override void SetObjectsPosition()
+ {
+ int posX = _pictureWidth / _placeSizeWidth - 1;
+ int posY = 0;
+ for (int i = 0; i < _collection?.Count; i++)
+ {
+ if (_collection.Get(i) != null)
+ {
+ _collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
+ _collection?.Get(i)?.SetPosition(posX * _placeSizeWidth + 5, posY * _placeSizeHeight + 5);
+ }
+ if (posX > 0)
+ {
+ posX--;
+ }
+ else
+ {
+ posY++;
+ posX = _pictureWidth / _placeSizeWidth - 1;
+ }
+ if (posX < 0) { return; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectBomber/ProjectBomber/FormAirBomber.Designer.cs b/ProjectBomber/ProjectBomber/FormAirBomber.Designer.cs
index 6658de9..bf9d909 100644
--- a/ProjectBomber/ProjectBomber/FormAirBomber.Designer.cs
+++ b/ProjectBomber/ProjectBomber/FormAirBomber.Designer.cs
@@ -33,12 +33,10 @@ namespace ProjectAirBomber
private void InitializeComponent()
{
pictureBoxAirBomber = new PictureBox();
- buttonCreate = new Button();
buttonLeft = new Button();
buttonUp = new Button();
buttonDown = new Button();
buttonRight = new Button();
- buttonCreatePlane = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).BeginInit();
@@ -53,17 +51,6 @@ namespace ProjectAirBomber
pictureBoxAirBomber.TabIndex = 0;
pictureBoxAirBomber.TabStop = false;
//
- // buttonCreate
- //
- buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreate.Location = new Point(0, 655);
- buttonCreate.Name = "buttonCreate";
- buttonCreate.Size = new Size(247, 29);
- buttonCreate.TabIndex = 1;
- buttonCreate.Text = "Создать бомбардировщик";
- buttonCreate.UseVisualStyleBackColor = true;
- buttonCreate.Click += ButtonCreate_Click;
- //
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
@@ -113,17 +100,6 @@ namespace ProjectAirBomber
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click;
//
- // buttonCreatePlane
- //
- buttonCreatePlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreatePlane.Location = new Point(253, 655);
- buttonCreatePlane.Name = "buttonCreatePlane";
- buttonCreatePlane.Size = new Size(247, 29);
- buttonCreatePlane.TabIndex = 6;
- buttonCreatePlane.Text = "Создать самолет";
- buttonCreatePlane.UseVisualStyleBackColor = true;
- buttonCreatePlane.Click += ButtonCreatePlane_Click;
- //
// comboBoxStrategy
//
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@@ -151,12 +127,10 @@ namespace ProjectAirBomber
ClientSize = new Size(1555, 684);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
- Controls.Add(buttonCreatePlane);
Controls.Add(buttonRight);
Controls.Add(buttonDown);
Controls.Add(buttonUp);
Controls.Add(buttonLeft);
- Controls.Add(buttonCreate);
Controls.Add(pictureBoxAirBomber);
Name = "ProjectAirBomber";
Text = "Бомбардировщик";
@@ -167,12 +141,10 @@ namespace ProjectAirBomber
#endregion
private PictureBox pictureBoxAirBomber;
- private Button buttonCreate;
private Button buttonLeft;
private Button buttonUp;
private Button buttonDown;
private Button buttonRight;
- private Button buttonCreatePlane;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}
diff --git a/ProjectBomber/ProjectBomber/FormAirBomber.cs b/ProjectBomber/ProjectBomber/FormAirBomber.cs
index eb92194..b66e04a 100644
--- a/ProjectBomber/ProjectBomber/FormAirBomber.cs
+++ b/ProjectBomber/ProjectBomber/FormAirBomber.cs
@@ -16,6 +16,20 @@ namespace ProjectAirBomber
///
private AbstractStategy? _strategy;
+ ///
+ /// Получение объекта
+ ///
+ public DrawningPlane SetPlane
+ {
+ set
+ {
+ _drawningPlane = value;
+ _drawningPlane.SetPictureSize(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ Draw();
+ }
+ }
///
/// Конструктор формы
///
@@ -38,46 +52,6 @@ namespace ProjectAirBomber
pictureBoxAirBomber.Image = bmp;
}
- private void CreateObject(string type)
- {
- Random rnd = new Random();
- switch (type)
- {
- case nameof(DrawningPlane):
- _drawningPlane = new DrawningPlane(rnd.Next(100, 300), rnd.Next(1000, 3000),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- break;
- case nameof(DrawingAirBomber):
- _drawningPlane = new DrawingAirBomber(rnd.Next(650, 700), rnd.Next(15760, 16130),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
- Convert.ToBoolean(rnd.Next(0, 2)),
- Convert.ToBoolean(rnd.Next(0, 2)));
- break;
- default:
- return;
- }
- _drawningPlane.SetPictureSize(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
- _drawningPlane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100));
- _strategy = null;
-
- Draw();
- }
-
- ///
- /// Обработка нажатия кнопки "Создать автобус с гармошкой"
- ///
- ///
- ///
- private void ButtonCreate_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingAirBomber));
-
- ///
- /// Обработка нажатия кнопки "Создать автобус"
- ///
- ///
- ///
- public void ButtonCreatePlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlane));
-
///
/// Перемещение объекта по форме (нажатие кнопок навигации)
///
diff --git a/ProjectBomber/ProjectBomber/FormPlaneCollection.Designer.cs b/ProjectBomber/ProjectBomber/FormPlaneCollection.Designer.cs
new file mode 100644
index 0000000..77fbedf
--- /dev/null
+++ b/ProjectBomber/ProjectBomber/FormPlaneCollection.Designer.cs
@@ -0,0 +1,169 @@
+namespace ProjectAirBomber
+{
+ partial class FormPlaneCollection
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ groupBoxTools = new GroupBox();
+ buttonRefresh = new Button();
+ buttonGoToCheck = new Button();
+ buttonDelPlane = new Button();
+ maskedTextBox = new MaskedTextBox();
+ buttonAddAirBomber = new Button();
+ buttonAddPlane = new Button();
+ comboBoxSelectionCompany = new ComboBox();
+ pictureBox = new PictureBox();
+ groupBoxTools.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
+ SuspendLayout();
+ //
+ // groupBoxTools
+ //
+ groupBoxTools.Controls.Add(buttonRefresh);
+ groupBoxTools.Controls.Add(buttonGoToCheck);
+ groupBoxTools.Controls.Add(buttonDelPlane);
+ groupBoxTools.Controls.Add(maskedTextBox);
+ groupBoxTools.Controls.Add(buttonAddAirBomber);
+ groupBoxTools.Controls.Add(buttonAddPlane);
+ groupBoxTools.Controls.Add(comboBoxSelectionCompany);
+ groupBoxTools.Dock = DockStyle.Right;
+ groupBoxTools.Location = new Point(1035, 0);
+ groupBoxTools.Name = "groupBoxTools";
+ groupBoxTools.Size = new Size(250, 667);
+ groupBoxTools.TabIndex = 0;
+ groupBoxTools.TabStop = false;
+ groupBoxTools.Text = "Инструменты";
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Location = new Point(6, 291);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(232, 32);
+ buttonRefresh.TabIndex = 7;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
+ //
+ // buttonGoToCheck
+ //
+ buttonGoToCheck.Location = new Point(6, 253);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(232, 32);
+ buttonGoToCheck.TabIndex = 6;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += ButtonGoToCheck_Click;
+ //
+ // buttonDelPlane
+ //
+ buttonDelPlane.Location = new Point(9, 211);
+ buttonDelPlane.Name = "buttonDelPlane";
+ buttonDelPlane.Size = new Size(232, 36);
+ buttonDelPlane.TabIndex = 5;
+ buttonDelPlane.Text = "Удаление бомбардировщика";
+ buttonDelPlane.UseVisualStyleBackColor = true;
+ buttonDelPlane.Click += ButtonDelPlane_Click;
+ //
+ // maskedTextBox
+ //
+ maskedTextBox.Location = new Point(9, 178);
+ maskedTextBox.Mask = "00";
+ maskedTextBox.Name = "maskedTextBox";
+ maskedTextBox.Size = new Size(229, 27);
+ maskedTextBox.TabIndex = 4;
+ maskedTextBox.ValidatingType = typeof(int);
+ //
+ // buttonAddAirBomber
+ //
+ buttonAddAirBomber.Location = new Point(9, 113);
+ buttonAddAirBomber.Name = "buttonAddAirBomber";
+ buttonAddAirBomber.Size = new Size(232, 59);
+ buttonAddAirBomber.TabIndex = 2;
+ buttonAddAirBomber.Text = "Добавление бомбардировщика";
+ buttonAddAirBomber.UseVisualStyleBackColor = true;
+ buttonAddAirBomber.Click += ButtonAddAirBomber_Click;
+ //
+ // buttonAddPlane
+ //
+ buttonAddPlane.Location = new Point(9, 60);
+ buttonAddPlane.Name = "buttonAddPlane";
+ buttonAddPlane.Size = new Size(232, 47);
+ buttonAddPlane.TabIndex = 1;
+ buttonAddPlane.Text = "Добавление самолетов";
+ buttonAddPlane.UseVisualStyleBackColor = true;
+ buttonAddPlane.Click += ButtonAddPlane_Click;
+ //
+ // comboBoxSelectionCompany
+ //
+ comboBoxSelectionCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ comboBoxSelectionCompany.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxSelectionCompany.FormattingEnabled = true;
+ comboBoxSelectionCompany.Items.AddRange(new object[] { "Ангар" });
+ comboBoxSelectionCompany.Location = new Point(6, 26);
+ comboBoxSelectionCompany.Name = "comboBoxSelectionCompany";
+ comboBoxSelectionCompany.Size = new Size(232, 28);
+ comboBoxSelectionCompany.TabIndex = 0;
+ comboBoxSelectionCompany.SelectedIndexChanged += ComboBoxSelectionCompany_SelectedIndexChanged;
+ comboBoxSelectionCompany.Click += ComboBoxSelectionCompany_SelectedIndexChanged;
+ //
+ // pictureBox
+ //
+ pictureBox.Dock = DockStyle.Fill;
+ pictureBox.Location = new Point(0, 0);
+ pictureBox.Name = "pictureBox";
+ pictureBox.Size = new Size(1035, 667);
+ pictureBox.TabIndex = 3;
+ pictureBox.TabStop = false;
+ //
+ // FormPlaneCollection
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1285, 667);
+ Controls.Add(pictureBox);
+ Controls.Add(groupBoxTools);
+ Name = "FormPlaneCollection";
+ Text = "Коллекция Самолетов";
+ groupBoxTools.ResumeLayout(false);
+ groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private ComboBox comboBoxSelectionCompany;
+ private Button buttonAddPlane;
+ private Button buttonAddAirBomber;
+ private PictureBox pictureBox;
+ private Button buttonDelPlane;
+ private MaskedTextBox maskedTextBox;
+ private Button buttonRefresh;
+ private Button buttonGoToCheck;
+ }
+}
\ No newline at end of file
diff --git a/ProjectBomber/ProjectBomber/FormPlaneCollection.cs b/ProjectBomber/ProjectBomber/FormPlaneCollection.cs
new file mode 100644
index 0000000..9065586
--- /dev/null
+++ b/ProjectBomber/ProjectBomber/FormPlaneCollection.cs
@@ -0,0 +1,163 @@
+using ProjectAirBomber.CollectionGenericObject;
+using ProjectAirBomber;
+using ProjectAirBomber.Drawnings;
+using ProjectAirBomber.MovementStrategy;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ProjectAirBomber
+{
+ public partial class FormPlaneCollection : Form
+ {
+ ///
+ /// Стратегия перемещения
+ ///
+ private AbstractCompany? _company = null;
+
+ public FormPlaneCollection()
+ {
+ InitializeComponent();
+ }
+
+ private void ComboBoxSelectionCompany_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectionCompany.Text)
+ {
+ case "Ангар":
+ _company = new PlaneHangar(pictureBox.Width,
+ pictureBox.Height, new MassiveGenericObject());
+ break;
+ }
+ }
+ private void CreateObject(string type)
+ {
+
+ if (_company == null)
+ {
+ return;
+ }
+ Random random = new();
+ DrawningPlane drawningPlane;
+
+ Random rnd = new Random();
+ switch (type)
+ {
+ case nameof(DrawningPlane):
+ drawningPlane = new DrawningPlane(rnd.Next(100, 300), rnd.Next(1000, 3000), GetColor(random));
+ break;
+ case nameof(DrawingAirBomber):
+ drawningPlane = new DrawingAirBomber(rnd.Next(650, 700), rnd.Next(15760, 16130),
+ GetColor(random), GetColor(random),
+ Convert.ToBoolean(rnd.Next(0, 2)),
+ Convert.ToBoolean(rnd.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+
+ if (_company + drawningPlane)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+
+ private static Color GetColor(Random random)
+ {
+ Color color = Color.FromArgb(random.Next(0, 256), random.Next(0,
+ 256), random.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+ return color;
+ }
+ ///
+ /// кнопка добавления самолета
+ ///
+ ///
+ ///
+ private void ButtonAddPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlane));
+ ///
+ /// кнопка добавления бомбардировщика
+ ///
+ ///
+ ///
+ private void ButtonAddAirBomber_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingAirBomber));
+ ///
+ /// кнопка удаления
+ ///
+ ///
+ ///
+ private void ButtonDelPlane_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ return;
+ }
+ int pos = Convert.ToInt32(maskedTextBox.Text);
+ if (_company - pos != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+
+ private void ButtonGoToCheck_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+ DrawningPlane? plane = null;
+ int counter = 100;
+ while (plane == null)
+ {
+ plane = _company.GetRandomObject();
+ counter--;
+ if (counter <= 0)
+ {
+ break;
+ }
+ }
+ if (plane == null)
+ {
+ return;
+ }
+ ProjectAirBomber form = new()
+ {
+ SetPlane = plane
+ };
+ form.ShowDialog();
+ }
+ private void ButtonRefresh_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+ pictureBox.Image = _company.Show();
+ }
+ }
+}
+
diff --git a/ProjectBomber/ProjectBomber/FormPlaneCollection.resx b/ProjectBomber/ProjectBomber/FormPlaneCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectBomber/ProjectBomber/FormPlaneCollection.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ProjectBomber/ProjectBomber/Program.cs b/ProjectBomber/ProjectBomber/Program.cs
index d7c0f92..b4c514a 100644
--- a/ProjectBomber/ProjectBomber/Program.cs
+++ b/ProjectBomber/ProjectBomber/Program.cs
@@ -11,7 +11,7 @@ namespace ProjectAirBomber
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new ProjectAirBomber());
+ Application.Run(new FormPlaneCollection());
}
}
}
\ No newline at end of file