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;