From 2b46380712450b307052a8ca95a2ccd439c167a1 Mon Sep 17 00:00:00 2001 From: kaznacheeva Date: Tue, 21 Nov 2023 15:14:59 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=87=D0=B0=D1=8F=205?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Battleship/Battleship/DrawningShip.cs | 4 ++-- Battleship/Battleship/FormShipCollection.cs | 7 ++----- Battleship/Battleship/FormShipConfig.cs | 5 +---- Battleship/Battleship/ShipGenericCollection.cs | 3 +++ 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Battleship/Battleship/DrawningShip.cs b/Battleship/Battleship/DrawningShip.cs index 019988f..6a56b76 100644 --- a/Battleship/Battleship/DrawningShip.cs +++ b/Battleship/Battleship/DrawningShip.cs @@ -22,11 +22,11 @@ namespace Battleship.DrawningObjects /// /// Ширина окна /// - private int _pictureWidth; + public int _pictureWidth; /// /// Высота окна /// - private int _pictureHeight; + public int _pictureHeight; /// /// Левая координата прорисовки /// diff --git a/Battleship/Battleship/FormShipCollection.cs b/Battleship/Battleship/FormShipCollection.cs index 0901969..a047311 100644 --- a/Battleship/Battleship/FormShipCollection.cs +++ b/Battleship/Battleship/FormShipCollection.cs @@ -100,8 +100,7 @@ namespace Battleship { return; } - var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? - string.Empty]; + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; if (obj == null) { return; @@ -109,10 +108,8 @@ namespace Battleship var FormShipConfig = new FormShipConfig(); FormShipConfig.AddEvent(AddShip); - FormShipConfig.Show(); - + FormShipConfig.Show(); } - private void AddShip(DrawningShip drawningShip) { if (listBoxStorages.SelectedIndex == -1) diff --git a/Battleship/Battleship/FormShipConfig.cs b/Battleship/Battleship/FormShipConfig.cs index 52a1b27..4f09ab2 100644 --- a/Battleship/Battleship/FormShipConfig.cs +++ b/Battleship/Battleship/FormShipConfig.cs @@ -15,7 +15,7 @@ namespace Battleship public partial class FormShipConfig : Form { /// - /// Переменная-выбранная машина + /// Переменная-выбранный корабль /// DrawningShip? _ship = null; /// @@ -37,9 +37,7 @@ namespace Battleship panelYellow.MouseDown += PanelColor_MouseDown; panelBlue.MouseDown += PanelColor_MouseDown; - // TODO buttonCancel.Click with lambda buttonCancel.Click += (s, e) => Close(); - } /// /// Отрисовать машину @@ -113,7 +111,6 @@ namespace Battleship } DrawShip(); } - // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта) /// /// Добавление машины /// diff --git a/Battleship/Battleship/ShipGenericCollection.cs b/Battleship/Battleship/ShipGenericCollection.cs index ac2d497..86d4fb8 100644 --- a/Battleship/Battleship/ShipGenericCollection.cs +++ b/Battleship/Battleship/ShipGenericCollection.cs @@ -73,11 +73,14 @@ namespace Battleship.Generics } private void DrawObjects(Graphics g) { + int width = _pictureWidth/ _placeSizeWidth; int i = 0; foreach(var ship in _collection.GetShips()) { if(ship != null) { + ship._pictureWidth = _pictureWidth; + ship._pictureHeight = _pictureHeight; int inRow = _pictureWidth / _placeSizeWidth; ship.SetPosition(i % inRow * _placeSizeWidth, _pictureHeight - _pictureHeight % _placeSizeHeight - (i / inRow + 1) * _placeSizeHeight + 5); ship.DrawTransport(g);