From cceb17014c5167224045364036c5f6b4813cecfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BE=D0=BB=D0=BE=D0=B4=D1=8F?= Date: Sun, 9 Oct 2022 21:48:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirPlaneWithRadar/FormPlain.cs | 30 +++++++++++++------ .../AirPlaneWithRadar/SetPlaneGeneric.cs | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs b/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs index a79afdc..f2205e4 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs @@ -29,10 +29,13 @@ namespace AirPlaneWithRadar private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _plain = new DrawingPlain(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - - - + Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + _plain = new DrawingPlain(rnd.Next(100, 300), rnd.Next(1000, 2000), color); SetData(); Draw(); } @@ -67,13 +70,22 @@ namespace AirPlaneWithRadar { Random rnd = new(); + Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialogDop = new(); + if (dialogDop.ShowDialog() == DialogResult.OK) + { + dopColor = dialogDop.Color; + } _plain = new DrawingRadarPlane(rnd.Next(100, 300), rnd.Next(1000, 2000), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), + color, + dopColor, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); - - - SetData(); Draw(); } diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs b/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs index b030bd8..03b74b3 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs @@ -63,7 +63,7 @@ namespace AirPlaneWithRadar public T Remove(int position) { T mid; - if (_places[position] != null) + if (_places[position] != null && position < _places.Length) { mid = _places[position]; _places[position] = null;