Реализация добавления объектов в хранилище.
This commit is contained in:
parent
9bba0b1a34
commit
31e27532f2
@ -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();
|
||||
|
@ -43,32 +43,33 @@ namespace Airbus
|
||||
}
|
||||
|
||||
//пеергрузка оператора сложения
|
||||
public static bool operator +(MapWithSetPlanesGeneric<T, U> map, T plane)
|
||||
{
|
||||
if (map._setPlanes.Insert(plane) != -1)
|
||||
public static int operator +(MapWithSetPlanesGeneric<T, U> 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<T, U> map, int position)
|
||||
public static T operator -(MapWithSetPlanesGeneric<T, U> 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--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user