diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/AbstractCompany.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/AbstractCompany.cs
new file mode 100644
index 0000000..b62b879
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/AbstractCompany.cs
@@ -0,0 +1,116 @@
+using SelfPropelledArtilleryUnit.Drawnings;
+
+namespace SelfPropelledArtilleryUnit.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, DrawningPropelledArtillery propelledartillery)
+ {
+ return company._collection.Insert(propelledartillery);
+ }
+
+ ///
+ /// Перегрузка оператора удаления для класса
+ ///
+ /// Компания
+ /// Номер удаляемого объекта
+ ///
+ public static DrawningPropelledArtillery operator -(AbstractCompany company, int position)
+ {
+ return company._collection?.Remove(position);
+ }
+
+ ///
+ /// Получение случайного объекта из коллекции
+ ///
+ ///
+ public DrawningPropelledArtillery? 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)
+ {
+ DrawningPropelledArtillery? obj = _collection?.Get(i);
+ obj?.DrawTransport(graphics);
+ }
+
+ return bitmap;
+ }
+
+ ///
+ /// Вывод заднего фона
+ ///
+ ///
+ protected abstract void DrawBackgound(Graphics g);
+
+ ///
+ /// Расстановка объектов
+ ///
+ protected abstract void SetObjectsPosition();
+}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ArtilleryBase.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ArtilleryBase.cs
new file mode 100644
index 0000000..e5afd86
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ArtilleryBase.cs
@@ -0,0 +1,29 @@
+using SelfPropelledArtilleryUnit.Drawnings;
+
+namespace SelfPropelledArtilleryUnit.CollectionGenericObjects;
+
+///
+/// Реализация абстрактной базы
+///
+public class ArtilleryBase : AbstractCompany
+{
+ ///
+ /// Конструктор
+ ///
+ ///
+ ///
+ ///
+ public ArtilleryBase(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection)
+ {
+ }
+
+ protected override void DrawBackgound(Graphics g)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override void SetObjectsPosition()
+ {
+ throw new NotImplementedException();
+ }
+}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ICollectionGenericObjects.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ICollectionGenericObjects.cs
index 42998a9..094d599 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -1,12 +1,43 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+namespace SelfPropelledArtilleryUnit.CollectionGenericObjects;
-namespace SelfPropelledArtilleryUnit.CollectionGenericObjects
+///
+/// Параметризованный набор объектов
+///
+/// Параметр: ограничение - ссылочный тип
+public interface ICollectionGenericObjects
+ where T : class
{
- internal interface ICollectionGenericObjects
- {
- }
+ ///
+ /// Количество объектов в коллекции
+ ///
+ 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);
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/MassiveGenericObjects.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/MassiveGenericObjects.cs
index 2ae8650..a87e788 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/MassiveGenericObjects.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -1,12 +1,90 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+namespace SelfPropelledArtilleryUnit.CollectionGenericObjects;
-namespace SelfPropelledArtilleryUnit.CollectionGenericObjects
+///
+/// Параметризованный набор объектов
+///
+/// Параметр: ограничение - ссылочный тип
+public class MassiveGenericObjects : ICollectionGenericObjects
+ where T : class
{
- internal class MassiveGenericObjects
+ ///
+ /// Массив объектов, которые храним
+ ///
+ 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)
+ {
+ // TODO проверка позиции
+ if (position >= _collection.Length || position < 0) return null;
+ return _collection[position];
+ }
+ public int Insert(T obj)
+ {
+ // TODO вставка в свободное место набора
+ 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)
+ {
+ // TODO проверка позиции
+ // TODO проверка, что элемент массива по этой позиции пустой, если нет, то
+ // ищется свободное место после этой позиции и идет вставка туда
+ // если нет после, ищем до
+ // TODO вставка
+ 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)
+ {
+ // TODO проверка позиции
+ // TODO удаление объекта из массива, присвоив элементу массива значение null
+ if (position >= _collection.Length || position < 0)
+ return null;
+ T obj = _collection[position];
+ _collection[position] = null;
+ return obj;
+ }
+}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.Designer.cs
new file mode 100644
index 0000000..dcaee96
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.Designer.cs
@@ -0,0 +1,173 @@
+namespace SelfPropelledArtilleryUnit
+{
+ partial class FormPropelledArtilleryCollection
+ {
+ ///
+ /// 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();
+ buttonRemovePropelledArtillery = new Button();
+ maskedTextBox = new MaskedTextBox();
+ buttonAddSelfPropelledArtilleryUnit = new Button();
+ buttonAddPropelledArtillery = 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(buttonRemovePropelledArtillery);
+ groupBoxTools.Controls.Add(maskedTextBox);
+ groupBoxTools.Controls.Add(buttonAddSelfPropelledArtilleryUnit);
+ groupBoxTools.Controls.Add(buttonAddPropelledArtillery);
+ groupBoxTools.Controls.Add(comboBoxSelectorCompany);
+ groupBoxTools.Dock = DockStyle.Right;
+ groupBoxTools.Location = new Point(736, 0);
+ groupBoxTools.Name = "groupBoxTools";
+ groupBoxTools.Size = new Size(200, 562);
+ groupBoxTools.TabIndex = 0;
+ groupBoxTools.TabStop = false;
+ groupBoxTools.Text = "Инструменты";
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(6, 520);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(188, 36);
+ 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, 362);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(188, 36);
+ buttonGoToCheck.TabIndex = 5;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += buttonGoToCheck_Click;
+ //
+ // buttonRemovePropelledArtillery
+ //
+ buttonRemovePropelledArtillery.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRemovePropelledArtillery.Location = new Point(6, 261);
+ buttonRemovePropelledArtillery.Name = "buttonRemovePropelledArtillery";
+ buttonRemovePropelledArtillery.Size = new Size(188, 36);
+ buttonRemovePropelledArtillery.TabIndex = 4;
+ buttonRemovePropelledArtillery.Text = "Удаление";
+ buttonRemovePropelledArtillery.UseVisualStyleBackColor = true;
+ buttonRemovePropelledArtillery.Click += buttonRemovePropelledArtillery_Click;
+ //
+ // maskedTextBox
+ //
+ maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ maskedTextBox.Location = new Point(6, 232);
+ maskedTextBox.Mask = "00";
+ maskedTextBox.Name = "maskedTextBox";
+ maskedTextBox.Size = new Size(188, 23);
+ maskedTextBox.TabIndex = 3;
+ maskedTextBox.ValidatingType = typeof(int);
+ maskedTextBox.MaskInputRejected += maskedTextBox_MaskInputRejected;
+ //
+ // buttonAddSelfPropelledArtilleryUnit
+ //
+ buttonAddSelfPropelledArtilleryUnit.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddSelfPropelledArtilleryUnit.Location = new Point(6, 138);
+ buttonAddSelfPropelledArtilleryUnit.Name = "buttonAddSelfPropelledArtilleryUnit";
+ buttonAddSelfPropelledArtilleryUnit.Size = new Size(188, 40);
+ buttonAddSelfPropelledArtilleryUnit.TabIndex = 2;
+ buttonAddSelfPropelledArtilleryUnit.Text = "Добавление самоходная арт. установки";
+ buttonAddSelfPropelledArtilleryUnit.UseVisualStyleBackColor = true;
+ //
+ // buttonAddPropelledArtillery
+ //
+ buttonAddPropelledArtillery.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddPropelledArtillery.Location = new Point(6, 92);
+ buttonAddPropelledArtillery.Name = "buttonAddPropelledArtillery";
+ buttonAddPropelledArtillery.Size = new Size(188, 40);
+ buttonAddPropelledArtillery.TabIndex = 1;
+ buttonAddPropelledArtillery.Text = "Добавление бронированной машины";
+ buttonAddPropelledArtillery.UseVisualStyleBackColor = true;
+ //
+ // 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, 22);
+ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
+ comboBoxSelectorCompany.Size = new Size(188, 23);
+ 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(736, 562);
+ pictureBox.TabIndex = 1;
+ pictureBox.TabStop = false;
+ //
+ // FormPropelledArtilleryCollection
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(936, 562);
+ Controls.Add(pictureBox);
+ Controls.Add(groupBoxTools);
+ Name = "FormPropelledArtilleryCollection";
+ Text = "Коллекция установок";
+ groupBoxTools.ResumeLayout(false);
+ groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private Button buttonAddPropelledArtillery;
+ private ComboBox comboBoxSelectorCompany;
+ private MaskedTextBox maskedTextBox;
+ private Button buttonAddSelfPropelledArtilleryUnit;
+ private PictureBox pictureBox;
+ private Button buttonRefresh;
+ private Button buttonGoToCheck;
+ private Button buttonRemovePropelledArtillery;
+ }
+}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.cs
new file mode 100644
index 0000000..a33e363
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.cs
@@ -0,0 +1,197 @@
+using SelfPropelledArtilleryUnit.CollectionGenericObjects;
+using SelfPropelledArtilleryUnit.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 SelfPropelledArtilleryUnit;
+
+public partial class FormPropelledArtilleryCollection : Form
+{
+ ///
+ /// Компания
+ ///
+ private AbstractCompany? _company = null;
+
+ ///
+ /// Конструктор
+ ///
+ public FormPropelledArtilleryCollection()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// Выбор компании
+ ///
+ ///
+ ///
+
+ private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new ArtilleryBase(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
+ break;
+ }
+ }
+
+ ///
+ /// Добавление Бронированная машина
+ ///
+ ///
+ ///
+ private void ButtonAddPropelledArtillery_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPropelledArtillery));
+
+ ///
+ /// Добавление Самоходная арт. установка
+ ///
+ ///
+ ///
+ private void ButtonAddSelfPropelledArtilleryUnit_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSelfPropelledArtilleryUnit));
+
+ ///
+ /// Создание объекта класса-перемещения
+ ///
+ /// Тип создаваемого объекта
+ private void CreateObject(string type)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+ Random random = new();
+ DrawningPropelledArtillery drawningPropelledArtillery;
+ switch (type)
+ {
+ case nameof(DrawningPropelledArtillery):
+ drawningPropelledArtillery = new DrawningPropelledArtillery(random.Next(100, 300),
+ random.Next(1000, 3000), GetColor(random));
+ break;
+ case nameof(DrawningSelfPropelledArtilleryUnit):
+ // TODO вызов диалогового окна для выбора цвета (made)
+ drawningPropelledArtillery = new DrawningSelfPropelledArtilleryUnit(random.Next(100, 300), random.Next(1000, 3000),
+ GetColor(random), GetColor(random),
+ Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+ if (_company + drawningPropelledArtillery != -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 maskedTextBox_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
+ {
+
+ }
+
+ ///
+ /// Удаление объекта
+ ///
+ ///
+ ///
+ private void buttonRemovePropelledArtillery_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ 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;
+ }
+
+ DrawningPropelledArtillery? propelledartillery = null;
+ int counter = 100;
+ while (propelledartillery == null)
+ {
+ propelledartillery = _company.GetRandomObject();
+ counter--;
+ if (counter <= 0)
+ {
+ break;
+ }
+ }
+
+ if (propelledartillery == null)
+ {
+ return;
+ }
+
+ SelfPropelledArtilleryUnit form = new()
+ {
+ SetPropelledArtillery = propelledartillery
+ };
+ form.ShowDialog();
+ }
+
+ ///
+ /// Перерисовка коллекции
+ ///
+ ///
+ ///
+ private void buttonRefresh_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+ pictureBox.Image = _company.Show();
+ }
+}
+
+
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.resx b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormPropelledArtilleryCollection.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/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Program.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Program.cs
index b7fe442..ac1eb51 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Program.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/Program.cs
@@ -11,7 +11,7 @@ namespace SelfPropelledArtilleryUnit
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new SelfPropelledArtilleryUnit());
+ Application.Run(new FormPropelledArtilleryCollection());
}
}
}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit.Designer.cs
index 10f2ab7..cf352e3 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit.Designer.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit.Designer.cs
@@ -29,12 +29,10 @@
private void InitializeComponent()
{
pictureBoxSelfPropelledArtilleryUnit = new PictureBox();
- buttonCreate = new Button();
buttonLeft = new Button();
buttonUp = new Button();
buttonDown = new Button();
buttonRight = new Button();
- button1 = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxSelfPropelledArtilleryUnit).BeginInit();
@@ -49,17 +47,6 @@
pictureBoxSelfPropelledArtilleryUnit.TabIndex = 0;
pictureBoxSelfPropelledArtilleryUnit.TabStop = false;
//
- // buttonCreate
- //
- buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreate.Location = new Point(12, 446);
- buttonCreate.Name = "buttonCreate";
- buttonCreate.Size = new Size(226, 35);
- buttonCreate.TabIndex = 1;
- buttonCreate.Text = "Создать самоходную арт. установку";
- buttonCreate.UseVisualStyleBackColor = true;
- buttonCreate.Click += buttonCreateSelfPropelledArtilleryUnit_Click;
- //
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
@@ -108,17 +95,6 @@
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click;
//
- // button1
- //
- button1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- button1.Location = new Point(253, 446);
- button1.Name = "button1";
- button1.Size = new Size(226, 35);
- button1.TabIndex = 6;
- button1.Text = "Создать бронированную машину";
- button1.UseVisualStyleBackColor = true;
- button1.Click += buttonCreatePropelledArtillery_Click;
- //
// comboBoxStrategy
//
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@@ -147,12 +123,10 @@
ClientSize = new Size(923, 493);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
- Controls.Add(button1);
Controls.Add(buttonRight);
Controls.Add(buttonDown);
Controls.Add(buttonUp);
Controls.Add(buttonLeft);
- Controls.Add(buttonCreate);
Controls.Add(pictureBoxSelfPropelledArtilleryUnit);
Name = "SelfPropelledArtilleryUnit";
Text = "Самоходная арт. установка";
@@ -163,12 +137,10 @@
#endregion
private PictureBox pictureBoxSelfPropelledArtilleryUnit;
- private Button buttonCreate;
private Button buttonLeft;
private Button buttonUp;
private Button buttonDown;
private Button buttonRight;
- private Button button1;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit.cs
index e6cbfc4..4c755f4 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit.cs
@@ -21,6 +21,21 @@ namespace SelfPropelledArtilleryUnit
///
private AbstractStrategy? _strategy;
+ ///
+ /// Получение объекта
+ ///
+ public DrawningPropelledArtillery SetPropelledArtillery
+ {
+ set
+ {
+ _drawningPropelledArtillery = value;
+ _drawningPropelledArtillery.SetPictureSize(pictureBoxSelfPropelledArtilleryUnit.Width, pictureBoxSelfPropelledArtilleryUnit.Height);
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ Draw();
+ }
+ }
+
///
/// Конструктор формы
///
@@ -42,45 +57,45 @@ namespace SelfPropelledArtilleryUnit
_drawningPropelledArtillery.DrawTransport(gr);
pictureBoxSelfPropelledArtilleryUnit.Image = bmp;
}
- private void CreateObject(string type)
- {
- Random random = new();
- switch (type)
- {
- case nameof(DrawningPropelledArtillery):
- _drawningPropelledArtillery = new DrawningPropelledArtillery(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(DrawningSelfPropelledArtilleryUnit):
- _drawningPropelledArtillery = new DrawningSelfPropelledArtilleryUnit(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;
- }
+ //private void CreateObject(string type)
+ //{
+ // Random random = new();
+ // switch (type)
+ // {
+ // case nameof(DrawningPropelledArtillery):
+ // _drawningPropelledArtillery = new DrawningPropelledArtillery(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(DrawningSelfPropelledArtilleryUnit):
+ // _drawningPropelledArtillery = new DrawningSelfPropelledArtilleryUnit(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;
+ // }
- _drawningPropelledArtillery.SetPictureSize(pictureBoxSelfPropelledArtilleryUnit.Width, pictureBoxSelfPropelledArtilleryUnit.Height);
- _drawningPropelledArtillery.SetPosition(random.Next(10, 100), random.Next(10, 100));
- _strategy = null;
- comboBoxStrategy.Enabled = true;
- Draw();
- }
+ // _drawningPropelledArtillery.SetPictureSize(pictureBoxSelfPropelledArtilleryUnit.Width, pictureBoxSelfPropelledArtilleryUnit.Height);
+ // _drawningPropelledArtillery.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ // _strategy = null;
+ // comboBoxStrategy.Enabled = true;
+ // Draw();
+ //}
- ///
- /// Обработка нажатия кнопки "Создать самоходную арт.установку"
- ///
- ///
- ///
- private void buttonCreateSelfPropelledArtilleryUnit_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSelfPropelledArtilleryUnit));
+ /////
+ ///// Обработка нажатия кнопки "Создать самоходную арт.установку"
+ /////
+ /////
+ /////
+ //private void buttonCreateSelfPropelledArtilleryUnit_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSelfPropelledArtilleryUnit));
- ///
- /// Обработка нажатия кнопки "Создать бронированную машину"
- ///
- ///
- ///
- private void buttonCreatePropelledArtillery_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPropelledArtillery));
+ /////
+ ///// Обработка нажатия кнопки "Создать бронированную машину"
+ /////
+ /////
+ /////
+ //private void buttonCreatePropelledArtillery_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPropelledArtillery));
private void ButtonMove_Click(object sender, EventArgs e)
{