From 91aeb23ae06720dad7c1424a330af4eb831ea416 Mon Sep 17 00:00:00 2001 From: Andrey_Abazov Date: Tue, 18 Oct 2022 11:34:43 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A2=D1=80=D0=B5=D1=82=D1=8C=D1=8F=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0.=20=D0=9C=D0=B5?= =?UTF-8?q?=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20+=20=D1=84=D0=B8=D0=BA=D1=81=20=D0=BD=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirBomber/FormMapWithSetAirBombers.cs | 4 ++-- .../AirBomber/MapWithSetAirBombersGeneric.cs | 2 +- AirBomber/AirBomber/SetAirBombersGeneric.cs | 23 ++----------------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/AirBomber/AirBomber/FormMapWithSetAirBombers.cs b/AirBomber/AirBomber/FormMapWithSetAirBombers.cs index 6f1ee06..1656aee 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirBombers.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirBombers.cs @@ -58,8 +58,8 @@ namespace AirBomber FormAirBomber form = new(); if (form.ShowDialog() == DialogResult.OK) { - DrawingObjectAirBomber car = new(form.SelectedAirBomber); - if (_mapAirBombersCollectionGeneric + car != -1) + DrawingObjectAirBomber airBomber = new(form.SelectedAirBomber); + if (_mapAirBombersCollectionGeneric + airBomber != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _mapAirBombersCollectionGeneric.ShowSet(); diff --git a/AirBomber/AirBomber/MapWithSetAirBombersGeneric.cs b/AirBomber/AirBomber/MapWithSetAirBombersGeneric.cs index c00618d..d58632c 100644 --- a/AirBomber/AirBomber/MapWithSetAirBombersGeneric.cs +++ b/AirBomber/AirBomber/MapWithSetAirBombersGeneric.cs @@ -165,7 +165,7 @@ namespace AirBomber int numOfObjectsInRow = _pictureWidth / _placeSizeWidth; for (int i = 0; i < _setAirBombers.Count; i++) { - _setAirBombers.Get(i)?.SetObject((i % numOfObjectsInRow) * _placeSizeWidth, (i / numOfObjectsInRow) * _placeSizeHeight, _pictureWidth, _pictureHeight); + _setAirBombers.Get(i)?.SetObject((numOfObjectsInRow - (i % numOfObjectsInRow) - 1) * _placeSizeWidth, (i / numOfObjectsInRow) * _placeSizeHeight, _pictureWidth, _pictureHeight); _setAirBombers.Get(i)?.DrawingObject(g); } } diff --git a/AirBomber/AirBomber/SetAirBombersGeneric.cs b/AirBomber/AirBomber/SetAirBombersGeneric.cs index 43e4d9f..48d9abb 100644 --- a/AirBomber/AirBomber/SetAirBombersGeneric.cs +++ b/AirBomber/AirBomber/SetAirBombersGeneric.cs @@ -32,26 +32,7 @@ namespace AirBomber /// public int Insert(T airBomber) { - if (_places[0] != null) { - int indexNull = -1; - for (int i = 0; i < _places.Length; i++) - { - if (_places[i] == null) - { - indexNull = i; - break; - } - } - if (indexNull == -1) return -1; - for (int i = indexNull; i > 0; i--) - { - T tmp = _places[i]; - _places[i] = _places[i - 1]; - _places[i - 1] = tmp; - } - } - _places[0] = airBomber; - return 0; + return Insert(airBomber, 0); } /// /// Добавление объекта в набор на конкретную позицию @@ -77,7 +58,7 @@ namespace AirBomber } } if (indexNull == -1) return -1; - for (int i = indexNull; i > position; i++) + for (int i = indexNull; i > position; i--) { T tmp = _places[i]; _places[i] = _places[i - 1];