From 939e4130a921646580587ccb6c0922569adc2145 Mon Sep 17 00:00:00 2001 From: just1valery Date: Mon, 3 Oct 2022 19:05:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarmlyShip/FormMapWithSetShips.Designer.cs | 3 ++- WarmlyShip/WarmlyShip/FormMapWithSetShips.cs | 11 +++++++---- WarmlyShip/WarmlyShip/MapWithSetShipsGeneric.cs | 12 ++++++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/WarmlyShip/WarmlyShip/FormMapWithSetShips.Designer.cs b/WarmlyShip/WarmlyShip/FormMapWithSetShips.Designer.cs index 65dd6d8..a341bb7 100644 --- a/WarmlyShip/WarmlyShip/FormMapWithSetShips.Designer.cs +++ b/WarmlyShip/WarmlyShip/FormMapWithSetShips.Designer.cs @@ -164,7 +164,8 @@ // this.comboBoxSelectorMap.FormattingEnabled = true; this.comboBoxSelectorMap.Items.AddRange(new object[] { - "Простая карта"}); + "Простая карта", + "Океан"}); this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 26); this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; this.comboBoxSelectorMap.Size = new System.Drawing.Size(238, 28); diff --git a/WarmlyShip/WarmlyShip/FormMapWithSetShips.cs b/WarmlyShip/WarmlyShip/FormMapWithSetShips.cs index 69a41c3..9c4fabe 100644 --- a/WarmlyShip/WarmlyShip/FormMapWithSetShips.cs +++ b/WarmlyShip/WarmlyShip/FormMapWithSetShips.cs @@ -32,6 +32,9 @@ namespace WarmlyShip case "Простая карта": map = new SimpleMap(); break; + case "Океан": + map = new OceanMap(); + break; } if (map != null) { @@ -58,14 +61,14 @@ namespace WarmlyShip if (form.ShowDialog() == DialogResult.OK) { DrawningObjectShip ship = new(form.SelectedShip); - if (_mapShipsCollectionGeneric + ship) + if (form.SelectedShip == null || !(_mapShipsCollectionGeneric + ship)) { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapShipsCollectionGeneric.ShowSet(); + MessageBox.Show("Не удалось добавить объект"); } else { - MessageBox.Show("Не удалось добавить объект"); + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapShipsCollectionGeneric.ShowSet(); } } } diff --git a/WarmlyShip/WarmlyShip/MapWithSetShipsGeneric.cs b/WarmlyShip/WarmlyShip/MapWithSetShipsGeneric.cs index 13bf9b4..9cb3bfd 100644 --- a/WarmlyShip/WarmlyShip/MapWithSetShipsGeneric.cs +++ b/WarmlyShip/WarmlyShip/MapWithSetShipsGeneric.cs @@ -21,11 +21,11 @@ namespace WarmlyShip /// /// Размер занимаемого объектом места (ширина) /// - private readonly int _placeSizeWidth = 210; + private readonly int _placeSizeWidth = 180; /// /// Размер занимаемого объектом места (высота) /// - private readonly int _placeSizeHeight = 90; + private readonly int _placeSizeHeight = 120; /// /// Набор объектов /// @@ -144,6 +144,14 @@ namespace WarmlyShip /// private void DrawBackground(Graphics g) { + for (int x = 0; x < _pictureWidth; x++) + { + for (int y = 0; y < _pictureWidth; y++) + { + Brush waterColor = new SolidBrush(Color.LightSkyBlue); + g.FillRectangle(waterColor, x * x, y * y, x * (x + 1), y * (y + 1)); + } + } Pen pen = new(Color.Black, 3); for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) {