From 8daf34e5241f91415ad47831b8ecc6ef521ce48b Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Fri, 10 Nov 2023 08:26:12 +0300 Subject: [PATCH] hard reboot --- .../AirplaneDelegate.cs | 12 --------- .../FormAirplaneConfig.cs | 25 +++++++++---------- .../FormAirplanesCollection.cs | 4 +-- 3 files changed, 14 insertions(+), 27 deletions(-) delete mode 100644 ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplaneDelegate.cs diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplaneDelegate.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplaneDelegate.cs deleted file mode 100644 index 30a98d8..0000000 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplaneDelegate.cs +++ /dev/null @@ -1,12 +0,0 @@ -using ProjectAirplaneWithRadar.DrawningObjects; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectAirplaneWithRadar -{ - public delegate void AirplaneDelegate(DrawningAirplane airplane); - -} diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneConfig.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneConfig.cs index 9b47ff3..1859eda 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneConfig.cs +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneConfig.cs @@ -9,20 +9,18 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; + namespace ProjectAirplaneWithRadar { public partial class FormAirplaneConfig : Form { DrawningAirplane? _airplane = null; - private event AirplaneDelegate? EventAddAirplane; - - DrawningAirplane SelectedAirplane(DrawningAirplane фшкздфту) - { - return _airplane; - } - - public void AddEvent(AirplaneDelegate ev) + Action? EventAddAirplane; + private readonly int PictureWidth; + private readonly int PictureHeight; + + public void AddEvent(Action? ev) { if (EventAddAirplane == null) { @@ -34,7 +32,7 @@ namespace ProjectAirplaneWithRadar } } - public FormAirplaneConfig() + public FormAirplaneConfig( int width, int height) { InitializeComponent(); blackPanel.MouseDown += PanelColor_MouseDown; @@ -48,6 +46,8 @@ namespace ProjectAirplaneWithRadar airplaneLabel.MouseDown += LabelObject_MouseDown; airplaneWithRadarLabel.MouseDown += LabelObject_MouseDown; cancelButton.Click += (s, e) => Close(); + PictureWidth = width; + PictureHeight = height; } public void DrawAirplane() @@ -70,13 +70,11 @@ namespace ProjectAirplaneWithRadar { case "airplaneLabel": _airplane = new DrawningAirplane((int)numericSpeed.Value, - (int)numericWeight.Value, Color.Silver, pictureBox.Width, - pictureBox.Height); + (int)numericWeight.Value, Color.Silver, PictureWidth, PictureHeight); break; case "airplaneWithRadarLabel": _airplane = new DrawningAirplaneWithRadar((int)numericSpeed.Value, - (int)numericWeight.Value, Color.Silver, Color.Black, checkRadar.Checked, checkDopBak.Checked, pictureBox.Width, - pictureBox.Height); + (int)numericWeight.Value, Color.Silver, Color.Black, checkRadar.Checked, checkDopBak.Checked, PictureWidth, PictureHeight); break; } colorLabel.BackColor = Color.Empty; @@ -100,6 +98,7 @@ namespace ProjectAirplaneWithRadar private void addButton_Click(object sender, EventArgs e) { + //_airplane?.SetPosition(5, 5); EventAddAirplane?.Invoke(_airplane); Close(); } diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs index 65cfadc..a3ea417 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs @@ -45,9 +45,9 @@ namespace ProjectAirplaneWithRadar { return; } - FormAirplaneConfig form = new(); + FormAirplaneConfig form = new(pictureBoxAirplanesCollection.Width, pictureBoxAirplanesCollection.Height); form.Show(); - AirplaneDelegate? airplaneDelegate = new((m) => { + Action < DrawningAirplane >? airplaneDelegate = new((m) => { bool q = (obj + m); if (q) {