From 0208828b09e5df96ade327fc621e9eaea7616c38 Mon Sep 17 00:00:00 2001 From: Ivan_Starostin Date: Tue, 19 Dec 2023 19:32:23 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BB=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lainer/Lainer1/FormLainerCollection.cs | 41 ++++++++++++++++---------- lainer/Lainer1/LainerDelegate.cs | 11 +++++++ 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 lainer/Lainer1/LainerDelegate.cs diff --git a/lainer/Lainer1/FormLainerCollection.cs b/lainer/Lainer1/FormLainerCollection.cs index 75fc4cf..5ad33d9 100644 --- a/lainer/Lainer1/FormLainerCollection.cs +++ b/lainer/Lainer1/FormLainerCollection.cs @@ -17,7 +17,7 @@ namespace ProjectLainer { int index = listBoxStorages.SelectedIndex; listBoxStorages.Items.Clear(); - + foreach (string key in _storage.Keys) { listBoxStorages.Items.Add(key); @@ -29,7 +29,7 @@ namespace ProjectLainer { listBoxStorages.SelectedIndex = index; } - } + } } private void ButtonAddObject_Click(object sender, EventArgs e) { @@ -66,19 +66,9 @@ namespace ProjectLainer { return; } - LainerForm form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - if (obj + form.SelectedLainer) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowLainers(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + var formLinerConfig = new FormLainerConfig(); + formLinerConfig.AddEvent(AddLainer); + formLinerConfig.Show(); } private void ButtonRemove_Click(object sender, EventArgs e) { @@ -126,5 +116,26 @@ namespace ProjectLainer { pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLainers(); } + private void AddLainer(DrawingEntity lainer) + { + if (listBoxStorages.SelectedIndex == -1) + { + return; + } + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + if (obj + lainer) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowLainers(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } } } diff --git a/lainer/Lainer1/LainerDelegate.cs b/lainer/Lainer1/LainerDelegate.cs new file mode 100644 index 0000000..588bcf2 --- /dev/null +++ b/lainer/Lainer1/LainerDelegate.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectLainer.DrawningObjects; + +namespace Lainers +{ + public delegate void LainerDelegate(DrawingEntity lainer); +}