From e2d7c55de8e82ac2547fdde4bcefa64025e54e19 Mon Sep 17 00:00:00 2001
From: Garifullin-Farid <95081032+Garifullin-Farid@users.noreply.github.com>
Date: Sun, 19 May 2024 19:15:38 +0400
Subject: [PATCH 1/3] LabWork_2
# Conflicts:
# ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs
# ProjectTank/ProjectTank/Entities/EntityTank.cs
# ProjectTank/ProjectTank/FormBattleTank.cs
# ProjectTank/ProjectTank/MovementStrategy/MoveableTank.cs
---
.../Drawning/DrawningBattleTank.cs | 2 +-
ProjectTank/ProjectTank/FormBattleTank.cs | 88 +++++++++++++++++++
2 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs b/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs
index f090df9..289bdec 100644
--- a/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs
+++ b/ProjectTank/ProjectTank/Drawning/DrawningBattleTank.cs
@@ -1,4 +1,4 @@
-namespace ProjectTank.Drawning;
+namespace ProjectTank.Drawning;
///
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
///
diff --git a/ProjectTank/ProjectTank/FormBattleTank.cs b/ProjectTank/ProjectTank/FormBattleTank.cs
index 2338bd4..0998778 100644
--- a/ProjectTank/ProjectTank/FormBattleTank.cs
+++ b/ProjectTank/ProjectTank/FormBattleTank.cs
@@ -1,4 +1,8 @@
using ProjectTank.Drawning;
+using ProjectTank.Entities;
+using ProjectTank.MovementStrategy;
+
+using ProjectTank.Drawning;
using ProjectTank.MovementStrategy;
namespace ProjectTank
@@ -12,11 +16,14 @@ namespace ProjectTank
/// Поле-объект для прорисовки объекта
///
private DrawningTank? _drawningTank;
+ private DrawningTank? _drawningTank;
///
/// Стратегия перемещения
+ /// Стратегия перемещения
///
private AbstractStrategy? _strategy;
+ private AbstractStrategy? _strategy;
public DrawningTank SetTank
{
@@ -36,12 +43,15 @@ namespace ProjectTank
{
InitializeComponent();
_strategy = null;
+ _strategy = null;
}
///
/// Метод прорисовки танка
+ /// Метод прорисовки танка
///
private void Draw()
{
+ if (_drawningTank == null)
if (_drawningTank == null)
{
return;
@@ -49,6 +59,7 @@ namespace ProjectTank
Bitmap bmp = new(pictureBoxBattleTank.Width, pictureBoxBattleTank.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningTank.DrawTransport(gr);
+ _drawningTank.DrawTransport(gr);
pictureBoxBattleTank.Image = bmp;
}
///
@@ -79,6 +90,34 @@ namespace ProjectTank
СomboBoxStrategy.Enabled = true;
Draw();
}
+ ///
+ /// Создание объекта класса-перемещения
+ ///
+ /// Тип создаваемого объекта
+ private void CreateObject(string type)
+ {
+ Random random = new Random();
+ switch (type)
+ {
+ case nameof(DrawningTank):
+ _drawningTank = new DrawningTank(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(DrawningBattleTank):
+ _drawningTank = new DrawningBattleTank(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;
+ }
+ _drawningTank.SetPictureSize(pictureBoxBattleTank.Width, pictureBoxBattleTank.Height);
+ _drawningTank.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ _strategy = null;
+ СomboBoxStrategy.Enabled = true;
+ Draw();
+ }
///
/// Обработка нажатия кнопки "Создать"
@@ -86,6 +125,10 @@ namespace ProjectTank
///
///
+ private void ButtonCreateButtleTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningBattleTank));
+ private void ButtonCreateTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningTank));
+
+
private void ButtonCreateButtleTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningBattleTank));
private void ButtonCreateTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningTank));
@@ -96,6 +139,7 @@ namespace ProjectTank
///
private void ButtonMove_Click(object sender, EventArgs e)
{
+ if (_drawningTank == null)
if (_drawningTank == null)
{
return;
@@ -105,15 +149,19 @@ namespace ProjectTank
switch (name)
{
case "buttonUp":
+ result = _drawningTank.MoveTransport(DirectionType.Up);
result = _drawningTank.MoveTransport(DirectionType.Up);
break;
case "buttonLeft":
+ result = _drawningTank.MoveTransport(DirectionType.Left);
result = _drawningTank.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
+ result = _drawningTank.MoveTransport(DirectionType.Right);
result = _drawningTank.MoveTransport(DirectionType.Right);
break;
case "buttonDown":
+ result = _drawningTank.MoveTransport(DirectionType.Down);
result = _drawningTank.MoveTransport(DirectionType.Down);
break;
}
@@ -162,5 +210,45 @@ namespace ProjectTank
}
}
+ ///
+ /// Обработка нажатия кнопки "Шаг"
+ ///
+ ///
+ ///
+ private void ButtonStrategyStep_Ckick(object sender, EventArgs e)
+ {
+ if (_drawningTank == null)
+ {
+ return;
+ }
+ if (СomboBoxStrategy.Enabled)
+ {
+ _strategy = СomboBoxStrategy.SelectedIndex switch
+ {
+ 0 => new MoveToCenter(),
+ 1 => new MoveToBorder(),
+ _ => null,
+ };
+ if (_strategy == null)
+ {
+ return;
+ }
+ _strategy.SetData(new MoveableTank(_drawningTank),
+ pictureBoxBattleTank.Width, pictureBoxBattleTank.Height);
+ }
+ if (_strategy == null)
+ {
+ return;
+ }
+ СomboBoxStrategy.Enabled = false;
+ _strategy.MakeStep();
+ Draw();
+ if (_strategy.GetStatus() == StrategyStatus.Finish)
+ {
+ СomboBoxStrategy.Enabled = true;
+ _strategy = null;
+ }
+ }
+
}
}
--
2.25.1
From 7933a3417599421757db37b50be376705e7f0a44 Mon Sep 17 00:00:00 2001
From: Garifullin-Farid <95081032+Garifullin-Farid@users.noreply.github.com>
Date: Sun, 7 Apr 2024 21:29:46 +0400
Subject: [PATCH 2/3] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?=
=?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=B0=E2=84=964?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../CollectionGenericObjects/ICollectionGenericObjects.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/ICollectionGenericObjects.cs
index 812597b..33e01a5 100644
--- a/ProjectTank/ProjectTank/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/ProjectTank/ProjectTank/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -7,7 +7,6 @@
public interface ICollectionGenericObjects
where T : class
{
- ///
/// Количество объектов в коллекции
///
int Count { get; }
--
2.25.1
From 67456c2de941f672a739554490e22a4d41f8c601 Mon Sep 17 00:00:00 2001
From: Garifullin-Farid <95081032+Garifullin-Farid@users.noreply.github.com>
Date: Sun, 19 May 2024 19:16:40 +0400
Subject: [PATCH 3/3] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?=
=?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=B0=E2=84=964?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
# Conflicts:
# ProjectTank/ProjectTank/FormBattleTankCollection.cs
---
.../CollectionType.cs | 17 ++
.../ICollectionGenericObjects.cs | 66 ++---
.../ListGenericObjects.cs | 70 +++++
.../StorageCollection.cs | 73 +++++
ProjectTank/ProjectTank/FormBattleTank.cs | 92 +------
.../FormBattleTankCollection.Designer.cs | 260 +++++++++++++-----
.../ProjectTank/FormBattleTankCollection.cs | 103 ++++++-
7 files changed, 492 insertions(+), 189 deletions(-)
create mode 100644 ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType.cs
create mode 100644 ProjectTank/ProjectTank/CollectionGenericObjects/ListGenericObjects.cs
create mode 100644 ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs
diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType.cs
new file mode 100644
index 0000000..f4bf31f
--- /dev/null
+++ b/ProjectTank/ProjectTank/CollectionGenericObjects/CollectionType.cs
@@ -0,0 +1,17 @@
+namespace ProjectTank.CollectionGenericObjects;
+
+public enum CollectionType
+{
+ ///
+ /// Неопределено
+ ///
+ None = 0,
+ ///
+ /// Массив
+ ///
+ Massive = 1,
+ ///
+ /// Список
+ ///
+ List = 2
+}
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/ICollectionGenericObjects.cs
index 33e01a5..ec1ba1f 100644
--- a/ProjectTank/ProjectTank/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/ProjectTank/ProjectTank/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -7,42 +7,44 @@
public interface ICollectionGenericObjects
where T : class
{
- /// Количество объектов в коллекции
- ///
- int Count { get; }
+ ///
+ /// Количество объектов в коллекции
+ ///
+ int Count { get; }
- ///
- /// Установка максимального количества элементов
- ///
- int SetMaxCount { set; }
+ ///
+ /// Установка максимального количества элементов
+ ///
+ int SetMaxCount { set; }
- ///
- /// Добавление объекта в коллекцию
- ///
- /// Добавляемый объект
- /// true - вставка прошла удачно, false - вставка не удалась
- int Insert(T obj);
+ ///
+ /// Добавление объекта в коллекцию
+ ///
+ /// Добавляемый объект
+ /// true - вставка прошла удачно, false - вставка не удалась
+ int Insert(T obj);
- ///
- /// Добавление объекта в коллекцию на конкретную позицию
- ///
- /// Добавляемый объект
- /// Позиция
- /// true - вставка прошла удачно, false - вставка не удалась
- int Insert(T obj, int position);
+ ///
+ /// Добавление объекта в коллекцию на конкретную позицию
+ ///
+ /// Добавляемый объект
+ /// Позиция
+ /// true - вставка прошла удачно, false - вставка не удалась
+ int Insert(T obj, int position);
- ///
- /// Удаление объекта из коллекции с конкретной позиции
- ///
- /// Позиция
- /// true - удаление прошло удачно, false - удаление не удалось
- T? Remove(int position);
+ ///
+ /// Удаление объекта из коллекции с конкретной позиции
+ ///
+ /// Позиция
+ /// true - удаление прошло удачно, false - удаление не удалось
+ T? Remove(int position);
+
+ ///
+ /// Получение объекта по позиции
+ ///
+ /// Позиция
+ /// Объект
+ T? Get(int position);
- ///
- /// Получение объекта по позиции
- ///
- /// Позиция
- /// Объект
- T? Get(int position);
}
}
diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/ListGenericObjects.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/ListGenericObjects.cs
new file mode 100644
index 0000000..bc45ea5
--- /dev/null
+++ b/ProjectTank/ProjectTank/CollectionGenericObjects/ListGenericObjects.cs
@@ -0,0 +1,70 @@
+using ProjectTank.CollectionGenericObjects;
+
+
+///
+/// Параметризованный набор объектов
+///
+/// Параметр: ограничение - ссылочный тип
+public class ListGenericObjects : ICollectionGenericObjects
+ where T : class
+{
+ ///
+ /// Список объектов, которые храним
+ ///
+ private readonly List _collection;
+ ///
+ /// Максимально допустимое число объектов в списке
+ ///
+ private int _maxCount;
+ public int Count => _collection.Count;
+ public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
+ ///
+ /// Конструктор
+ ///
+ public ListGenericObjects()
+ {
+ _collection = new();
+ }
+ public T? Get(int position)
+ {
+ // TODO проверка позиции
+ if (position <= Count)
+ {
+ return _collection[position];
+ }
+ else
+ return null;
+ }
+ public int Insert(T obj)
+ {
+ // TODO проверка, что не превышено максимальное количество элементов
+ // TODO вставка в конец набора
+ if (Count + 1 > _maxCount)
+ return -1;
+ _collection.Add(obj);
+ return Count;
+ }
+ public int Insert(T obj, int position)
+ {
+ // TODO проверка, что не превышено максимальное количество элементов
+ // TODO проверка позиции
+ // TODO вставка по позиции
+ if (Count + 1 > _maxCount)
+ return -1;
+ if (position < 0 || position > Count)
+ return -1;
+ _collection.Insert(position, obj);
+ return 1;
+
+ }
+ public T? Remove(int position)
+ {
+ // TODO проверка позиции
+ // TODO удаление объекта из списка
+ if (position < 0 || position > Count)
+ return null;
+ T? temp = _collection[position];
+ _collection.RemoveAt(position);
+ return temp;
+ }
+}
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs
new file mode 100644
index 0000000..6b0bc15
--- /dev/null
+++ b/ProjectTank/ProjectTank/CollectionGenericObjects/StorageCollection.cs
@@ -0,0 +1,73 @@
+
+namespace ProjectTank.CollectionGenericObjects
+{
+ public class StorageCollection
+ where T : class
+ {
+ ///
+ /// Словарь (хранилище) с коллекциями
+ ///
+ readonly Dictionary> _storages;
+ ///
+ /// Возвращение списка названий коллекций
+ ///
+ public List Keys => _storages.Keys.ToList();
+ ///
+ /// Конструктор
+ ///
+ public StorageCollection()
+ {
+ _storages = new Dictionary>();
+ }
+ ///
+ /// Добавление коллекции в хранилище
+ ///
+ /// Название коллекции
+ /// тип коллекции
+ public void AddCollection(string name, CollectionType collectionType)
+ {
+ // TODO проверка, что name не пустой и нет в словаре записи с таким ключом
+ // TODO Прописать логику для добавления
+ if (name == null || _storages.ContainsKey(name))
+ return;
+ switch (collectionType)
+ {
+ case CollectionType.None:
+ return;
+ case CollectionType.Massive:
+ _storages[name] = new MassiveGenericObjects();
+ return;
+ case CollectionType.List:
+ _storages[name] = new ListGenericObjects();
+ return;
+ }
+
+ }
+ ///
+ /// Удаление коллекции
+ ///
+ /// Название коллекции
+ public void DelCollection(string name)
+ {
+ // TODO Прописать логику для удаления коллекции
+ if (_storages.ContainsKey(name))
+ _storages.Remove(name);
+ }
+ ///
+ /// Доступ к коллекции
+ ///
+ /// Название коллекции
+ ///
+ public ICollectionGenericObjects? this[string name]
+ {
+ get
+ {
+ // TODO Продумать логику получения объекта
+ if (name == null || !_storages.ContainsKey(name))
+ return null;
+ return _storages[name];
+ }
+ }
+
+ }
+}
diff --git a/ProjectTank/ProjectTank/FormBattleTank.cs b/ProjectTank/ProjectTank/FormBattleTank.cs
index 0998778..dbc70e9 100644
--- a/ProjectTank/ProjectTank/FormBattleTank.cs
+++ b/ProjectTank/ProjectTank/FormBattleTank.cs
@@ -1,9 +1,8 @@
using ProjectTank.Drawning;
-using ProjectTank.Entities;
+
using ProjectTank.MovementStrategy;
-using ProjectTank.Drawning;
-using ProjectTank.MovementStrategy;
+
namespace ProjectTank
{
@@ -16,14 +15,13 @@ namespace ProjectTank
/// Поле-объект для прорисовки объекта
///
private DrawningTank? _drawningTank;
- private DrawningTank? _drawningTank;
+
///
/// Стратегия перемещения
- /// Стратегия перемещения
///
private AbstractStrategy? _strategy;
- private AbstractStrategy? _strategy;
+
public DrawningTank SetTank
{
@@ -51,7 +49,6 @@ namespace ProjectTank
///
private void Draw()
{
- if (_drawningTank == null)
if (_drawningTank == null)
{
return;
@@ -59,37 +56,9 @@ namespace ProjectTank
Bitmap bmp = new(pictureBoxBattleTank.Width, pictureBoxBattleTank.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningTank.DrawTransport(gr);
- _drawningTank.DrawTransport(gr);
pictureBoxBattleTank.Image = bmp;
}
- ///
- /// Создание объекта класса-перемещения
- ///
- /// Тип создаваемого объекта
- private void CreateObject(string type)
- {
- Random random = new Random();
- switch (type)
- {
- case nameof(DrawningTank):
- _drawningTank = new DrawningTank(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(DrawningBattleTank):
- _drawningTank = new DrawningBattleTank(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;
- }
- _drawningTank.SetPictureSize(pictureBoxBattleTank.Width, pictureBoxBattleTank.Height);
- _drawningTank.SetPosition(random.Next(10, 100), random.Next(10, 100));
- _strategy = null;
- СomboBoxStrategy.Enabled = true;
- Draw();
- }
+
///
/// Создание объекта класса-перемещения
///
@@ -124,11 +93,6 @@ namespace ProjectTank
///
///
///
-
- private void ButtonCreateButtleTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningBattleTank));
- private void ButtonCreateTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningTank));
-
-
private void ButtonCreateButtleTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningBattleTank));
private void ButtonCreateTank_Ckick(object sender, EventArgs e) => CreateObject(nameof(DrawningTank));
@@ -139,7 +103,6 @@ namespace ProjectTank
///
private void ButtonMove_Click(object sender, EventArgs e)
{
- if (_drawningTank == null)
if (_drawningTank == null)
{
return;
@@ -149,19 +112,15 @@ namespace ProjectTank
switch (name)
{
case "buttonUp":
- result = _drawningTank.MoveTransport(DirectionType.Up);
result = _drawningTank.MoveTransport(DirectionType.Up);
break;
case "buttonLeft":
- result = _drawningTank.MoveTransport(DirectionType.Left);
result = _drawningTank.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
- result = _drawningTank.MoveTransport(DirectionType.Right);
result = _drawningTank.MoveTransport(DirectionType.Right);
break;
case "buttonDown":
- result = _drawningTank.MoveTransport(DirectionType.Down);
result = _drawningTank.MoveTransport(DirectionType.Down);
break;
}
@@ -210,45 +169,8 @@ namespace ProjectTank
}
}
- ///
- /// Обработка нажатия кнопки "Шаг"
- ///
- ///
- ///
- private void ButtonStrategyStep_Ckick(object sender, EventArgs e)
- {
- if (_drawningTank == null)
- {
- return;
- }
- if (СomboBoxStrategy.Enabled)
- {
- _strategy = СomboBoxStrategy.SelectedIndex switch
- {
- 0 => new MoveToCenter(),
- 1 => new MoveToBorder(),
- _ => null,
- };
- if (_strategy == null)
- {
- return;
- }
- _strategy.SetData(new MoveableTank(_drawningTank),
- pictureBoxBattleTank.Width, pictureBoxBattleTank.Height);
- }
- if (_strategy == null)
- {
- return;
- }
- СomboBoxStrategy.Enabled = false;
- _strategy.MakeStep();
- Draw();
- if (_strategy.GetStatus() == StrategyStatus.Finish)
- {
- СomboBoxStrategy.Enabled = true;
- _strategy = null;
- }
- }
+
+
}
}
diff --git a/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs b/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs
index 72e3bdf..073fc60 100644
--- a/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs
+++ b/ProjectTank/ProjectTank/FormBattleTankCollection.Designer.cs
@@ -29,98 +29,213 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
- buttonRefresh = new Button();
- buttonGoToCheck = new Button();
- buttonRemoveTank = new Button();
- maskedTextBox = new MaskedTextBox();
- buttonAddBattleTank = new Button();
+ panelCompanyTools = new Panel();
buttonAddTank = new Button();
+ buttonAddBattleTank = new Button();
+ maskedTextBox = new MaskedTextBox();
+ buttonRefresh = new Button();
+ buttonRemoveTank = new Button();
+ buttonGoToCheck = new Button();
+ buttonCreateCompany = new Button();
+ panelStorage = new Panel();
+ buttonCollectionDel = new Button();
+ listBoxСollection = new ListBox();
+ buttonCollectionAdd = new Button();
+ radioButtonList = new RadioButton();
+ radioButtonMassive = new RadioButton();
+ textBoxCollectionName = new TextBox();
+ labelCollectionName = new Label();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout();
+ panelCompanyTools.SuspendLayout();
+ panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
- groupBoxTools.Controls.Add(buttonRefresh);
- groupBoxTools.Controls.Add(buttonGoToCheck);
- groupBoxTools.Controls.Add(buttonRemoveTank);
- groupBoxTools.Controls.Add(maskedTextBox);
- groupBoxTools.Controls.Add(buttonAddBattleTank);
- groupBoxTools.Controls.Add(buttonAddTank);
+ groupBoxTools.Controls.Add(panelCompanyTools);
+ groupBoxTools.Controls.Add(buttonCreateCompany);
+ groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
- groupBoxTools.Location = new Point(613, 0);
+ groupBoxTools.Location = new Point(815, 0);
groupBoxTools.Name = "groupBoxTools";
- groupBoxTools.Size = new Size(187, 450);
+ groupBoxTools.Size = new Size(187, 610);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "инструменты";
//
- // buttonRefresh
+ // panelCompanyTools
//
- buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonRefresh.Location = new Point(6, 379);
- buttonRefresh.Name = "buttonRefresh";
- buttonRefresh.Size = new Size(175, 35);
- buttonRefresh.TabIndex = 6;
- buttonRefresh.Text = "Обновить";
- buttonRefresh.UseVisualStyleBackColor = true;
- buttonRefresh.Click += ButtonRefresh_Click;
+ panelCompanyTools.Controls.Add(buttonAddTank);
+ panelCompanyTools.Controls.Add(buttonAddBattleTank);
+ panelCompanyTools.Controls.Add(maskedTextBox);
+ panelCompanyTools.Controls.Add(buttonRefresh);
+ panelCompanyTools.Controls.Add(buttonRemoveTank);
+ panelCompanyTools.Controls.Add(buttonGoToCheck);
+ panelCompanyTools.Enabled = false;
+ panelCompanyTools.Location = new Point(3, 372);
+ panelCompanyTools.Name = "panelCompanyTools";
+ panelCompanyTools.Size = new Size(184, 238);
+ panelCompanyTools.TabIndex = 8;
//
- // buttonGoToCheck
+ // buttonAddTank
//
- buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonGoToCheck.Location = new Point(6, 302);
- buttonGoToCheck.Name = "buttonGoToCheck";
- buttonGoToCheck.Size = new Size(175, 35);
- buttonGoToCheck.TabIndex = 5;
- buttonGoToCheck.Text = "Передать на тесты";
- buttonGoToCheck.UseVisualStyleBackColor = true;
- buttonGoToCheck.Click += ButtonGoToCheck_Click;
- //
- // buttonRemoveTank
- //
- buttonRemoveTank.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonRemoveTank.Location = new Point(6, 241);
- buttonRemoveTank.Name = "buttonRemoveTank";
- buttonRemoveTank.Size = new Size(175, 35);
- buttonRemoveTank.TabIndex = 4;
- buttonRemoveTank.Text = "Удаление танка";
- buttonRemoveTank.UseVisualStyleBackColor = true;
- buttonRemoveTank.Click += buttonRemoveTank_Click;
- //
- // maskedTextBox
- //
- maskedTextBox.Location = new Point(6, 212);
- maskedTextBox.Mask = "00";
- maskedTextBox.Name = "maskedTextBox";
- maskedTextBox.Size = new Size(169, 23);
- maskedTextBox.TabIndex = 3;
- maskedTextBox.ValidatingType = typeof(int);
+ buttonAddTank.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddTank.Location = new Point(6, 3);
+ buttonAddTank.Name = "buttonAddTank";
+ buttonAddTank.Size = new Size(169, 35);
+ buttonAddTank.TabIndex = 1;
+ buttonAddTank.Text = "Добавление танка";
+ buttonAddTank.UseVisualStyleBackColor = true;
+ buttonAddTank.Click += ButtonAddTank_Click;
//
// buttonAddBattleTank
//
buttonAddBattleTank.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddBattleTank.Location = new Point(6, 133);
+ buttonAddBattleTank.Location = new Point(6, 44);
buttonAddBattleTank.Name = "buttonAddBattleTank";
- buttonAddBattleTank.Size = new Size(175, 35);
+ buttonAddBattleTank.Size = new Size(169, 35);
buttonAddBattleTank.TabIndex = 2;
buttonAddBattleTank.Text = "Добавление боевого танка";
buttonAddBattleTank.UseVisualStyleBackColor = true;
buttonAddBattleTank.Click += ButtonAddBattleTank_Click;
//
- // buttonAddTank
+ // maskedTextBox
//
- buttonAddTank.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddTank.Location = new Point(6, 92);
- buttonAddTank.Name = "buttonAddTank";
- buttonAddTank.Size = new Size(175, 35);
- buttonAddTank.TabIndex = 1;
- buttonAddTank.Text = "Добавление танка";
- buttonAddTank.UseVisualStyleBackColor = true;
- buttonAddTank.Click += ButtonAddTank_Click;
+ maskedTextBox.Location = new Point(6, 85);
+ maskedTextBox.Mask = "00";
+ maskedTextBox.Name = "maskedTextBox";
+ maskedTextBox.Size = new Size(166, 23);
+ maskedTextBox.TabIndex = 3;
+ maskedTextBox.ValidatingType = typeof(int);
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(3, 200);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(166, 35);
+ buttonRefresh.TabIndex = 6;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
+ //
+ // buttonRemoveTank
+ //
+ buttonRemoveTank.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRemoveTank.Location = new Point(3, 114);
+ buttonRemoveTank.Name = "buttonRemoveTank";
+ buttonRemoveTank.Size = new Size(169, 35);
+ buttonRemoveTank.TabIndex = 4;
+ buttonRemoveTank.Text = "Удаление танка";
+ buttonRemoveTank.UseVisualStyleBackColor = true;
+ buttonRemoveTank.Click += buttonRemoveTank_Click;
+ //
+ // buttonGoToCheck
+ //
+ buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonGoToCheck.Location = new Point(6, 159);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(159, 35);
+ buttonGoToCheck.TabIndex = 5;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += ButtonGoToCheck_Click;
+ //
+ // buttonCreateCompany
+ //
+ buttonCreateCompany.Location = new Point(6, 334);
+ buttonCreateCompany.Name = "buttonCreateCompany";
+ buttonCreateCompany.Size = new Size(175, 32);
+ buttonCreateCompany.TabIndex = 7;
+ buttonCreateCompany.Text = "Создать компанию";
+ buttonCreateCompany.UseVisualStyleBackColor = true;
+ buttonCreateCompany.Click += buttonCreateCompany_Click;
+ //
+ // panelStorage
+ //
+ panelStorage.Controls.Add(buttonCollectionDel);
+ panelStorage.Controls.Add(listBoxСollection);
+ panelStorage.Controls.Add(buttonCollectionAdd);
+ panelStorage.Controls.Add(radioButtonList);
+ panelStorage.Controls.Add(radioButtonMassive);
+ panelStorage.Controls.Add(textBoxCollectionName);
+ panelStorage.Controls.Add(labelCollectionName);
+ panelStorage.Dock = DockStyle.Top;
+ panelStorage.Location = new Point(3, 19);
+ panelStorage.Name = "panelStorage";
+ panelStorage.Size = new Size(181, 280);
+ panelStorage.TabIndex = 7;
+ //
+ // buttonCollectionDel
+ //
+ buttonCollectionDel.Location = new Point(3, 235);
+ buttonCollectionDel.Name = "buttonCollectionDel";
+ buttonCollectionDel.Size = new Size(175, 31);
+ buttonCollectionDel.TabIndex = 6;
+ buttonCollectionDel.Text = "Удалить Коллекцию";
+ buttonCollectionDel.UseVisualStyleBackColor = true;
+ buttonCollectionDel.Click += buttonCollectionDel_Click;
+ //
+ // listBoxСollection
+ //
+ listBoxСollection.FormattingEnabled = true;
+ listBoxСollection.ItemHeight = 15;
+ listBoxСollection.Location = new Point(3, 123);
+ listBoxСollection.Name = "listBoxСollection";
+ listBoxСollection.Size = new Size(169, 94);
+ listBoxСollection.TabIndex = 5;
+ //
+ // buttonCollectionAdd
+ //
+ buttonCollectionAdd.Location = new Point(3, 94);
+ buttonCollectionAdd.Name = "buttonCollectionAdd";
+ buttonCollectionAdd.Size = new Size(175, 23);
+ buttonCollectionAdd.TabIndex = 4;
+ buttonCollectionAdd.Text = "Добавить Коллекцию";
+ buttonCollectionAdd.UseVisualStyleBackColor = true;
+ buttonCollectionAdd.Click += buttonCollectionAdd_Click;
+ //
+ // radioButtonList
+ //
+ radioButtonList.AutoSize = true;
+ radioButtonList.Location = new Point(106, 70);
+ radioButtonList.Name = "radioButtonList";
+ radioButtonList.Size = new Size(66, 19);
+ radioButtonList.TabIndex = 3;
+ radioButtonList.TabStop = true;
+ radioButtonList.Text = "Список";
+ radioButtonList.UseVisualStyleBackColor = true;
+ //
+ // radioButtonMassive
+ //
+ radioButtonMassive.AutoSize = true;
+ radioButtonMassive.Location = new Point(13, 70);
+ radioButtonMassive.Name = "radioButtonMassive";
+ radioButtonMassive.Size = new Size(67, 19);
+ radioButtonMassive.TabIndex = 2;
+ radioButtonMassive.TabStop = true;
+ radioButtonMassive.Text = "Массив";
+ radioButtonMassive.UseVisualStyleBackColor = true;
+ //
+ // textBoxCollectionName
+ //
+ textBoxCollectionName.Location = new Point(3, 41);
+ textBoxCollectionName.Name = "textBoxCollectionName";
+ textBoxCollectionName.Size = new Size(175, 23);
+ textBoxCollectionName.TabIndex = 1;
+ //
+ // labelCollectionName
+ //
+ labelCollectionName.AutoSize = true;
+ labelCollectionName.Location = new Point(30, 13);
+ labelCollectionName.Name = "labelCollectionName";
+ labelCollectionName.Size = new Size(120, 15);
+ labelCollectionName.TabIndex = 0;
+ labelCollectionName.Text = "нвзвание коллекции";
//
// comboBoxSelectorCompany
//
@@ -128,7 +243,7 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
- comboBoxSelectorCompany.Location = new Point(6, 25);
+ comboBoxSelectorCompany.Location = new Point(6, 305);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(175, 23);
comboBoxSelectorCompany.TabIndex = 0;
@@ -139,7 +254,7 @@
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
- pictureBox.Size = new Size(613, 450);
+ pictureBox.Size = new Size(815, 610);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
@@ -147,13 +262,16 @@
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(800, 450);
+ ClientSize = new Size(1002, 610);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormBattleTankCollection";
Text = "Коллекция танков";
groupBoxTools.ResumeLayout(false);
- groupBoxTools.PerformLayout();
+ panelCompanyTools.ResumeLayout(false);
+ panelCompanyTools.PerformLayout();
+ panelStorage.ResumeLayout(false);
+ panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
}
@@ -169,5 +287,15 @@
private Button buttonRemoveTank;
private Button buttonRefresh;
private Button buttonGoToCheck;
+ private Panel panelStorage;
+ private RadioButton radioButtonList;
+ private RadioButton radioButtonMassive;
+ private TextBox textBoxCollectionName;
+ private Label labelCollectionName;
+ private Button buttonCreateCompany;
+ private Button buttonCollectionDel;
+ private ListBox listBoxСollection;
+ private Button buttonCollectionAdd;
+ private Panel panelCompanyTools;
}
}
\ No newline at end of file
diff --git a/ProjectTank/ProjectTank/FormBattleTankCollection.cs b/ProjectTank/ProjectTank/FormBattleTankCollection.cs
index 0457743..7bb8eaf 100644
--- a/ProjectTank/ProjectTank/FormBattleTankCollection.cs
+++ b/ProjectTank/ProjectTank/FormBattleTankCollection.cs
@@ -8,6 +8,10 @@ namespace ProjectTank
///
public partial class FormBattleTankCollection : Form
{
+ ///
+ /// Хранилище коллекций
+ ///
+ private readonly StorageCollection _storageCollection;
///
/// Компания
///
@@ -19,6 +23,7 @@ namespace ProjectTank
public FormBattleTankCollection()
{
InitializeComponent();
+ _storageCollection = new();
}
///
@@ -28,12 +33,7 @@ namespace ProjectTank
///
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
- switch (comboBoxSelectorCompany.Text)
- {
- case "Хранилище":
- _company = new TankBase(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
- break;
- }
+ panelCompanyTools.Enabled = false;
}
///
@@ -146,5 +146,96 @@ namespace ProjectTank
if (_company == null) return;
pictureBox.Image = _company.Show();
}
+ ///
+ /// Добавление коллекции
+ ///
+ ///
+ ///
+ private void buttonCollectionAdd_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
+ {
+ MessageBox.Show("Не все данные заполнены", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ CollectionType collectionType = CollectionType.None;
+ if (radioButtonMassive.Checked)
+ {
+ collectionType = CollectionType.Massive;
+ }
+ else if (radioButtonList.Checked)
+ {
+ collectionType = CollectionType.List;
+ }
+ _storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
+ RerfreshListBoxItems();
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void buttonCollectionDel_Click(object sender, EventArgs e)
+ {
+ if (listBoxСollection.SelectedIndex < 0 || listBoxСollection.SelectedItem == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+ if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ return;
+ }
+ _storageCollection.DelCollection(listBoxСollection.SelectedItem.ToString());
+ RerfreshListBoxItems();
+ }
+ ///
+ /// Обновление списка в listBoxCollection
+ ///
+ private void RerfreshListBoxItems()
+ {
+ listBoxСollection.Items.Clear();
+ for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
+ {
+ string? colName = _storageCollection.Keys?[i];
+ if (!string.IsNullOrEmpty(colName))
+ {
+ listBoxСollection.Items.Add(colName);
+ }
+ }
+ }
+ ///
+ /// Создание компании
+ ///
+ ///
+ ///
+ private void buttonCreateCompany_Click(object sender, EventArgs e)
+ {
+ if (listBoxСollection.SelectedIndex < 0 || listBoxСollection.SelectedItems == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+
+ ICollectionGenericObjects? collection = _storageCollection[listBoxСollection.SelectedItem.ToString() ?? string.Empty];
+
+ if (collection == null)
+ {
+ MessageBox.Show("Коллекция не проинициализирована");
+ return;
+ }
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new TankBase(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
+ break;
+ }
+ panelCompanyTools.Enabled = true;
+ RerfreshListBoxItems();
+ }
+
+
}
}
--
2.25.1