Готово
This commit is contained in:
parent
6f25644d0c
commit
43b355e7dd
@ -102,10 +102,11 @@ public abstract class AbstractCompany
|
|||||||
DrawningAirCraft? obj = _collection?.Get(i);
|
DrawningAirCraft? obj = _collection?.Get(i);
|
||||||
obj?.DrawTransport(graphics);
|
obj?.DrawTransport(graphics);
|
||||||
}
|
}
|
||||||
catch (ObjectNotFoundException e){}
|
catch (ObjectNotFoundException)
|
||||||
catch (PositionOutOfCollectionException e){}
|
{
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,10 @@ public class AirCraftAngar : AbstractCompany
|
|||||||
_collection.Get(currentIndex)?.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
|
_collection.Get(currentIndex)?.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ObjectNotFoundException e){}
|
catch (ObjectNotFoundException)
|
||||||
catch (PositionOutOfCollectionException e){}
|
{
|
||||||
|
|
||||||
|
}
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using ProjectAirFighter.Drawnings;
|
using ProjectAirFighter.Drawnings;
|
||||||
using ProjectAirFighter.Exceptions;
|
using ProjectAirFighter.Exceptions;
|
||||||
|
using System.Data;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace ProjectAirFighter.CollectionGenericObjects;
|
namespace ProjectAirFighter.CollectionGenericObjects;
|
||||||
@ -93,7 +94,7 @@ public class StorageCollection<T>
|
|||||||
{
|
{
|
||||||
if (_storages.Count == 0)
|
if (_storages.Count == 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("В хранилище отсутствуют коллекции для сохранения");
|
throw new InvalidDataException("В хранилище отсутствуют коллекции для сохранения");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File.Exists(filename))
|
if (File.Exists(filename))
|
||||||
@ -133,7 +134,6 @@ public class StorageCollection<T>
|
|||||||
}
|
}
|
||||||
writer.Write(sb);
|
writer.Write(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ public class StorageCollection<T>
|
|||||||
{
|
{
|
||||||
if (!File.Exists(filename))
|
if (!File.Exists(filename))
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException("Файл не существует");
|
throw new FileNotFoundException($"{filename} не существует");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (StreamReader fs = File.OpenText(filename))
|
using (StreamReader fs = File.OpenText(filename))
|
||||||
@ -153,11 +153,11 @@ public class StorageCollection<T>
|
|||||||
string str = fs.ReadLine();
|
string str = fs.ReadLine();
|
||||||
if (str == null || str.Length == 0)
|
if (str == null || str.Length == 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("В файле нет данных");
|
throw new FileFormatException("Файл не подходит");
|
||||||
}
|
}
|
||||||
if (!str.StartsWith(_collectionKey))
|
if (!str.StartsWith(_collectionKey))
|
||||||
{
|
{
|
||||||
throw new InvalidDataException("В файле неверные данные");
|
throw new IOException("В файле неверные данные");
|
||||||
}
|
}
|
||||||
_storages.Clear();
|
_storages.Clear();
|
||||||
string strs = "";
|
string strs = "";
|
||||||
@ -189,7 +189,7 @@ public class StorageCollection<T>
|
|||||||
}
|
}
|
||||||
catch (CollectionOverflowException ex)
|
catch (CollectionOverflowException ex)
|
||||||
{
|
{
|
||||||
throw new CollectionOverflowException("Коллекция переполнена", ex);
|
throw new DataException("Коллекция переполнена", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public partial class FormAirCraftCollection : Form
|
|||||||
catch (CollectionOverflowException ex)
|
catch (CollectionOverflowException ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
_logger.LogWarning($"Не удалось добавить объект: {ex.Message}");
|
_logger.LogError($"Не удалось добавить объект: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public partial class FormAirCraftCollection : Form
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
|
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Удаление объекта из несуществующей коллекции");
|
_logger.LogError("Удаление объекта из несуществующей коллекции");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,18 +105,18 @@ public partial class FormAirCraftCollection : Form
|
|||||||
{
|
{
|
||||||
object decrementObject = _company - pos;
|
object decrementObject = _company - pos;
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
_logger.LogInformation($"Удален по позиции {pos}");
|
_logger.LogInformation($"Удален объект по позиции {pos}");
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
}
|
}
|
||||||
catch (ObjectNotFoundException ex)
|
catch (ObjectNotFoundException)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект не найден");
|
MessageBox.Show("Объект не найден");
|
||||||
_logger.LogWarning($"Удаление не найденного объекта в позиции {pos} ");
|
_logger.LogError($"Удаление не найденного объекта в позиции {pos} ");
|
||||||
}
|
}
|
||||||
catch (PositionOutOfCollectionException ex)
|
catch (PositionOutOfCollectionException)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Удаление вне рамках коллекции");
|
MessageBox.Show("Удаление вне рамках коллекции");
|
||||||
_logger.LogWarning($"Удаление объекта за пределами коллекции {pos} ");
|
_logger.LogError($"Удаление объекта за пределами коллекции {pos} ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,8 @@ public partial class FormAirCraftCollection : Form
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
DrawningAirCraft? aircraft = null;
|
DrawningAirCraft? aircraft = null;
|
||||||
int counter = 100;
|
int counter = 100;
|
||||||
while (aircraft == null)
|
while (aircraft == null)
|
||||||
@ -143,18 +144,21 @@ public partial class FormAirCraftCollection : Form
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aircraft == null)
|
if (aircraft == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FormAirFighter form = new()
|
FormAirFighter form = new()
|
||||||
{
|
{
|
||||||
SetAirCraft = aircraft
|
SetAirCraft = aircraft
|
||||||
};
|
};
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
catch (ObjectNotFoundException)
|
||||||
|
{
|
||||||
|
_logger.LogError("Ошибка при передаче объекта на FormAirFighter");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перерисовка коллекции
|
/// Перерисовка коллекции
|
||||||
@ -181,7 +185,7 @@ public partial class FormAirCraftCollection : Form
|
|||||||
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
|
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
_logger.LogWarning("Не заполненная коллекция");
|
_logger.LogError("Не заполненная коллекция");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +214,7 @@ public partial class FormAirCraftCollection : Form
|
|||||||
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Коллекция не выбрана");
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
_logger.LogWarning("Удаление невыбранной коллекции");
|
_logger.LogError("Удаление невыбранной коллекции");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string name = listBoxCollection.SelectedItem.ToString() ?? string.Empty;
|
string name = listBoxCollection.SelectedItem.ToString() ?? string.Empty;
|
||||||
@ -248,7 +252,7 @@ public partial class FormAirCraftCollection : Form
|
|||||||
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Коллекция не выбрана");
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
_logger.LogWarning("Создание компании невыбранной коллекции");
|
_logger.LogError("Создание компании невыбранной коллекции");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +260,7 @@ public partial class FormAirCraftCollection : Form
|
|||||||
if (collection == null)
|
if (collection == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Коллекция не проинициализирована");
|
MessageBox.Show("Коллекция не проинициализирована");
|
||||||
_logger.LogWarning("Не удалось инициализировать коллекцию");
|
_logger.LogError("Не удалось инициализировать коллекцию");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user