Сданная лаба
This commit is contained in:
parent
2d38dcf373
commit
378ba86d6c
@ -67,7 +67,7 @@ namespace Airbus
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawningObjectPlane plane = new(form.SelectedPlane);
|
||||
if (_mapPlanesCollectionGeneric + plane)
|
||||
if (_mapPlanesCollectionGeneric + plane != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet();
|
||||
@ -94,7 +94,7 @@ namespace Airbus
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapPlanesCollectionGeneric - pos)
|
||||
if (_mapPlanesCollectionGeneric - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet();
|
||||
|
@ -55,7 +55,7 @@ namespace Airbus
|
||||
/// <param name="map"></param>
|
||||
/// <param name="planes"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(MapWithSetPlanesGeneric<T, U> map, T planes)
|
||||
public static int operator +(MapWithSetPlanesGeneric<T, U> map, T planes)
|
||||
{
|
||||
return map._setPlanes.Insert(planes);
|
||||
}
|
||||
@ -65,7 +65,7 @@ namespace Airbus
|
||||
/// <param name="map"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator -(MapWithSetPlanesGeneric<T, U> map, int position)
|
||||
public static T operator -(MapWithSetPlanesGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setPlanes.Remove(position);
|
||||
}
|
||||
@ -144,6 +144,23 @@ namespace Airbus
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Brush road = new SolidBrush(Color.Gray);
|
||||
g.FillRectangle(road, 0, 0, _pictureWidth, _pictureHeight);
|
||||
Brush lines = new SolidBrush(Color.White);
|
||||
for (int y = 0; y < _pictureHeight; y+=80)
|
||||
{
|
||||
g.FillRectangle(lines, _pictureWidth / 2 - 10, y, 20, 70);
|
||||
}
|
||||
int lastLine = 0;
|
||||
for (int y = 50; y < _pictureHeight; y += _pictureHeight/3 - 50)
|
||||
{
|
||||
g.FillRectangle(lines, _pictureWidth / 3 - 10, y, 20, 70);
|
||||
g.FillRectangle(lines, _pictureWidth - _pictureWidth / 3 - 10, y, 20, 70);
|
||||
lastLine = y;
|
||||
}
|
||||
g.FillRectangle(lines, _pictureWidth / 3 - 40, lastLine, 20, 70);
|
||||
g.FillRectangle(lines, _pictureWidth - _pictureWidth / 3 + 20, lastLine, 20, 70);
|
||||
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
@ -155,6 +172,8 @@ namespace Airbus
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth,
|
||||
(_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод прорисовки объектов
|
||||
@ -170,7 +189,7 @@ namespace Airbus
|
||||
// TODO установка позиции
|
||||
if(_setPlanes.Get(i) != null)
|
||||
{
|
||||
_setPlanes.Get(i).SetObject(i % width * _placeSizeWidth, (height - 1 - i / width) * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
||||
_setPlanes.Get(i).SetObject((width - i % width - 1) * _placeSizeWidth,(height - i / width - 1) * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
||||
_setPlanes.Get(i)?.DrawningObject(g);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace Airbus
|
||||
/// </summary>
|
||||
/// <param name="car">Добавляемый самолёт</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T plane)
|
||||
public int Insert(T plane)
|
||||
{
|
||||
// TODO вставка в начало набора
|
||||
return Insert(plane, 0);
|
||||
@ -42,7 +42,7 @@ namespace Airbus
|
||||
/// <param name="plane">Добавляемый самолёт</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T plane, int position)
|
||||
public int Insert(T plane, int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||
@ -53,6 +53,7 @@ namespace Airbus
|
||||
if(_places[position] == null)
|
||||
{
|
||||
_places[position] = plane;
|
||||
return position;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -71,32 +72,27 @@ namespace Airbus
|
||||
{
|
||||
for (var i = pos; i > position; --i) _places[i] = _places[i - 1];
|
||||
_places[position] = plane;
|
||||
return position;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public bool Remove(int position)
|
||||
public T Remove(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO удаление объекта из массива, присовив элементу массива значение null
|
||||
if (position < 0 || position >= Count || _places[position] == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_places[position] = null;
|
||||
return true;
|
||||
}
|
||||
if (position < 0 || position >= Count || _places[position] == null) return null;
|
||||
T DeletePlane = _places[position];
|
||||
_places[position] = null;
|
||||
return DeletePlane;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
|
Loading…
Reference in New Issue
Block a user