diff --git a/AirBomber/DrawningBomber.cs b/AirBomber/DrawningBomber.cs index 689cb22..e7c551f 100644 --- a/AirBomber/DrawningBomber.cs +++ b/AirBomber/DrawningBomber.cs @@ -52,13 +52,13 @@ namespace AirBomber.DrawningObjects } public void SetPosition(int x, int y) { - if (_startPosX + _PlaneWidth > _pictureWidth) + if (x < 0 || x + _PlaneWidth > _pictureWidth) { - _startPosX = _pictureWidth - _PlaneWidth; + x = _pictureWidth - _PlaneWidth; } - if (_startPosY + _PlaneHeight > 740) + if (y < 0 || y + _PlaneWidth > _pictureHeight) { - _startPosY = 740 - _PlaneHeight; + y = _pictureHeight - _PlaneWidth; } _startPosX = x; _startPosY = y; diff --git a/AirBomber/FormBomberCollection.cs b/AirBomber/FormBomberCollection.cs index c5deaa0..406e803 100644 --- a/AirBomber/FormBomberCollection.cs +++ b/AirBomber/FormBomberCollection.cs @@ -80,6 +80,11 @@ namespace AirBomber PicBoxBomberCollection.Image = obj.ShowBomber(); _logger.LogInformation($"Добавлен объект в набор {listBoxStorages.SelectedItem.ToString()}"); } + catch (ArgumentException ex) + { + MessageBox.Show("Такой объект уже существует"); + _logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}"); + } catch (Exception ex) { MessageBox.Show("Не удалось добавить объект");