diff --git a/LabOOP_1/LabOOP_1/CollectionGenereticObjects/AbstractCompany.cs b/LabOOP_1/LabOOP_1/CollectionGenereticObjects/AbstractCompany.cs
new file mode 100644
index 0000000..206ce02
--- /dev/null
+++ b/LabOOP_1/LabOOP_1/CollectionGenereticObjects/AbstractCompany.cs
@@ -0,0 +1,116 @@
+using Project_Catamaran.Drawnings;
+
+namespace ProjectCatamaran.CollectionGenericObjects;
+
+///
+/// Абстракция компании, хранящий коллекцию лодок
+///
+public abstract class AbstractCompany
+{
+ ///
+ /// Размер места (ширина)
+ ///
+ protected readonly int _placeSizeWidth = 120;
+
+ ///
+ /// Размер места (высота)
+ ///
+ protected readonly int _placeSizeHeight = 105;
+
+ ///
+ /// Ширина окна
+ ///
+ 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, DrawningSimpleCatamaran catamaran)
+ {
+ return company._collection?.Insert(catamaran) ?? -1;
+ }
+
+ ///
+ /// Перегрузка оператора удаления для класса
+ ///
+ /// Компания
+ /// Номер удаляемого объекта
+ ///
+ public static DrawningSimpleCatamaran operator -(AbstractCompany company, int position)
+ {
+ return company._collection?.Remove(position) ?? null;
+ }
+
+ ///
+ /// Получение случайного объекта из коллекции
+ ///
+ ///
+ public DrawningSimpleCatamaran? GetRandomObject()
+ {
+ Random rnd = new();
+ return _collection?.Get(rnd.Next(GetMaxCount));
+ }
+
+ ///
+ /// Вывод всей коллекции
+ ///
+ ///
+ public Bitmap? Show()
+ {
+ Bitmap bitmap = new(_pictureWidth, _pictureHeight);
+ Graphics graphics = Graphics.FromImage(bitmap);
+ DrawBackground(graphics);
+
+ SetObjectsPosition();
+ for (int i = 0; i < (_collection?.Count ?? 0); ++i)
+ {
+ DrawningSimpleCatamaran? obj = _collection?.Get(i);
+ obj?.DrawTransport(graphics);
+ }
+
+ return bitmap;
+ }
+
+ ///
+ /// Вывод заднего фона
+ ///
+ ///
+ protected abstract void DrawBackground(Graphics g);
+
+ ///
+ /// Расстановка объектов
+ ///
+ protected abstract void SetObjectsPosition();
+}
diff --git a/LabOOP_1/LabOOP_1/CollectionGenereticObjects/CatamaranSharingService.cs b/LabOOP_1/LabOOP_1/CollectionGenereticObjects/CatamaranSharingService.cs
new file mode 100644
index 0000000..417c960
--- /dev/null
+++ b/LabOOP_1/LabOOP_1/CollectionGenereticObjects/CatamaranSharingService.cs
@@ -0,0 +1,72 @@
+using Project_Catamaran.Drawnings;
+using ProjectCatamaran.CollectionGenericObjects;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Project_Catamaran.CollectionGenereticObjects
+{
+ public class CatamaranSharingService : AbstractCompany
+ {
+ private List> locCoord = new List>();
+ private int numRows, numCols;
+ ///
+ /// Конструктор
+ ///
+ ///
+ ///
+ ///
+ public CatamaranSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection)
+ {
+ }
+
+ protected override void DrawBackground(Graphics g)
+ {
+ Color backgroundColor = Color.White;
+ using (Brush brush = new SolidBrush(backgroundColor))
+ {
+ g.FillRectangle(brush, new Rectangle(0, 0, _pictureWidth, _pictureHeight));
+ }
+ Pen pen = new Pen(Color.Brown, 3);
+ int offsetX = 10, offsetY = -5;
+ int x = 1 + offsetX, y = _pictureHeight - _placeSizeHeight + offsetY;
+ numRows = 0;
+ while (y >= 0)
+ {
+ int numCols = 0;
+ while (x + _placeSizeWidth <= _pictureWidth)
+ {
+ numCols++;
+ g.DrawLine(pen, x, y, x + _placeSizeWidth / 2, y);
+ g.DrawLine(pen, x, y, x, y + _placeSizeHeight + 4);
+ locCoord.Add(new Tuple(x, y));
+ x += _placeSizeWidth + 2;
+ }
+ numRows++;
+ x = 1 + offsetX;
+ y -= _placeSizeHeight + 2 + offsetY;
+ }
+ }
+
+ protected override void SetObjectsPosition()
+ {
+ if (locCoord == null || _collection == null)
+ {
+ return;
+ }
+ int row = numRows - 1, col = numCols;
+ for (int i = 0; i < _collection?.Count; i++, col--)
+ {
+ _collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
+ _collection?.Get(i)?.SetPosition(locCoord[row * numCols - col].Item1 + 5, locCoord[row * numCols - col].Item2 + 9);
+ if (col == 1)
+ {
+ col = numCols + 1;
+ row--;
+ }
+ }
+ }
+ }
+}
diff --git a/LabOOP_1/LabOOP_1/Drawnings/DrawningCatamaran.cs b/LabOOP_1/LabOOP_1/Drawnings/DrawningCatamaran.cs
index 9e842c9..157950f 100644
--- a/LabOOP_1/LabOOP_1/Drawnings/DrawningCatamaran.cs
+++ b/LabOOP_1/LabOOP_1/Drawnings/DrawningCatamaran.cs
@@ -22,14 +22,15 @@ public class DrawningCatamaran : DrawningSimpleCatamaran
{
-
-
-
- public DrawningCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail, bool deck) : base(100, 90, bodyColor)
+ public DrawningCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail, bool deck ) : base(speed, weight, bodyColor)
{
- EntitySimpleCatamaran = new EntityCatamaran(speed, weight, bodyColor, additionalColor, floats, sail, deck);
+ EntitySimpleCatamaran = new EntityCatamaran(speed, weight, bodyColor, additionalColor, floats, sail, true);
}
+
+
+
+
public override void DrawTransport(Graphics g)
diff --git a/LabOOP_1/LabOOP_1/Drawnings/DrawningSimpleCatamaran.cs b/LabOOP_1/LabOOP_1/Drawnings/DrawningSimpleCatamaran.cs
index 157da07..7121951 100644
--- a/LabOOP_1/LabOOP_1/Drawnings/DrawningSimpleCatamaran.cs
+++ b/LabOOP_1/LabOOP_1/Drawnings/DrawningSimpleCatamaran.cs
@@ -37,12 +37,12 @@ public class DrawningSimpleCatamaran
///
/// Ширина прорисовки катамарана
///
- private readonly int _drawningCatamaranWidth = 100;
+ private readonly int _drawningCatamaranWidth = 90;
///
/// Высота прорисовки катамарана
///
- private readonly int _drawningCatamaranHeight = 85;
+ private readonly int _drawningCatamaranHeight = 95;
///
diff --git a/LabOOP_1/LabOOP_1/FormCatamaran.Designer.cs b/LabOOP_1/LabOOP_1/FormCatamaran.Designer.cs
index 7f1ba4e..8921a83 100644
--- a/LabOOP_1/LabOOP_1/FormCatamaran.Designer.cs
+++ b/LabOOP_1/LabOOP_1/FormCatamaran.Designer.cs
@@ -28,29 +28,16 @@ partial class FormCatamaran
///
private void InitializeComponent()
{
- buttonCreateSimpleCatamaran = new Button();
buttonLeft = new Button();
buttonDown = new Button();
buttonUp = new Button();
buttonRight = new Button();
pictureBoxCatamaran = new PictureBox();
- buttonCreateCatamaran = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
SuspendLayout();
//
- // buttonCreateSimpleCatamaran
- //
- buttonCreateSimpleCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateSimpleCatamaran.Location = new Point(12, 404);
- buttonCreateSimpleCatamaran.Name = "buttonCreateSimpleCatamaran";
- buttonCreateSimpleCatamaran.Size = new Size(260, 34);
- buttonCreateSimpleCatamaran.TabIndex = 1;
- buttonCreateSimpleCatamaran.Text = "Создать простой катамаран";
- buttonCreateSimpleCatamaran.UseVisualStyleBackColor = true;
- buttonCreateSimpleCatamaran.Click += buttonCreateSimpleCatamaran_Click;
- //
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
@@ -108,17 +95,6 @@ partial class FormCatamaran
pictureBoxCatamaran.TabIndex = 6;
pictureBoxCatamaran.TabStop = false;
//
- // buttonCreateCatamaran
- //
- buttonCreateCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateCatamaran.Location = new Point(291, 404);
- buttonCreateCatamaran.Name = "buttonCreateCatamaran";
- buttonCreateCatamaran.Size = new Size(202, 34);
- buttonCreateCatamaran.TabIndex = 7;
- buttonCreateCatamaran.Text = "Создать катамаран";
- buttonCreateCatamaran.UseVisualStyleBackColor = true;
- buttonCreateCatamaran.Click += buttonCreateCatamaran_Click;
- //
// comboBoxStrategy
//
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@@ -146,12 +122,10 @@ partial class FormCatamaran
ClientSize = new Size(800, 450);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
- Controls.Add(buttonCreateCatamaran);
Controls.Add(buttonRight);
Controls.Add(buttonUp);
Controls.Add(buttonDown);
Controls.Add(buttonLeft);
- Controls.Add(buttonCreateSimpleCatamaran);
Controls.Add(pictureBoxCatamaran);
Name = "FormCatamaran";
Text = "Катамаран";
@@ -160,13 +134,11 @@ partial class FormCatamaran
}
#endregion
- private Button buttonCreateSimpleCatamaran;
private Button buttonLeft;
private Button buttonDown;
private Button buttonUp;
private Button buttonRight;
private PictureBox pictureBoxCatamaran;
- private Button buttonCreateCatamaran;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}
\ No newline at end of file
diff --git a/LabOOP_1/LabOOP_1/FormCatamaran.cs b/LabOOP_1/LabOOP_1/FormCatamaran.cs
index b3b8fec..21ba9a9 100644
--- a/LabOOP_1/LabOOP_1/FormCatamaran.cs
+++ b/LabOOP_1/LabOOP_1/FormCatamaran.cs
@@ -23,6 +23,18 @@ public partial class FormCatamaran : Form
private AbstractStrategy? _strategy;
+ public DrawningSimpleCatamaran SetSimpleCatamaran
+ {
+ set
+ {
+ _drawningSimpleCatamaran = value;
+ _drawningSimpleCatamaran.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ Draw();
+ }
+ }
+
public FormCatamaran()
{
InitializeComponent();
@@ -42,51 +54,8 @@ public partial class FormCatamaran : Form
pictureBoxCatamaran.Image = bmp;
}
- ///
- /// Обработка нажатия кнопки "Создать"
- ///
- ///
- ///
- private void CreateObject(string type)
- {
- Random random = new();
- switch (type)
- {
- case nameof(DrawningSimpleCatamaran):
- _drawningSimpleCatamaran = new DrawningSimpleCatamaran(random.Next(30, 70), random.Next(100, 500),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
- break;
- case nameof(DrawningCatamaran):
- _drawningSimpleCatamaran = new DrawningCatamaran(random.Next(30, 70), random.Next(100, 500),
- 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;
- }
- _drawningSimpleCatamaran.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
- _drawningSimpleCatamaran.SetPosition(random.Next(10, 100), random.Next(10, 100));
- _strategy = null;
- comboBoxStrategy.Enabled = true;
- Draw();
-
- }
- ///
- /// Обработка кнопки "Создать обычнвй катамаран"
- ///
- ///
- ///
-
- private void buttonCreateSimpleCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSimpleCatamaran));
- ///
- /// Обработка кнопки "Создать катамаран"
- ///
- ///
- ///
-
- private void buttonCreateCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCatamaran));
+
///
diff --git a/LabOOP_1/LabOOP_1/FormCatamaranColection.Designer.cs b/LabOOP_1/LabOOP_1/FormCatamaranColection.Designer.cs
new file mode 100644
index 0000000..43f950e
--- /dev/null
+++ b/LabOOP_1/LabOOP_1/FormCatamaranColection.Designer.cs
@@ -0,0 +1,173 @@
+namespace Project_Catamaran
+{
+ partial class FormCatamaranColection
+ {
+ ///
+ /// 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();
+ buttonRemoveCatamaran = new Button();
+ maskedTextBoxPosition = new MaskedTextBox();
+ buttonAddCatamaran = new Button();
+ buttonAddSimpleCatamaran = 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(buttonRemoveCatamaran);
+ groupBoxTools.Controls.Add(maskedTextBoxPosition);
+ groupBoxTools.Controls.Add(buttonAddCatamaran);
+ groupBoxTools.Controls.Add(buttonAddSimpleCatamaran);
+ groupBoxTools.Controls.Add(comboBoxSelectorCompany);
+ groupBoxTools.Dock = DockStyle.Right;
+ groupBoxTools.Location = new Point(643, 0);
+ groupBoxTools.Name = "groupBoxTools";
+ groupBoxTools.Size = new Size(228, 477);
+ groupBoxTools.TabIndex = 0;
+ groupBoxTools.TabStop = false;
+ groupBoxTools.Text = "Инструменты";
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(18, 298);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(198, 39);
+ 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(18, 256);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(198, 36);
+ buttonGoToCheck.TabIndex = 5;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += buttonGoToCheck_Click;
+ //
+ // buttonRemoveCatamaran
+ //
+ buttonRemoveCatamaran.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRemoveCatamaran.Location = new Point(18, 220);
+ buttonRemoveCatamaran.Name = "buttonRemoveCatamaran";
+ buttonRemoveCatamaran.Size = new Size(198, 30);
+ buttonRemoveCatamaran.TabIndex = 4;
+ buttonRemoveCatamaran.Text = "Удалить катамаран";
+ buttonRemoveCatamaran.UseVisualStyleBackColor = true;
+ buttonRemoveCatamaran.Click += buttonRemoveCatamaran_Click_1;
+ //
+ // maskedTextBoxPosition
+ //
+ maskedTextBoxPosition.Location = new Point(18, 174);
+ maskedTextBoxPosition.Mask = "00";
+ maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ maskedTextBoxPosition.Size = new Size(198, 31);
+ maskedTextBoxPosition.TabIndex = 3;
+ maskedTextBoxPosition.ValidatingType = typeof(int);
+ //
+ // buttonAddCatamaran
+ //
+ buttonAddCatamaran.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddCatamaran.Location = new Point(18, 109);
+ buttonAddCatamaran.Name = "buttonAddCatamaran";
+ buttonAddCatamaran.Size = new Size(198, 59);
+ buttonAddCatamaran.TabIndex = 2;
+ buttonAddCatamaran.Text = "Создать улучшенный катамаран";
+ buttonAddCatamaran.UseVisualStyleBackColor = true;
+ buttonAddCatamaran.Click += buttonAddCatamaran_Click_1;
+ //
+ // buttonAddSimpleCatamaran
+ //
+ buttonAddSimpleCatamaran.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddSimpleCatamaran.Location = new Point(18, 69);
+ buttonAddSimpleCatamaran.Name = "buttonAddSimpleCatamaran";
+ buttonAddSimpleCatamaran.Size = new Size(198, 34);
+ buttonAddSimpleCatamaran.TabIndex = 1;
+ buttonAddSimpleCatamaran.Text = "Создать Катамаран";
+ buttonAddSimpleCatamaran.UseVisualStyleBackColor = true;
+ buttonAddSimpleCatamaran.Click += buttonAddSimpleCatamaran_Click_1;
+ //
+ // 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(18, 30);
+ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
+ comboBoxSelectorCompany.Size = new Size(198, 33);
+ 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(643, 477);
+ pictureBox.TabIndex = 1;
+ pictureBox.TabStop = false;
+ //
+ // FormCatamaranColection
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(871, 477);
+ Controls.Add(pictureBox);
+ Controls.Add(groupBoxTools);
+ Name = "FormCatamaranColection";
+ Text = "Коллекция катамаранов";
+ groupBoxTools.ResumeLayout(false);
+ groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private ComboBox comboBoxSelectorCompany;
+ private Button buttonAddCatamaran;
+ private Button buttonAddSimpleCatamaran;
+ private PictureBox pictureBox;
+ private Button buttonRemoveCatamaran;
+ private MaskedTextBox maskedTextBoxPosition;
+ private Button buttonRefresh;
+ private Button buttonGoToCheck;
+ }
+}
\ No newline at end of file
diff --git a/LabOOP_1/LabOOP_1/FormCatamaranColection.cs b/LabOOP_1/LabOOP_1/FormCatamaranColection.cs
new file mode 100644
index 0000000..b706a3b
--- /dev/null
+++ b/LabOOP_1/LabOOP_1/FormCatamaranColection.cs
@@ -0,0 +1,176 @@
+using Project_Catamaran.CollectionGenereticObjects;
+using Project_Catamaran.Drawnings;
+using ProjectCatamaran.CollectionGenericObjects;
+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 Project_Catamaran
+{
+ public partial class FormCatamaranColection : Form
+ {
+ ///
+ /// Компания
+ ///
+ private AbstractCompany? _company;
+
+ ///
+ /// Конструктор
+ ///
+ public FormCatamaranColection()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// Выбор компании
+ ///
+ ///
+ ///
+
+
+ private void CreateObject(string type)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+ DrawningSimpleCatamaran drawningSimpleCatamaran;
+ Random random = new();
+ switch (type)
+ {
+ case nameof(DrawningSimpleCatamaran):
+ drawningSimpleCatamaran = new DrawningSimpleCatamaran(random.Next(30, 70), random.Next(100, 500),
+ GetColor(random));
+ break;
+ case nameof(DrawningCatamaran):
+ drawningSimpleCatamaran = new DrawningCatamaran(random.Next(30, 70), random.Next(100, 500),
+ GetColor(random), GetColor(random),
+ Convert.ToBoolean(random.Next(2, 2)), Convert.ToBoolean(random.Next(2, 2)), Convert.ToBoolean(random.Next(2, 2)));
+ break;
+ default:
+ return;
+
+ }
+ if (_company + drawningSimpleCatamaran != -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 buttonRefresh_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ pictureBox.Image = _company.Show();
+ }
+ ///
+ /// Передача объекта в другую форму
+ ///
+ ///
+ ///
+
+ private void buttonGoToCheck_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ DrawningSimpleCatamaran? catamaran = null;
+ int counter = 100;
+ while (catamaran == null)
+ {
+ catamaran = _company.GetRandomObject();
+ counter--;
+ if (counter <= 0)
+ {
+ break;
+ }
+ }
+
+ if (catamaran == null)
+ {
+ return;
+ }
+
+
+
+ FormCatamaran form = new FormCatamaran();
+ form.SetSimpleCatamaran = catamaran;
+ form.ShowDialog();
+ }
+
+ private void buttonAddSimpleCatamaran_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawningSimpleCatamaran));
+
+ private void buttonAddCatamaran_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawningCatamaran));
+
+ private void buttonRemoveCatamaran_Click_1(object sender, EventArgs e)
+ {
+
+ if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
+ {
+ return;
+ }
+
+ if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ return;
+ }
+
+ int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
+ if (_company - pos != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+
+ private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new CatamaranSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
+ break;
+ }
+ }
+ }
+}
diff --git a/LabOOP_1/LabOOP_1/FormCatamaranColection.resx b/LabOOP_1/LabOOP_1/FormCatamaranColection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/LabOOP_1/LabOOP_1/FormCatamaranColection.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/LabOOP_1/LabOOP_1/Program.cs b/LabOOP_1/LabOOP_1/Program.cs
index ede9231..1710df7 100644
--- a/LabOOP_1/LabOOP_1/Program.cs
+++ b/LabOOP_1/LabOOP_1/Program.cs
@@ -11,6 +11,6 @@ internal static class Program
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormCatamaran());
+ Application.Run(new FormCatamaranColection());
}
}
\ No newline at end of file