Сданная лаба

This commit is contained in:
ArtemEmelyanov 2022-11-30 10:08:55 +04:00
parent 39f7f8c79b
commit 5fa1c4cdc3
4 changed files with 29 additions and 18 deletions

View File

@ -176,7 +176,7 @@ namespace Airbus
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
{ {
MessageBox.Show("Объект удален"); MessageBox.Show("Объект удален");
_logger.LogInformation("Из текущей карты удалён объект {@Plane}", _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos); _logger.LogInformation("Из текущей карты удалён объект");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
} }
else else

View File

@ -169,8 +169,6 @@ namespace Airbus
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth,
(_pictureHeight / _placeSizeHeight) * _placeSizeHeight); (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
} }
} }
/// <summary> /// <summary>
/// Метод прорисовки объектов /// Метод прорисовки объектов
@ -214,7 +212,5 @@ namespace Airbus
_setPlanes.Insert(DrawningObjectPlane.Create(rec) as T); _setPlanes.Insert(DrawningObjectPlane.Create(rec) as T);
} }
} }
} }
} }

View File

@ -34,7 +34,9 @@ namespace Airbus
/// <returns></returns> /// <returns></returns>
public int Insert(T plane) public int Insert(T plane)
{ {
return Insert(plane, 0); ; if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount);
_places.Insert(0, plane);
return 0;
} }
/// <summary> /// <summary>
/// Добавление объекта в набор на конкретную позицию /// Добавление объекта в набор на конкретную позицию
@ -46,11 +48,7 @@ namespace Airbus
{ {
// TODO проверка позиции // TODO проверка позиции
// TODO вставка по позиции // TODO вставка по позиции
if (Count == _maxCount) if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount);
{
throw new StorageOverflowException(_maxCount);
}
if (position < 0 || position > _maxCount) return -1;
_places.Insert(position, plane); _places.Insert(position, plane);
return position; return position;
} }
@ -63,13 +61,13 @@ namespace Airbus
{ {
// TODO проверка позиции // TODO проверка позиции
// TODO удаление объекта из массива, присовив элементу массива значение null // TODO удаление объекта из массива, присовив элементу массива значение null
if (position >= _maxCount || position < 0) if (position >= _maxCount || position >= _places.Count) throw new PlaneNotFoundException(position);
{
throw new PlaneNotFoundException(position); T res = _places[position];
} _places.Remove(res);
T DeletePlane = _places[position];
_places.RemoveAt(position); if (res == null) throw new PlaneNotFoundException(position);
return DeletePlane; return res;
} }
/// <summary> /// <summary>
/// Получение объекта из набора по позиции /// Получение объекта из набора по позиции

View File

@ -0,0 +1,17 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Information",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/log_.log",
"rollingInterval": "Day",
"outputTemplate": "{Level:u4}: {Message:lj} [{Timestamp:HH:mm:ss.fff}]{NewLine}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
}
}