Убраны некоторые лишние пустые строки
This commit is contained in:
parent
4ed898c5a2
commit
f577b5ac4f
@ -10,32 +10,26 @@ public abstract class AbstractCompany
|
|||||||
/// Размер места (ширина)
|
/// Размер места (ширина)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _placeSizeWidth = 180;
|
protected readonly int _placeSizeWidth = 180;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Размер места (высота)
|
/// Размер места (высота)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _placeSizeHeight = 100;
|
protected readonly int _placeSizeHeight = 100;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _pictureWidth;
|
protected readonly int _pictureWidth;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота окна
|
/// Высота окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _pictureHeight;
|
protected readonly int _pictureHeight;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Коллекция cамолетов
|
/// Коллекция cамолетов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected ICollectionGenericObjects<DrawingBasicSeaplane>? _collection = null;
|
protected ICollectionGenericObjects<DrawingBasicSeaplane>? _collection = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вычисление максимального количества элементов, который можно разместить в окне
|
/// Вычисление максимального количества элементов, который можно разместить в окне
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int GetMaxCount => (_pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight))-15;
|
private int GetMaxCount => (_pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight))-15;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -49,7 +43,6 @@ public abstract class AbstractCompany
|
|||||||
_collection = collection;
|
_collection = collection;
|
||||||
_collection.MaxCount = GetMaxCount;
|
_collection.MaxCount = GetMaxCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора сложения для класса
|
/// Перегрузка оператора сложения для класса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -60,7 +53,6 @@ public abstract class AbstractCompany
|
|||||||
{
|
{
|
||||||
return company._collection.Insert(seaplane, new DrawingSeaplaneEqutables());
|
return company._collection.Insert(seaplane, new DrawingSeaplaneEqutables());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора удаления для класса
|
/// Перегрузка оператора удаления для класса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -71,7 +63,6 @@ public abstract class AbstractCompany
|
|||||||
{
|
{
|
||||||
return company._collection?.Remove(position);
|
return company._collection?.Remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение случайного объекта из коллекции
|
/// Получение случайного объекта из коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -81,7 +72,6 @@ public abstract class AbstractCompany
|
|||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
return _collection?.Get(rnd.Next(GetMaxCount));
|
return _collection?.Get(rnd.Next(GetMaxCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод всей коллекции
|
/// Вывод всей коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -105,18 +95,15 @@ public abstract class AbstractCompany
|
|||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод заднего фона
|
/// Вывод заднего фона
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
protected abstract void DrawBackgound(Graphics g);
|
protected abstract void DrawBackgound(Graphics g);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Расстановка объектов
|
/// Расстановка объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void SetObjectsPosition();
|
protected abstract void SetObjectsPosition();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сортировка
|
/// Сортировка
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -11,19 +11,16 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// Количество объектов в коллекции
|
/// Количество объектов в коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка максимального количества элементов
|
/// Установка максимального количества элементов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int MaxCount { get; set; }
|
int MaxCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию
|
/// Добавление объекта в коллекцию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
/// <param name="obj">Добавляемый объект</param>
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
||||||
int Insert(T obj, IEqualityComparer<T?>? compaper = null);
|
int Insert(T obj, IEqualityComparer<T?>? compaper = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию на конкретную позицию
|
/// Добавление объекта в коллекцию на конкретную позицию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -31,14 +28,12 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
||||||
int Insert(T obj, int position, IEqualityComparer<T?>? compaper = null);
|
int Insert(T obj, int position, IEqualityComparer<T?>? compaper = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из коллекции с конкретной позиции
|
/// Удаление объекта из коллекции с конкретной позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
||||||
T Remove(int position);
|
T Remove(int position);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта по позиции
|
/// Получение объекта по позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -31,7 +31,6 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public CollectionType GetCollectionType => CollectionType.List;
|
public CollectionType GetCollectionType => CollectionType.List;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -86,7 +85,6 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection.RemoveAt(position);
|
_collection.RemoveAt(position);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<T?> GetItems()
|
public IEnumerable<T?> GetItems()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Count; i++)
|
for (int i = 0; i < Count; i++)
|
||||||
|
@ -39,7 +39,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CollectionType GetCollectionType => CollectionType.Massive;
|
public CollectionType GetCollectionType => CollectionType.Massive;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -101,14 +100,12 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
{
|
{
|
||||||
throw new PositionOutOfCollectionException(position);
|
throw new PositionOutOfCollectionException(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_collection[position] == null)
|
if (_collection[position] == null)
|
||||||
{
|
{
|
||||||
_collection[position] = obj;
|
_collection[position] = obj;
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
for (index = position + 1; index < _collection.Length; ++index)
|
for (index = position + 1; index < _collection.Length; ++index)
|
||||||
{
|
{
|
||||||
if (_collection[index] == null)
|
if (_collection[index] == null)
|
||||||
@ -117,7 +114,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index = position - 1; index >= 0; --index)
|
for (index = position - 1; index >= 0; --index)
|
||||||
{
|
{
|
||||||
if (_collection[index] == null)
|
if (_collection[index] == null)
|
||||||
@ -128,7 +124,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
}
|
}
|
||||||
throw new CollectionOverflowException(Count);
|
throw new CollectionOverflowException(Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
// TODO проверка позиции
|
||||||
@ -139,7 +134,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection[position] = null;
|
_collection[position] = null;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<T?> GetItems()
|
public IEnumerable<T?> GetItems()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _collection.Length; i++)
|
for (int i = 0; i < _collection.Length; i++)
|
||||||
|
@ -14,27 +14,22 @@ public class StorageCollection<T>
|
|||||||
/// Словарь (хранилище) с коллекциями
|
/// Словарь (хранилище) с коллекциями
|
||||||
/// </summary>
|
/// </summary>
|
||||||
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
|
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Возвращение списка названий коллекций
|
/// Возвращение списка названий коллекций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectionInfo> Keys => _storages.Keys.ToList();
|
public List<CollectionInfo> Keys => _storages.Keys.ToList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ключевое слово, с которого должен начинаться файл
|
/// Ключевое слово, с которого должен начинаться файл
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly string _collectionKey = "CollectionsStorage";
|
private readonly string _collectionKey = "CollectionsStorage";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Разделитель для записи ключа и значения элемента словаря
|
/// Разделитель для записи ключа и значения элемента словаря
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly string _separatorForKeyValue = "|";
|
private readonly string _separatorForKeyValue = "|";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Разделитель для записей коллекции данных в файл
|
/// Разделитель для записей коллекции данных в файл
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly string _separatorItems = ";";
|
private readonly string _separatorItems = ";";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -71,7 +66,6 @@ public class StorageCollection<T>
|
|||||||
if (_storages.ContainsKey(collectionInfo))
|
if (_storages.ContainsKey(collectionInfo))
|
||||||
_storages.Remove(collectionInfo);
|
_storages.Remove(collectionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Доступ к коллекции
|
/// Доступ к коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -90,7 +84,6 @@ public class StorageCollection<T>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сохранение информации по самолетам в хранилище в файл
|
/// Сохранение информации по самолетам в хранилище в файл
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -93,8 +93,6 @@ public partial class FormPlaneCollection : Form
|
|||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта
|
/// Удаление объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -106,12 +104,10 @@ public partial class FormPlaneCollection : Form
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -128,7 +124,6 @@ public partial class FormPlaneCollection : Form
|
|||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Передача объекта в другую форму
|
/// Передача объекта в другую форму
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -172,7 +167,6 @@ public partial class FormPlaneCollection : Form
|
|||||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перерисовка коллекции
|
/// Перерисовка коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -187,9 +181,6 @@ public partial class FormPlaneCollection : Form
|
|||||||
|
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// добавление коллекции
|
/// добавление коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -240,7 +231,6 @@ public partial class FormPlaneCollection : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// удаление коллекции
|
/// удаление коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -297,7 +287,6 @@ public partial class FormPlaneCollection : Form
|
|||||||
RerfreshListBoxItems();
|
RerfreshListBoxItems();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обработка нажатия "Сохранение"
|
/// Обработка нажатия "Сохранение"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -322,7 +311,6 @@ public partial class FormPlaneCollection : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обработка нажатия "Загрузка"
|
/// Обработка нажатия "Загрузка"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user