Исправлен выброс исключения в переполненом хранилище
This commit is contained in:
parent
648fd7ac3f
commit
4c76b5ca81
@ -24,10 +24,11 @@ namespace AirBomber
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FormMapWithSetAirplanes()
|
public FormMapWithSetAirplanes(ILogger<FormMapWithSetAirplanes> logger)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||||
|
_logger = logger;
|
||||||
comboBoxSelectorMap.Items.Clear();
|
comboBoxSelectorMap.Items.Clear();
|
||||||
foreach(var elem in _mapsDict)
|
foreach(var elem in _mapsDict)
|
||||||
{
|
{
|
||||||
@ -73,6 +74,7 @@ namespace AirBomber
|
|||||||
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_logger.LogInformation("Добавлена карта \"%s\"", _mapsDict[comboBoxSelectorMap.Text]);
|
||||||
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
||||||
ReloadMaps();
|
ReloadMaps();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ namespace AirBomber
|
|||||||
/// <returns>Возвращает позицию вставленного объекта, либо -1 если его не удалось вставить</returns>
|
/// <returns>Возвращает позицию вставленного объекта, либо -1 если его не удалось вставить</returns>
|
||||||
public int Insert(T airplane, int position)
|
public int Insert(T airplane, int position)
|
||||||
{
|
{
|
||||||
if (position == _maxcount)
|
if (Count == _maxcount)
|
||||||
throw new StorageOverflowException();
|
throw new StorageOverflowException();
|
||||||
if (!isCorrectPosition(position))
|
if (!isCorrectPosition(position))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user