From 31e27532f24804934ff8114b4186686554497c92 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Tue, 11 Oct 2022 00:41:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B2=20=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D0=BB=D0=B8?= =?UTF-8?q?=D1=89=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/FormMapWithSetPlanes.cs | 4 +- Airbus/Airbus/MapWithSetPlanesGeneric.cs | 59 ++++++++++-------------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index 0977f9d..826e5a6 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -63,7 +63,7 @@ namespace Airbus { DrawningObjectPlane plane = new(form.SelectedPlane); - if(_mapPlanesCollectionGeneric + plane) + if(_mapPlanesCollectionGeneric + plane != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet(); @@ -91,7 +91,7 @@ namespace Airbus int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if(_mapPlanesCollectionGeneric - pos) + if(_mapPlanesCollectionGeneric - pos != null) { MessageBox.Show("Объект удалён"); pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet(); diff --git a/Airbus/Airbus/MapWithSetPlanesGeneric.cs b/Airbus/Airbus/MapWithSetPlanesGeneric.cs index 909a633..b1e12fe 100644 --- a/Airbus/Airbus/MapWithSetPlanesGeneric.cs +++ b/Airbus/Airbus/MapWithSetPlanesGeneric.cs @@ -43,32 +43,33 @@ namespace Airbus } //пеергрузка оператора сложения - public static bool operator +(MapWithSetPlanesGeneric map, T plane) - { - if (map._setPlanes.Insert(plane) != -1) + public static int operator +(MapWithSetPlanesGeneric map, T plane) + { + /*if (map._setPlanes.Insert(plane) != -1) { return true; } else { return false; - } - //return map._setPlanes.Insert(plane); + }*/ + + return map._setPlanes.Insert(plane); } //перегрузка оператора вычитания - public static bool operator -(MapWithSetPlanesGeneric map, int position) + public static T operator -(MapWithSetPlanesGeneric map, int position) { - if (map._setPlanes.Remove(position) != null) + /*if (map._setPlanes.Remove(position) != null) { return true; } else { return false; - } + }*/ - //return map._setPlanes.Remove(position); + return map._setPlanes.Remove(position); } //вывод всего набора объектов @@ -121,11 +122,11 @@ namespace Airbus { for (; j > i; j--) { - var car = _setPlanes.Get(j); + var plane = _setPlanes.Get(j); - if (car != null) + if (plane != null) { - _setPlanes.Insert(car, i); + _setPlanes.Insert(plane, i); _setPlanes.Remove(j); break; } @@ -202,37 +203,25 @@ namespace Airbus //метод прорисовки объеков public void DrawPlanes(Graphics g) { - int width = _pictureWidth / _placeSizeWidth; - int height = _pictureHeight / _placeSizeHeight; + int position = 0; + int currentWidth = 1; + int currentHeight = 5; - int currentWidth = 0; - int currentHeight = 0; - - for(int i = 0; i < _setPlanes.Count; i++) + for (int i = 0; i < _setPlanes.Count; i++) { - int bias = 0; //величина смещения - - if (currentWidth > 0 && currentHeight > 0) - { - bias = width; - } - - _setPlanes.Get(i)?.SetObject(_pictureWidth - currentWidth, _pictureHeight - height * currentHeight, _pictureWidth, _pictureHeight); + _setPlanes.Get(i)?.SetObject(currentWidth * _placeSizeWidth + 20, currentHeight * _placeSizeHeight + 20, _pictureWidth, _pictureHeight); _setPlanes.Get(i)?.DrawningObject(g); - if (currentWidth < width - 1) + if(position % 2 == 0) { - currentWidth++; + position++; + currentWidth--; } else { - currentWidth = 0; - currentHeight++; - } - - if (currentHeight > height) - { - return; + position = 0; + currentWidth = 1; + currentHeight--; } } }