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] =?UTF-8?q?=D0=BC=D0=B0=D0=BB=D0=B5=D0=BD=D1=8C=D0=BA?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=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(); - } } }