From c241b589f3550bae6879e63e0ad6b49a33b6d412 Mon Sep 17 00:00:00 2001 From: vkobi Date: Tue, 23 Apr 2024 11:00:15 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B2=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=B4=D0=B5=D0=BB=D0=B5=D0=B3=D0=B0=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarmlyLocomotive/FormLocomotiveCollection.cs | 4 ++++ WarmlyLocomotive/WarmlyLocomotive/FormLocomotiveConfig.cs | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormLocomotiveCollection.cs b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotiveCollection.cs index d3790d6..4574a58 100644 --- a/WarmlyLocomotive/WarmlyLocomotive/FormLocomotiveCollection.cs +++ b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotiveCollection.cs @@ -44,6 +44,10 @@ public partial class FormLocomotiveCollection : Form /// private void ButtonAddLocomotive_Click(object sender, EventArgs e) { + if(_company == null) + { + return; + } FormLocomotiveConfig form = new(); // TODO передать метод form.AddEvent(SetLocomotive); diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormLocomotiveConfig.cs b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotiveConfig.cs index 03a0dec..4398f0b 100644 --- a/WarmlyLocomotive/WarmlyLocomotive/FormLocomotiveConfig.cs +++ b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotiveConfig.cs @@ -16,7 +16,7 @@ public partial class FormLocomotiveConfig : Form /// /// Событие для передачи объекта /// - private event LocomotiveDelegate? LocomotiveDelegate; + private event Action? LocomotiveDelegate; /// /// Конструктор @@ -34,15 +34,13 @@ public partial class FormLocomotiveConfig : Form panelBlue.MouseDown += Panel_MouseDown; buttonCancel.Click += (events, e) => Close(); - - } /// /// Привязка внешнего метода к событию /// /// - public void AddEvent(LocomotiveDelegate locomotiveDelegate) + public void AddEvent(Action locomotiveDelegate) { LocomotiveDelegate += locomotiveDelegate; }