diff --git a/Cruiser/Cruiser/CollectionGenericObjects/AbstractCompany.cs b/Cruiser/Cruiser/CollectionGenericObjects/AbstractCompany.cs
new file mode 100644
index 0000000..b2c2834
--- /dev/null
+++ b/Cruiser/Cruiser/CollectionGenericObjects/AbstractCompany.cs
@@ -0,0 +1,107 @@
+using Cruiser.Drawings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Cruiser.CollectionGenericObjects;
+
+public abstract class AbstractCompany
+{
+ ///
+ /// Размер места (ширина)
+ ///
+ protected readonly int _placeSizeWidth = 160;
+
+ ///
+ /// Ширина окна (высота)
+ ///
+ protected readonly int _placeSizeHeight = 50;
+
+ ///
+ /// Ширина окна
+ ///
+ protected readonly int _pictureWidth;
+
+ ///
+ /// Высота окна
+ ///
+ protected readonly int _pictureHeight;
+
+ ///
+ /// Коллекция кораблей
+ ///
+ protected ICollectionGenericObjects? _collection = null;
+
+ ///
+ /// Вычисление максимального количества элементов, которое можно разместить в окне
+ ///
+ private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeHeight * _placeSizeWidth);
+
+ ///
+ /// Конструктор
+ ///
+ ///
+ ///
+ ///
+ public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection)
+ {
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _collection = collection;
+ _collection.SetMaxCount = GetMaxCount;
+ }
+
+ ///
+ /// Перегрузка оператора сложения для класса
+ ///
+ ///
+ ///
+ ///
+ public static int operator +(AbstractCompany company, DrawingShip ship)
+ {
+ return company._collection.Insert(ship);
+ }
+
+ ///
+ /// Перегрузка оператора вычитания для класса
+ ///
+ ///
+ ///
+ ///
+ public static int operator -(AbstractCompany company, int position)
+ {
+ company._collection?.Remove(position);
+ return 1;
+ }
+
+ ///
+ /// Получение случайного элемента из коллекции
+ ///
+ ///
+ public DrawingShip? GetRandomObject()
+ {
+ Random rnd = new();
+ return _collection?.Get(rnd.Next(GetMaxCount));
+ }
+
+ public Bitmap? Show()
+ {
+ Bitmap bitmap = new(_pictureWidth, _pictureHeight);
+ Graphics g = Graphics.FromImage(bitmap);
+ DrawBackground(g);
+
+ SetObjectsPosition();
+ for (int i = 0; i < (_collection?.Count ?? 0); ++i)
+ {
+ DrawingShip? obj = _collection?.Get(i);
+ obj?.DrawTransport(g);
+ }
+ return bitmap;
+ }
+
+ protected abstract void SetObjectsPosition();
+
+ protected abstract void DrawBackground(Graphics g);
+}
diff --git a/Cruiser/Cruiser/CollectionGenericObjects/Docs.cs b/Cruiser/Cruiser/CollectionGenericObjects/Docs.cs
new file mode 100644
index 0000000..89db831
--- /dev/null
+++ b/Cruiser/Cruiser/CollectionGenericObjects/Docs.cs
@@ -0,0 +1,55 @@
+using Cruiser.Drawings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Cruiser.CollectionGenericObjects;
+
+public class Docs : AbstractCompany
+{
+ public Docs(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection)
+ {
+
+ }
+
+ protected override void DrawBackground(Graphics g)
+ {
+ Pen pen = new Pen(Color.Black, 4f);
+ for (int i = 0; i < _pictureHeight - _placeSizeHeight * 2; i= i + (_placeSizeHeight * 2))
+ {
+ g.DrawLine(pen, 30, i, _pictureWidth / _placeSizeWidth * _placeSizeWidth + 30, i);
+ for (int j = 0; j < _pictureWidth / _placeSizeWidth + 1; ++j)
+ {
+ g.DrawLine(pen, j * _placeSizeWidth + 30, i, j * _placeSizeWidth + 30, i + _placeSizeHeight);
+ }
+ }
+ }
+
+ protected override void SetObjectsPosition()
+ {
+ int nowWidth = 35;
+ int nowHeight = 10;
+
+ for (int i = 0; i < (_collection?.Count ?? 0); i++)
+ {
+ if (nowHeight > _pictureHeight)
+ {
+ return;
+ }
+ if (_collection?.Get(i) != null)
+ {
+ _collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
+ _collection?.Get(i)?.SetPosition(nowWidth, nowHeight);
+ }
+
+ if (nowWidth < _pictureWidth - _placeSizeWidth - 35) nowWidth += _placeSizeWidth;
+ else
+ {
+ nowWidth = 35;
+ nowHeight+= _placeSizeHeight * 2;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Cruiser/Cruiser/CollectionGenericObjects/ICollectionGenericObjects.cs b/Cruiser/Cruiser/CollectionGenericObjects/ICollectionGenericObjects.cs
new file mode 100644
index 0000000..e831577
--- /dev/null
+++ b/Cruiser/Cruiser/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Cruiser.CollectionGenericObjects;
+
+public interface ICollectionGenericObjects
+ where T : class
+{
+ ///
+ /// Кол-во элементов в коллекции
+ ///
+ int Count { get; }
+
+ int SetMaxCount { set; }
+
+ ///
+ /// Добавление объекта в коллекцию
+ ///
+ ///
+ ///
+ int Insert(T obj);
+
+ ///
+ /// Добавление в коллекцию по индексу
+ ///
+ ///
+ ///
+ ///
+ int Insert(T obj, int position);
+
+ ///
+ /// Удаление из коллекции по индесу
+ ///
+ ///
+ ///
+ T? Remove(int position);
+
+ ///
+ /// ПОлучение элемента по индексу
+ ///
+ ///
+ ///
+ T? Get(int position);
+}
diff --git a/Cruiser/Cruiser/CollectionGenericObjects/MassiveGenericObjects.cs b/Cruiser/Cruiser/CollectionGenericObjects/MassiveGenericObjects.cs
new file mode 100644
index 0000000..e756723
--- /dev/null
+++ b/Cruiser/Cruiser/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -0,0 +1,86 @@
+using Cruiser.Drawings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Cruiser.CollectionGenericObjects;
+
+public class MassiveGenericObjects : ICollectionGenericObjects
+ where T : class
+{
+ private T?[] _collection;
+
+ public int Count => _collection.Length;
+
+ public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } }
+
+ public MassiveGenericObjects()
+ {
+ _collection = Array.Empty();
+ }
+
+ public T? Get(int position)
+ {
+ if (position >= _collection.Length || position < 0)
+ {
+ return default(T?);
+ }
+ return _collection[position];
+ }
+
+ public int Insert(T obj)
+ {
+ for (int i = 0; i < _collection.Length; i++)
+ {
+ if (_collection[i] == null)
+ {
+ _collection[i] = obj;
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int Insert(T obj, int position)
+ {
+ if (position >= _collection.Length || position < 0)
+ {
+ return -1;
+ }
+ if (_collection[position] != null)
+ {
+ return -1;
+ }
+
+ for (int i = position; i < _collection.Length; i++)
+ {
+ if (_collection[i] == null)
+ {
+ _collection[i] = obj;
+ return i;
+ }
+ }
+ for (int i = 0; i < position; i++)
+ {
+ _collection[i] = obj;
+ return i;
+ }
+
+ return -1;
+ }
+
+ public T? Remove(int position)
+ {
+ if (position > _collection.Length || position < 0)
+ {
+ return null;
+ }
+ T? obj = _collection[position];
+ _collection[position] = null;
+ return obj;
+ }
+}
+
+
diff --git a/Cruiser/Cruiser/FormCruiser.Designer.cs b/Cruiser/Cruiser/FormCruiser.Designer.cs
index 799a607..77cb6b4 100644
--- a/Cruiser/Cruiser/FormCruiser.Designer.cs
+++ b/Cruiser/Cruiser/FormCruiser.Designer.cs
@@ -29,12 +29,10 @@
private void InitializeComponent()
{
pictureBoxCruiser = new PictureBox();
- buttonCreateCruiser = new Button();
buttonRight = new Button();
buttonDown = new Button();
buttonUp = new Button();
buttonLeft = new Button();
- buttonCreateShip = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).BeginInit();
@@ -50,16 +48,6 @@
pictureBoxCruiser.TabIndex = 9;
pictureBoxCruiser.TabStop = false;
//
- // buttonCreateCruiser
- //
- buttonCreateCruiser.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateCruiser.Location = new Point(12, 678);
- buttonCreateCruiser.Name = "buttonCreateCruiser";
- buttonCreateCruiser.Size = new Size(299, 34);
- buttonCreateCruiser.TabIndex = 8;
- buttonCreateCruiser.Text = "Создать Крейсер";
- buttonCreateCruiser.Click += ButtonCreateCruiser_Click;
- //
// buttonRight
//
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
@@ -108,16 +96,6 @@
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += ButtonMove_Click;
//
- // buttonCreateShip
- //
- buttonCreateShip.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateShip.Location = new Point(349, 678);
- buttonCreateShip.Name = "buttonCreateShip";
- buttonCreateShip.Size = new Size(299, 34);
- buttonCreateShip.TabIndex = 10;
- buttonCreateShip.Text = "Создать Корабль";
- buttonCreateShip.Click += ButtonCreateShip_Click;
- //
// comboBoxStrategy
//
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@@ -145,12 +123,10 @@
ClientSize = new Size(1002, 724);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
- Controls.Add(buttonCreateShip);
Controls.Add(buttonLeft);
Controls.Add(buttonUp);
Controls.Add(buttonDown);
Controls.Add(buttonRight);
- Controls.Add(buttonCreateCruiser);
Controls.Add(pictureBoxCruiser);
Name = "FormCruiser";
Text = "Круизер";
@@ -161,12 +137,10 @@
#endregion
private PictureBox pictureBoxCruiser;
- private Button buttonCreateCruiser;
private Button buttonRight;
private Button buttonDown;
private Button buttonUp;
private Button buttonLeft;
- private Button buttonCreateShip;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}
diff --git a/Cruiser/Cruiser/FormCruiser.cs b/Cruiser/Cruiser/FormCruiser.cs
index 7c767ec..a9c3702 100644
--- a/Cruiser/Cruiser/FormCruiser.cs
+++ b/Cruiser/Cruiser/FormCruiser.cs
@@ -9,37 +9,25 @@ public partial class FormCruiser : Form
private AbstructStrategy? _strategy;
+ public DrawingShip SetShip
+ {
+ set
+ {
+ _drawingShip = value;
+ _drawingShip.SetPictureSize(pictureBoxCruiser.Width, pictureBoxCruiser.Height);
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ Draw();
+ }
+ }
+
public FormCruiser()
{
InitializeComponent();
_strategy = null;
}
- private void CreateObject(string type)
- {
- Random random = new();
- switch (type)
- {
- case nameof(DrawingShip):
- _drawingShip = new DrawingShip(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(DrawingCruiser):
- _drawingShip = new DrawingCruiser(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)), Convert.ToBoolean(random.Next(0, 2)));
- break;
- default:
- return;
- }
- _drawingShip.SetPictureSize(pictureBoxCruiser.Width, pictureBoxCruiser.Height);
- _drawingShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
- _strategy = null;
- comboBoxStrategy.Enabled = true;
- Draw();
- }
-
+
private void Draw()
{
if (_drawingShip == null)
@@ -52,19 +40,7 @@ public partial class FormCruiser : Form
pictureBoxCruiser.Image = bmp;
}
- ///
- /// Обработка кнопки "Создать Крейсер"
- ///
- ///
- ///
- private void ButtonCreateCruiser_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingCruiser));
-
- ///
- /// Обработка кнопки "Создать Корабль"
- ///
- ///
- ///
- private void ButtonCreateShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingShip));
+
private void ButtonMove_Click(object sender, EventArgs e)
{
diff --git a/Cruiser/Cruiser/FormShipCollection.Designer.cs b/Cruiser/Cruiser/FormShipCollection.Designer.cs
new file mode 100644
index 0000000..98b0d1b
--- /dev/null
+++ b/Cruiser/Cruiser/FormShipCollection.Designer.cs
@@ -0,0 +1,174 @@
+namespace Cruiser
+{
+ partial class FormShipCollection
+ {
+ ///
+ /// 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();
+ buttonRemoveShip = new Button();
+ maskedTextBox = new MaskedTextBox();
+ buttonAddCruiser = new Button();
+ buttonAddShip = 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(buttonRemoveShip);
+ groupBoxTools.Controls.Add(maskedTextBox);
+ groupBoxTools.Controls.Add(buttonAddCruiser);
+ groupBoxTools.Controls.Add(buttonAddShip);
+ groupBoxTools.Controls.Add(comboBoxSelectorCompany);
+ groupBoxTools.Dock = DockStyle.Right;
+ groupBoxTools.Location = new Point(852, 0);
+ groupBoxTools.Name = "groupBoxTools";
+ groupBoxTools.Size = new Size(324, 661);
+ groupBoxTools.TabIndex = 0;
+ groupBoxTools.TabStop = false;
+ groupBoxTools.Text = "Инструменты";
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(6, 466);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(306, 52);
+ buttonRefresh.TabIndex = 6;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
+ //
+ // buttonGoToCheck
+ //
+ buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonGoToCheck.Location = new Point(6, 370);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(306, 52);
+ buttonGoToCheck.TabIndex = 5;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += ButtonGoToCheck_Click;
+ //
+ // buttonRemoveShip
+ //
+ buttonRemoveShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRemoveShip.Location = new Point(6, 279);
+ buttonRemoveShip.Name = "buttonRemoveShip";
+ buttonRemoveShip.Size = new Size(306, 52);
+ buttonRemoveShip.TabIndex = 4;
+ buttonRemoveShip.Text = "Удалить корабль";
+ buttonRemoveShip.UseVisualStyleBackColor = true;
+ buttonRemoveShip.Click += ButtonRemoveShip_Click;
+ //
+ // maskedTextBox
+ //
+ maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ maskedTextBox.Location = new Point(6, 246);
+ maskedTextBox.Mask = "00";
+ maskedTextBox.Name = "maskedTextBox";
+ maskedTextBox.Size = new Size(306, 27);
+ maskedTextBox.TabIndex = 3;
+ maskedTextBox.ValidatingType = typeof(int);
+ //
+ // buttonAddCruiser
+ //
+ buttonAddCruiser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddCruiser.Location = new Point(6, 159);
+ buttonAddCruiser.Name = "buttonAddCruiser";
+ buttonAddCruiser.Size = new Size(306, 52);
+ buttonAddCruiser.TabIndex = 2;
+ buttonAddCruiser.Text = "Добавление круизера";
+ buttonAddCruiser.UseVisualStyleBackColor = true;
+ buttonAddCruiser.Click += ButtonAddCruiser_Click;
+ //
+ // buttonAddShip
+ //
+ buttonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddShip.Location = new Point(6, 101);
+ buttonAddShip.Name = "buttonAddShip";
+ buttonAddShip.Size = new Size(306, 52);
+ buttonAddShip.TabIndex = 1;
+ buttonAddShip.Text = "Добавление корабля";
+ buttonAddShip.UseVisualStyleBackColor = true;
+ buttonAddShip.Click += ButtonAddShip_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(306, 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(852, 661);
+ pictureBox.TabIndex = 1;
+ pictureBox.TabStop = false;
+ //
+ // FormShipCollection
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1176, 661);
+ Controls.Add(pictureBox);
+ Controls.Add(groupBoxTools);
+ Name = "FormShipCollection";
+ Text = "Коллекция кораблей";
+ groupBoxTools.ResumeLayout(false);
+ groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private Button buttonAddCruiser;
+ private Button buttonAddShip;
+ private MaskedTextBox maskedTextBox;
+ private PictureBox pictureBox;
+ private Button buttonRemoveShip;
+ private Button buttonRefresh;
+ private Button buttonGoToCheck;
+ private ComboBox comboBoxSelectorCompany;
+ }
+}
\ No newline at end of file
diff --git a/Cruiser/Cruiser/FormShipCollection.cs b/Cruiser/Cruiser/FormShipCollection.cs
new file mode 100644
index 0000000..6cac011
--- /dev/null
+++ b/Cruiser/Cruiser/FormShipCollection.cs
@@ -0,0 +1,143 @@
+using Cruiser.CollectionGenericObjects;
+using Cruiser.Drawings;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics.Metrics;
+using System.Drawing;
+using System.Linq;
+using System.Runtime.InteropServices.Marshalling;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Cruiser;
+
+public partial class FormShipCollection : Form
+{
+ private AbstractCompany? _company = null;
+ public FormShipCollection()
+ {
+ InitializeComponent();
+ }
+
+ private void CreateObject(string type)
+ {
+ if (_company == null) { return; }
+ DrawingShip drawingShip;
+ Random random = new();
+ switch (type)
+ {
+ case nameof(DrawingShip):
+ drawingShip = new DrawingShip(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
+ break;
+ case nameof(DrawingCruiser):
+ Color mainColor = GetColor(random);
+ Color additionalColor = GetColor(random);
+ drawingShip = new DrawingCruiser(random.Next(100, 300), random.Next(1000, 3000),
+ mainColor, additionalColor,
+ Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+ if (_company + drawingShip > 0)
+ {
+ 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 comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new Docs(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
+ break;
+ }
+ }
+
+ private void ButtonAddShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingShip));
+
+
+ private void ButtonAddCruiser_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingCruiser));
+
+ private void ButtonRemoveShip_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 == 1)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+
+ private void ButtonGoToCheck_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+ DrawingShip? ship = null;
+ int counter = 100;
+ while (ship == null)
+ {
+ ship = _company.GetRandomObject();
+ counter--;
+ if (counter <= 100)
+ {
+ break;
+ }
+ }
+ if (ship == null)
+ {
+ return;
+ }
+
+ FormCruiser form = new()
+ {
+ SetShip = ship
+ };
+ form.ShowDialog();
+ }
+
+ private void ButtonRefresh_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+ pictureBox.Image = _company.Show();
+ }
+}
diff --git a/Cruiser/Cruiser/FormShipCollection.resx b/Cruiser/Cruiser/FormShipCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/Cruiser/Cruiser/FormShipCollection.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/Cruiser/Cruiser/Program.cs b/Cruiser/Cruiser/Program.cs
index 626bc14..15dbcaa 100644
--- a/Cruiser/Cruiser/Program.cs
+++ b/Cruiser/Cruiser/Program.cs
@@ -11,7 +11,7 @@ namespace Cruiser
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormCruiser());
+ Application.Run(new FormShipCollection());
}
}
}
\ No newline at end of file