diff --git a/AiSD Lab02/AiSD Lab02.sln b/AiSD Lab02/AiSD Lab02.sln new file mode 100644 index 0000000..a6557e6 --- /dev/null +++ b/AiSD Lab02/AiSD Lab02.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AiSD_Lab02", "AiSD Lab02\AiSD_Lab02.csproj", "{FA17B31D-8779-415E-B3A9-140812864D38}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FA17B31D-8779-415E-B3A9-140812864D38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA17B31D-8779-415E-B3A9-140812864D38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA17B31D-8779-415E-B3A9-140812864D38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA17B31D-8779-415E-B3A9-140812864D38}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {268E47D2-9C2D-4863-BCE2-130796952BAF} + EndGlobalSection +EndGlobal diff --git a/AiSD Lab02/AiSD Lab02/AiSD_Lab02.csproj b/AiSD Lab02/AiSD Lab02/AiSD_Lab02.csproj new file mode 100644 index 0000000..548f22a --- /dev/null +++ b/AiSD Lab02/AiSD Lab02/AiSD_Lab02.csproj @@ -0,0 +1,55 @@ + + + + + Debug + AnyCPU + {FA17B31D-8779-415E-B3A9-140812864D38} + Exe + AiSD_Lab02 + AiSD Lab02 + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AiSD Lab02/AiSD Lab02/App.config b/AiSD Lab02/AiSD Lab02/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/AiSD Lab02/AiSD Lab02/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/AiSD Lab02/AiSD Lab02/EntityItem.cs b/AiSD Lab02/AiSD Lab02/EntityItem.cs new file mode 100644 index 0000000..5697b6c --- /dev/null +++ b/AiSD Lab02/AiSD Lab02/EntityItem.cs @@ -0,0 +1,7 @@ +namespace AiSD_Lab02; +public class EntityItem +{ + public int Weight { get; set; } + public int Value { get; set; } + +} diff --git a/AiSD Lab02/AiSD Lab02/FibNums.cs b/AiSD Lab02/AiSD Lab02/FibNums.cs new file mode 100644 index 0000000..7e93c47 --- /dev/null +++ b/AiSD Lab02/AiSD Lab02/FibNums.cs @@ -0,0 +1,64 @@ +namespace AiSD_Lab02; + +public class FibNums +{ + public int Fib(int num) + { + if (num < 2) return 1; + else return Fib(num - 1) + Fib(num - 2); + } + + public void Merge(int[] array, int lowIndex, int middleIndex, int highIndex) + { + int left = lowIndex; + int right = middleIndex + 1; + int[] tempArray = new int[highIndex - lowIndex + 1]; + int index = 0; + + while ((left <= middleIndex) && (right <= highIndex)) + { + if (array[left] < array[right]) + { + tempArray[index] = array[left]; + left++; + } + else + { + tempArray[index] = array[right]; + right++; + } + + index++; + } + + for (int i = left; i <= middleIndex; i++) + { + tempArray[index] = array[i]; + index++; + } + + for (int i = right; i <= highIndex; i++) + { + tempArray[index] = array[i]; + index++; + } + + for (int i = 0; i < tempArray.Length; i++) + { + array[lowIndex + i] = tempArray[i]; + } + } + + public int[] MergeSort(int[] array, int lowIndex, int highIndex) + { + if (lowIndex < highIndex) + { + int middleInd = (lowIndex + highIndex) / 2; + MergeSort(array, lowIndex, middleInd); + MergeSort(array, middleInd + 1, highIndex); + Merge(array, lowIndex, middleInd, highIndex); + } + + return array; + } +} diff --git a/AiSD Lab02/AiSD Lab02/Program.cs b/AiSD Lab02/AiSD Lab02/Program.cs new file mode 100644 index 0000000..d11e476 --- /dev/null +++ b/AiSD Lab02/AiSD Lab02/Program.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System; + +namespace AiSD_Lab02; +public class Program +{ + public static void Main(string[] args) + { + List items = new List() + { + new EntityItem { Weight = 2, Value = 10 }, + new EntityItem { Weight = 3, Value = 5 }, + new EntityItem { Weight = 5, Value = 15 }, + new EntityItem { Weight = 7, Value = 7 }, + new EntityItem { Weight = 1, Value = 6 } + }; + + int capacity = 10; + + for (int i = 0; i < items.Count - 1; i++) + { + for (int j = 0; j < items.Count - i - 1; j++) + { + double ratio1 = items[j].Value / (double)items[j].Weight; + double ratio2 = items[j + 1].Value / (double)items[j + 1].Weight; + + if (ratio1 < ratio2) + { + EntityItem temp = items[j]; + items[j] = items[j + 1]; + items[j + 1] = temp; + } + } + } + + int totalValue = 0; + int totalWeight = 0; + + foreach (EntityItem item in items) + { + if (totalWeight + item.Weight <= capacity) + { + totalValue += item.Value; + totalWeight += item.Weight; + Console.WriteLine($"Предмет: вес={item.Weight}, значение={item.Value}"); + } + } + + Console.WriteLine($"Суммарное значение: {totalValue}"); + Console.WriteLine($"Суммарный вес: {totalWeight}"); + + FibNums fibNums = new FibNums(); + Console.WriteLine(fibNums.Fib(5)); + } + +} diff --git a/AiSD Lab02/AiSD Lab02/Properties/AssemblyInfo.cs b/AiSD Lab02/AiSD Lab02/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dfbe217 --- /dev/null +++ b/AiSD Lab02/AiSD Lab02/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные с этой сборкой. +[assembly: AssemblyTitle("AiSD Lab02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AiSD Lab02")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// из модели COM задайте для атрибута ComVisible этого типа значение true. +[assembly: ComVisible(false)] + +// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM +[assembly: Guid("fa17b31d-8779-415e-b3a9-140812864d38")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Номер редакции +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AiSD_Lab/AiSD Lab02.sln b/AiSD_Lab/AiSD Lab02.sln new file mode 100644 index 0000000..1db5ae1 --- /dev/null +++ b/AiSD_Lab/AiSD Lab02.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AiSD Lab02", "AiSD Lab02\AiSD Lab02.csproj", "{FA17B31D-8779-415E-B3A9-140812864D38}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FA17B31D-8779-415E-B3A9-140812864D38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA17B31D-8779-415E-B3A9-140812864D38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA17B31D-8779-415E-B3A9-140812864D38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA17B31D-8779-415E-B3A9-140812864D38}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {268E47D2-9C2D-4863-BCE2-130796952BAF} + EndGlobalSection +EndGlobal diff --git a/AiSD_Lab/AiSD Lab02/AiSD_Lab02.csproj b/AiSD_Lab/AiSD Lab02/AiSD_Lab02.csproj new file mode 100644 index 0000000..5e6c43d --- /dev/null +++ b/AiSD_Lab/AiSD Lab02/AiSD_Lab02.csproj @@ -0,0 +1,55 @@ + + + + + Debug + AnyCPU + {FA17B31D-8779-415E-B3A9-140812864D38} + Exe + AiSD_Lab02 + AiSD Lab02 + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AiSD_Lab/AiSD Lab02/App.config b/AiSD_Lab/AiSD Lab02/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/AiSD_Lab/AiSD Lab02/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/AiSD_Lab/AiSD Lab02/EntityItem.cs b/AiSD_Lab/AiSD Lab02/EntityItem.cs new file mode 100644 index 0000000..78144dd --- /dev/null +++ b/AiSD_Lab/AiSD Lab02/EntityItem.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +public class EntityItem +{ + public int Weight { get; set; } + public int Value { get; set; } + + public EntityItem(int weight, int value) + { + Weight = weight; + Value = value; + } +} diff --git a/AiSD_Lab/AiSD Lab02/FibNums.cs b/AiSD_Lab/AiSD Lab02/FibNums.cs new file mode 100644 index 0000000..49de6df --- /dev/null +++ b/AiSD_Lab/AiSD Lab02/FibNums.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AiSD_Lab02 +{ + internal class FibNums + { + } +} diff --git a/AiSD_Lab/AiSD Lab02/Program.cs b/AiSD_Lab/AiSD Lab02/Program.cs new file mode 100644 index 0000000..b1dc6b2 --- /dev/null +++ b/AiSD_Lab/AiSD Lab02/Program.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using System; + +public class Program +{ + public static void Main(string[] args) + { + List items = new List() + { + new EntityItem(2, 10), + new EntityItem(3, 5), + new EntityItem(5, 15), + new EntityItem(7, 7), + new EntityItem(1, 6) + }; + + int capacity = 10; + + List result = FillKnapsack(items, capacity); + + Console.WriteLine("Предмет в рюкзаке:"); + foreach (EntityItem item in result) + { + Console.WriteLine($"Вес: {item.Weight}, Стоимость: {item.Value}"); + } + } +} +} diff --git a/AiSD_Lab/AiSD Lab02/Properties/AssemblyInfo.cs b/AiSD_Lab/AiSD Lab02/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dfbe217 --- /dev/null +++ b/AiSD_Lab/AiSD Lab02/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные с этой сборкой. +[assembly: AssemblyTitle("AiSD Lab02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AiSD Lab02")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// из модели COM задайте для атрибута ComVisible этого типа значение true. +[assembly: ComVisible(false)] + +// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM +[assembly: Guid("fa17b31d-8779-415e-b3a9-140812864d38")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Номер редакции +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AiSD_Lab1/AiSD_Lab1.sln b/AiSD_Lab/AiSD_Lab1.sln similarity index 100% rename from AiSD_Lab1/AiSD_Lab1.sln rename to AiSD_Lab/AiSD_Lab1.sln diff --git a/AiSD_Lab1/AiSD_Lab1/AiSD_Lab1.csproj b/AiSD_Lab/AiSD_Lab1/AiSD_Lab1.csproj similarity index 100% rename from AiSD_Lab1/AiSD_Lab1/AiSD_Lab1.csproj rename to AiSD_Lab/AiSD_Lab1/AiSD_Lab1.csproj diff --git a/AiSD_Lab/AiSD_Lab1/Deque.cs b/AiSD_Lab/AiSD_Lab1/Deque.cs new file mode 100644 index 0000000..fa3275e --- /dev/null +++ b/AiSD_Lab/AiSD_Lab1/Deque.cs @@ -0,0 +1,67 @@ +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace AiSD_Lab1; + +public class Deque +{ + Landmark first; + + public Deque(string data) + { + Landmark newEl = new Landmark(data); + first = newEl; + } + + public void AddFirst(string data) + { + Landmark newEl = new Landmark(data); + newEl.next = first; + first = newEl; + } + + + public Landmark RemoveFirst() + { + Landmark delEl = first; + first = delEl.next; + delEl.next = null; + return delEl; + } + + public void RemoveLast() + { + Landmark delEl = first; + while (delEl.next.next != null) + { + delEl = delEl.next; + } + delEl.next = null; + } + + public void AddLast(string data) + { + Landmark newEl = first; + while (newEl.next != null) + { + newEl = newEl.next; + } + newEl.next = new Landmark(data); + } + + public string GetAll() + { + string Deque = ""; + + Landmark curr = first; + + while (curr.next != null) + { + Deque += " " + curr.data; + curr = curr.next; + } + Deque += " " + curr.data; + + return Deque; + } + +} \ No newline at end of file diff --git a/AiSD_Lab/AiSD_Lab1/Landmark.cs b/AiSD_Lab/AiSD_Lab1/Landmark.cs new file mode 100644 index 0000000..a2a31d0 --- /dev/null +++ b/AiSD_Lab/AiSD_Lab1/Landmark.cs @@ -0,0 +1,12 @@ +namespace AiSD_Lab1; + +public class Landmark +{ + public String data; + public Landmark next; + + public Landmark(String _data) + { + data = _data; + } +} \ No newline at end of file diff --git a/AiSD_Lab/AiSD_Lab1/Program.cs b/AiSD_Lab/AiSD_Lab1/Program.cs new file mode 100644 index 0000000..7456df6 --- /dev/null +++ b/AiSD_Lab/AiSD_Lab1/Program.cs @@ -0,0 +1,27 @@ +using System; + +namespace AiSD_Lab1; + +public class Program +{ + public static void Main(String[] args) + { + Console.WriteLine("Сортировка слиянием"); + Sort sort = new Sort(); + sort.RandomArr(); + sort.PrintArr(); + sort.MergeSort(sort.arr, 0, sort.arr.Length - 1); + sort.PrintArr(); + + Deque deque = new Deque("Статуя свободы"); + Console.WriteLine(deque.GetAll()); + deque.AddFirst("Успенский собор"); + Console.WriteLine(deque.GetAll()); + deque.AddLast("Эйфелева башня"); + Console.WriteLine(deque.GetAll()); + deque.RemoveLast(); + Console.WriteLine(deque.GetAll()); + deque.RemoveFirst(); + Console.WriteLine(deque.GetAll()); + } +} diff --git a/AiSD_Lab1/AiSD_Lab1/Sort.cs b/AiSD_Lab/AiSD_Lab1/Sort.cs similarity index 100% rename from AiSD_Lab1/AiSD_Lab1/Sort.cs rename to AiSD_Lab/AiSD_Lab1/Sort.cs diff --git a/AiSD_Lab1/AiSD_Lab1/Deque.cs b/AiSD_Lab1/AiSD_Lab1/Deque.cs deleted file mode 100644 index 777a6f1..0000000 --- a/AiSD_Lab1/AiSD_Lab1/Deque.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace AiSD_Lab1; - -public class Deque : Node -{ - Node? head; - - Node? tail; - - int count; - - public AddFirst(T node) - { - - } - - public AddLast(T node) - { - - } - - public RemoveFirst() - { - - } - - public RemoveLast() - { - - } -} \ No newline at end of file diff --git a/AiSD_Lab1/AiSD_Lab1/Node.cs b/AiSD_Lab1/AiSD_Lab1/Node.cs deleted file mode 100644 index f3fbda8..0000000 --- a/AiSD_Lab1/AiSD_Lab1/Node.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace AiSD_Lab1; - -public class Node -{ - public Node(T data) - { - Data = data; - } - public T Data { get; set; } - public Node? Next { get; set; } -} \ No newline at end of file diff --git a/AiSD_Lab1/AiSD_Lab1/Program.cs b/AiSD_Lab1/AiSD_Lab1/Program.cs deleted file mode 100644 index 5f28270..0000000 --- a/AiSD_Lab1/AiSD_Lab1/Program.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/ProjectPlane/ProjectPlane/Entities/EntityContainer.cs b/ProjectPlane/ProjectPlane/Entities/EntityContainer.cs index a23e130..09f6381 100644 --- a/ProjectPlane/ProjectPlane/Entities/EntityContainer.cs +++ b/ProjectPlane/ProjectPlane/Entities/EntityContainer.cs @@ -25,4 +25,9 @@ public class EntityContainer : EntityShip Container = container; Crane = crane; } + + public void ContainerColorChange(Color newColor) + { + ContainerColor = newColor; + } } diff --git a/ProjectPlane/ProjectPlane/Entities/EntityShip.cs b/ProjectPlane/ProjectPlane/Entities/EntityShip.cs index 5024a95..26a5dd7 100644 --- a/ProjectPlane/ProjectPlane/Entities/EntityShip.cs +++ b/ProjectPlane/ProjectPlane/Entities/EntityShip.cs @@ -21,4 +21,9 @@ public class EntityShip Weight = weight; ShipColor = shipColor; } + + public void ShipColorChange(Color newColor) + { + ShipColor = newColor; + } } \ No newline at end of file diff --git a/ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs b/ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs index 2de725b..d31cda8 100644 --- a/ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs +++ b/ProjectPlane/ProjectPlane/FormShipCollection.Designer.cs @@ -29,6 +29,12 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); + panelCompanyTools = new Panel(); + ButtonAddShip = new Button(); + maskedTextBoxPosition = new MaskedTextBox(); + ButtonRefresh = new Button(); + ButtonDel = new Button(); + ButtonGoToCheck = new Button(); ButtonCreateCompany = new Button(); panelStorage = new Panel(); radioButtonMassive = new RadioButton(); @@ -38,19 +44,12 @@ radioButtonList = new RadioButton(); textBoxCollectionName = new TextBox(); labelCollectionName = new Label(); - ButtonRefresh = new Button(); - ButtonGoToCheck = new Button(); - ButtonDel = new Button(); - maskedTextBoxPosition = new MaskedTextBox(); - ButtonAddCont = new Button(); - ButtonAddShip = new Button(); ComboBoxSelectorCompany = new ComboBox(); pictureBox = new PictureBox(); - panelCompanyTools = new Panel(); groupBoxTools.SuspendLayout(); + panelCompanyTools.SuspendLayout(); panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); - panelCompanyTools.SuspendLayout(); SuspendLayout(); // // groupBoxTools @@ -67,6 +66,72 @@ groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // + // panelCompanyTools + // + panelCompanyTools.Controls.Add(ButtonAddShip); + panelCompanyTools.Controls.Add(maskedTextBoxPosition); + panelCompanyTools.Controls.Add(ButtonRefresh); + panelCompanyTools.Controls.Add(ButtonDel); + panelCompanyTools.Controls.Add(ButtonGoToCheck); + panelCompanyTools.Enabled = false; + panelCompanyTools.Location = new Point(3, 400); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(194, 274); + panelCompanyTools.TabIndex = 9; + // + // ButtonAddShip + // + ButtonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + ButtonAddShip.Location = new Point(6, 20); + ButtonAddShip.Name = "ButtonAddShip"; + ButtonAddShip.Size = new Size(182, 40); + ButtonAddShip.TabIndex = 1; + ButtonAddShip.Text = "Добавление корабля"; + ButtonAddShip.UseVisualStyleBackColor = true; + ButtonAddShip.Click += ButtonAddShip_Click; + // + // maskedTextBoxPosition + // + maskedTextBoxPosition.Location = new Point(6, 111); + maskedTextBoxPosition.Mask = "00"; + maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + maskedTextBoxPosition.Size = new Size(188, 23); + maskedTextBoxPosition.TabIndex = 3; + maskedTextBoxPosition.ValidatingType = typeof(int); + // + // ButtonRefresh + // + ButtonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + ButtonRefresh.Location = new Point(6, 230); + ButtonRefresh.Name = "ButtonRefresh"; + ButtonRefresh.Size = new Size(182, 39); + ButtonRefresh.TabIndex = 6; + ButtonRefresh.Text = "Обновить"; + ButtonRefresh.UseVisualStyleBackColor = true; + ButtonRefresh.Click += ButtonRefresh_Click; + // + // ButtonDel + // + ButtonDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + ButtonDel.Location = new Point(6, 140); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(182, 39); + ButtonDel.TabIndex = 4; + ButtonDel.Text = "Удплить контейнеровоз"; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonGoToCheck + // + ButtonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + ButtonGoToCheck.Location = new Point(6, 185); + ButtonGoToCheck.Name = "ButtonGoToCheck"; + ButtonGoToCheck.Size = new Size(182, 39); + ButtonGoToCheck.TabIndex = 5; + ButtonGoToCheck.Text = "Передать на тесты"; + ButtonGoToCheck.UseVisualStyleBackColor = true; + ButtonGoToCheck.Click += ButtonGoToCheck_Click; + // // ButtonCreateCompany // ButtonCreateCompany.Location = new Point(6, 371); @@ -159,70 +224,6 @@ labelCollectionName.TabIndex = 0; labelCollectionName.Text = "Название коллекции:"; // - // ButtonRefresh - // - ButtonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - ButtonRefresh.Location = new Point(6, 230); - ButtonRefresh.Name = "ButtonRefresh"; - ButtonRefresh.Size = new Size(182, 39); - ButtonRefresh.TabIndex = 6; - ButtonRefresh.Text = "Обновить"; - ButtonRefresh.UseVisualStyleBackColor = true; - ButtonRefresh.Click += ButtonRefresh_Click; - // - // ButtonGoToCheck - // - ButtonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - ButtonGoToCheck.Location = new Point(6, 185); - ButtonGoToCheck.Name = "ButtonGoToCheck"; - ButtonGoToCheck.Size = new Size(182, 39); - ButtonGoToCheck.TabIndex = 5; - ButtonGoToCheck.Text = "Передать на тесты"; - ButtonGoToCheck.UseVisualStyleBackColor = true; - ButtonGoToCheck.Click += ButtonGoToCheck_Click; - // - // ButtonDel - // - ButtonDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - ButtonDel.Location = new Point(6, 140); - ButtonDel.Name = "ButtonDel"; - ButtonDel.Size = new Size(182, 39); - ButtonDel.TabIndex = 4; - ButtonDel.Text = "Удплить контейнеровоз"; - ButtonDel.UseVisualStyleBackColor = true; - ButtonDel.Click += ButtonDel_Click; - // - // maskedTextBoxPosition - // - maskedTextBoxPosition.Location = new Point(6, 111); - maskedTextBoxPosition.Mask = "00"; - maskedTextBoxPosition.Name = "maskedTextBoxPosition"; - maskedTextBoxPosition.Size = new Size(188, 23); - maskedTextBoxPosition.TabIndex = 3; - maskedTextBoxPosition.ValidatingType = typeof(int); - // - // ButtonAddCont - // - ButtonAddCont.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - ButtonAddCont.Location = new Point(6, 66); - ButtonAddCont.Name = "ButtonAddCont"; - ButtonAddCont.Size = new Size(182, 39); - ButtonAddCont.TabIndex = 2; - ButtonAddCont.Text = "Добавление контейнеровоза"; - ButtonAddCont.UseVisualStyleBackColor = true; - ButtonAddCont.Click += ButtonAddCont_Click; - // - // ButtonAddShip - // - ButtonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - ButtonAddShip.Location = new Point(6, 20); - ButtonAddShip.Name = "ButtonAddShip"; - ButtonAddShip.Size = new Size(182, 40); - ButtonAddShip.TabIndex = 1; - ButtonAddShip.Text = "Добавление корабля"; - ButtonAddShip.UseVisualStyleBackColor = true; - ButtonAddShip.Click += ButtonAddShip_Click; - // // ComboBoxSelectorCompany // ComboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; @@ -244,20 +245,6 @@ pictureBox.TabIndex = 1; pictureBox.TabStop = false; // - // panelCompanyTools - // - panelCompanyTools.Controls.Add(ButtonAddShip); - panelCompanyTools.Controls.Add(ButtonAddCont); - panelCompanyTools.Controls.Add(maskedTextBoxPosition); - panelCompanyTools.Controls.Add(ButtonRefresh); - panelCompanyTools.Controls.Add(ButtonDel); - panelCompanyTools.Controls.Add(ButtonGoToCheck); - panelCompanyTools.Enabled = false; - panelCompanyTools.Location = new Point(3, 400); - panelCompanyTools.Name = "panelCompanyTools"; - panelCompanyTools.Size = new Size(194, 274); - panelCompanyTools.TabIndex = 9; - // // FormShipCollection // AutoScaleDimensions = new SizeF(7F, 15F); @@ -268,11 +255,11 @@ Name = "FormShipCollection"; Text = "Коллекция кораблей"; groupBoxTools.ResumeLayout(false); + panelCompanyTools.ResumeLayout(false); + panelCompanyTools.PerformLayout(); panelStorage.ResumeLayout(false); panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); - panelCompanyTools.ResumeLayout(false); - panelCompanyTools.PerformLayout(); ResumeLayout(false); } @@ -280,7 +267,6 @@ private GroupBox groupBoxTools; private ComboBox ComboBoxSelectorCompany; - private Button ButtonAddCont; private Button ButtonAddShip; private PictureBox pictureBox; private MaskedTextBox maskedTextBoxPosition; diff --git a/ProjectPlane/ProjectPlane/FormShipCollection.cs b/ProjectPlane/ProjectPlane/FormShipCollection.cs index 06650ed..0e3b4fb 100644 --- a/ProjectPlane/ProjectPlane/FormShipCollection.cs +++ b/ProjectPlane/ProjectPlane/FormShipCollection.cs @@ -20,30 +20,21 @@ public partial class FormShipCollection : Form panelCompanyTools.Enabled = false; } - private void CreateObject(string type) + private void ButtonAddShip_Click(object sender, EventArgs e) { - if (_company == null) + FormShipConfig form = new(); + form.AddEvent(SetShip); + form.Show(); + } + + private void SetShip(DrawningShip? ship) + { + if (_company == null || ship == null) { return; } - - Random random = new Random(); - DrawningShip drawShip; - switch (type) - { - case nameof(DrawningShip): - drawShip = new DrawningShip(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); - break; - case nameof(DrawCont): - drawShip = new DrawCont(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 + drawShip != -1) + if (_company + ship != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); @@ -54,21 +45,6 @@ public partial class FormShipCollection : Form } } - 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; - } - - private void ButtonAddShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningShip)); - - private void ButtonAddCont_Click(object sender, EventArgs e) => CreateObject(nameof(DrawCont)); - private void ButtonDel_Click(object sender, EventArgs e) { @@ -136,11 +112,6 @@ public partial class FormShipCollection : Form pictureBox.Image = _company.Show(); } - private void RadioButtonMassive_CheckedChanged(object sender, EventArgs e) - { - - } - private void RerfreshListBoxItems() { listBoxCollection.Items.Clear(); @@ -154,7 +125,6 @@ public partial class FormShipCollection : Form } } - private void ButtonCollectionAdd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked)) diff --git a/ProjectPlane/ProjectPlane/FormShipConfig.Designer.cs b/ProjectPlane/ProjectPlane/FormShipConfig.Designer.cs new file mode 100644 index 0000000..52c3fcf --- /dev/null +++ b/ProjectPlane/ProjectPlane/FormShipConfig.Designer.cs @@ -0,0 +1,365 @@ +namespace ProjectPlane +{ + partial class FormShipConfig + { + /// + /// 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(); + panelBlue = new Panel(); + panelGray = new Panel(); + panelWhite = new Panel(); + panelGreen = new Panel(); + panelRed = new Panel(); + checkBoxCrane = new CheckBox(); + checkBoxContainer = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + numericUpDownSpeed = new NumericUpDown(); + labelWeight = new Label(); + labelSpeed = new Label(); + labelModifiedObject = new Label(); + labelSimpleObject = new Label(); + pictureBoxObject = new PictureBox(); + buttonAdd = new Button(); + buttonCancel = new Button(); + panelObject = new Panel(); + labelContainerColor = new Label(); + labelShipColor = 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(checkBoxCrane); + groupBoxConfig.Controls.Add(checkBoxContainer); + groupBoxConfig.Controls.Add(numericUpDownWeight); + groupBoxConfig.Controls.Add(numericUpDownSpeed); + groupBoxConfig.Controls.Add(labelWeight); + 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(571, 222); + groupBoxConfig.TabIndex = 0; + groupBoxConfig.TabStop = false; + groupBoxConfig.Text = "Параметры"; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelPurple); + groupBoxColors.Controls.Add(panelYellow); + groupBoxColors.Controls.Add(panelBlack); + groupBoxColors.Controls.Add(panelBlue); + groupBoxColors.Controls.Add(panelGray); + groupBoxColors.Controls.Add(panelWhite); + groupBoxColors.Controls.Add(panelGreen); + groupBoxColors.Controls.Add(panelRed); + groupBoxColors.Location = new Point(266, 30); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Size = new Size(253, 119); + groupBoxColors.TabIndex = 8; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "Цвета"; + // + // panelPurple + // + panelPurple.BackColor = Color.Purple; + panelPurple.Location = new Point(190, 70); + panelPurple.Name = "panelPurple"; + panelPurple.Size = new Size(43, 40); + panelPurple.TabIndex = 3; + panelPurple.MouseDown += Panel_MouseDown; + // + // panelYellow + // + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(190, 22); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(43, 40); + panelYellow.TabIndex = 1; + panelYellow.MouseDown += Panel_MouseDown; + // + // panelBlack + // + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(129, 70); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(43, 40); + panelBlack.TabIndex = 4; + panelBlack.MouseDown += Panel_MouseDown; + // + // panelBlue + // + panelBlue.BackColor = Color.Blue; + panelBlue.Location = new Point(129, 22); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(43, 40); + panelBlue.TabIndex = 1; + panelBlue.MouseDown += Panel_MouseDown; + // + // panelGray + // + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(71, 70); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(43, 40); + panelGray.TabIndex = 5; + panelGray.MouseDown += Panel_MouseDown; + // + // panelWhite + // + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(14, 70); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(43, 40); + panelWhite.TabIndex = 2; + panelWhite.MouseDown += Panel_MouseDown; + // + // panelGreen + // + panelGreen.BackColor = Color.Green; + panelGreen.Location = new Point(71, 22); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(43, 40); + panelGreen.TabIndex = 1; + panelGreen.MouseDown += Panel_MouseDown; + // + // panelRed + // + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(14, 22); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(43, 40); + panelRed.TabIndex = 0; + panelRed.MouseDown += Panel_MouseDown; + // + // checkBoxCrane + // + checkBoxCrane.AutoSize = true; + checkBoxCrane.Location = new Point(37, 160); + checkBoxCrane.Name = "checkBoxCrane"; + checkBoxCrane.Size = new Size(158, 19); + checkBoxCrane.TabIndex = 7; + checkBoxCrane.Text = "Признак наличия крана"; + checkBoxCrane.UseVisualStyleBackColor = true; + // + // checkBoxContainer + // + checkBoxContainer.AutoSize = true; + checkBoxContainer.Location = new Point(37, 121); + checkBoxContainer.Name = "checkBoxContainer"; + checkBoxContainer.Size = new Size(190, 19); + checkBoxContainer.TabIndex = 6; + checkBoxContainer.Text = "Признак наличия контейнера"; + checkBoxContainer.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(105, 59); + 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(122, 23); + numericUpDownWeight.TabIndex = 5; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(105, 30); + 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(122, 23); + numericUpDownSpeed.TabIndex = 4; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelWeight + // + labelWeight.AutoSize = true; + labelWeight.Location = new Point(37, 59); + labelWeight.Name = "labelWeight"; + labelWeight.Size = new Size(29, 15); + labelWeight.TabIndex = 3; + labelWeight.Text = "Вес:"; + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(37, 30); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(62, 15); + labelSpeed.TabIndex = 2; + labelSpeed.Text = "Скорость:"; + // + // labelModifiedObject + // + labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; + labelModifiedObject.Location = new Point(419, 160); + labelModifiedObject.Name = "labelModifiedObject"; + labelModifiedObject.Size = new Size(100, 38); + labelModifiedObject.TabIndex = 1; + labelModifiedObject.Text = "Продвинутый"; + labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + labelModifiedObject.MouseDown += LabelObject_MouseDown; + // + // labelSimpleObject + // + labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; + labelSimpleObject.Location = new Point(266, 160); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(100, 38); + labelSimpleObject.TabIndex = 0; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.MouseDown += LabelObject_MouseDown; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(11, 47); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(209, 110); + pictureBoxObject.TabIndex = 1; + pictureBoxObject.TabStop = false; + // + // buttonAdd + // + buttonAdd.Location = new Point(588, 187); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 23); + buttonAdd.TabIndex = 2; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(722, 187); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // panelObject + // + panelObject.AllowDrop = true; + panelObject.Controls.Add(labelContainerColor); + panelObject.Controls.Add(labelShipColor); + panelObject.Controls.Add(pictureBoxObject); + panelObject.Location = new Point(577, 12); + panelObject.Name = "panelObject"; + panelObject.Size = new Size(229, 167); + panelObject.TabIndex = 4; + panelObject.DragDrop += PanelObject_DragDrop; + panelObject.DragEnter += PanelObject_DragEnter; + // + // labelContainerColor + // + labelContainerColor.AllowDrop = true; + labelContainerColor.BorderStyle = BorderStyle.FixedSingle; + labelContainerColor.Location = new Point(117, 8); + labelContainerColor.Name = "labelContainerColor"; + labelContainerColor.Size = new Size(100, 33); + labelContainerColor.TabIndex = 3; + labelContainerColor.Text = "Доп цвет"; + labelContainerColor.TextAlign = ContentAlignment.MiddleCenter; + labelContainerColor.DragDrop += LabelAdditionalColor_DragDrop; + labelContainerColor.DragEnter += LabelAdditionalColor_DragEnter; + // + // labelShipColor + // + labelShipColor.AllowDrop = true; + labelShipColor.BorderStyle = BorderStyle.FixedSingle; + labelShipColor.Location = new Point(11, 8); + labelShipColor.Name = "labelShipColor"; + labelShipColor.Size = new Size(100, 33); + labelShipColor.TabIndex = 2; + labelShipColor.Text = "Цвет"; + labelShipColor.TextAlign = ContentAlignment.MiddleCenter; + labelShipColor.DragDrop += LabelBodyColor_DragDrop; + labelShipColor.DragEnter += LabelBodyColor_DragEnter; + // + // FormShipConfig + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(809, 222); + Controls.Add(panelObject); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(groupBoxConfig); + Name = "FormShipConfig"; + 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 labelModifiedObject; + private Label labelSimpleObject; + private Label labelSpeed; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelWeight; + private CheckBox checkBoxCrane; + private CheckBox checkBoxContainer; + private GroupBox groupBoxColors; + private Panel panelRed; + private Panel panelPurple; + private Panel panelYellow; + private Panel panelBlack; + private Panel panelBlue; + private Panel panelGray; + private Panel panelWhite; + private Panel panelGreen; + private PictureBox pictureBoxObject; + private Button buttonAdd; + private Button buttonCancel; + private Panel panelObject; + private Label labelContainerColor; + private Label labelShipColor; + } +} \ No newline at end of file diff --git a/ProjectPlane/ProjectPlane/FormShipConfig.cs b/ProjectPlane/ProjectPlane/FormShipConfig.cs new file mode 100644 index 0000000..4d7a90c --- /dev/null +++ b/ProjectPlane/ProjectPlane/FormShipConfig.cs @@ -0,0 +1,126 @@ +using ProjectPlane.Drawnings; +using ProjectPlane.Entities; +namespace ProjectPlane; + +public partial class FormShipConfig : Form +{ + private DrawningShip? _ship; + + private event Action? ShipDelegate; + + public FormShipConfig() + { + 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(); + } + + private void DrawObject() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _ship?.SetPictureSize(pictureBoxObject.Width, + pictureBoxObject.Height); + _ship?.SetPosition(15, 15); + _ship?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + + public void AddEvent(Action shipDelegate) + { + ShipDelegate += shipDelegate; + } + + 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": + _ship = new DrawningShip((int)numericUpDownSpeed.Value, + (double)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _ship = new + DrawCont((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, + Color.White, + Color.Black, checkBoxContainer.Checked, + checkBoxCrane.Checked); + break; + } + DrawObject(); + } + + private void Panel_MouseDown(object? sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor ?? Color.Black, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void LabelBodyColor_DragEnter(object sender, DragEventArgs e) + { + e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None; + } + + /// + /// Действия при приеме перетаскиваемой информации(Основной цвет) + /// + /// + /// + private void LabelBodyColor_DragDrop(object sender, DragEventArgs e) + { + _ship?.EntityShip?.ShipColorChange((Color)e.Data?.GetData(typeof(Color))); + DrawObject(); + } + + /// + /// Проверка получаемой информации(Доп. цвет) (ее типа на соответствие требуемому) + /// + /// + /// + private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e) + { + e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None; + } + + /// + /// Действия при приеме перетаскиваемой информации(Доп. цвет) + /// + /// + /// + private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e) + { + if (_ship?.EntityShip is EntityContainer _container) + { + _container.ContainerColorChange((Color)e.Data?.GetData(typeof(Color))); + } + DrawObject(); + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + if (_ship != null) + { + ShipDelegate?.Invoke(_ship); + Close(); + } + } +} + diff --git a/ProjectPlane/ProjectPlane/FormShipConfig.resx b/ProjectPlane/ProjectPlane/FormShipConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectPlane/ProjectPlane/FormShipConfig.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectPlane/ProjectPlane/ShipDelegate.cs b/ProjectPlane/ProjectPlane/ShipDelegate.cs new file mode 100644 index 0000000..fe387d3 --- /dev/null +++ b/ProjectPlane/ProjectPlane/ShipDelegate.cs @@ -0,0 +1,5 @@ +using ProjectPlane.Drawnings; + +namespace ProjectPlane; + +public delegate void ShipDelegate(DrawningShip ship);