From 8cb74ade231053482a79d4bad82e8409aa78889e Mon Sep 17 00:00:00 2001 From: the Date: Tue, 25 Oct 2022 09:28:25 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ship/Ship/FormShip.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Ship/Ship/FormShip.cs b/Ship/Ship/FormShip.cs index 14aad64..74fc689 100644 --- a/Ship/Ship/FormShip.cs +++ b/Ship/Ship/FormShip.cs @@ -37,7 +37,13 @@ namespace Ship private void buttonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _ship = new DrawingShip(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; + } + _ship = new DrawingShip(rnd.Next(100, 300), rnd.Next(1000, 2000), color); _ship.SetPosition(rnd.Next(10, 100), pictureBoxShip.Height - rnd.Next(50, 100), pictureBoxShip.Width, pictureBoxShip.Height); SetData(); @@ -88,10 +94,18 @@ namespace Ship private void buttonCreateModif_Click(object sender, EventArgs e) { Random rnd = new(); - _ship = new DrawingMotorShip(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)), - Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); + Color colorMain = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + Color colorAdd = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + colorMain = dialog.Color; + } + if (dialog.ShowDialog() == DialogResult.OK) + { + colorAdd = dialog.Color; + } + _ship = new DrawingMotorShip(rnd.Next(100, 300), rnd.Next(1000, 2000), colorMain, colorAdd, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); _ship.SetPosition(rnd.Next(50, 100), pictureBoxShip.Height - rnd.Next(80, 100), pictureBoxShip.Width, pictureBoxShip.Height); SetData(); Draw();