diff --git a/AiSD_Lab1/AiSD_Lab1.sln b/AiSD_Lab1/AiSD_Lab1.sln
new file mode 100644
index 0000000..5d14592
--- /dev/null
+++ b/AiSD_Lab1/AiSD_Lab1.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.7.34031.279
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AiSD_Lab1", "AiSD_Lab1\AiSD_Lab1.csproj", "{9015CE0F-B12D-4C87-9827-75FBDDB6AE48}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9015CE0F-B12D-4C87-9827-75FBDDB6AE48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9015CE0F-B12D-4C87-9827-75FBDDB6AE48}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9015CE0F-B12D-4C87-9827-75FBDDB6AE48}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9015CE0F-B12D-4C87-9827-75FBDDB6AE48}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F9A02028-472E-4A74-938E-A366C44E2A55}
+ EndGlobalSection
+EndGlobal
diff --git a/AiSD_Lab1/AiSD_Lab1/AiSD_Lab1.csproj b/AiSD_Lab1/AiSD_Lab1/AiSD_Lab1.csproj
new file mode 100644
index 0000000..f02677b
--- /dev/null
+++ b/AiSD_Lab1/AiSD_Lab1/AiSD_Lab1.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net7.0
+ enable
+ enable
+
+
+
diff --git a/AiSD_Lab1/AiSD_Lab1/Deque.cs b/AiSD_Lab1/AiSD_Lab1/Deque.cs
new file mode 100644
index 0000000..777a6f1
--- /dev/null
+++ b/AiSD_Lab1/AiSD_Lab1/Deque.cs
@@ -0,0 +1,30 @@
+namespace AiSD_Lab1;
+
+public class Deque : Node
+{
+ Node? head;
+
+ Node? tail;
+
+ int count;
+
+ public AddFirst(T node)
+ {
+
+ }
+
+ public AddLast(T node)
+ {
+
+ }
+
+ public RemoveFirst()
+ {
+
+ }
+
+ public RemoveLast()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/AiSD_Lab1/AiSD_Lab1/Node.cs b/AiSD_Lab1/AiSD_Lab1/Node.cs
new file mode 100644
index 0000000..f3fbda8
--- /dev/null
+++ b/AiSD_Lab1/AiSD_Lab1/Node.cs
@@ -0,0 +1,11 @@
+namespace AiSD_Lab1;
+
+public class Node
+{
+ public Node(T data)
+ {
+ Data = data;
+ }
+ public T Data { get; set; }
+ public Node? Next { get; set; }
+}
\ No newline at end of file
diff --git a/AiSD_Lab1/AiSD_Lab1/Program.cs b/AiSD_Lab1/AiSD_Lab1/Program.cs
new file mode 100644
index 0000000..5f28270
--- /dev/null
+++ b/AiSD_Lab1/AiSD_Lab1/Program.cs
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/AiSD_Lab1/AiSD_Lab1/Sort.cs b/AiSD_Lab1/AiSD_Lab1/Sort.cs
new file mode 100644
index 0000000..dd04baf
--- /dev/null
+++ b/AiSD_Lab1/AiSD_Lab1/Sort.cs
@@ -0,0 +1,150 @@
+using System;
+
+namespace AiSD_Lab1;
+
+public class Sort
+{
+ public int[] arr = new int[5];
+
+
+ ///
+ /// Заполняет массив рандомными значениями
+ ///
+ public void RandomArr()
+ {
+ for (int i = 0; i < arr.Length; i++)
+ {
+ Random random = new Random();
+ arr[i] = random.Next(-100, 100);
+ }
+ }
+
+ ///
+ /// Вывод массива в консоль
+ ///
+ public void PrintArr()
+ {
+ Console.WriteLine("Array:");
+ for (int i = 0; i < arr.Length; i++)
+ {
+ Console.WriteLine("[" + i + "]: " + arr[i]);
+ }
+ }
+
+ ///
+ /// Проверяет, отсортирован ли массив по возрастанию
+ ///
+ public void IsSortedUp()
+ {
+ for (int i = 0; i < arr.Length - 1; i++)
+ {
+ if (arr[i] > arr[i + 1])
+ {
+ Console.WriteLine("Массив НЕ отсортирован по возрастанию");
+ return;
+ }
+ }
+ Console.WriteLine("Массив отсортирован по возрастанию");
+ }
+
+ ///
+ /// Проверяет, отсортирован ли массив по убыванию
+ ///
+ public void IsSortedDown()
+ {
+ for (int i = 1; i < arr.Length; i++)
+ {
+ if (arr[i - 1] < arr[i])
+ {
+ Console.WriteLine("Массив НЕ отсортирован по убыванию");
+ return;
+ }
+ }
+ Console.WriteLine("Массив отсортирован по убыванию");
+ }
+
+ ///
+ /// Сортировка выбором
+ ///
+ public void Choise()
+ {
+ for(int i = 0; i < arr.Length; i++)
+ {
+ int min = i;
+ for(int j = i + 1; j < arr.Length; j++)
+ {
+ if (arr[j] < arr[min])
+ {
+ min = j;
+ }
+ int temp = arr[min];
+ arr[min] = arr[i];
+ arr[i] = temp;
+ }
+ }
+ }
+
+ ///
+ /// Метод для слияния массивов
+ ///
+ public void Merge(int[] array, int lowIndex, int middleIndex, int highIndex)
+ {
+ // Индекс первого элемента левой части массива
+ int left = lowIndex;
+ // Индекс первого элемента правой части массива
+ int right = middleIndex + 1;
+ // Массив для слияния
+ int[] tempArray = new int[highIndex - lowIndex + 1];
+ int index = 0;
+
+ // Проходимся по левой и правой половине массива
+ while ((left <= middleIndex) && (right <= highIndex))
+ {
+ if (array[left] < array[right])
+ {
+ tempArray[index] = array[left];
+ left++;
+ }
+ else
+ {
+ tempArray[index] = array[right];
+ right++;
+ }
+
+ index++;
+ }
+
+ for (int i = left; i <= middleIndex; i++)
+ {
+ tempArray[index] = array[i];
+ index++;
+ }
+
+ for (int i = right; i <= highIndex; i++)
+ {
+ tempArray[index] = array[i];
+ index++;
+ }
+
+ // Вносим в массив отсортированные элементы
+ for (int i = 0; i < tempArray.Length; i++)
+ {
+ array[lowIndex + i] = tempArray[i];
+ }
+ }
+
+ // Сортировка слиянием
+ public int[] MergeSort(int[] array, int lowIndex, int highIndex)
+ {
+ if (lowIndex < highIndex)
+ {
+ // Индекс середины массива
+ int middleInd = (lowIndex + highIndex) / 2;
+ MergeSort(array, lowIndex, middleInd);
+ MergeSort(array, middleInd + 1, highIndex);
+ Merge(array, lowIndex, middleInd, highIndex);
+ }
+
+ return array;
+ }
+}
diff --git a/ProjectPlane/ProjectPlane/CollectionGenericObjects/CollectionType.cs b/ProjectPlane/ProjectPlane/CollectionGenericObjects/CollectionType.cs
new file mode 100644
index 0000000..3b2bc9e
--- /dev/null
+++ b/ProjectPlane/ProjectPlane/CollectionGenericObjects/CollectionType.cs
@@ -0,0 +1,10 @@
+namespace ProjectPlane.CollectionGenericObjects;
+
+public enum CollectionType
+{
+ None = 0,
+
+ Massive = 1,
+
+ List = 2
+}
diff --git a/ProjectPlane/ProjectPlane/CollectionGenericObjects/ListGenericObjects.cs b/ProjectPlane/ProjectPlane/CollectionGenericObjects/ListGenericObjects.cs
new file mode 100644
index 0000000..4f8bb5f
--- /dev/null
+++ b/ProjectPlane/ProjectPlane/CollectionGenericObjects/ListGenericObjects.cs
@@ -0,0 +1,65 @@
+using System.CodeDom.Compiler;
+
+namespace ProjectPlane.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)
+ {
+ if (position < 0 || position >= Count)
+ {
+ return null;
+ }
+
+ return _collection[position];
+ }
+
+ public int Insert(T obj)
+ {
+ if (Count == _maxCount)
+ {
+ return -1;
+ }
+
+ _collection.Add(obj);
+ return _collection.Count;
+ }
+
+ public int Insert(T obj, int position)
+ {
+ if (Count == _maxCount || position < 0 || position > Count)
+ {
+ return -1;
+ }
+
+ _collection.Insert(position, obj);
+ return position;
+ }
+
+ public T? Remove(int position)
+ {
+ if (position < 0 || position > Count)
+ {
+ return null;
+ }
+
+ T? obj = _collection[position];
+ _collection.RemoveAt(position);
+
+ return obj;
+ }
+}
diff --git a/ProjectPlane/ProjectPlane/CollectionGenericObjects/StorageCollection.cs b/ProjectPlane/ProjectPlane/CollectionGenericObjects/StorageCollection.cs
new file mode 100644
index 0000000..d00b567
--- /dev/null
+++ b/ProjectPlane/ProjectPlane/CollectionGenericObjects/StorageCollection.cs
@@ -0,0 +1,76 @@
+using ProjectPlane.Drawnings;
+using ProjectPlane.CollectionGenericObjects;
+using System.Xml.Linq;
+
+namespace ProjectPlane.CollectionGenericObjects;
+
+public class StorageCollection
+ where T : class
+{
+ private Dictionary> _storages;
+
+ public List Keys => _storages.Keys.ToList();
+
+ ///
+ /// Конструктор
+ ///
+ public StorageCollection()
+ {
+ _storages = new Dictionary>();
+ }
+
+ ///
+ /// Добавление коллекции в хранилище
+ ///
+ /// Название коллекции
+ /// Тип коллекции
+ public void AddCollection(string name, CollectionType collectionType)
+ {
+ if (name == null || _storages.ContainsKey(name))
+ {
+ return;
+ }
+
+ if (collectionType == CollectionType.Massive)
+ {
+ _storages.Add(name, new MassiveGenericObjects());
+ }
+
+ if (collectionType == CollectionType.List)
+ {
+ _storages.Add(name, new ListGenericObjects());
+ }
+ }
+
+ ///
+ /// Удаление коллекции
+ ///
+ /// Название коллекции
+ public void DelCollection(string name)
+ {
+ if (name == null || !_storages.ContainsKey(name))
+ {
+ return;
+ }
+
+ _storages.Remove(name);
+ }
+
+ ///
+ /// Доступ к коллекции
+ ///
+ /// Название коллекции
+ ///
+ public ICollectionGenericObjects? this[string name]
+ {
+ get
+ {
+ if (_storages.ContainsKey(name))
+ {
+ return _storages[name];
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs b/ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs
index fdc3efc..2de725b 100644
--- a/ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs
+++ b/ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs
@@ -29,6 +29,15 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
+ ButtonCreateCompany = new Button();
+ panelStorage = new Panel();
+ radioButtonMassive = new RadioButton();
+ ButtonCollectionDel = new Button();
+ listBoxCollection = new ListBox();
+ ButtonCollectionAdd = new Button();
+ radioButtonList = new RadioButton();
+ textBoxCollectionName = new TextBox();
+ labelCollectionName = new Label();
ButtonRefresh = new Button();
ButtonGoToCheck = new Button();
ButtonDel = new Button();
@@ -37,33 +46,125 @@
ButtonAddShip = new Button();
ComboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
+ panelCompanyTools = new Panel();
groupBoxTools.SuspendLayout();
+ panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
+ panelCompanyTools.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
//
- groupBoxTools.Controls.Add(ButtonRefresh);
- groupBoxTools.Controls.Add(ButtonGoToCheck);
- groupBoxTools.Controls.Add(ButtonDel);
- groupBoxTools.Controls.Add(maskedTextBoxPosition);
- groupBoxTools.Controls.Add(ButtonAddCont);
- groupBoxTools.Controls.Add(ButtonAddShip);
+ groupBoxTools.Controls.Add(panelCompanyTools);
+ groupBoxTools.Controls.Add(ButtonCreateCompany);
+ groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(ComboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(785, 0);
groupBoxTools.Name = "groupBoxTools";
- groupBoxTools.Size = new Size(200, 678);
+ groupBoxTools.Size = new Size(200, 696);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
+ // ButtonCreateCompany
+ //
+ ButtonCreateCompany.Location = new Point(6, 371);
+ ButtonCreateCompany.Name = "ButtonCreateCompany";
+ ButtonCreateCompany.Size = new Size(188, 23);
+ ButtonCreateCompany.TabIndex = 8;
+ ButtonCreateCompany.Text = "Создать компанию";
+ ButtonCreateCompany.UseVisualStyleBackColor = true;
+ ButtonCreateCompany.Click += ButtonCreateCompany_Click;
+ //
+ // panelStorage
+ //
+ panelStorage.Controls.Add(radioButtonMassive);
+ panelStorage.Controls.Add(ButtonCollectionDel);
+ panelStorage.Controls.Add(listBoxCollection);
+ panelStorage.Controls.Add(ButtonCollectionAdd);
+ panelStorage.Controls.Add(radioButtonList);
+ 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(194, 317);
+ panelStorage.TabIndex = 7;
+ //
+ // radioButtonMassive
+ //
+ radioButtonMassive.AutoSize = true;
+ radioButtonMassive.Location = new Point(3, 57);
+ radioButtonMassive.Name = "radioButtonMassive";
+ radioButtonMassive.Size = new Size(67, 19);
+ radioButtonMassive.TabIndex = 7;
+ radioButtonMassive.TabStop = true;
+ radioButtonMassive.Text = "Массив";
+ radioButtonMassive.UseVisualStyleBackColor = true;
+ //
+ // ButtonCollectionDel
+ //
+ ButtonCollectionDel.Location = new Point(3, 274);
+ ButtonCollectionDel.Name = "ButtonCollectionDel";
+ ButtonCollectionDel.Size = new Size(188, 23);
+ ButtonCollectionDel.TabIndex = 6;
+ ButtonCollectionDel.Text = "Удалить коллекцию";
+ ButtonCollectionDel.UseVisualStyleBackColor = true;
+ ButtonCollectionDel.Click += ButtonCollectionDel_Click;
+ //
+ // listBoxCollection
+ //
+ listBoxCollection.FormattingEnabled = true;
+ listBoxCollection.ItemHeight = 15;
+ listBoxCollection.Location = new Point(3, 122);
+ listBoxCollection.Name = "listBoxCollection";
+ listBoxCollection.Size = new Size(188, 124);
+ listBoxCollection.TabIndex = 5;
+ //
+ // ButtonCollectionAdd
+ //
+ ButtonCollectionAdd.Location = new Point(3, 93);
+ ButtonCollectionAdd.Name = "ButtonCollectionAdd";
+ ButtonCollectionAdd.Size = new Size(188, 23);
+ ButtonCollectionAdd.TabIndex = 4;
+ ButtonCollectionAdd.Text = "Добавить коллекцию";
+ ButtonCollectionAdd.UseVisualStyleBackColor = true;
+ ButtonCollectionAdd.Click += ButtonCollectionAdd_Click;
+ //
+ // radioButtonList
+ //
+ radioButtonList.AutoSize = true;
+ radioButtonList.Location = new Point(95, 57);
+ radioButtonList.Name = "radioButtonList";
+ radioButtonList.Size = new Size(66, 19);
+ radioButtonList.TabIndex = 3;
+ radioButtonList.TabStop = true;
+ radioButtonList.Text = "Список";
+ radioButtonList.UseVisualStyleBackColor = true;
+ //
+ // textBoxCollectionName
+ //
+ textBoxCollectionName.Location = new Point(3, 28);
+ textBoxCollectionName.Name = "textBoxCollectionName";
+ textBoxCollectionName.Size = new Size(188, 23);
+ textBoxCollectionName.TabIndex = 1;
+ //
+ // labelCollectionName
+ //
+ labelCollectionName.AutoSize = true;
+ labelCollectionName.Location = new Point(36, 10);
+ labelCollectionName.Name = "labelCollectionName";
+ labelCollectionName.Size = new Size(125, 15);
+ labelCollectionName.TabIndex = 0;
+ labelCollectionName.Text = "Название коллекции:";
+ //
// ButtonRefresh
//
ButtonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- ButtonRefresh.Location = new Point(6, 425);
+ ButtonRefresh.Location = new Point(6, 230);
ButtonRefresh.Name = "ButtonRefresh";
- ButtonRefresh.Size = new Size(188, 39);
+ ButtonRefresh.Size = new Size(182, 39);
ButtonRefresh.TabIndex = 6;
ButtonRefresh.Text = "Обновить";
ButtonRefresh.UseVisualStyleBackColor = true;
@@ -72,9 +173,9 @@
// ButtonGoToCheck
//
ButtonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- ButtonGoToCheck.Location = new Point(6, 320);
+ ButtonGoToCheck.Location = new Point(6, 185);
ButtonGoToCheck.Name = "ButtonGoToCheck";
- ButtonGoToCheck.Size = new Size(188, 39);
+ ButtonGoToCheck.Size = new Size(182, 39);
ButtonGoToCheck.TabIndex = 5;
ButtonGoToCheck.Text = "Передать на тесты";
ButtonGoToCheck.UseVisualStyleBackColor = true;
@@ -83,9 +184,9 @@
// ButtonDel
//
ButtonDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- ButtonDel.Location = new Point(6, 237);
+ ButtonDel.Location = new Point(6, 140);
ButtonDel.Name = "ButtonDel";
- ButtonDel.Size = new Size(188, 39);
+ ButtonDel.Size = new Size(182, 39);
ButtonDel.TabIndex = 4;
ButtonDel.Text = "Удплить контейнеровоз";
ButtonDel.UseVisualStyleBackColor = true;
@@ -93,7 +194,7 @@
//
// maskedTextBoxPosition
//
- maskedTextBoxPosition.Location = new Point(6, 198);
+ maskedTextBoxPosition.Location = new Point(6, 111);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(188, 23);
@@ -103,9 +204,9 @@
// ButtonAddCont
//
ButtonAddCont.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- ButtonAddCont.Location = new Point(6, 138);
+ ButtonAddCont.Location = new Point(6, 66);
ButtonAddCont.Name = "ButtonAddCont";
- ButtonAddCont.Size = new Size(188, 39);
+ ButtonAddCont.Size = new Size(182, 39);
ButtonAddCont.TabIndex = 2;
ButtonAddCont.Text = "Добавление контейнеровоза";
ButtonAddCont.UseVisualStyleBackColor = true;
@@ -114,9 +215,9 @@
// ButtonAddShip
//
ButtonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- ButtonAddShip.Location = new Point(6, 81);
+ ButtonAddShip.Location = new Point(6, 20);
ButtonAddShip.Name = "ButtonAddShip";
- ButtonAddShip.Size = new Size(188, 40);
+ ButtonAddShip.Size = new Size(182, 40);
ButtonAddShip.TabIndex = 1;
ButtonAddShip.Text = "Добавление корабля";
ButtonAddShip.UseVisualStyleBackColor = true;
@@ -128,7 +229,7 @@
ComboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
ComboBoxSelectorCompany.FormattingEnabled = true;
ComboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
- ComboBoxSelectorCompany.Location = new Point(6, 22);
+ ComboBoxSelectorCompany.Location = new Point(6, 342);
ComboBoxSelectorCompany.Name = "ComboBoxSelectorCompany";
ComboBoxSelectorCompany.Size = new Size(188, 23);
ComboBoxSelectorCompany.TabIndex = 0;
@@ -139,22 +240,39 @@
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
- pictureBox.Size = new Size(785, 678);
+ pictureBox.Size = new Size(785, 696);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
+ // panelCompanyTools
+ //
+ panelCompanyTools.Controls.Add(ButtonAddShip);
+ panelCompanyTools.Controls.Add(ButtonAddCont);
+ panelCompanyTools.Controls.Add(maskedTextBoxPosition);
+ panelCompanyTools.Controls.Add(ButtonRefresh);
+ panelCompanyTools.Controls.Add(ButtonDel);
+ panelCompanyTools.Controls.Add(ButtonGoToCheck);
+ panelCompanyTools.Enabled = false;
+ panelCompanyTools.Location = new Point(3, 400);
+ panelCompanyTools.Name = "panelCompanyTools";
+ panelCompanyTools.Size = new Size(194, 274);
+ panelCompanyTools.TabIndex = 9;
+ //
// FormShipCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(985, 678);
+ ClientSize = new Size(985, 696);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormShipCollection";
Text = "Коллекция кораблей";
groupBoxTools.ResumeLayout(false);
- groupBoxTools.PerformLayout();
+ panelStorage.ResumeLayout(false);
+ panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ panelCompanyTools.ResumeLayout(false);
+ panelCompanyTools.PerformLayout();
ResumeLayout(false);
}
@@ -169,5 +287,15 @@
private Button ButtonDel;
private Button ButtonGoToCheck;
private Button ButtonRefresh;
+ private Panel panelStorage;
+ private TextBox textBoxCollectionName;
+ private Label labelCollectionName;
+ private RadioButton radioButtonList;
+ private Button ButtonCollectionAdd;
+ private Button ButtonCreateCompany;
+ private Button ButtonCollectionDel;
+ private ListBox listBoxCollection;
+ private RadioButton radioButtonMassive;
+ private Panel panelCompanyTools;
}
}
\ No newline at end of file
diff --git a/ProjectPlane/ProjectPlane/FormShipCollection.cs b/ProjectPlane/ProjectPlane/FormShipCollection.cs
index c29fbd4..06650ed 100644
--- a/ProjectPlane/ProjectPlane/FormShipCollection.cs
+++ b/ProjectPlane/ProjectPlane/FormShipCollection.cs
@@ -1,26 +1,23 @@
-
-using ProjectPlane.CollectionGenericObjects;
+using ProjectPlane.CollectionGenericObjects;
using ProjectPlane.Drawnings;
namespace ProjectPlane;
public partial class FormShipCollection : Form
{
+ private readonly StorageCollection _storageCollection;
+
private AbstractCompany? _company = null;
public FormShipCollection()
{
InitializeComponent();
+ _storageCollection = new();
}
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
- switch (ComboBoxSelectorCompany.Text)
- {
- case "Хранилище":
- _company = new Marina(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
- break;
- }
+ panelCompanyTools.Enabled = false;
}
private void CreateObject(string type)
@@ -138,4 +135,86 @@ public partial class FormShipCollection : Form
pictureBox.Image = _company.Show();
}
+
+ private void RadioButtonMassive_CheckedChanged(object sender, EventArgs e)
+ {
+
+ }
+
+ private void RerfreshListBoxItems()
+ {
+ listBoxCollection.Items.Clear();
+ for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
+ {
+ string? colName = _storageCollection.Keys?[i];
+ if (!string.IsNullOrEmpty(colName))
+ {
+ listBoxCollection.Items.Add(colName);
+ }
+ }
+ }
+
+
+ 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 (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+
+ if (MessageBox.Show("Вы уверены, что хотите удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ return;
+ }
+ _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
+ RerfreshListBoxItems();
+ }
+
+ private void ButtonCreateCompany_Click(object sender, EventArgs e)
+ {
+ if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+
+ ICollectionGenericObjects? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
+ if (collection == null)
+ {
+ MessageBox.Show("Коллекция не проинициализирована");
+ return;
+ }
+
+ switch (ComboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new Marina(pictureBox.Width, pictureBox.Height, collection);
+ break;
+ }
+ panelCompanyTools.Enabled = true;
+ RerfreshListBoxItems();
+ }
}