diff --git a/Project_airbus/Project_airbus/CollectionGenericObjects/AbstractCompany.cs b/Project_airbus/Project_airbus/CollectionGenericObjects/AbstractCompany.cs
new file mode 100644
index 0000000..8c6f12a
--- /dev/null
+++ b/Project_airbus/Project_airbus/CollectionGenericObjects/AbstractCompany.cs
@@ -0,0 +1,113 @@
+using Project_airbus.Drawings;
+
+namespace Project_airbus.CollectionGenericObjects;
+public abstract class AbstractCompany
+{
+ ///
+ /// Размер места (ширина)
+ ///
+ protected readonly int _placeSizeWidth = 210;
+
+ ///
+ /// Размер места (высота)
+ ///
+ protected readonly int _placeSizeHeight = 80;
+
+ ///
+ /// Ширина окна
+ ///
+ protected readonly int _pictureWidth;
+
+ ///
+ /// Высота окна
+ ///
+ protected readonly int _pictureHeight;
+
+ ///
+ /// Коллекция самолётов
+ ///
+ protected ICollectionGenericObjects? _collection = null;
+
+ ///
+ /// Вычисление максимального количества элементов, который можно разместить в окне
+ ///
+ private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
+
+ ///
+ /// Конструктор
+ ///
+ /// Ширина окна
+ /// Высота окна
+ /// Коллекция самолётов
+ public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection)
+ {
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _collection = collection;
+ _collection.SetMaxCount = GetMaxCount;
+ }
+
+ ///
+ /// Перегрузка оператора сложения для класса
+ ///
+ /// Компания
+ /// Добавляемый объект
+ ///
+ public static int operator +(AbstractCompany company, DrawingAirplan airplan)
+ {
+ return company._collection.Insert(airplan);
+ }
+
+ ///
+ /// Перегрузка оператора удаления для класса
+ ///
+ /// Компания
+ /// Номер удаляемого объекта
+ ///
+ public static DrawingAirplan operator -(AbstractCompany company, int position)
+ {
+ return company._collection.Remove(position);
+ }
+
+ ///
+ /// Получение случайного объекта из коллекции
+ ///
+ ///
+ public DrawingAirplan? 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)
+ {
+ DrawingAirplan? obj = _collection?.Get(i);
+ obj?.DrawTransport(graphics);
+ }
+
+ return bitmap;
+ }
+
+ ///
+ /// Вывод заднего фона
+ ///
+ ///
+ protected abstract void DrawBackgound(Graphics g);
+
+ ///
+ /// Расстановка объектов
+ ///
+ protected abstract void SetObjectsPosition();
+}
+
diff --git a/Project_airbus/Project_airbus/CollectionGenericObjects/AirplanSharingService.cs b/Project_airbus/Project_airbus/CollectionGenericObjects/AirplanSharingService.cs
new file mode 100644
index 0000000..028fcf0
--- /dev/null
+++ b/Project_airbus/Project_airbus/CollectionGenericObjects/AirplanSharingService.cs
@@ -0,0 +1,64 @@
+using Project_airbus.Drawings;
+
+namespace Project_airbus.CollectionGenericObjects;
+
+///
+/// Реализация абстрактной компании - каршеринг
+///
+public class AirplanSharingService : AbstractCompany
+{
+ ///
+ /// Конструктор
+ ///
+ ///
+ ///
+ ///
+ public AirplanSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection)
+ {
+ }
+
+ protected override void DrawBackgound(Graphics g)
+ {
+ int width = _pictureWidth / _placeSizeWidth;
+ int height = _pictureHeight / _placeSizeHeight;
+ Pen pen = new(Color.Black, 2);
+ for (int i = 0; i < width; i++)
+ {
+ for (int j = 0; j < height + 1; ++j)
+ {
+ g.DrawLine(pen, i * _placeSizeWidth + 5, j * _placeSizeHeight, i * _placeSizeWidth + 5 + _placeSizeWidth - 45, j * _placeSizeHeight);
+ g.DrawLine(pen, i * _placeSizeWidth + 5, j * _placeSizeHeight, i * _placeSizeWidth + 5, j * _placeSizeHeight - _placeSizeHeight);
+ }
+ }
+ }
+
+ protected override void SetObjectsPosition()
+ {
+ int width = _pictureWidth / _placeSizeWidth;
+ int height = _pictureHeight / _placeSizeHeight;
+
+ int AirplanWidth = 0;
+ int AirplanHeight = 0;
+
+ for (int i = 0; i < (_collection?.Count ?? 0); i++)
+ {
+ if (_collection?.Get(i) != null)
+ {
+ _collection.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
+ _collection.Get(i)?.SetPosition(_placeSizeWidth * AirplanWidth + 20, AirplanHeight * _placeSizeHeight + 20);
+ }
+
+ if (AirplanWidth < width - 1)
+ AirplanWidth++;
+ else
+ {
+ AirplanWidth = 0;
+ AirplanHeight++;
+ }
+ if (AirplanHeight > height)
+ {
+ return;
+ }
+ }
+ }
+}
diff --git a/Project_airbus/Project_airbus/CollectionGenericObjects/ICollectionGenericObjects.cs b/Project_airbus/Project_airbus/CollectionGenericObjects/ICollectionGenericObjects.cs
new file mode 100644
index 0000000..fcd5723
--- /dev/null
+++ b/Project_airbus/Project_airbus/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -0,0 +1,48 @@
+namespace Project_airbus.CollectionGenericObjects;
+
+///
+/// Интерфейс описания действий для набора хранимых объектов
+///
+/// Параметр: ограничение - ссылочный тип
+public interface ICollectionGenericObjects
+ where T : class
+{
+ ///
+ /// Количество объектов в коллекции
+ ///
+ int Count { get; }
+
+ ///
+ /// Установка максимального количества элементов
+ ///
+ int SetMaxCount { set; }
+
+ ///
+ /// Добавление объекта в коллекцию
+ ///
+ /// Добавляемый объект
+ /// true - вставка прошла удачно, false - вставка не удалась
+ int Insert(T obj);
+
+ ///
+ /// Добавление объекта в коллекцию на конкретную позицию
+ ///
+ /// Добавляемый объект
+ /// Позиция
+ /// true - вставка прошла удачно, false - вставка не удалась
+ int Insert(T obj, int position);
+
+ ///
+ /// Удаление объекта из коллекции с конкретной позиции
+ ///
+ /// Позиция
+ /// true - удаление прошло удачно, false - удаление не удалось
+ T? Remove(int position);
+
+ ///
+ /// Получение объекта по позиции
+ ///
+ /// Позиция
+ /// Объект
+ T? Get(int position);
+}
\ No newline at end of file
diff --git a/Project_airbus/Project_airbus/CollectionGenericObjects/MassiveGenericObjects.cs b/Project_airbus/Project_airbus/CollectionGenericObjects/MassiveGenericObjects.cs
new file mode 100644
index 0000000..6647495
--- /dev/null
+++ b/Project_airbus/Project_airbus/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -0,0 +1,103 @@
+namespace Project_airbus.CollectionGenericObjects;
+
+///
+/// Параметризованный набор объектов
+///
+/// Параметр: ограничение - ссылочный тип
+public class MassiveGenericObjects : ICollectionGenericObjects
+ where T : class
+{
+ ///
+ /// Массив объектов, которые храним
+ ///
+ private T?[] _collection;
+
+ public int Count => _collection.Length;
+
+ public int SetMaxCount
+ {
+ set
+ {
+ if (value > 0)
+ {
+ if (_collection.Length > 0)
+ {
+ Array.Resize(ref _collection, value);
+ }
+ else
+ {
+ _collection = new T?[value];
+ }
+ }
+ }
+ }
+
+ ///
+ /// Конструктор
+ ///
+ public MassiveGenericObjects()
+ {
+ _collection = Array.Empty();
+ }
+
+ public T? Get(int position)
+ {
+ if (position >= _collection.Length || position < 0) return null;
+ return _collection[position];
+ }
+
+ public int Insert(T obj)
+ {
+ int index = 0;
+ while (index < _collection.Length)
+ {
+ if (_collection[index] == null)
+ {
+ _collection[index] = obj;
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+
+
+ public int Insert(T obj, int position)
+ {
+ if (position >= _collection.Length || position < 0) return -1;
+ if (_collection[position] == null)
+ {
+ _collection[position] = obj;
+ return position;
+ }
+ int index = position + 1;
+ while (index < _collection.Length)
+ {
+ if (_collection[index] == null)
+ {
+ _collection[index] = obj;
+ return index;
+ }
+ index++;
+ }
+ index = position - 1;
+ while (index >= 0)
+ {
+ if (_collection[index] == null)
+ {
+ _collection[index] = obj;
+ return index;
+ }
+ index--;
+ }
+ return -1;
+ }
+
+ public T? Remove(int position)
+ {
+ if (position >= _collection.Length || position < 0) return null;
+ T? removeObj = _collection[position];
+ _collection[position] = null;
+ return removeObj;
+ }
+}
diff --git a/Project_airbus/Project_airbus/Drawings/DirectionType.cs b/Project_airbus/Project_airbus/Drawings/DirectionType.cs
index bd57169..5096096 100644
--- a/Project_airbus/Project_airbus/Drawings/DirectionType.cs
+++ b/Project_airbus/Project_airbus/Drawings/DirectionType.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Project_airbus.Drawings;
+namespace Project_airbus.Drawings;
///
/// Направление перемещения
///
diff --git a/Project_airbus/Project_airbus/Drawings/DrawingAirbus.cs b/Project_airbus/Project_airbus/Drawings/DrawingAirbus.cs
index dc37a0a..6360bf2 100644
--- a/Project_airbus/Project_airbus/Drawings/DrawingAirbus.cs
+++ b/Project_airbus/Project_airbus/Drawings/DrawingAirbus.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Project_airbus.Entities;
+using Project_airbus.Entities;
namespace Project_airbus.Drawings;
diff --git a/Project_airbus/Project_airbus/Drawings/DrawingAirplan.cs b/Project_airbus/Project_airbus/Drawings/DrawingAirplan.cs
index 48537d1..8769601 100644
--- a/Project_airbus/Project_airbus/Drawings/DrawingAirplan.cs
+++ b/Project_airbus/Project_airbus/Drawings/DrawingAirplan.cs
@@ -1,9 +1,4 @@
using Project_airbus.Entities;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Project_airbus.Drawings;
@@ -225,7 +220,7 @@ public class DrawingAirplan
{
return;
}
- Pen pen = new(Color.Black);
+ Pen pen = new Pen(EntityAirplan.BodyAirbus);
//корпус
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 20, 100, 20);
diff --git a/Project_airbus/Project_airbus/Entities/EntityAirplan.cs b/Project_airbus/Project_airbus/Entities/EntityAirplan.cs
index f42c811..548cd6d 100644
--- a/Project_airbus/Project_airbus/Entities/EntityAirplan.cs
+++ b/Project_airbus/Project_airbus/Entities/EntityAirplan.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Project_airbus.Entities;
+namespace Project_airbus.Entities;
///
/// Класс-сущность "Самолёт"
diff --git a/Project_airbus/Project_airbus/FormAirbus.Designer.cs b/Project_airbus/Project_airbus/FormAirbus.Designer.cs
index 728b269..58091ad 100644
--- a/Project_airbus/Project_airbus/FormAirbus.Designer.cs
+++ b/Project_airbus/Project_airbus/FormAirbus.Designer.cs
@@ -30,12 +30,10 @@
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAirbus));
pictureBoxAirbus = new PictureBox();
- buttonCreateAirbus = new Button();
buttonUp = new Button();
buttonRight = new Button();
buttonLeft = new Button();
buttonDown = new Button();
- buttonCreateAirplan = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxAirbus).BeginInit();
@@ -51,17 +49,6 @@
pictureBoxAirbus.TabIndex = 6;
pictureBoxAirbus.TabStop = false;
//
- // buttonCreateAirbus
- //
- buttonCreateAirbus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateAirbus.Location = new Point(12, 330);
- buttonCreateAirbus.Name = "buttonCreateAirbus";
- buttonCreateAirbus.Size = new Size(162, 43);
- buttonCreateAirbus.TabIndex = 7;
- buttonCreateAirbus.Text = "Создать аэробас";
- buttonCreateAirbus.UseVisualStyleBackColor = true;
- buttonCreateAirbus.Click += ButtonCreateAirbus_Click;
- //
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
@@ -114,17 +101,6 @@
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += ButtonMove_CLick;
//
- // buttonCreateAirplan
- //
- buttonCreateAirplan.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateAirplan.Location = new Point(198, 330);
- buttonCreateAirplan.Name = "buttonCreateAirplan";
- buttonCreateAirplan.Size = new Size(162, 43);
- buttonCreateAirplan.TabIndex = 12;
- buttonCreateAirplan.Text = "Создать самолёт";
- buttonCreateAirplan.UseVisualStyleBackColor = true;
- buttonCreateAirplan.Click += buttonCreateAirplan_Click;
- //
// comboBoxStrategy
//
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@@ -152,12 +128,10 @@
ClientSize = new Size(752, 385);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
- Controls.Add(buttonCreateAirplan);
Controls.Add(buttonDown);
Controls.Add(buttonLeft);
Controls.Add(buttonRight);
Controls.Add(buttonUp);
- Controls.Add(buttonCreateAirbus);
Controls.Add(pictureBoxAirbus);
Name = "FormAirbus";
Text = "Аэробус";
@@ -168,12 +142,10 @@
#endregion
private PictureBox pictureBoxAirbus;
- private Button buttonCreateAirbus;
private Button buttonUp;
private Button buttonRight;
private Button buttonLeft;
private Button buttonDown;
- private Button buttonCreateAirplan;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}
diff --git a/Project_airbus/Project_airbus/FormAirbus.cs b/Project_airbus/Project_airbus/FormAirbus.cs
index 26d7aa6..490acb0 100644
--- a/Project_airbus/Project_airbus/FormAirbus.cs
+++ b/Project_airbus/Project_airbus/FormAirbus.cs
@@ -18,6 +18,21 @@ namespace Project_airbus
///
private AbstractStrategy? _strategy;
+ ///
+ /// Получение объекта
+ ///
+ public DrawingAirplan SetAirplan
+ {
+ set
+ {
+ _drawingAirplan = value;
+ _drawingAirplan.SetPictureSize(pictureBoxAirbus.Width, pictureBoxAirbus.Height);
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ Draw();
+ }
+ }
+
///
/// Конструктор формы
///
@@ -44,49 +59,6 @@ namespace Project_airbus
}
- ///
- /// Создание объекта класса-перемещения
- ///
- /// Тип создаваемого объекта
- private void CreateObject(string type)
- {
- Random random = new();
- switch (type)
- {
- case nameof(DrawingAirplan):
- _drawingAirplan = new DrawingAirplan(random.Next(100, 300), random.Next(1000, 3000),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
- break;
- case nameof(DrawingAirbus):
- _drawingAirplan = new DrawingAirbus(random.Next(100, 300), random.Next(1000, 3000),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
- break;
- default:
- return;
- }
- _drawingAirplan.SetPictureSize(pictureBoxAirbus.Width, pictureBoxAirbus.Height);
- _drawingAirplan.SetPosition(random.Next(10, 100), random.Next(10, 100));
- _strategy = null;
- comboBoxStrategy.Enabled = true;
- Draw();
- }
-
- ///
- /// Обработка нажатия кнопки "Создать Аэробас"
- ///
- ///
- ///
- private void ButtonCreateAirbus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingAirbus));
-
- ///
- /// Обработка нажатия кнопки "Создать Самолёт"
- ///
- ///
- ///
- private void buttonCreateAirplan_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingAirplan));
-
///
/// Перемещение объекта по форме (нажатие кнопок навигации)
///
diff --git a/Project_airbus/Project_airbus/FormAirplanCollection.Designer.cs b/Project_airbus/Project_airbus/FormAirplanCollection.Designer.cs
new file mode 100644
index 0000000..bf27fec
--- /dev/null
+++ b/Project_airbus/Project_airbus/FormAirplanCollection.Designer.cs
@@ -0,0 +1,168 @@
+namespace Project_airbus
+{
+ partial class FormAirplanCollection
+ {
+ ///
+ /// 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();
+ ButtonDelAirplan = new Button();
+ maskedTextBox = new MaskedTextBox();
+ buttonAddAirbus = new Button();
+ buttonAddAirplan = new Button();
+ comboBoxSelectorCompany = 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(ButtonDelAirplan);
+ groupBoxTools.Controls.Add(maskedTextBox);
+ groupBoxTools.Controls.Add(buttonAddAirbus);
+ groupBoxTools.Controls.Add(buttonAddAirplan);
+ groupBoxTools.Controls.Add(comboBoxSelectorCompany);
+ groupBoxTools.Dock = DockStyle.Right;
+ groupBoxTools.Location = new Point(860, 0);
+ groupBoxTools.Name = "groupBoxTools";
+ groupBoxTools.Size = new Size(210, 617);
+ groupBoxTools.TabIndex = 0;
+ groupBoxTools.TabStop = false;
+ groupBoxTools.Text = "Инструменты";
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Location = new Point(6, 495);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(195, 46);
+ buttonRefresh.TabIndex = 6;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += buttonRefresh_Click;
+ //
+ // buttonGoToCheck
+ //
+ buttonGoToCheck.Location = new Point(6, 355);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(195, 46);
+ buttonGoToCheck.TabIndex = 5;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += buttonGoToCheck_Click;
+ //
+ // ButtonDelAirplan
+ //
+ ButtonDelAirplan.Location = new Point(6, 267);
+ ButtonDelAirplan.Name = "ButtonDelAirplan";
+ ButtonDelAirplan.Size = new Size(195, 46);
+ ButtonDelAirplan.TabIndex = 4;
+ ButtonDelAirplan.Text = "Удалить самолёт";
+ ButtonDelAirplan.UseVisualStyleBackColor = true;
+ ButtonDelAirplan.Click += buttonDelAirplan_Click;
+ //
+ // maskedTextBox
+ //
+ maskedTextBox.Location = new Point(6, 234);
+ maskedTextBox.Mask = "00";
+ maskedTextBox.Name = "maskedTextBox";
+ maskedTextBox.Size = new Size(192, 27);
+ maskedTextBox.TabIndex = 3;
+ maskedTextBox.ValidatingType = typeof(int);
+ //
+ // buttonAddAirbus
+ //
+ buttonAddAirbus.Location = new Point(6, 142);
+ buttonAddAirbus.Name = "buttonAddAirbus";
+ buttonAddAirbus.Size = new Size(192, 47);
+ buttonAddAirbus.TabIndex = 2;
+ buttonAddAirbus.Text = "Добавление аэробаса";
+ buttonAddAirbus.UseVisualStyleBackColor = true;
+ buttonAddAirbus.Click += buttonAddAirbus_Click;
+ //
+ // buttonAddAirplan
+ //
+ buttonAddAirplan.Location = new Point(6, 85);
+ buttonAddAirplan.Name = "buttonAddAirplan";
+ buttonAddAirplan.Size = new Size(192, 51);
+ buttonAddAirplan.TabIndex = 1;
+ buttonAddAirplan.Text = "Добавление самолёта";
+ buttonAddAirplan.UseVisualStyleBackColor = true;
+ buttonAddAirplan.Click += buttonAddAirplan_Click;
+ //
+ // comboBoxSelectorCompany
+ //
+ comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxSelectorCompany.FormattingEnabled = true;
+ comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
+ comboBoxSelectorCompany.Location = new Point(6, 26);
+ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
+ comboBoxSelectorCompany.Size = new Size(192, 28);
+ comboBoxSelectorCompany.TabIndex = 0;
+ comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
+ //
+ // pictureBox
+ //
+ pictureBox.Dock = DockStyle.Fill;
+ pictureBox.Location = new Point(0, 0);
+ pictureBox.Name = "pictureBox";
+ pictureBox.Size = new Size(860, 617);
+ pictureBox.TabIndex = 1;
+ pictureBox.TabStop = false;
+ //
+ // FormAirplanCollection
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1070, 617);
+ Controls.Add(pictureBox);
+ Controls.Add(groupBoxTools);
+ Name = "FormAirplanCollection";
+ Text = "Коллекция самолётов";
+ groupBoxTools.ResumeLayout(false);
+ groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private Button buttonAddAirbus;
+ private Button buttonAddAirplan;
+ private ComboBox comboBoxSelectorCompany;
+ private Button ButtonDelAirplan;
+ private MaskedTextBox maskedTextBox;
+ private PictureBox pictureBox;
+ private Button buttonRefresh;
+ private Button buttonGoToCheck;
+ }
+}
\ No newline at end of file
diff --git a/Project_airbus/Project_airbus/FormAirplanCollection.cs b/Project_airbus/Project_airbus/FormAirplanCollection.cs
new file mode 100644
index 0000000..f8f1650
--- /dev/null
+++ b/Project_airbus/Project_airbus/FormAirplanCollection.cs
@@ -0,0 +1,186 @@
+using Project_airbus.CollectionGenericObjects;
+using Project_airbus.Drawings;
+
+namespace Project_airbus;
+
+///
+/// Форма работы с компанией и ее коллекцией
+///
+public partial class FormAirplanCollection : Form
+{
+ ///
+ /// Компания
+ ///
+ private AbstractCompany? _company = null;
+
+ ///
+ /// Конструктор
+ ///
+ public FormAirplanCollection()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// Выбор компании
+ ///
+ ///
+ ///
+ private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new AirplanSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
+ break;
+ }
+ }
+
+ ///
+ /// Добавление обычного самолёта
+ ///
+ ///
+ ///
+ private void buttonAddAirplan_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingAirplan));
+
+ ///
+ /// Добавление аэробаса
+ ///
+ ///
+ ///
+ private void buttonAddAirbus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingAirbus));
+
+ ///
+ /// Создание объекта класса-перемещения
+ ///
+ /// Тип создаваемого объекта
+ private void CreateObject(string type)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ Random random = new();
+ DrawingAirplan drawingAirplan;
+ switch (type)
+ {
+ case nameof(DrawingAirplan):
+ drawingAirplan = new DrawingAirplan(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
+ break;
+ case nameof(DrawingAirbus):
+ drawingAirplan = new DrawingAirbus(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random),
+ Convert.ToBoolean(random.Next(1, 2)), Convert.ToBoolean(random.Next(1, 2)));
+ break;
+ default:
+ return;
+ }
+
+ if (_company + drawingAirplan != -1)
+ {
+ 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 buttonDelAirplan_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;
+ }
+
+ DrawingAirplan? airplan = null;
+ int counter = 100;
+ while (airplan == null)
+ {
+ airplan = _company.GetRandomObject();
+ counter--;
+ if (counter <= 0)
+ {
+ break;
+ }
+ }
+
+ if (airplan == null)
+ {
+ return;
+ }
+
+ FormAirbus form = new()
+ {
+ SetAirplan = airplan
+ };
+ form.ShowDialog();
+ }
+
+ ///
+ /// Перерисовка коллекции
+ ///
+ ///
+ ///
+ private void buttonRefresh_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ pictureBox.Image = _company.Show();
+ }
+}
\ No newline at end of file
diff --git a/Project_airbus/Project_airbus/FormAirplanCollection.resx b/Project_airbus/Project_airbus/FormAirplanCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/Project_airbus/Project_airbus/FormAirplanCollection.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/Project_airbus/Project_airbus/Program.cs b/Project_airbus/Project_airbus/Program.cs
index d69e8f8..436d42a 100644
--- a/Project_airbus/Project_airbus/Program.cs
+++ b/Project_airbus/Project_airbus/Program.cs
@@ -11,7 +11,7 @@ namespace Project_airbus
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormAirbus());
+ Application.Run(new FormAirplanCollection());
}
}
}
\ No newline at end of file