diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/CarPark.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/CarPark.cs
index 490d9f6..69e4455 100644
--- a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/CarPark.cs
+++ b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/CarPark.cs
@@ -47,7 +47,7 @@ public class CarPark : AbstractCompany
return;
}
int row = numRows - 1, col = numCols;
- for (int i = 0; i < _collection?.Count-4; i++, col--)
+ for (int i = 0; i < _collection?.Count; i++, col--)
{
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
_collection?.Get(i)?.SetPosition(locCoord[row * numCols - col].Item1 + 5, locCoord[row * numCols - col].Item2 + 9);
diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/CollectionType.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/CollectionType.cs
new file mode 100644
index 0000000..3ed0234
--- /dev/null
+++ b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/CollectionType.cs
@@ -0,0 +1,23 @@
+
+namespace ProjectGasolineTanker.CollectionGenericObjects;
+
+///
+/// Тип коллекции
+///
+public enum CollectionType
+{
+ ///
+ /// Неопределено
+ ///
+ None = 0,
+
+ ///
+ /// Массив
+ ///
+ Massive = 1,
+
+ ///
+ /// Список
+ ///
+ List = 2
+}
\ No newline at end of file
diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ListGenericObjects.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ListGenericObjects.cs
new file mode 100644
index 0000000..84bec82
--- /dev/null
+++ b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ListGenericObjects.cs
@@ -0,0 +1,58 @@
+
+namespace ProjectGasolineTanker.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 _collection[position];
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+
+ public int Insert(T obj)
+ {
+ if (Count == _maxCount) { return -1; }
+ _collection.Add(obj);
+ return Count;
+ }
+
+ public int Insert(T obj, int position)
+ {
+ if (position < 0 || position >= Count || Count == _maxCount)
+ {
+ return -1;
+ }
+ _collection.Insert(position, obj);
+ return position;
+
+ }
+
+ public T Remove(int position)
+ {
+ if (position >= Count || position < 0) return null;
+ T obj = _collection[position];
+ _collection.RemoveAt(position);
+ return obj;
+ }
+}
\ No newline at end of file
diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/StorageCollection.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/StorageCollection.cs
new file mode 100644
index 0000000..5590311
--- /dev/null
+++ b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/StorageCollection.cs
@@ -0,0 +1,77 @@
+
+namespace ProjectGasolineTanker.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)
+ {
+ if (string.IsNullOrEmpty(name) || _storages.ContainsKey(name))
+ {
+ return;
+ }
+ switch (collectionType)
+ {
+ case CollectionType.Massive:
+ _storages[name] = new MassiveGenericObjects();
+ break;
+ case CollectionType.List:
+ _storages[name] = new ListGenericObjects();
+ break;
+ default:
+ return;
+ }
+ }
+
+ ///
+ /// Удаление коллекции
+ ///
+ /// Название коллекции
+ public void DelCollection(string name)
+ {
+ if (_storages.ContainsKey(name))
+ {
+ _storages.Remove(name);
+ }
+
+ }
+
+ ///
+ /// Доступ к коллекции
+ ///
+ /// Название коллекции
+ ///
+ public ICollectionGenericObjects? this[string name]
+ {
+ get
+ {
+ if (_storages.ContainsKey(name))
+ {
+ return _storages[name];
+ }
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.Designer.cs b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.Designer.cs
index 68d6a5d..5ad2f22 100644
--- a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.Designer.cs
+++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.Designer.cs
@@ -30,54 +30,97 @@ namespace ProjectGasolineTanker
///
private void InitializeComponent()
{
- groupBoxTools = new GroupBox();
- buttonRefresh = new Button();
+ Инструменты = new GroupBox();
+ panelCompanyTools = new Panel();
+ buttonAddTanker = new Button();
+ buttonAddGasolineTanker = new Button();
+ maskedTextBoxPosition = new MaskedTextBox();
buttonGoToCheck = new Button();
buttonRemoveTanker = new Button();
- maskedTextBoxPosition = new MaskedTextBox();
- buttonAddGasolineTanker = new Button();
- buttonAddTanker = new Button();
+ buttonRefresh = new Button();
+ buttonCreateCompany = new Button();
+ panelStorage = new Panel();
+ buttonCollectionDel = new Button();
+ listBoxCollection = 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();
+ Инструменты.SuspendLayout();
+ panelCompanyTools.SuspendLayout();
+ panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
- // groupBoxTools
+ // Инструменты
//
- groupBoxTools.Controls.Add(buttonRefresh);
- groupBoxTools.Controls.Add(buttonGoToCheck);
- groupBoxTools.Controls.Add(buttonRemoveTanker);
- groupBoxTools.Controls.Add(maskedTextBoxPosition);
- groupBoxTools.Controls.Add(buttonAddGasolineTanker);
- groupBoxTools.Controls.Add(buttonAddTanker);
- groupBoxTools.Controls.Add(comboBoxSelectorCompany);
- groupBoxTools.Dock = DockStyle.Right;
- groupBoxTools.Location = new Point(783, 0);
- groupBoxTools.Name = "groupBoxTools";
- groupBoxTools.Size = new Size(179, 616);
- groupBoxTools.TabIndex = 0;
- groupBoxTools.TabStop = false;
- groupBoxTools.Text = "Инструменты";
+ Инструменты.Controls.Add(panelCompanyTools);
+ Инструменты.Controls.Add(buttonCreateCompany);
+ Инструменты.Controls.Add(panelStorage);
+ Инструменты.Controls.Add(comboBoxSelectorCompany);
+ Инструменты.Dock = DockStyle.Right;
+ Инструменты.Location = new Point(861, 0);
+ Инструменты.Name = "Инструменты";
+ Инструменты.Size = new Size(225, 651);
+ Инструменты.TabIndex = 0;
+ Инструменты.TabStop = false;
+ Инструменты.Text = "Инструменты";
//
- // buttonRefresh
+ // panelCompanyTools
//
- buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonRefresh.Location = new Point(6, 499);
- buttonRefresh.Name = "buttonRefresh";
- buttonRefresh.Size = new Size(167, 40);
- buttonRefresh.TabIndex = 6;
- buttonRefresh.Text = "Обновить";
- buttonRefresh.UseVisualStyleBackColor = true;
- buttonRefresh.Click += ButtonRefresh_Click;
+ panelCompanyTools.Controls.Add(buttonAddTanker);
+ panelCompanyTools.Controls.Add(buttonAddGasolineTanker);
+ panelCompanyTools.Controls.Add(maskedTextBoxPosition);
+ panelCompanyTools.Controls.Add(buttonGoToCheck);
+ panelCompanyTools.Controls.Add(buttonRemoveTanker);
+ panelCompanyTools.Controls.Add(buttonRefresh);
+ panelCompanyTools.Dock = DockStyle.Bottom;
+ panelCompanyTools.Location = new Point(3, 383);
+ panelCompanyTools.Name = "panelCompanyTools";
+ panelCompanyTools.Size = new Size(219, 265);
+ panelCompanyTools.TabIndex = 8;
+ //
+ // buttonAddTanker
+ //
+ buttonAddTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddTanker.Location = new Point(3, 3);
+ buttonAddTanker.Name = "buttonAddTanker";
+ buttonAddTanker.Size = new Size(213, 37);
+ buttonAddTanker.TabIndex = 1;
+ buttonAddTanker.Text = "Добавление грузовика";
+ buttonAddTanker.UseVisualStyleBackColor = true;
+ buttonAddTanker.Click += buttonAddTanker_Click;
+ //
+ // buttonAddGasolineTanker
+ //
+ buttonAddGasolineTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddGasolineTanker.Location = new Point(3, 43);
+ buttonAddGasolineTanker.Name = "buttonAddGasolineTanker";
+ buttonAddGasolineTanker.Size = new Size(213, 37);
+ buttonAddGasolineTanker.TabIndex = 2;
+ buttonAddGasolineTanker.Text = "Добавление бензовоза\r\n";
+ buttonAddGasolineTanker.UseVisualStyleBackColor = true;
+ buttonAddGasolineTanker.Click += buttonAddGasolineTanker_Click;
+ //
+ // maskedTextBoxPosition
+ //
+ maskedTextBoxPosition.Location = new Point(3, 86);
+ maskedTextBoxPosition.Mask = "00";
+ maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ maskedTextBoxPosition.Size = new Size(213, 23);
+ maskedTextBoxPosition.TabIndex = 3;
+ maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonGoToCheck.Location = new Point(6, 361);
+ buttonGoToCheck.Location = new Point(3, 161);
buttonGoToCheck.Name = "buttonGoToCheck";
- buttonGoToCheck.Size = new Size(167, 40);
- buttonGoToCheck.TabIndex = 5;
+ buttonGoToCheck.Size = new Size(213, 40);
+ buttonGoToCheck.TabIndex = 6;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
@@ -85,44 +128,116 @@ namespace ProjectGasolineTanker
// buttonRemoveTanker
//
buttonRemoveTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonRemoveTanker.Location = new Point(6, 251);
+ buttonRemoveTanker.Location = new Point(3, 115);
buttonRemoveTanker.Name = "buttonRemoveTanker";
- buttonRemoveTanker.Size = new Size(167, 40);
+ buttonRemoveTanker.Size = new Size(213, 40);
buttonRemoveTanker.TabIndex = 4;
- buttonRemoveTanker.Text = "Удалить автомобиль";
+ buttonRemoveTanker.Text = "Удаление машины";
buttonRemoveTanker.UseVisualStyleBackColor = true;
buttonRemoveTanker.Click += ButtonRemoveTanker_Click;
//
- // maskedTextBoxPosition
+ // buttonRefresh
//
- maskedTextBoxPosition.Location = new Point(6, 222);
- maskedTextBoxPosition.Mask = "00";
- maskedTextBoxPosition.Name = "maskedTextBoxPosition";
- maskedTextBoxPosition.Size = new Size(167, 23);
- maskedTextBoxPosition.TabIndex = 3;
- maskedTextBoxPosition.ValidatingType = typeof(int);
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(3, 207);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(213, 40);
+ buttonRefresh.TabIndex = 5;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
//
- // buttonAddGaslineTanker
+ // buttonCreateCompany
//
- buttonAddGasolineTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddGasolineTanker.Location = new Point(6, 137);
- buttonAddGasolineTanker.Name = "buttonAddGasolineTanker";
- buttonAddGasolineTanker.Size = new Size(167, 40);
- buttonAddGasolineTanker.TabIndex = 2;
- buttonAddGasolineTanker.Text = "Добавление бензовоза";
- buttonAddGasolineTanker.UseVisualStyleBackColor = true;
- buttonAddGasolineTanker.Click += ButtonAddGasolineTanker_Click;
+ buttonCreateCompany.Location = new Point(6, 350);
+ buttonCreateCompany.Name = "buttonCreateCompany";
+ buttonCreateCompany.Size = new Size(213, 24);
+ buttonCreateCompany.TabIndex = 7;
+ buttonCreateCompany.Text = "Создать компанию";
+ buttonCreateCompany.UseVisualStyleBackColor = true;
+ buttonCreateCompany.Click += ButtonCreateCompany_Click;
//
- // buttonAddTanker
+ // panelStorage
//
- buttonAddTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddTanker.Location = new Point(6, 91);
- buttonAddTanker.Name = "buttonAddTanker";
- buttonAddTanker.Size = new Size(167, 40);
- buttonAddTanker.TabIndex = 1;
- buttonAddTanker.Text = "Добавление грузовика";
- buttonAddTanker.UseVisualStyleBackColor = true;
- buttonAddTanker.Click += ButtonAddTanker_Click;
+ panelStorage.Controls.Add(buttonCollectionDel);
+ panelStorage.Controls.Add(listBoxCollection);
+ 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(219, 296);
+ panelStorage.TabIndex = 7;
+ //
+ // buttonCollectionDel
+ //
+ buttonCollectionDel.Location = new Point(3, 267);
+ buttonCollectionDel.Name = "buttonCollectionDel";
+ buttonCollectionDel.Size = new Size(213, 24);
+ 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(213, 139);
+ listBoxCollection.TabIndex = 5;
+ //
+ // buttonCollectionAdd
+ //
+ buttonCollectionAdd.Location = new Point(3, 85);
+ buttonCollectionAdd.Name = "buttonCollectionAdd";
+ buttonCollectionAdd.Size = new Size(213, 24);
+ buttonCollectionAdd.TabIndex = 4;
+ buttonCollectionAdd.Text = "Добавить коллекцию";
+ buttonCollectionAdd.UseVisualStyleBackColor = true;
+ buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
+ //
+ // radioButtonList
+ //
+ radioButtonList.AutoSize = true;
+ radioButtonList.Location = new Point(139, 60);
+ 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(19, 60);
+ 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, 31);
+ textBoxCollectionName.Name = "textBoxCollectionName";
+ textBoxCollectionName.Size = new Size(213, 23);
+ textBoxCollectionName.TabIndex = 1;
+ //
+ // labelCollectionName
+ //
+ labelCollectionName.AutoSize = true;
+ labelCollectionName.Location = new Point(47, 13);
+ labelCollectionName.Name = "labelCollectionName";
+ labelCollectionName.Size = new Size(125, 15);
+ labelCollectionName.TabIndex = 0;
+ labelCollectionName.Text = "Название коллекции:";
//
// comboBoxSelectorCompany
//
@@ -130,9 +245,9 @@ namespace ProjectGasolineTanker
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
- comboBoxSelectorCompany.Location = new Point(6, 22);
+ comboBoxSelectorCompany.Location = new Point(6, 321);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
- comboBoxSelectorCompany.Size = new Size(167, 23);
+ comboBoxSelectorCompany.Size = new Size(213, 23);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
//
@@ -141,7 +256,7 @@ namespace ProjectGasolineTanker
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
- pictureBox.Size = new Size(783, 616);
+ pictureBox.Size = new Size(861, 651);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
@@ -149,28 +264,40 @@ namespace ProjectGasolineTanker
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(962, 616);
+ ClientSize = new Size(1086, 651);
Controls.Add(pictureBox);
- Controls.Add(groupBoxTools);
+ Controls.Add(Инструменты);
Name = "FormTankerCollection";
- Text = "Коллекция автомобилей";
- groupBoxTools.ResumeLayout(false);
- groupBoxTools.PerformLayout();
+ Text = "Коллекция лодок";
+ Инструменты.ResumeLayout(false);
+ panelCompanyTools.ResumeLayout(false);
+ panelCompanyTools.PerformLayout();
+ panelStorage.ResumeLayout(false);
+ panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
-
}
#endregion
- private GroupBox groupBoxTools;
+ private GroupBox Инструменты;
+ private Button buttonAddTanker;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddGasolineTanker;
- private Button buttonAddTanker;
- private Button buttonRemoveTanker;
private MaskedTextBox maskedTextBoxPosition;
private PictureBox pictureBox;
- private Button buttonGoToCheck;
private Button buttonRefresh;
+ private Button buttonRemoveTanker;
+ private Button buttonGoToCheck;
+ private Panel panelStorage;
+ private Label labelCollectionName;
+ private RadioButton radioButtonMassive;
+ private TextBox textBoxCollectionName;
+ private Button buttonCollectionDel;
+ private ListBox listBoxCollection;
+ private Button buttonCollectionAdd;
+ private RadioButton radioButtonList;
+ private Button buttonCreateCompany;
+ private Panel panelCompanyTools;
}
}
\ No newline at end of file
diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.cs b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.cs
index 7320eaa..8c87c44 100644
--- a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.cs
+++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.cs
@@ -8,7 +8,12 @@ namespace ProjectGasolineTanker;
/// Форма работы с компанией и ее коллекцией
///
public partial class FormTankerCollection : Form
+
{
+ ///
+ /// Хранилише коллекций
+ ///
+ private readonly StorageCollection _storageCollection;
///
/// Компания
///
@@ -20,6 +25,7 @@ public partial class FormTankerCollection : Form
public FormTankerCollection()
{
InitializeComponent();
+ _storageCollection = new();
}
///
@@ -37,24 +43,6 @@ public partial class FormTankerCollection : Form
}
}
- ///
- /// Добавление обычного автомобиля
- ///
- ///
- ///
- private void ButtonAddTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTanker));
-
- ///
- /// Добавление спортивного автомобиля
- ///
- ///
- ///
- private void ButtonAddGasolineTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningGasolineTanker));
-
- ///
- /// Создание объекта класса-перемещения
- ///
- /// Тип создаваемого объекта
private void CreateObject(string type)
{
if (_company == null)
@@ -91,11 +79,25 @@ public partial class FormTankerCollection : Form
}
///
- /// Получение цвета
+ /// Добавление обычного автомобиля
+ ///
+ ///
+ ///
+ private void buttonAddTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTanker));
+
+ ///
+ /// Добавление спортивного автомобиля
///
- /// Генератор случайных чисел
- ///
- private static Color GetColor(Random random)
+ ///
+ ///
+ private void buttonAddGasolineTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningGasolineTanker));
+
+ ///
+ /// Получение цвета
+ ///
+ /// Генератор случайных чисел
+ ///
+ 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();
@@ -107,11 +109,6 @@ public partial class FormTankerCollection : Form
return color;
}
- ///
- /// Удаление объекта
- ///
- ///
- ///
private void ButtonRemoveTanker_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
@@ -186,4 +183,81 @@ public partial class FormTankerCollection : Form
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);
+ RefreshListBoxItems();
+ }
+ ///
+ /// Обновление списка в listBoxCollection
+ ///
+ private void RefreshListBoxItems()
+ {
+ 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 ButtonCollectionDel_Click(object sender, EventArgs e)
+ {
+ if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItems == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+ if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ return;
+ }
+ _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
+ RefreshListBoxItems();
+ }
+
+ 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 CarPark(pictureBox.Width, pictureBox.Height, collection);
+ break;
+ }
+
+ panelCompanyTools.Enabled = true;
+ RefreshListBoxItems();
+ }
}
\ No newline at end of file
diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.resx b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.resx
index 1af7de1..af32865 100644
--- a/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.resx
+++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.resx
@@ -1,17 +1,17 @@
-