diff --git a/ConsoleApp1/ConsoleApp1.sln b/ConsoleApp1/ConsoleApp1.sln deleted file mode 100644 index 2ba4487..0000000 --- a/ConsoleApp1/ConsoleApp1.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34525.116 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{D8A4ACE0-0728-47AB-9F80-9EDA475782ED}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Release|Any CPU.Build.0 = Release|Any CPU - {C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {3368BA78-2800-49EC-9A71-865DC3C2F15F} - EndGlobalSection -EndGlobal diff --git a/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj b/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj deleted file mode 100644 index 2150e37..0000000 --- a/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/ConsoleApp1/ConsoleApp1/Program.cs b/ConsoleApp1/ConsoleApp1/Program.cs deleted file mode 100644 index 16bb850..0000000 --- a/ConsoleApp1/ConsoleApp1/Program.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections; -using System; - -// Класс компонента компьютера -public class ComputerComponent -{ - public string Name { get; set; } - public string Type { get; set; } - - public ComputerComponent(string name, string type) - { - Name = name; - Type = type; - } -} - -// АТД Очередь на основе массива -public class CustomQueue -{ - private ArrayList elements = new ArrayList(); - - public int Count { get { return elements.Count; } } - - public void Enqueue(ComputerComponent component) - { - elements.Add(component); - } - - public ComputerComponent Dequeue() - { - if (elements.Count == 0) - { - throw new InvalidOperationException("Queue is empty"); - } - - ComputerComponent component = (ComputerComponent)elements[0]; - elements.RemoveAt(0); - return component; - } - - public ComputerComponent Peek() - { - if (elements.Count == 0) - { - throw new InvalidOperationException("Queue is empty"); - } - - return (ComputerComponent)elements[0]; - } -} -class Program -{ - public static void Main(string[] args) - { - CustomQueue queue = new CustomQueue(); - - // Добавление компонентов в очередь - ComputerComponent cpu = new ComputerComponent("Intel Core i7", "CPU"); - ComputerComponent gpu = new ComputerComponent("Nvidia RTX 3080", "GPU"); - - queue.Enqueue(cpu); - queue.Enqueue(gpu); - - // Проверка совместимости компонентов в сборке - Console.WriteLine("Первый компонент в очереди: {0} ({1})", queue.Peek().Name, queue.Peek().Type); - Console.WriteLine("Извлечен компонент из очереди: {0} ({1})", queue.Dequeue().Name, queue.Dequeue().Type); - } -} diff --git a/ConsoleApp1/ConsoleApp2/ConsoleApp2.csproj b/ConsoleApp1/ConsoleApp2/ConsoleApp2.csproj deleted file mode 100644 index 2150e37..0000000 --- a/ConsoleApp1/ConsoleApp2/ConsoleApp2.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/ConsoleApp1/ConsoleApp2/Program.cs b/ConsoleApp1/ConsoleApp2/Program.cs deleted file mode 100644 index ae6071b..0000000 --- a/ConsoleApp1/ConsoleApp2/Program.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; - -// Реализация АТД Очередь -public class Queue -{ - private T[] elements; - private int front, rear, size, capacity; - - public Queue(int capacity) - { - this.capacity = capacity; - elements = new T[capacity]; - front = size = 0; - rear = capacity - 1; - } - - public void Enqueue(T item) - { - if (size == capacity) - throw new Exception("Queue is full"); - rear = (rear + 1) % capacity; - elements[rear] = item; - size++; - } - - public T Dequeue() - { - if (size == 0) - throw new Exception("Queue is empty"); - T item = elements[front]; - front = (front + 1) % capacity; - size--; - return item; - } - - // Реализация СД Массив - public static void SelectionSort(int[] array) - { - for (int i = 0; i < array.Length - 1; i++) - { - int minIndex = i; - for (int j = i + 1; j < array.Length; j++) - { - if (array[j] < array[minIndex]) - { - minIndex = j; - } - } - if (minIndex != i) - { - int temp = array[i]; - array[i] = array[minIndex]; - array[minIndex] = temp; - } - } - } - - // Быстрая сортировка - public static void QuickSort(int[] array, int left, int right) - { - if (left < right) - { - int pivot = Partition(array, left, right); - QuickSort(array, left, pivot - 1); - QuickSort(array, pivot + 1, right); - } - } - - private static int Partition(int[] array, int left, int right) - { - int pivot = array[right]; - int i = left - 1; - for (int j = left; j < right; j++) - { - if (array[j] < pivot) - { - i++; - int temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - } - int temp1 = array[i + 1]; - array[i + 1] = array[right]; - array[right] = temp1; - return i + 1; - } - - public static void Main() - { - int[] array = { 64, 34, 25, 12, 22, 11, 90 }; - - // Сортировка выбором - Console.WriteLine("Before selection sort:"); - foreach (var item in array) Console.Write(item + " "); - SelectionSort(array); - Console.WriteLine("\n\nAfter selection sort:"); - foreach (var item in array) Console.Write(item + " "); - - // Быстрая сортировка - Console.WriteLine("\n\nBefore quick sort:"); - foreach (var item in array) Console.Write(item + " "); - QuickSort(array, 0, array.Length - 1); - Console.WriteLine("\n\nAfter quick sort:"); - foreach (var item in array) Console.Write(item + " "); - - // Использование Очереди - Queue queue = new Queue(5); - queue.Enqueue(10); - queue.Enqueue(20); - queue.Dequeue(); - } -} \ No newline at end of file diff --git a/LAB01/LAB01.sln b/LAB01/LAB01.sln deleted file mode 100644 index f4800cf..0000000 --- a/LAB01/LAB01.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34525.116 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LAB01", "LAB01\LAB01.csproj", "{34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}.Debug|Any CPU.Build.0 = Debug|Any CPU - {34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}.Release|Any CPU.ActiveCfg = Release|Any CPU - {34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {70E24174-2A6E-49F3-92B6-8C86A8B8C4EF} - EndGlobalSection -EndGlobal diff --git a/LAB01/LAB01/Form1.Designer.cs b/LAB01/LAB01/Form1.Designer.cs deleted file mode 100644 index 4748214..0000000 --- a/LAB01/LAB01/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace LAB01 -{ - partial class Form1 - { - /// - /// 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() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/LAB01/LAB01/Form1.cs b/LAB01/LAB01/Form1.cs deleted file mode 100644 index b65a46d..0000000 --- a/LAB01/LAB01/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace LAB01 -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/LAB01/LAB01/Form1.resx b/LAB01/LAB01/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/LAB01/LAB01/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/LAB01/LAB01/LAB01.csproj b/LAB01/LAB01/LAB01.csproj deleted file mode 100644 index 2150e37..0000000 --- a/LAB01/LAB01/LAB01.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/LAB01/LAB01/Program.cs b/LAB01/LAB01/Program.cs deleted file mode 100644 index c38d06e..0000000 --- a/LAB01/LAB01/Program.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; - -// Структура данных для комплектующих компьютера -public class ComputerComponent -{ - public string Name { get; set; } - public string Type { get; set; } - // Другие характеристики компонента - - public ComputerComponent(string name, string type) - { - Name = name; - Type = type; - } -} - -// Класс для проверки совместимости компонентов в сборке -public class CompatibilityChecker -{ - public bool CheckCompatibility(List components) - { - // Логика проверки совместимости компонентов - foreach (var component in components) - { - // Проверка совместимости - if (component.Type == "CPU" && components.Exists(c => c.Type == "Motherboard")) - { - // Логика проверки совместимости процессора и материнской платы - Console.WriteLine($"Процессор {component.Name} совместим с материнской платой."); - } - // Другие логические проверки - - } - Console.WriteLine("Проверка совместимости завершена."); - return true; // или false в зависимости от результата проверки - } -} - -// Пример использования -class Program -{ - static void Main() - { - var components = new List - { - new ComputerComponent("Intel Core i7", "CPU"), - new ComputerComponent("MSI Z390 Gaming Pro", "Motherboard"), - // Другие компоненты - }; - - var checker = new CompatibilityChecker(); - checker.CheckCompatibility(components); - } -} diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/CollectionType.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/CollectionType.cs new file mode 100644 index 0000000..eb3ec09 --- /dev/null +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/CollectionType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectMotorboat.CollectionGenericObjects; + +public enum CollectionType +{ + + None = 0, + Massive = 1, + List = 2 +} diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs new file mode 100644 index 0000000..9310c0f --- /dev/null +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectMotorboat.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 || position < 0) return null; + return _collection[position]; + } + + 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? pos = _collection[position]; + _collection.RemoveAt(position); + return pos; + } +} \ No newline at end of file diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs new file mode 100644 index 0000000..f8c08a8 --- /dev/null +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectMotorboat.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]; + } + } +} \ No newline at end of file diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs index 6a44c48..b53da45 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs @@ -29,97 +29,213 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); - buttonRefresh = new Button(); - buttonGoToCheck = new Button(); - buttonDelBoat = new Button(); - maskedTextBox = new MaskedTextBox(); - buttonAddMotorboat = new Button(); + panelCompanyTools = new Panel(); buttonAddBoat = new Button(); + buttonAddMotorboat = new Button(); + maskedTextBox = new MaskedTextBox(); + buttonRefresh = new Button(); + buttonDelBoat = new Button(); + buttonGoToCheck = 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(); + panelCompanyTools.SuspendLayout(); + panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); SuspendLayout(); // // groupBoxTools // - groupBoxTools.Controls.Add(buttonRefresh); - groupBoxTools.Controls.Add(buttonGoToCheck); - groupBoxTools.Controls.Add(buttonDelBoat); - groupBoxTools.Controls.Add(maskedTextBox); - groupBoxTools.Controls.Add(buttonAddMotorboat); - groupBoxTools.Controls.Add(buttonAddBoat); + groupBoxTools.Controls.Add(panelCompanyTools); + groupBoxTools.Controls.Add(buttonCreateCompany); + groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(821, 0); + groupBoxTools.Location = new Point(1027, 0); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(231, 569); + groupBoxTools.Size = new Size(231, 746); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // - // buttonRefresh + // panelCompanyTools // - buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(20, 488); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(199, 54); - buttonRefresh.TabIndex = 6; - buttonRefresh.Text = "Обновить"; - buttonRefresh.UseVisualStyleBackColor = true; + panelCompanyTools.Controls.Add(buttonAddBoat); + panelCompanyTools.Controls.Add(buttonAddMotorboat); + panelCompanyTools.Controls.Add(maskedTextBox); + panelCompanyTools.Controls.Add(buttonRefresh); + panelCompanyTools.Controls.Add(buttonDelBoat); + panelCompanyTools.Controls.Add(buttonGoToCheck); + panelCompanyTools.Dock = DockStyle.Bottom; + panelCompanyTools.Enabled = false; + panelCompanyTools.Location = new Point(3, 418); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(225, 325); + panelCompanyTools.TabIndex = 7; // - // buttonGoToCheck + // buttonAddBoat // - buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(20, 365); - buttonGoToCheck.Name = "buttonGoToCheck"; - buttonGoToCheck.Size = new Size(199, 54); - buttonGoToCheck.TabIndex = 5; - buttonGoToCheck.Text = "Передать на тесты"; - buttonGoToCheck.UseVisualStyleBackColor = true; - buttonGoToCheck.Click += ButtonGoToCheck_Click; - // - // buttonDelBoat - // - buttonDelBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonDelBoat.Location = new Point(20, 272); - buttonDelBoat.Name = "buttonDelBoat"; - buttonDelBoat.Size = new Size(199, 54); - buttonDelBoat.TabIndex = 4; - buttonDelBoat.Text = "удалить лодку"; - buttonDelBoat.UseVisualStyleBackColor = true; - buttonDelBoat.Click += ButtonRemoveBoat_Click; - // - // maskedTextBox - // - maskedTextBox.Location = new Point(20, 239); - maskedTextBox.Mask = "00"; - maskedTextBox.Name = "maskedTextBox"; - maskedTextBox.Size = new Size(199, 27); - maskedTextBox.TabIndex = 3; - maskedTextBox.ValidatingType = typeof(int); + buttonAddBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddBoat.Location = new Point(3, 3); + buttonAddBoat.Name = "buttonAddBoat"; + buttonAddBoat.Size = new Size(219, 54); + buttonAddBoat.TabIndex = 1; + buttonAddBoat.Text = "Добавление лодки"; + buttonAddBoat.UseVisualStyleBackColor = true; + buttonAddBoat.Click += ButtonAddBoat_Click; // // buttonAddMotorboat // buttonAddMotorboat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddMotorboat.Location = new Point(20, 130); + buttonAddMotorboat.Location = new Point(6, 63); buttonAddMotorboat.Name = "buttonAddMotorboat"; - buttonAddMotorboat.Size = new Size(199, 54); + buttonAddMotorboat.Size = new Size(216, 54); buttonAddMotorboat.TabIndex = 2; buttonAddMotorboat.Text = "Добавление моторной лодки"; buttonAddMotorboat.UseVisualStyleBackColor = true; buttonAddMotorboat.Click += ButtonMotorboat_Click; // - // buttonAddBoat + // maskedTextBox // - buttonAddBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddBoat.Location = new Point(20, 70); - buttonAddBoat.Name = "buttonAddBoat"; - buttonAddBoat.Size = new Size(199, 54); - buttonAddBoat.TabIndex = 1; - buttonAddBoat.Text = "Добавление лодки"; - buttonAddBoat.UseVisualStyleBackColor = true; - buttonAddBoat.Click += ButtonAddBoat_Click; + maskedTextBox.Location = new Point(3, 123); + maskedTextBox.Mask = "00"; + maskedTextBox.Name = "maskedTextBox"; + maskedTextBox.Size = new Size(219, 27); + maskedTextBox.TabIndex = 3; + maskedTextBox.ValidatingType = typeof(int); + // + // buttonRefresh + // + buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRefresh.Location = new Point(3, 276); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(219, 54); + buttonRefresh.TabIndex = 6; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRefresh_Click; + // + // buttonDelBoat + // + buttonDelBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonDelBoat.Location = new Point(3, 156); + buttonDelBoat.Name = "buttonDelBoat"; + buttonDelBoat.Size = new Size(222, 54); + buttonDelBoat.TabIndex = 4; + buttonDelBoat.Text = "удалить лодку"; + buttonDelBoat.UseVisualStyleBackColor = true; + buttonDelBoat.Click += ButtonRemoveBoat_Click; + // + // buttonGoToCheck + // + buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonGoToCheck.Location = new Point(3, 216); + buttonGoToCheck.Name = "buttonGoToCheck"; + buttonGoToCheck.Size = new Size(219, 54); + buttonGoToCheck.TabIndex = 5; + buttonGoToCheck.Text = "Передать на тесты"; + buttonGoToCheck.UseVisualStyleBackColor = true; + buttonGoToCheck.Click += ButtonGoToCheck_Click; + // + // buttonCreateCompany + // + buttonCreateCompany.Location = new Point(6, 383); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(222, 29); + buttonCreateCompany.TabIndex = 8; + buttonCreateCompany.Text = "Создать компанию"; + buttonCreateCompany.UseVisualStyleBackColor = true; + buttonCreateCompany.Click += ButtonCreateCompany_Click; + // + // panelStorage + // + 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, 23); + panelStorage.Name = "panelStorage"; + panelStorage.Size = new Size(225, 320); + panelStorage.TabIndex = 7; + // + // buttonCollectionDel + // + buttonCollectionDel.Location = new Point(0, 251); + buttonCollectionDel.Name = "buttonCollectionDel"; + buttonCollectionDel.Size = new Size(222, 29); + buttonCollectionDel.TabIndex = 6; + buttonCollectionDel.Text = "Удалить коллекцию"; + buttonCollectionDel.UseVisualStyleBackColor = true; + buttonCollectionDel.Click += ButtonCollectionDel_Click; + // + // listBoxCollection + // + listBoxCollection.FormattingEnabled = true; + listBoxCollection.Location = new Point(3, 141); + listBoxCollection.Name = "listBoxCollection"; + listBoxCollection.Size = new Size(213, 104); + listBoxCollection.TabIndex = 5; + // + // buttonCollectionAdd + // + buttonCollectionAdd.Location = new Point(3, 106); + buttonCollectionAdd.Name = "buttonCollectionAdd"; + buttonCollectionAdd.Size = new Size(222, 29); + buttonCollectionAdd.TabIndex = 4; + buttonCollectionAdd.Text = "Добавить коллекцию"; + buttonCollectionAdd.UseVisualStyleBackColor = true; + buttonCollectionAdd.Click += ButtonCollectionAdd_Click; + // + // radioButtonList + // + radioButtonList.AutoSize = true; + radioButtonList.Location = new Point(121, 76); + radioButtonList.Name = "radioButtonList"; + radioButtonList.Size = new Size(80, 24); + radioButtonList.TabIndex = 3; + radioButtonList.TabStop = true; + radioButtonList.Text = "Список"; + radioButtonList.UseVisualStyleBackColor = true; + // + // radioButtonMassive + // + radioButtonMassive.AutoSize = true; + radioButtonMassive.Location = new Point(13, 76); + radioButtonMassive.Name = "radioButtonMassive"; + radioButtonMassive.Size = new Size(82, 24); + radioButtonMassive.TabIndex = 2; + radioButtonMassive.TabStop = true; + radioButtonMassive.Text = "Массив"; + radioButtonMassive.UseVisualStyleBackColor = true; + // + // textBoxCollectionName + // + textBoxCollectionName.Location = new Point(3, 43); + textBoxCollectionName.Name = "textBoxCollectionName"; + textBoxCollectionName.Size = new Size(219, 27); + textBoxCollectionName.TabIndex = 1; + // + // labelCollectionName + // + labelCollectionName.AutoSize = true; + labelCollectionName.Location = new Point(43, 20); + labelCollectionName.Name = "labelCollectionName"; + labelCollectionName.Size = new Size(158, 20); + labelCollectionName.TabIndex = 0; + labelCollectionName.Text = "Название коллекции:"; // // comboBoxSelectorCompany // @@ -127,9 +243,9 @@ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.FormattingEnabled = true; comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - comboBoxSelectorCompany.Location = new Point(20, 36); + comboBoxSelectorCompany.Location = new Point(6, 349); comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; - comboBoxSelectorCompany.Size = new Size(199, 28); + comboBoxSelectorCompany.Size = new Size(213, 28); comboBoxSelectorCompany.TabIndex = 0; comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged; // @@ -138,7 +254,7 @@ pictureBox.Dock = DockStyle.Fill; pictureBox.Location = new Point(0, 0); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(821, 569); + pictureBox.Size = new Size(1027, 746); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // @@ -146,13 +262,16 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1052, 569); + ClientSize = new Size(1258, 746); Controls.Add(pictureBox); Controls.Add(groupBoxTools); Name = "FormBoatCollection"; Text = "Коллекция лодок"; groupBoxTools.ResumeLayout(false); - groupBoxTools.PerformLayout(); + panelCompanyTools.ResumeLayout(false); + panelCompanyTools.PerformLayout(); + panelStorage.ResumeLayout(false); + panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); ResumeLayout(false); } @@ -168,5 +287,15 @@ private Button buttonDelBoat; private Button buttonGoToCheck; private Button buttonRefresh; + private Panel panelStorage; + private Label labelCollectionName; + private TextBox textBoxCollectionName; + private RadioButton radioButtonList; + private RadioButton radioButtonMassive; + private Button buttonCollectionAdd; + private ListBox listBoxCollection; + private Button buttonCollectionDel; + private Button buttonCreateCompany; + private Panel panelCompanyTools; } } \ No newline at end of file diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs index aecf8ae..ca56212 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs @@ -1,8 +1,5 @@ using ProjectMotorboat.CollectionGenericObjects; using ProjectMotorboat.Drownings; -using ProjectMotorboat.CollectionGenericObjects; -using ProjectMotorboat.Drownings; -using System.Windows.Forms; namespace ProjectMotorboat; @@ -10,7 +7,9 @@ namespace ProjectMotorboat; /// Форма работы с компанией и ее коллекцией /// public partial class FormBoatCollection : Form -{ +{ + private readonly StorageCollection _storageCollection; + /// /// Компания /// @@ -22,6 +21,7 @@ public partial class FormBoatCollection : Form public FormBoatCollection() { InitializeComponent(); + _storageCollection = new(); } /// @@ -31,12 +31,7 @@ public partial class FormBoatCollection : Form /// private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) { - switch (comboBoxSelectorCompany.Text) - { - case "Хранилище": - _company = new HarborService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); - break; - } + panelCompanyTools.Enabled = false; } /// @@ -187,4 +182,80 @@ public partial class FormBoatCollection : 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); + RerfreshListBoxItems(); + } + + private void ButtonCollectionDel_Click(object sender, EventArgs e) + { + if (listBoxCollection.SelectedItem == null) + { + MessageBox.Show("Коллекция не выбрана"); + return; + } + if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) + { + return; + } + _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); + RerfreshListBoxItems(); + } + + 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 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 HarborService(pictureBox.Width, pictureBox.Height, collection); + break; + } + + panelCompanyTools.Enabled = true; + RerfreshListBoxItems(); + } } \ No newline at end of file diff --git a/WinFormsApp1/WinFormsApp1.sln b/WinFormsApp1/WinFormsApp1.sln deleted file mode 100644 index cc16879..0000000 --- a/WinFormsApp1/WinFormsApp1.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34525.116 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsApp1", "WinFormsApp1\WinFormsApp1.csproj", "{50092433-6AF5-4E71-9559-079AE2F9901A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {50092433-6AF5-4E71-9559-079AE2F9901A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {50092433-6AF5-4E71-9559-079AE2F9901A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {50092433-6AF5-4E71-9559-079AE2F9901A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {50092433-6AF5-4E71-9559-079AE2F9901A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {59C3FED6-0E53-4AF0-9E1B-5ACF902ED5CE} - EndGlobalSection -EndGlobal diff --git a/WinFormsApp1/WinFormsApp1/Form1.Designer.cs b/WinFormsApp1/WinFormsApp1/Form1.Designer.cs deleted file mode 100644 index 1ac166c..0000000 --- a/WinFormsApp1/WinFormsApp1/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace WinFormsApp1 -{ - partial class Form1 - { - /// - /// 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() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/WinFormsApp1/WinFormsApp1/Form1.cs b/WinFormsApp1/WinFormsApp1/Form1.cs deleted file mode 100644 index dabe0d0..0000000 --- a/WinFormsApp1/WinFormsApp1/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace WinFormsApp1 -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/WinFormsApp1/WinFormsApp1/Form1.resx b/WinFormsApp1/WinFormsApp1/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/WinFormsApp1/WinFormsApp1/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/WinFormsApp1/WinFormsApp1/Program.cs b/WinFormsApp1/WinFormsApp1/Program.cs deleted file mode 100644 index 1e39c2a..0000000 --- a/WinFormsApp1/WinFormsApp1/Program.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace WinFormsApp1 -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); - } - } -} \ No newline at end of file diff --git a/WinFormsApp1/WinFormsApp1/WinFormsApp1.csproj b/WinFormsApp1/WinFormsApp1/WinFormsApp1.csproj deleted file mode 100644 index 663fdb8..0000000 --- a/WinFormsApp1/WinFormsApp1/WinFormsApp1.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - WinExe - net8.0-windows - enable - true - enable - - - \ No newline at end of file