Готовая 7 лаба
This commit is contained in:
parent
8fed0cc8c9
commit
4b3d7d9694
@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Tank.Exceptions
|
||||
|
||||
namespace Tank
|
||||
{
|
||||
[Serializable]
|
||||
internal class TankStorageOverflowException : ApplicationException
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@ -12,19 +11,19 @@ using Tank.DrawingObjects;
|
||||
using Tank.MovementStrategy;
|
||||
using Tank.Generics;
|
||||
using Tank.Exceptions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Tank
|
||||
{
|
||||
public partial class FormArmoredCarCollection : Form
|
||||
{
|
||||
private readonly TanksGenericStorage _storage;
|
||||
|
||||
// Логгер
|
||||
private readonly ILogger _logger;
|
||||
public FormArmoredCarCollection()
|
||||
public FormArmoredCarCollection(ILogger<FormArmoredCarCollection> logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new TanksGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private void ReloadObjects()
|
||||
@ -45,7 +44,6 @@ namespace Tank
|
||||
}
|
||||
public void AddArmoredCar(DrawingArmoredCar tank)
|
||||
{
|
||||
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
@ -56,20 +54,21 @@ namespace Tank
|
||||
_logger.LogWarning("Добавление пустого объекта");
|
||||
return;
|
||||
}
|
||||
try
|
||||
_logger.LogInformation("Начало попытки добавления объекта");
|
||||
|
||||
|
||||
if ((obj + tank) != false)
|
||||
{
|
||||
if ((obj + tank) != false)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowTanks();
|
||||
_logger.LogInformation($"Добавлен объект {obj}");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowTanks();
|
||||
_logger.LogInformation($"Добавлен объект {obj}");
|
||||
}
|
||||
catch (TankStorageOverflowException ex)
|
||||
else
|
||||
{
|
||||
_logger.LogWarning($"{ex.Message} в {listBoxStorages.SelectedItem.ToString()}");
|
||||
TankStorageOverflowException ex = new TankStorageOverflowException();
|
||||
MessageBox.Show(ex.Message);
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
_logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}");
|
||||
}
|
||||
}
|
||||
private void ButtonAddArmoredCar_Click(object sender, EventArgs e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user