diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/AbstractCompany.cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/AbstractCompany.cs
new file mode 100644
index 0000000..3387242
--- /dev/null
+++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/AbstractCompany.cs
@@ -0,0 +1,104 @@
+using ProjectCatamaran.Drawnings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectCatamaran.CollectiongGenericObjects;
+
+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, DrawningBoat boat)
+ {
+ return company._collection?.Insert(boat) ?? 0;
+ }
+ ///
+ /// Перегрузка оператора удаления для класса
+ ///
+ /// Компания
+ /// Номер удаляемого объекта
+ ///
+ public static DrawningBoat operator -(AbstractCompany company, int position)
+ {
+ return company._collection?.Remove(position);
+ }
+ ///
+ /// Получение случайного объекта из коллекции
+ ///
+ ///
+ public DrawningBoat? 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)
+ {
+ DrawningBoat? obj = _collection?.Get(i);
+ obj?.DrawTransport(graphics);
+ }
+ return bitmap;
+ }
+ ///
+ /// Вывод заднего фона
+ ///
+ ///
+ protected abstract void DrawBackgound(Graphics g);
+ ///
+ /// Расстановка объектов
+ ///
+ protected abstract void SetObjectsPosition();
+}
diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatSharingService.cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatSharingService.cs
new file mode 100644
index 0000000..96723c5
--- /dev/null
+++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatSharingService.cs
@@ -0,0 +1,70 @@
+using ProjectCatamaran.Drawnings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectCatamaran.CollectiongGenericObjects;
+
+///
+/// Реализация абстрактной компании - каршеринг
+///
+public class BoatSharingService : AbstractCompany
+{
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public BoatSharingService(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, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight);
+ g.DrawLine(pen, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight + _placeSizeHeight);
+ }
+ }
+ }
+
+ protected override void SetObjectsPosition()
+ {
+ int width = _pictureWidth / _placeSizeWidth;
+ int height = _pictureHeight / _placeSizeHeight;
+
+ int curWidth = 0;
+ int curHeight = 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 * curWidth + 30, curHeight * _placeSizeHeight);
+ }
+
+ if (curWidth < width - 1)
+ curWidth++;
+ else
+ {
+ curWidth = 0;
+ curHeight++;
+ }
+
+ if (curHeight >= height)
+ {
+ return;
+ }
+ }
+ }
+}
diff --git a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs
new file mode 100644
index 0000000..b96b5d1
--- /dev/null
+++ b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs
@@ -0,0 +1,174 @@
+namespace ProjectCatamaran
+{
+ partial class FormBoatCollection
+ {
+ ///
+ /// 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();
+ buttonRemoveBoat = new Button();
+ maskedTextBoxPosition = new MaskedTextBox();
+ buttonAddCatamaran = new Button();
+ buttonAddBoat = new Button();
+ comboBoxSelectorCompany = new ComboBox();
+ pictureBoxBoat = new PictureBox();
+ groupBoxTools.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxBoat).BeginInit();
+ SuspendLayout();
+ //
+ // groupBoxTools
+ //
+ groupBoxTools.Controls.Add(buttonRefresh);
+ groupBoxTools.Controls.Add(buttonGoToCheck);
+ groupBoxTools.Controls.Add(buttonRemoveBoat);
+ groupBoxTools.Controls.Add(maskedTextBoxPosition);
+ groupBoxTools.Controls.Add(buttonAddCatamaran);
+ groupBoxTools.Controls.Add(buttonAddBoat);
+ groupBoxTools.Controls.Add(comboBoxSelectorCompany);
+ groupBoxTools.Dock = DockStyle.Right;
+ groupBoxTools.Location = new Point(728, 0);
+ groupBoxTools.Name = "groupBoxTools";
+ groupBoxTools.Size = new Size(279, 633);
+ groupBoxTools.TabIndex = 0;
+ groupBoxTools.TabStop = false;
+ groupBoxTools.Text = "Инструменты";
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(16, 522);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(250, 51);
+ 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(16, 408);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(250, 51);
+ buttonGoToCheck.TabIndex = 5;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += ButtonGoToCheck_Click;
+ //
+ // buttonRemoveBoat
+ //
+ buttonRemoveBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRemoveBoat.Location = new Point(16, 301);
+ buttonRemoveBoat.Name = "buttonRemoveBoat";
+ buttonRemoveBoat.Size = new Size(250, 51);
+ buttonRemoveBoat.TabIndex = 4;
+ buttonRemoveBoat.Text = "Удалить лодку";
+ buttonRemoveBoat.UseVisualStyleBackColor = true;
+ buttonRemoveBoat.Click += ButtonRemoveBoat_Click;
+ //
+ // maskedTextBoxPosition
+ //
+ maskedTextBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ maskedTextBoxPosition.Location = new Point(16, 258);
+ maskedTextBoxPosition.Mask = "00";
+ maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ maskedTextBoxPosition.Size = new Size(250, 27);
+ maskedTextBoxPosition.TabIndex = 3;
+ maskedTextBoxPosition.ValidatingType = typeof(int);
+ //
+ // buttonAddCatamaran
+ //
+ buttonAddCatamaran.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddCatamaran.Location = new Point(16, 174);
+ buttonAddCatamaran.Name = "buttonAddCatamaran";
+ buttonAddCatamaran.Size = new Size(250, 51);
+ buttonAddCatamaran.TabIndex = 2;
+ buttonAddCatamaran.Text = "Добавление катамарана";
+ buttonAddCatamaran.UseVisualStyleBackColor = true;
+ buttonAddCatamaran.Click += ButtonAddCatamaran_Click;
+ //
+ // buttonAddBoat
+ //
+ buttonAddBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddBoat.Location = new Point(16, 117);
+ buttonAddBoat.Name = "buttonAddBoat";
+ buttonAddBoat.Size = new Size(250, 51);
+ buttonAddBoat.TabIndex = 1;
+ buttonAddBoat.Text = "Добавление лодки";
+ buttonAddBoat.UseVisualStyleBackColor = true;
+ buttonAddBoat.Click += ButtonAddBoat_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(16, 30);
+ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
+ comboBoxSelectorCompany.Size = new Size(250, 28);
+ comboBoxSelectorCompany.TabIndex = 0;
+ comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
+ //
+ // pictureBoxBoat
+ //
+ pictureBoxBoat.Dock = DockStyle.Fill;
+ pictureBoxBoat.Location = new Point(0, 0);
+ pictureBoxBoat.Name = "pictureBoxBoat";
+ pictureBoxBoat.Size = new Size(728, 633);
+ pictureBoxBoat.TabIndex = 1;
+ pictureBoxBoat.TabStop = false;
+ //
+ // FormBoatCollection
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1007, 633);
+ Controls.Add(pictureBoxBoat);
+ Controls.Add(groupBoxTools);
+ Name = "FormBoatCollection";
+ Text = "Коллекция лодок";
+ groupBoxTools.ResumeLayout(false);
+ groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxBoat).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private Button buttonAddCatamaran;
+ private Button buttonAddBoat;
+ private ComboBox comboBoxSelectorCompany;
+ private Button buttonRefresh;
+ private Button buttonGoToCheck;
+ private Button buttonRemoveBoat;
+ private MaskedTextBox maskedTextBoxPosition;
+ private PictureBox pictureBoxBoat;
+ }
+}
\ No newline at end of file
diff --git a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs
new file mode 100644
index 0000000..888131c
--- /dev/null
+++ b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs
@@ -0,0 +1,190 @@
+using ProjectCatamaran.CollectiongGenericObjects;
+using ProjectCatamaran.Drawnings;
+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 ProjectCatamaran;
+
+///
+/// Форма работы с компанией и ее коллекцией
+///
+public partial class FormBoatCollection : Form
+{
+ ///
+ /// Компания
+ ///
+ private AbstractCompany? _company = null;
+
+ public FormBoatCollection()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// Выбор компании
+ ///
+ ///
+ ///
+ private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new BoatSharingService(pictureBoxBoat.Width,
+ pictureBoxBoat.Height, new MassiveGenericObjects());
+ break;
+ }
+
+ }
+
+
+
+
+ ///
+ /// Создание объекта класса-перемещение
+ ///
+ ///
+ private void CreateObject(string type)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+ Random random = new();
+ DrawningBoat drawningBoat;
+ switch (type)
+ {
+ case nameof(DrawningBoat):
+ drawningBoat = new DrawningBoat(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
+ break;
+ case nameof(DrawningCatamaran):
+ drawningBoat = new DrawningCatamaran(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random),
+ Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+ if (_company + drawningBoat != -1)
+ {
+ MessageBox.Show("объект добавлен");
+ pictureBoxBoat.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("не удалось добавить объект");
+ }
+ }
+
+ ///
+ /// Получение цвета
+ ///
+ ///
+ ///
+ private 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 ButtonAddBoat_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBoat));
+
+ ///
+ /// Добавление катамарана
+ ///
+ ///
+ ///
+ private void ButtonAddCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCatamaran));
+
+ ///
+ /// Удаление объекта
+ ///
+ ///
+ ///
+ private void ButtonRemoveBoat_Click(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("объект удален");
+ pictureBoxBoat.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("не удалось удалить объект");
+ }
+ }
+
+ ///
+ /// Передача объекта в другую форму
+ ///
+ ///
+ ///
+ private void ButtonGoToCheck_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ DrawningBoat? boat = null;
+ int counter = 100;
+ while (boat == null)
+ {
+ boat = _company.GetRandomObject();
+ counter--;
+ if (counter <= 0)
+ {
+ break;
+ }
+ }
+ if (boat == null)
+ {
+ return;
+ }
+ FormCatamaran form = new()
+ {
+ SetBoat = boat
+ };
+ form.ShowDialog();
+ }
+
+ ///
+ /// Перерисовка коллекции
+ ///
+ ///
+ ///
+ private void ButtonRefresh_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ pictureBoxBoat.Image = _company.Show();
+ }
+}
diff --git a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.resx b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.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/ProjectCatamaran/ProjectCatamaran/FormCatamaran.Designer.cs b/ProjectCatamaran/ProjectCatamaran/FormCatamaran.Designer.cs
index bc91fa0..a058366 100644
--- a/ProjectCatamaran/ProjectCatamaran/FormCatamaran.Designer.cs
+++ b/ProjectCatamaran/ProjectCatamaran/FormCatamaran.Designer.cs
@@ -29,12 +29,10 @@
private void InitializeComponent()
{
pictureBoxCatamaran = new PictureBox();
- buttonCreateCatamaran = new Button();
buttonUp = new Button();
buttonLeft = new Button();
buttonDown = new Button();
buttonRight = new Button();
- buttonCreatBoat = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
@@ -49,17 +47,6 @@
pictureBoxCatamaran.TabIndex = 0;
pictureBoxCatamaran.TabStop = false;
//
- // buttonCreateCatamaran
- //
- buttonCreateCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateCatamaran.Location = new Point(12, 409);
- buttonCreateCatamaran.Name = "buttonCreateCatamaran";
- buttonCreateCatamaran.Size = new Size(203, 29);
- buttonCreateCatamaran.TabIndex = 1;
- buttonCreateCatamaran.Text = "Создать катамаран";
- buttonCreateCatamaran.UseVisualStyleBackColor = true;
- buttonCreateCatamaran.Click += ButtonCreateCatamaran_Click;
- //
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
@@ -110,17 +97,6 @@
buttonRight.UseVisualStyleBackColor = false;
buttonRight.Click += ButtonMove_Click;
//
- // buttonCreatBoat
- //
- buttonCreatBoat.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreatBoat.Location = new Point(233, 409);
- buttonCreatBoat.Name = "buttonCreatBoat";
- buttonCreatBoat.Size = new Size(203, 29);
- buttonCreatBoat.TabIndex = 6;
- buttonCreatBoat.Text = "Создать лодку";
- buttonCreatBoat.UseVisualStyleBackColor = true;
- buttonCreatBoat.Click += ButtonCreatBoat_Click;
- //
// comboBoxStrategy
//
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@@ -148,12 +124,10 @@
ClientSize = new Size(800, 450);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
- Controls.Add(buttonCreatBoat);
Controls.Add(buttonRight);
Controls.Add(buttonDown);
Controls.Add(buttonLeft);
Controls.Add(buttonUp);
- Controls.Add(buttonCreateCatamaran);
Controls.Add(pictureBoxCatamaran);
Name = "FormCatamaran";
Text = "Катамаран";
@@ -164,12 +138,10 @@
#endregion
private PictureBox pictureBoxCatamaran;
- private Button buttonCreateCatamaran;
private Button buttonUp;
private Button buttonLeft;
private Button buttonDown;
private Button buttonRight;
- private Button buttonCreatBoat;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}
diff --git a/ProjectCatamaran/ProjectCatamaran/FormCatamaran.cs b/ProjectCatamaran/ProjectCatamaran/FormCatamaran.cs
index 8b7a425..c746878 100644
--- a/ProjectCatamaran/ProjectCatamaran/FormCatamaran.cs
+++ b/ProjectCatamaran/ProjectCatamaran/FormCatamaran.cs
@@ -24,6 +24,21 @@ namespace ProjectCatamaran
///
private AbstractStrategy? _strategy;
+ ///
+ /// Получение объекта
+ ///
+ public DrawningBoat SetBoat
+ {
+ set
+ {
+ _drawningBoat = value;
+ _drawningBoat.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ Draw();
+ }
+ }
+
///
/// Конструктор формы
@@ -34,51 +49,6 @@ namespace ProjectCatamaran
_strategy = null;
}
- ///
- /// Создание объекта класса-перемещения
- ///
- ///
- private void CreateObject(string type)
- {
- Random random = new();
- switch (type)
- {
- case nameof(DrawningBoat):
- _drawningBoat = new DrawningBoat(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(DrawningCatamaran):
- _drawningBoat = new DrawningCatamaran(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;
- }
- _drawningBoat.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
- _drawningBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
- _strategy = null;
- comboBoxStrategy.Enabled = true;
- Draw();
- }
-
-
- ///
- /// Обработка нажатия кнопки "Создать катамаран"
- ///
- ///
- ///
- private void ButtonCreateCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCatamaran));
-
-
- ///
- /// Обработка нажатия кнопки "Создать лодку"
- ///
- ///
- ///
- private void ButtonCreatBoat_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBoat));
///
/// Метод прорисовки катамарана
diff --git a/ProjectCatamaran/ProjectCatamaran/Program.cs b/ProjectCatamaran/ProjectCatamaran/Program.cs
new file mode 100644
index 0000000..59feea7
--- /dev/null
+++ b/ProjectCatamaran/ProjectCatamaran/Program.cs
@@ -0,0 +1,17 @@
+namespace ProjectCatamaran
+{
+ internal static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ Application.Run(new FormBoatCollection());
+ }
+ }
+}
\ No newline at end of file