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/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/BoatDelegate.cs b/ProjectMotorboat/ProjectMotorboat/BoatDelegate.cs new file mode 100644 index 0000000..d7c5e5d --- /dev/null +++ b/ProjectMotorboat/ProjectMotorboat/BoatDelegate.cs @@ -0,0 +1,10 @@ +using ProjectMotorboat.Drownings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectMotorboat; + +public delegate void BoatDelegate(DrawningBoat car); \ No newline at end of file diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs index f8c08a8..4f3a336 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs @@ -9,14 +9,9 @@ namespace ProjectMotorboat.CollectionGenericObjects; public class StorageCollection where T : class { - /// - /// Словарь (хранилище) с коллекциями - /// + readonly Dictionary> _storages; - /// - /// Возвращение списка названий коллекций - /// public List Keys => _storages.Keys.ToList(); public StorageCollection() @@ -24,11 +19,7 @@ public class StorageCollection _storages = new Dictionary>(); } - /// - /// Добавление коллекции в хранилище - /// - /// Название коллекции - /// тип коллекции + public void AddCollection(string name, CollectionType collectionType) { // TODO проверка, что name не пустой и нет в словаре записи с таким ключом @@ -48,10 +39,7 @@ public class StorageCollection } } - /// - /// Удаление коллекции - /// - /// Название коллекции + public void DelCollection(string name) { // TODO Прописать логику для удаления коллекции @@ -59,11 +47,7 @@ public class StorageCollection _storages.Remove(name); } - /// - /// Доступ к коллекции - /// - /// Название коллекции - /// + public ICollectionGenericObjects? this[string name] { get diff --git a/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs b/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs index 5c2de74..73e61fe 100644 --- a/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs +++ b/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs @@ -13,6 +13,11 @@ public class EntityBoat public double Weight { get; private set; } public Color BodyColor { get; private set; } + + public void SetBodyColor(Color color) + { + BodyColor = color; + } public double Step => Speed * 100 / Weight; public EntityBoat(int speed, double weight, Color bodyColor) diff --git a/ProjectMotorboat/ProjectMotorboat/Entities/EntityMotorboat.cs b/ProjectMotorboat/ProjectMotorboat/Entities/EntityMotorboat.cs index 3e3e176..3632655 100644 --- a/ProjectMotorboat/ProjectMotorboat/Entities/EntityMotorboat.cs +++ b/ProjectMotorboat/ProjectMotorboat/Entities/EntityMotorboat.cs @@ -4,6 +4,11 @@ public class EntityMotorboat : EntityBoat { public Color AdditionalColor { get; private set; } + public void SetAdditionalColor(Color color) + { + AdditionalColor = color; + } + public bool Motor { get; private set; } public bool Glass { get; private set; } diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs index b53da45..f0eb980 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs @@ -31,7 +31,6 @@ groupBoxTools = new GroupBox(); panelCompanyTools = new Panel(); buttonAddBoat = new Button(); - buttonAddMotorboat = new Button(); maskedTextBox = new MaskedTextBox(); buttonRefresh = new Button(); buttonDelBoat = new Button(); @@ -70,7 +69,6 @@ // panelCompanyTools // panelCompanyTools.Controls.Add(buttonAddBoat); - panelCompanyTools.Controls.Add(buttonAddMotorboat); panelCompanyTools.Controls.Add(maskedTextBox); panelCompanyTools.Controls.Add(buttonRefresh); panelCompanyTools.Controls.Add(buttonDelBoat); @@ -93,17 +91,6 @@ buttonAddBoat.UseVisualStyleBackColor = true; buttonAddBoat.Click += ButtonAddBoat_Click; // - // buttonAddMotorboat - // - buttonAddMotorboat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddMotorboat.Location = new Point(6, 63); - buttonAddMotorboat.Name = "buttonAddMotorboat"; - buttonAddMotorboat.Size = new Size(216, 54); - buttonAddMotorboat.TabIndex = 2; - buttonAddMotorboat.Text = "Добавление моторной лодки"; - buttonAddMotorboat.UseVisualStyleBackColor = true; - buttonAddMotorboat.Click += ButtonMotorboat_Click; - // // maskedTextBox // maskedTextBox.Location = new Point(3, 123); @@ -282,7 +269,6 @@ private Button buttonAddBoat; private ComboBox comboBoxSelectorCompany; private MaskedTextBox maskedTextBox; - private Button buttonAddMotorboat; private PictureBox pictureBox; private Button buttonDelBoat; private Button buttonGoToCheck; diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs index ca56212..e894fa7 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs @@ -39,43 +39,22 @@ public partial class FormBoatCollection : Form /// /// /// - private void ButtonAddBoat_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBoat)); - - /// - /// Добавление спортивного автомобиля - /// - /// - /// - private void ButtonMotorboat_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningMotorboat)); - - /// - /// Создание объекта класса-перемещения - /// - /// Тип создаваемого объекта - private void CreateObject(string type) + private void ButtonAddBoat_Click(object sender, EventArgs e) { + FormBoatConfig form = new(); + // TODO передать метод + form.AddEvent(SetBoat); - if (_company == null) + form.Show(); + } + private void SetBoat(DrawningBoat? boat) + { + if (_company == null || boat == null) { return; } - Random random = new(); - DrawningBoat drawningBoat; - switch (type) - { - case nameof(DrawningBoat): - drawningBoat = new DrawningBoat(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); - break; - case nameof(DrawningMotorboat): - drawningBoat = new DrawningMotorboat(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), - GetColor(random), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); - break; - default: - return; - } - - if (_company + drawningBoat != -1) + if (_company + boat != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); @@ -84,24 +63,15 @@ public partial class FormBoatCollection : Form { MessageBox.Show("Не удалось добавить объект"); } + } + + /// - /// Получение цвета + /// Создание объекта класса-перемещения /// - /// Генератор случайных чисел - /// - private static Color GetColor(Random random) - { - Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); - ColorDialog dialog = new(); - if (dialog.ShowDialog() == DialogResult.OK) - { - color = dialog.Color; - } - - return color; - } + /// Тип создаваемого объекта /// /// Удаление объекта diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.Designer.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.Designer.cs new file mode 100644 index 0000000..23a9782 --- /dev/null +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.Designer.cs @@ -0,0 +1,357 @@ +namespace ProjectMotorboat +{ + partial class FormBoatConfig + { + /// + /// 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() + { + groupBoxConfig = new GroupBox(); + groupBoxColors = new GroupBox(); + panelPurple = new Panel(); + panelYellow = new Panel(); + panelBlack = new Panel(); + panelGray = new Panel(); + panelBlue = new Panel(); + panelWhite = new Panel(); + panelGreen = new Panel(); + panelRed = new Panel(); + checkBoxGlass = new CheckBox(); + checkBoxMotor = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + labelWeight = new Label(); + numericUpDownSpeed = new NumericUpDown(); + labelSpeed = new Label(); + labelModifiedObject = new Label(); + labelSimpleObject = new Label(); + pictureBoxObject = new PictureBox(); + buttonAdd = new Button(); + buttonCancel = new Button(); + panelObject = new Panel(); + labelAdditionalColor = new Label(); + labelBodyColor = new Label(); + groupBoxConfig.SuspendLayout(); + groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + panelObject.SuspendLayout(); + SuspendLayout(); + // + // groupBoxConfig + // + groupBoxConfig.Controls.Add(groupBoxColors); + groupBoxConfig.Controls.Add(checkBoxGlass); + groupBoxConfig.Controls.Add(checkBoxMotor); + groupBoxConfig.Controls.Add(numericUpDownWeight); + groupBoxConfig.Controls.Add(labelWeight); + groupBoxConfig.Controls.Add(numericUpDownSpeed); + groupBoxConfig.Controls.Add(labelSpeed); + groupBoxConfig.Controls.Add(labelModifiedObject); + groupBoxConfig.Controls.Add(labelSimpleObject); + groupBoxConfig.Dock = DockStyle.Left; + groupBoxConfig.Location = new Point(0, 0); + groupBoxConfig.Name = "groupBoxConfig"; + groupBoxConfig.Size = new Size(491, 255); + groupBoxConfig.TabIndex = 0; + groupBoxConfig.TabStop = false; + groupBoxConfig.Text = "Параметры"; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelPurple); + groupBoxColors.Controls.Add(panelYellow); + groupBoxColors.Controls.Add(panelBlack); + groupBoxColors.Controls.Add(panelGray); + groupBoxColors.Controls.Add(panelBlue); + groupBoxColors.Controls.Add(panelWhite); + groupBoxColors.Controls.Add(panelGreen); + groupBoxColors.Controls.Add(panelRed); + groupBoxColors.Location = new Point(227, 26); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Size = new Size(252, 133); + groupBoxColors.TabIndex = 8; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "Цвета"; + // + // panelPurple + // + panelPurple.BackColor = Color.Purple; + panelPurple.Location = new Point(195, 83); + panelPurple.Name = "panelPurple"; + panelPurple.Size = new Size(38, 32); + panelPurple.TabIndex = 3; + // + // panelYellow + // + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(195, 26); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(38, 32); + panelYellow.TabIndex = 1; + // + // panelBlack + // + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(134, 83); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(38, 32); + panelBlack.TabIndex = 4; + // + // panelGray + // + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(73, 83); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(38, 32); + panelGray.TabIndex = 5; + // + // panelBlue + // + panelBlue.BackColor = Color.Blue; + panelBlue.Location = new Point(134, 26); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(38, 32); + panelBlue.TabIndex = 1; + // + // panelWhite + // + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(12, 83); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(38, 32); + panelWhite.TabIndex = 2; + // + // panelGreen + // + panelGreen.BackColor = Color.Green; + panelGreen.Location = new Point(73, 26); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(38, 32); + panelGreen.TabIndex = 1; + // + // panelRed + // + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(12, 26); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(38, 32); + panelRed.TabIndex = 0; + // + // checkBoxGlass + // + checkBoxGlass.AutoSize = true; + checkBoxGlass.Location = new Point(6, 199); + checkBoxGlass.Name = "checkBoxGlass"; + checkBoxGlass.Size = new Size(202, 24); + checkBoxGlass.TabIndex = 7; + checkBoxGlass.Text = "Признак наличия стекла"; + checkBoxGlass.UseVisualStyleBackColor = true; + // + // checkBoxMotor + // + checkBoxMotor.AutoSize = true; + checkBoxMotor.Location = new Point(6, 171); + checkBoxMotor.Name = "checkBoxMotor"; + checkBoxMotor.Size = new Size(210, 24); + checkBoxMotor.TabIndex = 6; + checkBoxMotor.Text = "Признак наличия мотора"; + checkBoxMotor.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(84, 64); + numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDownWeight.Name = "numericUpDownWeight"; + numericUpDownWeight.Size = new Size(88, 27); + numericUpDownWeight.TabIndex = 5; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelWeight + // + labelWeight.AutoSize = true; + labelWeight.Location = new Point(6, 66); + labelWeight.Name = "labelWeight"; + labelWeight.Size = new Size(36, 20); + labelWeight.TabIndex = 4; + labelWeight.Text = "Вес:"; + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(84, 33); + numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDownSpeed.Name = "numericUpDownSpeed"; + numericUpDownSpeed.Size = new Size(88, 27); + numericUpDownSpeed.TabIndex = 3; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(6, 33); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(76, 20); + labelSpeed.TabIndex = 2; + labelSpeed.Text = "Скорость:"; + // + // labelModifiedObject + // + labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; + labelModifiedObject.Location = new Point(362, 179); + labelModifiedObject.Name = "labelModifiedObject"; + labelModifiedObject.Size = new Size(117, 44); + labelModifiedObject.TabIndex = 1; + labelModifiedObject.Text = "Продвинутый"; + labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + labelModifiedObject.MouseDown += LabelObject_MouseDown; + // + // labelSimpleObject + // + labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; + labelSimpleObject.Location = new Point(227, 179); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(123, 44); + labelSimpleObject.TabIndex = 0; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.MouseDown += LabelObject_MouseDown; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(30, 66); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(179, 140); + pictureBoxObject.TabIndex = 1; + pictureBoxObject.TabStop = false; + // + // buttonAdd + // + buttonAdd.Location = new Point(518, 214); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(94, 29); + buttonAdd.TabIndex = 2; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(680, 214); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // panelObject + // + panelObject.AllowDrop = true; + panelObject.Controls.Add(labelAdditionalColor); + panelObject.Controls.Add(labelBodyColor); + panelObject.Controls.Add(pictureBoxObject); + panelObject.Location = new Point(518, 0); + panelObject.Name = "panelObject"; + panelObject.Size = new Size(256, 208); + panelObject.TabIndex = 4; + panelObject.DragDrop += PanelObject_DragDrop; + panelObject.DragEnter += PanelObject_DragEnter; + // + // labelAdditionalColor + // + labelAdditionalColor.AllowDrop = true; + labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; + labelAdditionalColor.Location = new Point(144, 9); + labelAdditionalColor.Name = "labelAdditionalColor"; + labelAdditionalColor.Size = new Size(94, 29); + labelAdditionalColor.TabIndex = 3; + labelAdditionalColor.Text = "Доп. цвет"; + labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; + labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop; + labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter; + // + // labelBodyColor + // + labelBodyColor.AllowDrop = true; + labelBodyColor.BorderStyle = BorderStyle.FixedSingle; + labelBodyColor.Location = new Point(14, 9); + labelBodyColor.Name = "labelBodyColor"; + labelBodyColor.Size = new Size(94, 29); + labelBodyColor.TabIndex = 2; + labelBodyColor.Text = "Цвет"; + labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; + labelBodyColor.DragDrop += LabelBodyColor_DragDrop; + labelBodyColor.DragEnter += LabelBodyColor_DragEnter; + // + // FormBoatConfig + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(811, 255); + Controls.Add(panelObject); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(groupBoxConfig); + Name = "FormBoatConfig"; + Text = "Создание объекта"; + groupBoxConfig.ResumeLayout(false); + groupBoxConfig.PerformLayout(); + groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit(); + panelObject.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxConfig; + private Label labelSimpleObject; + private Label labelModifiedObject; + private Label labelWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelSpeed; + private NumericUpDown numericUpDownWeight; + private CheckBox checkBoxMotor; + private CheckBox checkBoxGlass; + private GroupBox groupBoxColors; + private Panel panelYellow; + private Panel panelBlue; + private Panel panelGreen; + private Panel panelRed; + private Panel panelPurple; + private Panel panelBlack; + private Panel panelGray; + private Panel panelWhite; + private PictureBox pictureBoxObject; + private Button buttonAdd; + private Button buttonCancel; + private Panel panelObject; + private Label labelAdditionalColor; + private Label labelBodyColor; + } +} \ No newline at end of file diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs new file mode 100644 index 0000000..cdcba04 --- /dev/null +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs @@ -0,0 +1,154 @@ +using ProjectMotorboat.Drownings; +using ProjectMotorboat.Entities; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectMotorboat +{ + public partial class FormBoatConfig : Form + { + private DrawningBoat? _boat; + + private event Action? BoatDelegate; + public FormBoatConfig() + { + InitializeComponent(); + panelRed.MouseDown += Panel_MouseDown; + panelGreen.MouseDown += Panel_MouseDown; + panelBlue.MouseDown += Panel_MouseDown; + panelYellow.MouseDown += Panel_MouseDown; + panelWhite.MouseDown += Panel_MouseDown; + panelGray.MouseDown += Panel_MouseDown; + panelBlack.MouseDown += Panel_MouseDown; + panelPurple.MouseDown += Panel_MouseDown; + + buttonCancel.Click += (sender, e) => Close(); + } + + public void AddEvent(Action boatDelegate) + { + if (BoatDelegate != null) + { + BoatDelegate = boatDelegate; + } + else + { + BoatDelegate += boatDelegate; + } + } + + private void DrawObject() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _boat?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); + _boat?.SetPosition(15, 15); + _boat?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void PanelObject_DragEnter(object sender, DragEventArgs e) + { + e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None; + } + + private void PanelObject_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text)?.ToString()) + { + case "labelSimpleObject": + _boat = new DrawningBoat((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _boat = new DrawningMotorboat((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, + Color.Black, checkBoxMotor.Checked, checkBoxGlass.Checked); + break; + } + DrawObject(); + } + + private void Panel_MouseDown(object? sender, MouseEventArgs e) + { + // TODO отправка цвета в Drag&Drop + (sender as Control)?.DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + + } + // Логика смены цветов: основного и дополнительного (для продвинутого объекта) + private void LabelBodyColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(typeof(Color)) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + + private void LabelBodyColor_DragDrop(object sender, DragEventArgs e) + { + if (_boat != null) + { + if (e.Data?.GetDataPresent(typeof(Color)) ?? false) + { + _boat.EntityBoat.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + + } + DrawObject(); + } + } + private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e) + { + if (_boat != null && _boat is DrawningMotorboat) + { + if (e.Data?.GetDataPresent(typeof(Color)) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + } + + private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e) + { + if (_boat != null && _boat.EntityBoat is EntityMotorboat _battleship) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + _battleship.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); + + } + DrawObject(); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + + if (_boat != null) + { + BoatDelegate?.Invoke(_boat); + Close(); + } + + } + } + +} diff --git a/LAB01/LAB01/Form1.resx b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.resx similarity index 93% rename from LAB01/LAB01/Form1.resx rename to ProjectMotorboat/ProjectMotorboat/FormBoatConfig.resx index 1af7de1..af32865 100644 --- a/LAB01/LAB01/Form1.resx +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.resx @@ -1,17 +1,17 @@  - 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