diff --git a/WarmlyShip/WarmlyShip/FormMapWithSetShips.Designer.cs b/WarmlyShip/WarmlyShip/FormMapWithSetShips.Designer.cs index a341bb7..d2b41f7 100644 --- a/WarmlyShip/WarmlyShip/FormMapWithSetShips.Designer.cs +++ b/WarmlyShip/WarmlyShip/FormMapWithSetShips.Designer.cs @@ -75,6 +75,7 @@ this.buttonLeft.TabIndex = 10; this.buttonLeft.Text = " "; this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonRight // @@ -87,6 +88,7 @@ this.buttonRight.TabIndex = 9; this.buttonRight.Text = " "; this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonUp // @@ -99,6 +101,7 @@ this.buttonUp.TabIndex = 8; this.buttonUp.Text = " "; this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonDown // @@ -111,6 +114,7 @@ this.buttonDown.TabIndex = 7; this.buttonDown.Text = " "; this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonShowOnMap // diff --git a/WarmlyShip/WarmlyShip/FormMapWithSetShips.cs b/WarmlyShip/WarmlyShip/FormMapWithSetShips.cs index 9c4fabe..c8c6313 100644 --- a/WarmlyShip/WarmlyShip/FormMapWithSetShips.cs +++ b/WarmlyShip/WarmlyShip/FormMapWithSetShips.cs @@ -141,16 +141,24 @@ namespace WarmlyShip switch (name) { case "buttonUp": - dir = Direction.Up; + { + dir = Direction.Up; + } break; case "buttonDown": - dir = Direction.Down; + { + dir = Direction.Down; + } break; case "buttonLeft": - dir = Direction.Left; + { + dir = Direction.Left; + } break; case "buttonRight": - dir = Direction.Right; + { + dir = Direction.Right; + } break; } pictureBox.Image = _mapShipsCollectionGeneric.MoveObject(dir); diff --git a/WarmlyShip/WarmlyShip/FormShip.cs b/WarmlyShip/WarmlyShip/FormShip.cs index f9c1185..14a5ceb 100644 --- a/WarmlyShip/WarmlyShip/FormShip.cs +++ b/WarmlyShip/WarmlyShip/FormShip.cs @@ -34,10 +34,16 @@ namespace WarmlyShip private void buttonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _ship = new DrawningShip(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - _ship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxShip.Width, pictureBoxShip.Height); + 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 DrawningShip(rnd.Next(100, 300), rnd.Next(1000, 2000), + color); SetData(); - Draw(); } private void ButtonMove_Click(object sender, EventArgs e) @@ -69,12 +75,27 @@ namespace WarmlyShip private void ButtonCreateModif_Click(object sender, EventArgs e) { 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; + } _ship = new DrawningWarmlyShip(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, dopColor, + Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, + 2))); SetData(); Draw(); + } private void ButtonSelectShip_Click(object sender, EventArgs e)