From d4ccb9c74aafe82bb2c1ec6e3a30126856b9fbb0 Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:50:37 +0400 Subject: [PATCH 01/10] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HoistingCrane/HoistingCrane/CarDelegate.cs | 12 + .../Entities/EntityHoistingCrane.cs | 4 + .../Entities/EntityTrackedVehicle.cs | 6 +- .../FormCarCollection.Designer.cs | 222 +++++------ .../HoistingCrane/FormCarCollection.cs | 34 +- .../HoistingCrane/FormCarConfig.Designer.cs | 355 ++++++++++++++++++ HoistingCrane/HoistingCrane/FormCarConfig.cs | 122 ++++++ .../HoistingCrane/FormCarConfig.resx | 120 ++++++ 8 files changed, 747 insertions(+), 128 deletions(-) create mode 100644 HoistingCrane/HoistingCrane/CarDelegate.cs create mode 100644 HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs create mode 100644 HoistingCrane/HoistingCrane/FormCarConfig.cs create mode 100644 HoistingCrane/HoistingCrane/FormCarConfig.resx diff --git a/HoistingCrane/HoistingCrane/CarDelegate.cs b/HoistingCrane/HoistingCrane/CarDelegate.cs new file mode 100644 index 0000000..d33d144 --- /dev/null +++ b/HoistingCrane/HoistingCrane/CarDelegate.cs @@ -0,0 +1,12 @@ +using HoistingCrane.Drawning; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HoistingCrane +{ + public delegate void CarDelegate(DrawningTrackedVehicle car); + +} diff --git a/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs b/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs index 809ac3f..674c373 100644 --- a/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs @@ -38,4 +38,8 @@ public class EntityHoistingCrane : EntityTrackedVehicle } + public void SetAdditionalColor(Color newColor) + { + AdditionalColor = newColor; + } } \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs b/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs index 555320a..0a479d7 100644 --- a/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs +++ b/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs @@ -43,7 +43,11 @@ this.Weight = Weight; this.BodyColor = BodyColor; } - + + public void SetBodyColor(Color newBodyColor) + { + BodyColor = newBodyColor; + } } } diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs b/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs index d56e52d..4bb03f2 100644 --- a/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs +++ b/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs @@ -29,26 +29,25 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); + buttonCreateCompany = new Button(); + panelStorage = new Panel(); + buttonDeleteCollection = new Button(); + listBoxCollection = new ListBox(); + buttonCollectionAdd = new Button(); + radioButtonList = new RadioButton(); + radioButtonMassive = new RadioButton(); + textBoxCollectionName = new TextBox(); + labelCollectionName = new Label(); buttonGoToChek = new Button(); buttonRefresh = new Button(); buttonDeleteCar = new Button(); maskedTextBox = new MaskedTextBox(); comboBoxSelectorCompany = new ComboBox(); - buttonCreateTrackedVehicle = new Button(); buttonCreateHoistingCrane = new Button(); pictureBox = new PictureBox(); - panelStorage = new Panel(); - labelCollectionName = new Label(); - textBoxCollectionName = new TextBox(); - radioButtonMassive = new RadioButton(); - radioButtonList = new RadioButton(); - buttonCollectionAdd = new Button(); - listBoxCollection = new ListBox(); - buttonDeleteCollection = new Button(); - buttonCreateCompany = new Button(); groupBoxTools.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); panelStorage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); SuspendLayout(); // // groupBoxTools @@ -60,7 +59,6 @@ groupBoxTools.Controls.Add(buttonDeleteCar); groupBoxTools.Controls.Add(maskedTextBox); groupBoxTools.Controls.Add(comboBoxSelectorCompany); - groupBoxTools.Controls.Add(buttonCreateTrackedVehicle); groupBoxTools.Controls.Add(buttonCreateHoistingCrane); groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Location = new Point(763, 0); @@ -70,6 +68,98 @@ groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // + // buttonCreateCompany + // + buttonCreateCompany.Location = new Point(12, 295); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(192, 23); + buttonCreateCompany.TabIndex = 7; + buttonCreateCompany.Text = "Создать компанию"; + buttonCreateCompany.UseVisualStyleBackColor = true; + buttonCreateCompany.Click += buttonCreateCompany_Click; + // + // panelStorage + // + panelStorage.Controls.Add(buttonDeleteCollection); + panelStorage.Controls.Add(listBoxCollection); + panelStorage.Controls.Add(buttonCollectionAdd); + panelStorage.Controls.Add(radioButtonList); + panelStorage.Controls.Add(radioButtonMassive); + panelStorage.Controls.Add(textBoxCollectionName); + panelStorage.Controls.Add(labelCollectionName); + panelStorage.Dock = DockStyle.Top; + panelStorage.Location = new Point(3, 19); + panelStorage.Name = "panelStorage"; + panelStorage.Size = new Size(204, 229); + panelStorage.TabIndex = 7; + // + // buttonDeleteCollection + // + buttonDeleteCollection.Location = new Point(9, 199); + buttonDeleteCollection.Name = "buttonDeleteCollection"; + buttonDeleteCollection.Size = new Size(192, 27); + buttonDeleteCollection.TabIndex = 6; + buttonDeleteCollection.Text = "Удалить коллекцию"; + buttonDeleteCollection.UseVisualStyleBackColor = true; + buttonDeleteCollection.Click += buttonDeleteCollection_Click; + // + // listBoxCollection + // + listBoxCollection.FormattingEnabled = true; + listBoxCollection.ItemHeight = 15; + listBoxCollection.Location = new Point(9, 118); + listBoxCollection.Name = "listBoxCollection"; + listBoxCollection.Size = new Size(192, 79); + listBoxCollection.TabIndex = 5; + // + // buttonCollectionAdd + // + buttonCollectionAdd.Location = new Point(9, 81); + buttonCollectionAdd.Name = "buttonCollectionAdd"; + buttonCollectionAdd.Size = new Size(192, 23); + buttonCollectionAdd.TabIndex = 4; + buttonCollectionAdd.Text = "Добавить коллекцию"; + buttonCollectionAdd.UseVisualStyleBackColor = true; + buttonCollectionAdd.Click += buttonCollectionAdd_Click; + // + // radioButtonList + // + radioButtonList.AutoSize = true; + radioButtonList.Location = new Point(128, 56); + radioButtonList.Name = "radioButtonList"; + radioButtonList.Size = new Size(67, 19); + radioButtonList.TabIndex = 3; + radioButtonList.TabStop = true; + radioButtonList.Text = "Список"; + radioButtonList.UseVisualStyleBackColor = true; + // + // radioButtonMassive + // + radioButtonMassive.AutoSize = true; + radioButtonMassive.Location = new Point(18, 56); + radioButtonMassive.Name = "radioButtonMassive"; + radioButtonMassive.Size = new Size(69, 19); + radioButtonMassive.TabIndex = 2; + radioButtonMassive.TabStop = true; + radioButtonMassive.Text = "Массив"; + radioButtonMassive.UseVisualStyleBackColor = true; + // + // textBoxCollectionName + // + textBoxCollectionName.Location = new Point(9, 18); + textBoxCollectionName.Name = "textBoxCollectionName"; + textBoxCollectionName.Size = new Size(192, 23); + textBoxCollectionName.TabIndex = 1; + // + // labelCollectionName + // + labelCollectionName.AutoSize = true; + labelCollectionName.Location = new Point(35, 0); + labelCollectionName.Name = "labelCollectionName"; + labelCollectionName.Size = new Size(135, 15); + labelCollectionName.TabIndex = 0; + labelCollectionName.Text = "Название коллекции:"; + // // buttonGoToChek // buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; @@ -124,17 +214,6 @@ comboBoxSelectorCompany.TabIndex = 2; comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1; // - // buttonCreateTrackedVehicle - // - buttonCreateTrackedVehicle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonCreateTrackedVehicle.Location = new Point(12, 352); - buttonCreateTrackedVehicle.Name = "buttonCreateTrackedVehicle"; - buttonCreateTrackedVehicle.Size = new Size(192, 24); - buttonCreateTrackedVehicle.TabIndex = 1; - buttonCreateTrackedVehicle.Text = "Добавить гусеничную машину"; - buttonCreateTrackedVehicle.UseVisualStyleBackColor = true; - buttonCreateTrackedVehicle.Click += buttonCreateTrackedVehicle_Click; - // // buttonCreateHoistingCrane // buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; @@ -144,7 +223,7 @@ buttonCreateHoistingCrane.TabIndex = 0; buttonCreateHoistingCrane.Text = "Добавить подъемный кран"; buttonCreateHoistingCrane.UseVisualStyleBackColor = true; - buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click; + // // pictureBox // @@ -155,98 +234,6 @@ pictureBox.TabIndex = 1; pictureBox.TabStop = false; // - // panelStorage - // - panelStorage.Controls.Add(buttonDeleteCollection); - panelStorage.Controls.Add(listBoxCollection); - panelStorage.Controls.Add(buttonCollectionAdd); - panelStorage.Controls.Add(radioButtonList); - panelStorage.Controls.Add(radioButtonMassive); - panelStorage.Controls.Add(textBoxCollectionName); - panelStorage.Controls.Add(labelCollectionName); - panelStorage.Dock = DockStyle.Top; - panelStorage.Location = new Point(3, 19); - panelStorage.Name = "panelStorage"; - panelStorage.Size = new Size(204, 229); - panelStorage.TabIndex = 7; - // - // labelCollectionName - // - labelCollectionName.AutoSize = true; - labelCollectionName.Location = new Point(35, 0); - labelCollectionName.Name = "labelCollectionName"; - labelCollectionName.Size = new Size(135, 15); - labelCollectionName.TabIndex = 0; - labelCollectionName.Text = "Название коллекции:"; - // - // textBoxCollectionName - // - textBoxCollectionName.Location = new Point(9, 18); - textBoxCollectionName.Name = "textBoxCollectionName"; - textBoxCollectionName.Size = new Size(192, 23); - textBoxCollectionName.TabIndex = 1; - // - // radioButtonMassive - // - radioButtonMassive.AutoSize = true; - radioButtonMassive.Location = new Point(18, 56); - radioButtonMassive.Name = "radioButtonMassive"; - radioButtonMassive.Size = new Size(69, 19); - radioButtonMassive.TabIndex = 2; - radioButtonMassive.TabStop = true; - radioButtonMassive.Text = "Массив"; - radioButtonMassive.UseVisualStyleBackColor = true; - // - // radioButtonList - // - radioButtonList.AutoSize = true; - radioButtonList.Location = new Point(128, 56); - radioButtonList.Name = "radioButtonList"; - radioButtonList.Size = new Size(67, 19); - radioButtonList.TabIndex = 3; - radioButtonList.TabStop = true; - radioButtonList.Text = "Список"; - radioButtonList.UseVisualStyleBackColor = true; - // - // buttonCollectionAdd - // - buttonCollectionAdd.Location = new Point(9, 81); - buttonCollectionAdd.Name = "buttonCollectionAdd"; - buttonCollectionAdd.Size = new Size(192, 23); - buttonCollectionAdd.TabIndex = 4; - buttonCollectionAdd.Text = "Добавить коллекцию"; - buttonCollectionAdd.UseVisualStyleBackColor = true; - buttonCollectionAdd.Click += buttonCollectionAdd_Click; - // - // listBoxCollection - // - listBoxCollection.FormattingEnabled = true; - listBoxCollection.ItemHeight = 15; - listBoxCollection.Location = new Point(9, 118); - listBoxCollection.Name = "listBoxCollection"; - listBoxCollection.Size = new Size(192, 79); - listBoxCollection.TabIndex = 5; - // - // buttonDeleteCollection - // - buttonDeleteCollection.Location = new Point(9, 199); - buttonDeleteCollection.Name = "buttonDeleteCollection"; - buttonDeleteCollection.Size = new Size(192, 27); - buttonDeleteCollection.TabIndex = 6; - buttonDeleteCollection.Text = "Удалить коллекцию"; - buttonDeleteCollection.UseVisualStyleBackColor = true; - buttonDeleteCollection.Click += buttonDeleteCollection_Click; - // - // buttonCreateCompany - // - buttonCreateCompany.Location = new Point(12, 295); - buttonCreateCompany.Name = "buttonCreateCompany"; - buttonCreateCompany.Size = new Size(192, 23); - buttonCreateCompany.TabIndex = 7; - buttonCreateCompany.Text = "Создать компанию"; - buttonCreateCompany.UseVisualStyleBackColor = true; - buttonCreateCompany.Click += buttonCreateCompany_Click; - // // FormCarCollection // AutoScaleDimensions = new SizeF(7F, 15F); @@ -258,9 +245,9 @@ Text = "FormCarCollections"; groupBoxTools.ResumeLayout(false); groupBoxTools.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); panelStorage.ResumeLayout(false); panelStorage.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); ResumeLayout(false); } @@ -268,7 +255,6 @@ private GroupBox groupBoxTools; private Button buttonCreateHoistingCrane; - private Button buttonCreateTrackedVehicle; private ComboBox comboBoxSelectorCompany; private Button buttonRefresh; private Button buttonDeleteCar; diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.cs b/HoistingCrane/HoistingCrane/FormCarCollection.cs index 3dc984a..104913c 100644 --- a/HoistingCrane/HoistingCrane/FormCarCollection.cs +++ b/HoistingCrane/HoistingCrane/FormCarCollection.cs @@ -74,13 +74,29 @@ namespace HoistingCrane return color; } + private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) + { + FormCarConfig form = new(); + form.Show(); + form.AddEvent(SetCar); + } - - private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningHoistingCrane)); - - - private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrackedVehicle)); - + private void SetCar(DrawningTrackedVehicle car) + { + if(_company == null || car == null) + { + return; + } + if((_company + car) != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _company.Show(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } private void buttonDeleteCar_Click(object sender, EventArgs e) { @@ -149,7 +165,7 @@ namespace HoistingCrane private void buttonCollectionAdd_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(textBoxCollectionName.Text) ||(!radioButtonList.Checked && !radioButtonMassive.Checked)) + if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked)) { MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -184,7 +200,7 @@ namespace HoistingCrane return; _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); RerfreshListBoxItems(); - + } private void buttonCreateCompany_Click(object sender, EventArgs e) @@ -210,5 +226,5 @@ namespace HoistingCrane RerfreshListBoxItems(); } } - + } diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs b/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs new file mode 100644 index 0000000..9e6b7cf --- /dev/null +++ b/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs @@ -0,0 +1,355 @@ +namespace HoistingCrane +{ + partial class FormCarConfig + { + /// + /// 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(); + panelColorPurple = new Panel(); + panelColorYellow = new Panel(); + panelColorGray = new Panel(); + panelColorGreen = new Panel(); + panelColorWhite = new Panel(); + panelColorBlue = new Panel(); + panelColorBlack = new Panel(); + panelColorRed = new Panel(); + checkBoxPlatform = new CheckBox(); + checkBoxCounterweight = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + numericUpDownSpeed = new NumericUpDown(); + labelWeight = new Label(); + labelSpeed = new Label(); + labelModifiedObject = new Label(); + labelSimpleObject = new Label(); + panel = new Panel(); + labelAdditionalColor = new Label(); + labelBodyColor = new Label(); + pictureBoxObject = new PictureBox(); + buttonAdd = new Button(); + buttonCancel = new Button(); + groupBoxConfig.SuspendLayout(); + groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + SuspendLayout(); + // + // groupBoxConfig + // + groupBoxConfig.Controls.Add(groupBoxColors); + groupBoxConfig.Controls.Add(checkBoxPlatform); + groupBoxConfig.Controls.Add(checkBoxCounterweight); + 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(514, 207); + groupBoxConfig.TabIndex = 0; + groupBoxConfig.TabStop = false; + groupBoxConfig.Text = "Параметры"; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelColorPurple); + groupBoxColors.Controls.Add(panelColorYellow); + groupBoxColors.Controls.Add(panelColorGray); + groupBoxColors.Controls.Add(panelColorGreen); + groupBoxColors.Controls.Add(panelColorWhite); + groupBoxColors.Controls.Add(panelColorBlue); + groupBoxColors.Controls.Add(panelColorBlack); + groupBoxColors.Controls.Add(panelColorRed); + groupBoxColors.Location = new Point(283, 26); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Size = new Size(210, 114); + groupBoxColors.TabIndex = 8; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "Цвет"; + // + // panelColorPurple + // + panelColorPurple.BackColor = Color.Purple; + panelColorPurple.Location = new Point(168, 68); + panelColorPurple.Name = "panelColorPurple"; + panelColorPurple.Size = new Size(36, 35); + panelColorPurple.TabIndex = 7; + // + // panelColorYellow + // + panelColorYellow.BackColor = Color.Yellow; + panelColorYellow.Location = new Point(168, 22); + panelColorYellow.Name = "panelColorYellow"; + panelColorYellow.Size = new Size(36, 35); + panelColorYellow.TabIndex = 3; + // + // panelColorGray + // + panelColorGray.BackColor = Color.Gray; + panelColorGray.Location = new Point(114, 68); + panelColorGray.Name = "panelColorGray"; + panelColorGray.Size = new Size(36, 35); + panelColorGray.TabIndex = 6; + // + // panelColorGreen + // + panelColorGreen.BackColor = Color.Green; + panelColorGreen.Location = new Point(114, 22); + panelColorGreen.Name = "panelColorGreen"; + panelColorGreen.Size = new Size(36, 35); + panelColorGreen.TabIndex = 2; + // + // panelColorWhite + // + panelColorWhite.BackColor = Color.White; + panelColorWhite.Location = new Point(61, 68); + panelColorWhite.Name = "panelColorWhite"; + panelColorWhite.Size = new Size(36, 35); + panelColorWhite.TabIndex = 5; + // + // panelColorBlue + // + panelColorBlue.BackColor = Color.Blue; + panelColorBlue.Location = new Point(61, 22); + panelColorBlue.Name = "panelColorBlue"; + panelColorBlue.Size = new Size(36, 35); + panelColorBlue.TabIndex = 1; + // + // panelColorBlack + // + panelColorBlack.BackColor = Color.Black; + panelColorBlack.Location = new Point(6, 68); + panelColorBlack.Name = "panelColorBlack"; + panelColorBlack.Size = new Size(36, 35); + panelColorBlack.TabIndex = 4; + // + // panelColorRed + // + panelColorRed.BackColor = Color.Red; + panelColorRed.Location = new Point(6, 22); + panelColorRed.Name = "panelColorRed"; + panelColorRed.Size = new Size(36, 35); + panelColorRed.TabIndex = 0; + panelColorRed.MouseDown += panel_MouseDown; + // + // checkBoxPlatform + // + checkBoxPlatform.AutoSize = true; + checkBoxPlatform.Location = new Point(6, 135); + checkBoxPlatform.Name = "checkBoxPlatform"; + checkBoxPlatform.Size = new Size(148, 19); + checkBoxPlatform.TabIndex = 7; + checkBoxPlatform.Text = "Наличие платформы"; + checkBoxPlatform.UseVisualStyleBackColor = true; + // + // checkBoxCounterweight + // + checkBoxCounterweight.AutoSize = true; + checkBoxCounterweight.Location = new Point(6, 110); + checkBoxCounterweight.Name = "checkBoxCounterweight"; + checkBoxCounterweight.Size = new Size(155, 19); + checkBoxCounterweight.TabIndex = 6; + checkBoxCounterweight.Text = "Наличие противовеса"; + checkBoxCounterweight.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(72, 66); + 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(120, 23); + numericUpDownWeight.TabIndex = 5; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(72, 31); + 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(120, 23); + numericUpDownSpeed.TabIndex = 4; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelWeight + // + labelWeight.AutoSize = true; + labelWeight.Location = new Point(6, 68); + labelWeight.Name = "labelWeight"; + labelWeight.Size = new Size(28, 15); + labelWeight.TabIndex = 3; + labelWeight.Text = "Вес"; + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(6, 33); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(60, 15); + labelSpeed.TabIndex = 2; + labelSpeed.Text = "Скорость"; + // + // labelModifiedObject + // + labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; + labelModifiedObject.Location = new Point(139, 173); + labelModifiedObject.Name = "labelModifiedObject"; + labelModifiedObject.Size = new Size(114, 31); + labelModifiedObject.TabIndex = 1; + labelModifiedObject.Text = "Продвинутый"; + labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + labelModifiedObject.MouseDown += labelObject_MouseDown; + // + // labelSimpleObject + // + labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; + labelSimpleObject.Location = new Point(6, 172); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(114, 31); + labelSimpleObject.TabIndex = 0; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.MouseDown += labelObject_MouseDown; + // + // panel + // + panel.AllowDrop = true; + panel.Controls.Add(labelAdditionalColor); + panel.Controls.Add(labelBodyColor); + panel.Controls.Add(pictureBoxObject); + panel.Location = new Point(545, 0); + panel.Name = "panel"; + panel.Size = new Size(216, 167); + panel.TabIndex = 1; + panel.DragDrop += panel_DragDrop; + panel.DragEnter += panel_DragEnter; + // + // labelAdditionalColor + // + labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; + labelAdditionalColor.Location = new Point(116, 9); + labelAdditionalColor.Name = "labelAdditionalColor"; + labelAdditionalColor.Size = new Size(97, 31); + labelAdditionalColor.TabIndex = 10; + labelAdditionalColor.Text = "Доп. цвет"; + labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; + labelAdditionalColor.DragEnter += labelColors_DragEnter; + // + // labelBodyColor + // + labelBodyColor.BorderStyle = BorderStyle.FixedSingle; + labelBodyColor.Location = new Point(3, 9); + labelBodyColor.Name = "labelBodyColor"; + labelBodyColor.Size = new Size(97, 31); + labelBodyColor.TabIndex = 9; + labelBodyColor.Text = "Цвет"; + labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; + labelBodyColor.DragEnter += labelColors_DragEnter; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(3, 43); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(210, 121); + pictureBoxObject.TabIndex = 0; + pictureBoxObject.TabStop = false; + // + // buttonAdd + // + buttonAdd.Location = new Point(545, 172); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(91, 34); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(670, 173); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(91, 35); + buttonCancel.TabIndex = 2; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + + // + // FormCarConfig + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(777, 207); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(panel); + Controls.Add(groupBoxConfig); + Name = "FormCarConfig"; + Text = "FormCarConfig"; + groupBoxConfig.ResumeLayout(false); + groupBoxConfig.PerformLayout(); + groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxConfig; + private Label labelModifiedObject; + private Label labelSimpleObject; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelWeight; + private Label labelSpeed; + private CheckBox checkBoxPlatform; + private CheckBox checkBoxCounterweight; + private GroupBox groupBoxColors; + private Panel panelColorPurple; + private Panel panelColorYellow; + private Panel panelColorGray; + private Panel panelColorGreen; + private Panel panelColorWhite; + private Panel panelColorBlue; + private Panel panelColorBlack; + private Panel panelColorRed; + private Panel panel; + private PictureBox pictureBoxObject; + private Button buttonAdd; + private Button buttonCancel; + private Label labelAdditionalColor; + private Label labelBodyColor; + } +} \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.cs b/HoistingCrane/HoistingCrane/FormCarConfig.cs new file mode 100644 index 0000000..4142774 --- /dev/null +++ b/HoistingCrane/HoistingCrane/FormCarConfig.cs @@ -0,0 +1,122 @@ +using HoistingCrane.CollectionGenericObjects; +using HoistingCrane.Drawning; +using HoistingCrane.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 HoistingCrane +{ + public partial class FormCarConfig : Form + { + private DrawningTrackedVehicle? car = null; + private event CarDelegate? _carDelegate; + public FormCarConfig() + { + panelColorRed.MouseDown += panel_MouseDown; + panelColorBlue.MouseDown += panel_MouseDown; + panelColorGreen.MouseDown += panel_MouseDown; + panelColorYellow.MouseDown += panel_MouseDown; + panelColorBlack.MouseDown += panel_MouseDown; + panelColorWhite.MouseDown += panel_MouseDown; + panelColorGray.MouseDown += panel_MouseDown; + panelColorPurple.MouseDown += panel_MouseDown; + buttonCancel.Click += (sender, e) => Close(); + + InitializeComponent(); + } + public void AddEvent(CarDelegate carDelegate) + { + _carDelegate += carDelegate; + } + private void DrawObject() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + car?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); + car?.SetPosition(5, 5); + car?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + + private void labelObject_MouseDown(object sender, MouseEventArgs e) + { + var label = sender as Label; + label?.DoDragDrop(label.Name, DragDropEffects.Move); + label?.DoDragDrop(label.Name, DragDropEffects.Copy); + } + + private void panel_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void panel_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text)?.ToString()) + { + case "labelSimpleObject": + car = new DrawningTrackedVehicle((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + car = new DrawningHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCounterweight.Checked, + checkBoxPlatform.Checked); + break; + } + DrawObject(); + } + + private void panel_MouseDown(object? sender, MouseEventArgs e) + { + var color = sender as Label; + color?.DoDragDrop(color.BackColor, DragDropEffects.Move); + color?.DoDragDrop(color.BackColor, DragDropEffects.Copy); + } + + // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта) + private void labelColors_DragEnter(object sender, DragEventArgs e) + { + var label = (String)sender; + Color newColor = (Color)e.Data.GetData(typeof(Color).ToString()); + switch (label) + { + case "labelBodyColor": + car?.EntityTrackedVehicle?.SetBodyColor(newColor); + DrawObject(); + break; + case "labelAdditionalColor": + if (car is DrawningHoistingCrane) + { + (car.EntityTrackedVehicle as EntityHoistingCrane).SetAdditionalColor(newColor); + DrawObject(); + } + break; + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + if (car != null) + { + _carDelegate?.Invoke(car); + Close(); + } + } + + + } + +} diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.resx b/HoistingCrane/HoistingCrane/FormCarConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/HoistingCrane/HoistingCrane/FormCarConfig.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 -- 2.25.1 From a50b38a5927b8d61fb1719eee2683cde4b48bc80 Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sun, 14 Apr 2024 20:01:01 +0400 Subject: [PATCH 02/10] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HoistingCrane/HoistingCrane/CarDelegate.cs | 2 +- .../StorageCollection.cs | 16 +- .../FormCarCollection.Designer.cs | 4 +- .../HoistingCrane/FormCarCollection.cs | 20 +-- .../HoistingCrane/FormCarConfig.Designer.cs | 7 +- HoistingCrane/HoistingCrane/FormCarConfig.cs | 146 ++++++++++++------ 6 files changed, 120 insertions(+), 75 deletions(-) diff --git a/HoistingCrane/HoistingCrane/CarDelegate.cs b/HoistingCrane/HoistingCrane/CarDelegate.cs index d33d144..7383591 100644 --- a/HoistingCrane/HoistingCrane/CarDelegate.cs +++ b/HoistingCrane/HoistingCrane/CarDelegate.cs @@ -7,6 +7,6 @@ using System.Threading.Tasks; namespace HoistingCrane { - public delegate void CarDelegate(DrawningTrackedVehicle car); + public delegate void CarDelegate(DrawningTrackedVehicle car); } diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs index 7e84f1b..0765bd3 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs @@ -25,8 +25,6 @@ namespace HoistingCrane.CollectionGenericObjects /// тип коллекции public void AddCollection(string name, CollectionType collectionType) { - // TODO проверка, что name не пустой и нет в словаре записи с таким ключом - // TODO Прописать логику для добавления if (!string.IsNullOrEmpty(name) && !Keys.Contains(name)) { if(collectionType == CollectionType.Massive) @@ -45,12 +43,8 @@ namespace HoistingCrane.CollectionGenericObjects /// Название коллекции public void DelCollection(string name) { - // TODO Прописать логику для удаления коллекции - - if(Keys.Contains(name)) - { + if (dict.ContainsKey(name)) dict.Remove(name); - } } /// /// Доступ к коллекции @@ -61,12 +55,8 @@ namespace HoistingCrane.CollectionGenericObjects { get { - // TODO Продумать логику получения объекта - if (dict.TryGetValue(name, out ICollectionGenericObjects? result)) - { - return result; - } - return null; + if (name == null || !dict.ContainsKey(name)) { return null; } + return dict[name]; } } } diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs b/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs index 4bb03f2..871848a 100644 --- a/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs +++ b/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs @@ -221,9 +221,9 @@ buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane"; buttonCreateHoistingCrane.Size = new Size(192, 22); buttonCreateHoistingCrane.TabIndex = 0; - buttonCreateHoistingCrane.Text = "Добавить подъемный кран"; + buttonCreateHoistingCrane.Text = "Добавить транспорт"; buttonCreateHoistingCrane.UseVisualStyleBackColor = true; - + buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click; // // pictureBox // diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.cs b/HoistingCrane/HoistingCrane/FormCarCollection.cs index 104913c..8382a18 100644 --- a/HoistingCrane/HoistingCrane/FormCarCollection.cs +++ b/HoistingCrane/HoistingCrane/FormCarCollection.cs @@ -72,22 +72,15 @@ namespace HoistingCrane color = dialog.Color; } return color; - } - - private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) - { - FormCarConfig form = new(); - form.Show(); - form.AddEvent(SetCar); - } + } private void SetCar(DrawningTrackedVehicle car) { - if(_company == null || car == null) + if (_company == null || car == null) { return; } - if((_company + car) != -1) + if ((_company + car) != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); @@ -225,6 +218,13 @@ namespace HoistingCrane panelStorage.Enabled = true; RerfreshListBoxItems(); } + + private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) + { + FormCarConfig form = new(); + form.AddEvent(SetCar); + form.Show(); + } } } diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs b/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs index 9e6b7cf..2721270 100644 --- a/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs +++ b/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs @@ -263,7 +263,8 @@ labelAdditionalColor.TabIndex = 10; labelAdditionalColor.Text = "Доп. цвет"; labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; - labelAdditionalColor.DragEnter += labelColors_DragEnter; + labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop; + labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter; // // labelBodyColor // @@ -274,7 +275,8 @@ labelBodyColor.TabIndex = 9; labelBodyColor.Text = "Цвет"; labelBodyColor.TextAlign = ContentAlignment.MiddleCenter; - labelBodyColor.DragEnter += labelColors_DragEnter; + labelBodyColor.DragDrop += labelBodyColor_DragDrop; + labelBodyColor.DragEnter += labelBodyColor_DragEnter; // // pictureBoxObject // @@ -302,7 +304,6 @@ buttonCancel.TabIndex = 2; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; - // // FormCarConfig // diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.cs b/HoistingCrane/HoistingCrane/FormCarConfig.cs index 4142774..3135eb7 100644 --- a/HoistingCrane/HoistingCrane/FormCarConfig.cs +++ b/HoistingCrane/HoistingCrane/FormCarConfig.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar; namespace HoistingCrane { @@ -19,6 +20,7 @@ namespace HoistingCrane private event CarDelegate? _carDelegate; public FormCarConfig() { + InitializeComponent(); panelColorRed.MouseDown += panel_MouseDown; panelColorBlue.MouseDown += panel_MouseDown; panelColorGreen.MouseDown += panel_MouseDown; @@ -28,45 +30,53 @@ namespace HoistingCrane panelColorGray.MouseDown += panel_MouseDown; panelColorPurple.MouseDown += panel_MouseDown; buttonCancel.Click += (sender, e) => Close(); - - InitializeComponent(); } + /// + /// Привязка метода к событию + /// + /// public void AddEvent(CarDelegate carDelegate) { _carDelegate += carDelegate; } + /// + /// Отрисовка объекта + /// private void DrawObject() { Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); Graphics gr = Graphics.FromImage(bmp); car?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); - car?.SetPosition(5, 5); + car?.SetPosition(25, 25); car?.DrawTransport(gr); pictureBoxObject.Image = bmp; } - + /// + /// Передаем информацию при нажатии на Label + /// + /// + /// private void labelObject_MouseDown(object sender, MouseEventArgs e) { - var label = sender as Label; - label?.DoDragDrop(label.Name, DragDropEffects.Move); - label?.DoDragDrop(label.Name, DragDropEffects.Copy); + (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy); } - + /// + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// private void panel_DragEnter(object sender, DragEventArgs e) { - if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } + e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None; } - + /// + /// Действия при приеме перетаскиваемой информации + /// + /// + /// private void panel_DragDrop(object sender, DragEventArgs e) { - switch (e.Data?.GetData(DataFormats.Text)?.ToString()) + switch (e.Data?.GetData(DataFormats.Text).ToString()) { case "labelSimpleObject": car = new DrawningTrackedVehicle((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White); @@ -78,35 +88,20 @@ namespace HoistingCrane } DrawObject(); } - + /// + /// Передаем информацию при нажатии на Panel + /// + /// + /// private void panel_MouseDown(object? sender, MouseEventArgs e) { - var color = sender as Label; - color?.DoDragDrop(color.BackColor, DragDropEffects.Move); - color?.DoDragDrop(color.BackColor, DragDropEffects.Copy); + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor ?? Color.White, DragDropEffects.Move | DragDropEffects.Copy); } - - // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта) - private void labelColors_DragEnter(object sender, DragEventArgs e) - { - var label = (String)sender; - Color newColor = (Color)e.Data.GetData(typeof(Color).ToString()); - switch (label) - { - case "labelBodyColor": - car?.EntityTrackedVehicle?.SetBodyColor(newColor); - DrawObject(); - break; - case "labelAdditionalColor": - if (car is DrawningHoistingCrane) - { - (car.EntityTrackedVehicle as EntityHoistingCrane).SetAdditionalColor(newColor); - DrawObject(); - } - break; - } - } - + /// + /// Передача объекта + /// + /// + /// private void buttonAdd_Click(object sender, EventArgs e) { if (car != null) @@ -115,8 +110,67 @@ namespace HoistingCrane Close(); } } - - + /// + /// Прорисовка основным цветом + /// + /// + /// + private void labelBodyColor_DragDrop(object sender, DragEventArgs e) + { + if (car != null) + { + car.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + DrawObject(); + } + } + /// + /// Передача основного цвета + /// + /// + /// + private void labelBodyColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + /// + /// Прорисовка основным цветом + /// + /// + /// + private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) + { + if (car?.EntityTrackedVehicle is EntityHoistingCrane entityHoistingCrane) + { + entityHoistingCrane.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); + } + DrawObject(); + } + /// + /// Передача дополнительного цвета + /// + /// + /// + private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e) + { + if (car is DrawningHoistingCrane) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + } } } -- 2.25.1 From d1ad0107775826838cc613b63eddaafd06be061a Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sun, 14 Apr 2024 21:47:16 +0400 Subject: [PATCH 03/10] =?UTF-8?q?=D0=BC=D0=B0=D0=BB=D0=B5=D0=BD=D1=8C?= =?UTF-8?q?=D0=BA=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormCarCollection.Designer.cs | 37 ++++++++---- .../HoistingCrane/FormCarCollection.cs | 57 +++---------------- 2 files changed, 33 insertions(+), 61 deletions(-) diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs b/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs index 871848a..0977933 100644 --- a/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs +++ b/HoistingCrane/HoistingCrane/FormCarCollection.Designer.cs @@ -45,21 +45,19 @@ comboBoxSelectorCompany = new ComboBox(); buttonCreateHoistingCrane = new Button(); pictureBox = new PictureBox(); + panelCompanyTool = new Panel(); groupBoxTools.SuspendLayout(); panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); + panelCompanyTool.SuspendLayout(); SuspendLayout(); // // groupBoxTools // + groupBoxTools.Controls.Add(panelCompanyTool); groupBoxTools.Controls.Add(buttonCreateCompany); groupBoxTools.Controls.Add(panelStorage); - groupBoxTools.Controls.Add(buttonGoToChek); - groupBoxTools.Controls.Add(buttonRefresh); - groupBoxTools.Controls.Add(buttonDeleteCar); - groupBoxTools.Controls.Add(maskedTextBox); groupBoxTools.Controls.Add(comboBoxSelectorCompany); - groupBoxTools.Controls.Add(buttonCreateHoistingCrane); groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Location = new Point(763, 0); groupBoxTools.Name = "groupBoxTools"; @@ -163,7 +161,7 @@ // buttonGoToChek // buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToChek.Location = new Point(12, 440); + buttonGoToChek.Location = new Point(9, 99); buttonGoToChek.Name = "buttonGoToChek"; buttonGoToChek.Size = new Size(192, 24); buttonGoToChek.TabIndex = 6; @@ -174,7 +172,7 @@ // buttonRefresh // buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(12, 470); + buttonRefresh.Location = new Point(9, 129); buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Size = new Size(192, 27); buttonRefresh.TabIndex = 5; @@ -185,7 +183,7 @@ // buttonDeleteCar // buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonDeleteCar.Location = new Point(12, 411); + buttonDeleteCar.Location = new Point(9, 70); buttonDeleteCar.Name = "buttonDeleteCar"; buttonDeleteCar.Size = new Size(192, 23); buttonDeleteCar.TabIndex = 4; @@ -196,7 +194,7 @@ // maskedTextBox // maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - maskedTextBox.Location = new Point(12, 382); + maskedTextBox.Location = new Point(9, 41); maskedTextBox.Mask = "00"; maskedTextBox.Name = "maskedTextBox"; maskedTextBox.Size = new Size(192, 23); @@ -212,12 +210,12 @@ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Size = new Size(192, 23); comboBoxSelectorCompany.TabIndex = 2; - comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1; + comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged; // // buttonCreateHoistingCrane // buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonCreateHoistingCrane.Location = new Point(12, 324); + buttonCreateHoistingCrane.Location = new Point(9, 13); buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane"; buttonCreateHoistingCrane.Size = new Size(192, 22); buttonCreateHoistingCrane.TabIndex = 0; @@ -234,6 +232,19 @@ pictureBox.TabIndex = 1; pictureBox.TabStop = false; // + // panelCompanyTool + // + panelCompanyTool.Anchor = AnchorStyles.None; + panelCompanyTool.Controls.Add(buttonCreateHoistingCrane); + panelCompanyTool.Controls.Add(maskedTextBox); + panelCompanyTool.Controls.Add(buttonRefresh); + panelCompanyTool.Controls.Add(buttonGoToChek); + panelCompanyTool.Controls.Add(buttonDeleteCar); + panelCompanyTool.Location = new Point(6, 324); + panelCompanyTool.Name = "panelCompanyTool"; + panelCompanyTool.Size = new Size(204, 185); + panelCompanyTool.TabIndex = 8; + // // FormCarCollection // AutoScaleDimensions = new SizeF(7F, 15F); @@ -244,10 +255,11 @@ Name = "FormCarCollection"; Text = "FormCarCollections"; groupBoxTools.ResumeLayout(false); - groupBoxTools.PerformLayout(); panelStorage.ResumeLayout(false); panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + panelCompanyTool.ResumeLayout(false); + panelCompanyTool.PerformLayout(); ResumeLayout(false); } @@ -270,5 +282,6 @@ private Button buttonDeleteCollection; private ListBox listBoxCollection; private Button buttonCollectionAdd; + private Panel panelCompanyTool; } } \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.cs b/HoistingCrane/HoistingCrane/FormCarCollection.cs index 8382a18..7e10c97 100644 --- a/HoistingCrane/HoistingCrane/FormCarCollection.cs +++ b/HoistingCrane/HoistingCrane/FormCarCollection.cs @@ -21,19 +21,12 @@ namespace HoistingCrane { InitializeComponent(); _storageCollection = new(); + panelCompanyTool.Enabled = false; } - - private void comboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e) + private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) { - switch (comboBoxSelectorCompany.Text) - { - case "Хранилище": - _company = new Garage(pictureBox.Width, pictureBox.Height, new MassivGenericObjects()); - break; - } + panelCompanyTool.Enabled = false; } - - private void CreateObject(string type) { DrawningTrackedVehicle drawning; @@ -41,7 +34,6 @@ namespace HoistingCrane Random rand = new(); switch (type) { - case nameof(DrawningHoistingCrane): drawning = new DrawningHoistingCrane(rand.Next(100, 300), rand.Next(1000, 3000), GetColor(rand), GetColor(rand), true, true); break; @@ -62,7 +54,6 @@ namespace HoistingCrane MessageBox.Show("Не удалось добавить объект"); } } - private static Color GetColor(Random random) { Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); @@ -72,24 +63,10 @@ namespace HoistingCrane color = dialog.Color; } return color; - } - - private void SetCar(DrawningTrackedVehicle car) - { - if (_company == null || car == null) - { - return; - } - if ((_company + car) != -1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _company.Show(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } } + private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningHoistingCrane)); + + private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrackedVehicle)); private void buttonDeleteCar_Click(object sender, EventArgs e) { @@ -113,13 +90,11 @@ namespace HoistingCrane MessageBox.Show("Не удалось удалить объект"); } } - private void buttonRefresh_Click(object sender, EventArgs e) { if (_company == null) return; pictureBox.Image = _company.Show(); } - private void buttonGoToChek_Click(object sender, EventArgs e) { if (_company == null) return; @@ -137,7 +112,6 @@ namespace HoistingCrane SetCar = car }; form.ShowDialog(); - } /// @@ -155,7 +129,6 @@ namespace HoistingCrane } } } - private void buttonCollectionAdd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked)) @@ -177,25 +150,18 @@ namespace HoistingCrane collectionType); RerfreshListBoxItems(); } - private void buttonDeleteCollection_Click(object sender, EventArgs e) { - // TODO прописать логику удаления элемента из коллекции - // нужно убедиться, что есть выбранная коллекция - // спросить у пользователя через MessageBox, что он подтверждает, что хочет удалить запись - // удалить и обновить ListBox if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null) { MessageBox.Show("Коллекция не выбрана"); return; } - if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) + if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); RerfreshListBoxItems(); - } - private void buttonCreateCompany_Click(object sender, EventArgs e) { if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null) @@ -215,16 +181,9 @@ namespace HoistingCrane _company = new Garage(pictureBox.Width, pictureBox.Height, collection); break; } - panelStorage.Enabled = true; + panelCompanyTool.Enabled = true; RerfreshListBoxItems(); } - - private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) - { - FormCarConfig form = new(); - form.AddEvent(SetCar); - form.Show(); - } } } -- 2.25.1 From ea6a49ba00b4c4cbb9ba95cbe639819af2f1d37e Mon Sep 17 00:00:00 2001 From: Vladislav_396ntk Date: Mon, 15 Apr 2024 11:28:15 +0400 Subject: [PATCH 04/10] =?UTF-8?q?=D0=BF=D0=BE=D1=87=D1=82=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ListGenericObjects.cs | 26 +++++++------------ .../StorageCollection.cs | 1 - .../HoistingCrane/FormCarCollection.cs | 24 +++++++++++++++-- HoistingCrane/HoistingCrane/FormCarConfig.cs | 9 +++---- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs index de49ee1..48bb52d 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs @@ -20,16 +20,16 @@ namespace HoistingCrane.CollectionGenericObjects /// Максимально допустимое число объектов в списке /// private int _maxCount; - public int Count + public int Count { get { return list.Count; } } - public int SetMaxCount + public int SetMaxCount { set { - if(value > 0) + if (value > 0) { _maxCount = value; } @@ -39,11 +39,8 @@ namespace HoistingCrane.CollectionGenericObjects public T? Get(int position) { // TODO проверка позиции - if(position >= 0 && position < _maxCount) - { - return list[position]; - } - return null; + if (position >= Count || position < 0) return null; + return list[position]; } @@ -51,9 +48,9 @@ namespace HoistingCrane.CollectionGenericObjects { // TODO проверка, что не превышено максимальное количество элементов // TODO вставка в конец набора - if (Count == _maxCount) - { - return -1; + if (Count == _maxCount) + { + return -1; } list.Add(obj); return Count; @@ -70,21 +67,18 @@ namespace HoistingCrane.CollectionGenericObjects } list.Insert(position, obj); return position; - - } - public T? Remove(int position) { // TODO проверка позиции // TODO удаление объекта из списка - if(position >= 0 && position < list.Count) + if (position >= 0 && position < list.Count) { T? temp = list[position]; list.RemoveAt(position); return temp; } return null; - } + } } } diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs index 0765bd3..d1e5183 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs @@ -60,5 +60,4 @@ namespace HoistingCrane.CollectionGenericObjects } } } - } diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.cs b/HoistingCrane/HoistingCrane/FormCarCollection.cs index 7e10c97..bd42830 100644 --- a/HoistingCrane/HoistingCrane/FormCarCollection.cs +++ b/HoistingCrane/HoistingCrane/FormCarCollection.cs @@ -64,9 +64,29 @@ namespace HoistingCrane } return color; } - private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningHoistingCrane)); + private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) + { + FormCarConfig form = new(); + form.Show(); + form.AddEvent(SetCar); + } + private void SetCar(DrawningTrackedVehicle drawningTrackedVehicle) + { + if (_company == null || drawningTrackedVehicle == null) + { + return; + } - private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrackedVehicle)); + if (_company + drawningTrackedVehicle != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _company.Show(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } private void buttonDeleteCar_Click(object sender, EventArgs e) { diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.cs b/HoistingCrane/HoistingCrane/FormCarConfig.cs index 3135eb7..9105a92 100644 --- a/HoistingCrane/HoistingCrane/FormCarConfig.cs +++ b/HoistingCrane/HoistingCrane/FormCarConfig.cs @@ -117,11 +117,10 @@ namespace HoistingCrane /// private void labelBodyColor_DragDrop(object sender, DragEventArgs e) { - if (car != null) - { - car.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color))); - DrawObject(); - } + if (car == null) + return; + car.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + DrawObject(); } /// /// Передача основного цвета -- 2.25.1 From 1cd23e10d7e574732a8db6abd8d481a05cb3e91a Mon Sep 17 00:00:00 2001 From: Vladislav_396ntk Date: Mon, 15 Apr 2024 11:44:04 +0400 Subject: [PATCH 05/10] / --- HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs b/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs index 2721270..602cf09 100644 --- a/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs +++ b/HoistingCrane/HoistingCrane/FormCarConfig.Designer.cs @@ -166,7 +166,7 @@ checkBoxPlatform.AutoSize = true; checkBoxPlatform.Location = new Point(6, 135); checkBoxPlatform.Name = "checkBoxPlatform"; - checkBoxPlatform.Size = new Size(148, 19); + checkBoxPlatform.Size = new Size(144, 19); checkBoxPlatform.TabIndex = 7; checkBoxPlatform.Text = "Наличие платформы"; checkBoxPlatform.UseVisualStyleBackColor = true; @@ -176,7 +176,7 @@ checkBoxCounterweight.AutoSize = true; checkBoxCounterweight.Location = new Point(6, 110); checkBoxCounterweight.Name = "checkBoxCounterweight"; - checkBoxCounterweight.Size = new Size(155, 19); + checkBoxCounterweight.Size = new Size(148, 19); checkBoxCounterweight.TabIndex = 6; checkBoxCounterweight.Text = "Наличие противовеса"; checkBoxCounterweight.UseVisualStyleBackColor = true; @@ -206,7 +206,7 @@ labelWeight.AutoSize = true; labelWeight.Location = new Point(6, 68); labelWeight.Name = "labelWeight"; - labelWeight.Size = new Size(28, 15); + labelWeight.Size = new Size(26, 15); labelWeight.TabIndex = 3; labelWeight.Text = "Вес"; // @@ -215,7 +215,7 @@ labelSpeed.AutoSize = true; labelSpeed.Location = new Point(6, 33); labelSpeed.Name = "labelSpeed"; - labelSpeed.Size = new Size(60, 15); + labelSpeed.Size = new Size(59, 15); labelSpeed.TabIndex = 2; labelSpeed.Text = "Скорость"; // @@ -256,6 +256,7 @@ // // labelAdditionalColor // + labelAdditionalColor.AllowDrop = true; labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; labelAdditionalColor.Location = new Point(116, 9); labelAdditionalColor.Name = "labelAdditionalColor"; @@ -268,6 +269,7 @@ // // labelBodyColor // + labelBodyColor.AllowDrop = true; labelBodyColor.BorderStyle = BorderStyle.FixedSingle; labelBodyColor.Location = new Point(3, 9); labelBodyColor.Name = "labelBodyColor"; -- 2.25.1 From 68f321a652cb817ba6ebd979bcf76b61845ab50f Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sun, 28 Apr 2024 00:24:18 +0400 Subject: [PATCH 06/10] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MassivGenericObjects.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs index ef399d3..39d6839 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs @@ -8,39 +8,39 @@ namespace HoistingCrane.CollectionGenericObjects { arr = Array.Empty(); } - public int Count + public int Count { - get { return arr.Length; } - } + get { return arr.Length; } + } public int SetMaxCount { set { if (value > 0) { - arr = new T?[value]; + if (arr.Length > 0) + { + Array.Resize(ref arr, value); + } + else + { + arr = new T?[value]; + } } } } public T? Get(int position) { - if(position >= 0 && position < arr.Length) + if (position >= 0 && position < arr.Length) { return arr[position]; } - return null; + return null; } public int Insert(T obj) { - for (int i = 0; i < Count; i++) - { - if (arr[i] == null) - { - return Insert(obj, 0); - } - } - return -1; + return Insert(obj, 0); } public int Insert(T obj, int position) -- 2.25.1 From 242fad7ac8b6a41f6eb56e1b9ae434c4adb5a59d Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sun, 28 Apr 2024 01:09:39 +0400 Subject: [PATCH 07/10] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HoistingCrane/HoistingCrane/CarDelegate.cs | 12 ------ .../Entities/EntityHoistingCrane.cs | 6 +-- .../Entities/EntityTrackedVehicle.cs | 6 +-- HoistingCrane/HoistingCrane/FormCarConfig.cs | 38 +++++++++++-------- 4 files changed, 29 insertions(+), 33 deletions(-) delete mode 100644 HoistingCrane/HoistingCrane/CarDelegate.cs diff --git a/HoistingCrane/HoistingCrane/CarDelegate.cs b/HoistingCrane/HoistingCrane/CarDelegate.cs deleted file mode 100644 index 7383591..0000000 --- a/HoistingCrane/HoistingCrane/CarDelegate.cs +++ /dev/null @@ -1,12 +0,0 @@ -using HoistingCrane.Drawning; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace HoistingCrane -{ - public delegate void CarDelegate(DrawningTrackedVehicle car); - -} diff --git a/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs b/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs index 674c373..3c6c8f9 100644 --- a/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/Entities/EntityHoistingCrane.cs @@ -10,16 +10,16 @@ public class EntityHoistingCrane : EntityTrackedVehicle /// /// /// - public Color AdditionalColor { get; protected set; } + public Color AdditionalColor { get; private set; } /// /// /// - public bool Counterweight { get; protected set; } + public bool Counterweight { get; private set; } /// /// /// - public bool Platform { get; protected set; } + public bool Platform { get; private set; } /// /// diff --git a/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs b/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs index 0a479d7..caef6bc 100644 --- a/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs +++ b/HoistingCrane/HoistingCrane/Entities/EntityTrackedVehicle.cs @@ -9,19 +9,19 @@ /// /// Скорость, которой обладает объект /// - public int Speed { get; protected set; } + public int Speed { get; private set; } /// /// Вес, которым обладает объект /// - public double Weight { get; protected set; } + public double Weight { get; private set; } /// /// Основной цвет объекта /// - public Color BodyColor { get; protected set; } + public Color BodyColor { get; private set; } /// diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.cs b/HoistingCrane/HoistingCrane/FormCarConfig.cs index 9105a92..1908fc4 100644 --- a/HoistingCrane/HoistingCrane/FormCarConfig.cs +++ b/HoistingCrane/HoistingCrane/FormCarConfig.cs @@ -16,8 +16,8 @@ namespace HoistingCrane { public partial class FormCarConfig : Form { - private DrawningTrackedVehicle? car = null; - private event CarDelegate? _carDelegate; + private DrawningTrackedVehicle? drawningTrackedVehicle; + private event Action? _carDelegate; public FormCarConfig() { InitializeComponent(); @@ -35,9 +35,17 @@ namespace HoistingCrane /// Привязка метода к событию /// /// - public void AddEvent(CarDelegate carDelegate) + public void AddEvent(Action carDelegate) { - _carDelegate += carDelegate; + if (carDelegate == null) + { + _carDelegate = carDelegate; + } + else + { + _carDelegate += carDelegate; + } + } /// /// Отрисовка объекта @@ -46,9 +54,9 @@ namespace HoistingCrane { Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); Graphics gr = Graphics.FromImage(bmp); - car?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); - car?.SetPosition(25, 25); - car?.DrawTransport(gr); + drawningTrackedVehicle?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); + drawningTrackedVehicle?.SetPosition(25, 25); + drawningTrackedVehicle?.DrawTransport(gr); pictureBoxObject.Image = bmp; } /// @@ -79,10 +87,10 @@ namespace HoistingCrane switch (e.Data?.GetData(DataFormats.Text).ToString()) { case "labelSimpleObject": - car = new DrawningTrackedVehicle((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White); + drawningTrackedVehicle = new DrawningTrackedVehicle((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White); break; case "labelModifiedObject": - car = new DrawningHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCounterweight.Checked, + drawningTrackedVehicle = new DrawningHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCounterweight.Checked, checkBoxPlatform.Checked); break; } @@ -104,9 +112,9 @@ namespace HoistingCrane /// private void buttonAdd_Click(object sender, EventArgs e) { - if (car != null) + if (drawningTrackedVehicle != null) { - _carDelegate?.Invoke(car); + _carDelegate?.Invoke(drawningTrackedVehicle); Close(); } } @@ -117,9 +125,9 @@ namespace HoistingCrane /// private void labelBodyColor_DragDrop(object sender, DragEventArgs e) { - if (car == null) + if (drawningTrackedVehicle == null) return; - car.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + drawningTrackedVehicle.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color))); DrawObject(); } /// @@ -145,7 +153,7 @@ namespace HoistingCrane /// private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e) { - if (car?.EntityTrackedVehicle is EntityHoistingCrane entityHoistingCrane) + if (drawningTrackedVehicle?.EntityTrackedVehicle is EntityHoistingCrane entityHoistingCrane) { entityHoistingCrane.SetAdditionalColor((Color)e.Data.GetData(typeof(Color))); } @@ -158,7 +166,7 @@ namespace HoistingCrane /// private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e) { - if (car is DrawningHoistingCrane) + if (drawningTrackedVehicle is DrawningHoistingCrane) { if (e.Data.GetDataPresent(typeof(Color))) { -- 2.25.1 From ccc5ae522787c04460bbd808739e40ffd82b1bb7 Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sun, 28 Apr 2024 10:26:52 +0400 Subject: [PATCH 08/10] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HoistingCrane/CollectionGenericObjects/AbstractCompany.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs index 7ed15c5..3f787d3 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs @@ -31,7 +31,7 @@ namespace HoistingCrane.CollectionGenericObjects { get { - return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth); + return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth)-3; } } public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects array) -- 2.25.1 From 04c45def82545b8610691d27abad2a5002008066 Mon Sep 17 00:00:00 2001 From: sqdselo Date: Mon, 29 Apr 2024 12:19:14 +0400 Subject: [PATCH 09/10] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HoistingCrane/HoistingCrane/FormCarConfig.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.cs b/HoistingCrane/HoistingCrane/FormCarConfig.cs index 1908fc4..2d0cd40 100644 --- a/HoistingCrane/HoistingCrane/FormCarConfig.cs +++ b/HoistingCrane/HoistingCrane/FormCarConfig.cs @@ -45,7 +45,6 @@ namespace HoistingCrane { _carDelegate += carDelegate; } - } /// /// Отрисовка объекта @@ -105,6 +104,7 @@ namespace HoistingCrane { (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor ?? Color.White, DragDropEffects.Move | DragDropEffects.Copy); } + /// /// Передача объекта /// @@ -118,6 +118,7 @@ namespace HoistingCrane Close(); } } + /// /// Прорисовка основным цветом /// -- 2.25.1 From f6f705c9f2197d57a95d34870e79e596c73b6af4 Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sat, 4 May 2024 16:00:29 +0400 Subject: [PATCH 10/10] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HoistingCrane/CollectionGenericObjects/AbstractCompany.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs index 3f787d3..7ed15c5 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs @@ -31,7 +31,7 @@ namespace HoistingCrane.CollectionGenericObjects { get { - return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth)-3; + return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth); } } public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects array) -- 2.25.1