Лабораторная работа №8
This commit is contained in:
parent
913adffdfa
commit
2c8ad86353
@ -54,7 +54,7 @@ public abstract class AbstractCompany
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static int operator +(AbstractCompany company, DrawningPlane plane)
|
public static int operator +(AbstractCompany company, DrawningPlane plane)
|
||||||
{
|
{
|
||||||
return company._collection.Insert(plane);
|
return company._collection.Insert(plane, new DrawningPlaneEqutables());
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора удаления для класса
|
/// Перегрузка оператора удаления для класса
|
||||||
@ -105,4 +105,9 @@ public abstract class AbstractCompany
|
|||||||
/// Расстановка объектов
|
/// Расстановка объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void SetObjectsPosition();
|
protected abstract void SetObjectsPosition();
|
||||||
|
/// <summary>
|
||||||
|
/// Сортировка
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="comparer">Сравнитель объектов</param>
|
||||||
|
public void Sort(IComparer<DrawningPlane?> comparer) => _collection?.CollectionSort(comparer);
|
||||||
}
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirPlane.CollectionGenericObjects;
|
||||||
|
/// <summary>
|
||||||
|
/// Класс, хранящий информацию по коллекции
|
||||||
|
/// </summary>
|
||||||
|
public class CollectionInfo : IEquatable<CollectionInfo>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Название
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Тип
|
||||||
|
/// </summary>
|
||||||
|
public CollectionType CollectionType { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Описание
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи информации по объекту в файл
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string _separator = "-";
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="collectionType"></param>
|
||||||
|
/// <param name="description"></param>
|
||||||
|
public CollectionInfo(string name, CollectionType collectionType, string description)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
CollectionType = collectionType;
|
||||||
|
Description = description;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из строки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static CollectionInfo? GetCollectionInfo(string data)
|
||||||
|
{
|
||||||
|
string[] strs = data.Split(_separator,
|
||||||
|
StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (strs.Length < 1 || strs.Length > 3)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new CollectionInfo(strs[0],
|
||||||
|
(CollectionType)Enum.Parse(typeof(CollectionType), strs[1]), strs.Length > 2 ?
|
||||||
|
strs[2] : string.Empty);
|
||||||
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name + _separator + CollectionType + _separator + Description;
|
||||||
|
}
|
||||||
|
public bool Equals(CollectionInfo? other)
|
||||||
|
{
|
||||||
|
return Name == other?.Name;
|
||||||
|
}
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
return Equals(obj as CollectionInfo);
|
||||||
|
}
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return Name.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ProjectAirPlane.Drawnings;
|
||||||
|
|
||||||
namespace ProjectAirPlane.CollectionGenericObjects;
|
namespace ProjectAirPlane.CollectionGenericObjects;
|
||||||
|
|
||||||
@ -10,37 +11,34 @@ public interface ICollectionGenericObjects<T>
|
|||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Количество объектов в коллекции
|
/// Количество объектов в коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка максимального количества элементов
|
/// Установка максимального количества элементов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int MaxCount { set; get; }
|
int MaxCount { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию
|
/// Добавление объекта в коллекцию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
/// <param name="obj">Добавляемый объект</param>
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
/// /// <param name="comparer">Cравнение двух объектов</param>
|
||||||
int Insert(T obj);
|
/// <returns>true - вставка прошла удачно, false - вставка неудалась</returns>
|
||||||
|
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию на конкретную позицию
|
/// Добавление объекта в коллекцию на конкретную позицию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
/// <param name="obj">Добавляемый объект</param>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
/// <param name="comparer">Cравнение двух объектов</param>
|
||||||
int Insert(T obj, int position);
|
/// <returns>true - вставка прошла удачно, false - вставка неудалась</returns>
|
||||||
|
int Insert(T obj, int position, IEqualityComparer<T?>? comparer = 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>
|
||||||
@ -56,4 +54,9 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Поэлементый вывод элементов коллекции</returns>
|
/// <returns>Поэлементый вывод элементов коллекции</returns>
|
||||||
IEnumerable<T?> GetItems();
|
IEnumerable<T?> GetItems();
|
||||||
|
/// <summary>
|
||||||
|
/// Сортировка коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="comparer">Сравнитель объектов</param>
|
||||||
|
void CollectionSort(IComparer<T?> comparer);
|
||||||
}
|
}
|
||||||
|
@ -12,18 +12,17 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Список объектов, которые храним
|
/// Список объектов, которые храним
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly List<T?> _collection;
|
private readonly List<T?> _collection;
|
||||||
public CollectionType GetCollectionType => CollectionType.List;
|
public CollectionType GetCollectionType => CollectionType.List;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Максимально допустимое число объектов в списке
|
/// Максимально допустимое число объектов в списке
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _maxCount;
|
private int _maxCount;
|
||||||
|
|
||||||
public int Count => _collection.Count;
|
public int Count => _collection.Count;
|
||||||
|
public int MaxCount
|
||||||
public int MaxCount {
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Count;
|
return Count;
|
||||||
@ -36,8 +35,6 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -45,44 +42,45 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
{
|
{
|
||||||
_collection = new();
|
_collection = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
|
||||||
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
||||||
return _collection[position];
|
return _collection[position];
|
||||||
}
|
}
|
||||||
|
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
|
||||||
public int Insert(T obj)
|
|
||||||
{
|
{
|
||||||
// TODO проверка, что не превышено максимальное количество элементов
|
if (comparer != null)
|
||||||
// TODO вставка в конец набора
|
{
|
||||||
|
if (_collection.Contains(obj, comparer))
|
||||||
|
{
|
||||||
|
throw new ObjectIsEqualException();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (Count == _maxCount) throw new CollectionOverflowException(Count);
|
if (Count == _maxCount) throw new CollectionOverflowException(Count);
|
||||||
_collection.Add(obj);
|
_collection.Add(obj);
|
||||||
return Count;
|
return Count;
|
||||||
}
|
}
|
||||||
|
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
|
||||||
public int Insert(T obj, int position)
|
|
||||||
{
|
{
|
||||||
// TODO проверка, что не превышено максимальное количество элементов
|
if (comparer != null)
|
||||||
// TODO проверка позиции
|
{
|
||||||
// TODO вставка по позиции
|
if (_collection.Contains(obj, comparer))
|
||||||
|
{
|
||||||
|
throw new ObjectIsEqualException();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (Count == _maxCount) throw new CollectionOverflowException(Count);
|
if (Count == _maxCount) throw new CollectionOverflowException(Count);
|
||||||
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
||||||
_collection.Insert(position, obj);
|
_collection.Insert(position, obj);
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
|
||||||
// TODO удаление объекта из списка
|
|
||||||
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
||||||
T obj = _collection[position];
|
T obj = _collection[position];
|
||||||
_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)
|
||||||
@ -90,4 +88,8 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
yield return _collection[i];
|
yield return _collection[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void ICollectionGenericObjects<T>.CollectionSort(IComparer<T?> comparer)
|
||||||
|
{
|
||||||
|
_collection.Sort(comparer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ProjectAirPlane.Drawnings;
|
||||||
using ProjectAirPlane.Exceptions;
|
using ProjectAirPlane.Exceptions;
|
||||||
|
|
||||||
namespace ProjectAirPlane.CollectionGenericObjects;
|
namespace ProjectAirPlane.CollectionGenericObjects;
|
||||||
@ -57,9 +58,16 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
return _collection[position];
|
return _collection[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj)
|
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
|
||||||
{
|
{
|
||||||
// TODO вставка в свободное место набора
|
if (comparer != null)
|
||||||
|
{
|
||||||
|
foreach (T? item in _collection)
|
||||||
|
{
|
||||||
|
if ((comparer as IEqualityComparer<DrawningPlane>).Equals(obj as DrawningPlane, item as DrawningPlane))
|
||||||
|
throw new ObjectIsEqualException();
|
||||||
|
}
|
||||||
|
}
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (index < _collection.Length)
|
while (index < _collection.Length)
|
||||||
{
|
{
|
||||||
@ -73,15 +81,22 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
throw new CollectionOverflowException(Count);
|
throw new CollectionOverflowException(Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj, int position)
|
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
// TODO проверка позиции
|
||||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||||
// ищется свободное место после этой позиции и идет вставка туда
|
// ищется свободное место после этой позиции и идет вставка туда
|
||||||
// если нет после, ищем до
|
// если нет после, ищем до
|
||||||
// TODO вставка
|
// TODO вставка
|
||||||
|
if (comparer != null)
|
||||||
|
{
|
||||||
|
foreach (T? item in _collection)
|
||||||
|
{
|
||||||
|
if ((comparer as IEqualityComparer<DrawningPlane>).Equals(obj as DrawningPlane, item as DrawningPlane))
|
||||||
|
throw new ObjectIsEqualException();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (position >= _collection.Length || position < 0) throw new PositionOutOfCollectionException(position);
|
if (position >= _collection.Length || position < 0) throw new PositionOutOfCollectionException(position);
|
||||||
|
|
||||||
if (_collection[position] == null)
|
if (_collection[position] == null)
|
||||||
{
|
{
|
||||||
_collection[position] = obj;
|
_collection[position] = obj;
|
||||||
@ -130,4 +145,9 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
yield return _collection[i];
|
yield return _collection[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ICollectionGenericObjects<T>.CollectionSort(IComparer<T?> comparer)
|
||||||
|
{
|
||||||
|
Array.Sort(_collection, comparer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,17 +14,17 @@ public class StorageCollection<T>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Словарь (хранилище) с коллекциями
|
/// Словарь (хранилище) с коллекциями
|
||||||
/// </summary>
|
/// </summary>
|
||||||
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Возвращение списка названий коллекций
|
/// Возвращение списка названий коллекций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> Keys => _storages.Keys.ToList();
|
public List<CollectionInfo> Keys => _storages.Keys.ToList();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public StorageCollection()
|
public StorageCollection()
|
||||||
{
|
{
|
||||||
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление коллекции в хранилище
|
/// Добавление коллекции в хранилище
|
||||||
@ -33,12 +33,13 @@ public class StorageCollection<T>
|
|||||||
/// <param name="collectionType">тип коллекции</param>
|
/// <param name="collectionType">тип коллекции</param>
|
||||||
public void AddCollection(string name, CollectionType collectionType)
|
public void AddCollection(string name, CollectionType collectionType)
|
||||||
{
|
{
|
||||||
if (_storages.ContainsKey(name)) return;
|
CollectionInfo collectionInfo = new CollectionInfo(name, collectionType, string.Empty);
|
||||||
|
if (_storages.ContainsKey(collectionInfo)) return;
|
||||||
if (collectionType == CollectionType.None) return;
|
if (collectionType == CollectionType.None) return;
|
||||||
else if (collectionType == CollectionType.Massive)
|
else if (collectionType == CollectionType.Massive)
|
||||||
_storages[name] = new MassiveGenericObjects<T>();
|
_storages[collectionInfo] = new MassiveGenericObjects<T>();
|
||||||
else if (collectionType == CollectionType.List)
|
else if (collectionType == CollectionType.List)
|
||||||
_storages[name] = new ListGenericObjects<T>();
|
_storages[collectionInfo] = new ListGenericObjects<T>();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление коллекции
|
/// Удаление коллекции
|
||||||
@ -46,8 +47,9 @@ public class StorageCollection<T>
|
|||||||
/// <param name="name">Название коллекции</param>
|
/// <param name="name">Название коллекции</param>
|
||||||
public void DelCollection(string name)
|
public void DelCollection(string name)
|
||||||
{
|
{
|
||||||
if (_storages.ContainsKey(name))
|
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
|
||||||
_storages.Remove(name);
|
if (_storages.ContainsKey(collectionInfo))
|
||||||
|
_storages.Remove(collectionInfo);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Доступ к коллекции
|
/// Доступ к коллекции
|
||||||
@ -58,8 +60,9 @@ public class StorageCollection<T>
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_storages.ContainsKey(name))
|
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
|
||||||
return _storages[name];
|
if (_storages.ContainsKey(collectionInfo))
|
||||||
|
return _storages[collectionInfo];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +95,7 @@ public class StorageCollection<T>
|
|||||||
using (StreamWriter writer = new StreamWriter(filename))
|
using (StreamWriter writer = new StreamWriter(filename))
|
||||||
{
|
{
|
||||||
writer.Write(_collectionKey);
|
writer.Write(_collectionKey);
|
||||||
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
|
||||||
{
|
{
|
||||||
writer.Write(Environment.NewLine);
|
writer.Write(Environment.NewLine);
|
||||||
if (value.Value.Count == 0)
|
if (value.Value.Count == 0)
|
||||||
@ -101,8 +104,6 @@ public class StorageCollection<T>
|
|||||||
}
|
}
|
||||||
writer.Write(value.Key);
|
writer.Write(value.Key);
|
||||||
writer.Write(_separatorForKeyValue);
|
writer.Write(_separatorForKeyValue);
|
||||||
writer.Write(value.Value.GetCollectionType);
|
|
||||||
writer.Write(_separatorForKeyValue);
|
|
||||||
writer.Write(value.Value.MaxCount);
|
writer.Write(value.Value.MaxCount);
|
||||||
writer.Write(_separatorForKeyValue);
|
writer.Write(_separatorForKeyValue);
|
||||||
foreach (T? item in value.Value.GetItems())
|
foreach (T? item in value.Value.GetItems())
|
||||||
@ -144,18 +145,20 @@ public class StorageCollection<T>
|
|||||||
while ((strs = fs.ReadLine()) != null)
|
while ((strs = fs.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (record.Length != 4)
|
if (record.Length != 3)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
|
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ??
|
||||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
|
throw new Exception("Не удалось определить информацию коллекции: " + record[0]);
|
||||||
|
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionInfo.CollectionType) ??
|
||||||
|
throw new Exception("Не удалось создать коллекцию");
|
||||||
if (collection == null)
|
if (collection == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Не удалось создать коллекцию");
|
throw new Exception("Не удалось создать коллекцию");
|
||||||
}
|
}
|
||||||
collection.MaxCount = Convert.ToInt32(record[2]);
|
collection.MaxCount = Convert.ToInt32(record[1]);
|
||||||
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
||||||
foreach (string elem in set)
|
foreach (string elem in set)
|
||||||
{
|
{
|
||||||
if (elem?.CreateDrawningPlane() is T plane)
|
if (elem?.CreateDrawningPlane() is T plane)
|
||||||
@ -173,7 +176,7 @@ public class StorageCollection<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_storages.Add(record[0], collection);
|
_storages.Add(collectionInfo, collection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,8 +190,7 @@ public class StorageCollection<T>
|
|||||||
return collectionType switch
|
return collectionType switch
|
||||||
{
|
{
|
||||||
CollectionType.Massive => new MassiveGenericObjects<T>(),
|
CollectionType.Massive => new MassiveGenericObjects<T>(),
|
||||||
CollectionType.List => new ListGenericObjects<T>(),
|
CollectionType.List => new ListGenericObjects<T>(),_ => null,
|
||||||
_ => null,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirPlane.Drawnings;
|
||||||
|
/// <summary>
|
||||||
|
/// Сравнение по цвету, скорости, весу
|
||||||
|
/// </summary>
|
||||||
|
public class DrawningPlaneCompareByColor : IComparer<DrawningPlane?>
|
||||||
|
{
|
||||||
|
public int Compare(DrawningPlane? x, DrawningPlane? y)
|
||||||
|
{
|
||||||
|
if (x == null || x.EntityPlane == null)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y == null || y.EntityPlane == null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
var bodycolorCompare = x.EntityPlane.BodyColor.Name.CompareTo(y.EntityPlane.BodyColor.Name);
|
||||||
|
if (bodycolorCompare != 0)
|
||||||
|
{
|
||||||
|
return bodycolorCompare;
|
||||||
|
}
|
||||||
|
var speedCompare = x.EntityPlane.Speed.CompareTo(y.EntityPlane.Speed);
|
||||||
|
if (speedCompare != 0)
|
||||||
|
{
|
||||||
|
return speedCompare;
|
||||||
|
}
|
||||||
|
return x.EntityPlane.Weight.CompareTo(y.EntityPlane.Weight);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirPlane.Drawnings;
|
||||||
|
/// <summary>
|
||||||
|
/// Сравнение по типу, скорости, весу
|
||||||
|
/// </summary>
|
||||||
|
public class DrawningPlaneCompareByType : IComparer<DrawningPlane>
|
||||||
|
{
|
||||||
|
public int Compare(DrawningPlane? x, DrawningPlane? y)
|
||||||
|
{
|
||||||
|
if (x == null || x.EntityPlane == null)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y == null || y.EntityPlane == null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x.GetType().Name != y.GetType().Name)
|
||||||
|
{
|
||||||
|
return x.GetType().Name.CompareTo(y.GetType().Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
var speedCompare = x.EntityPlane.Speed.CompareTo(y.EntityPlane.Speed);
|
||||||
|
if (speedCompare != 0)
|
||||||
|
{
|
||||||
|
return speedCompare;
|
||||||
|
}
|
||||||
|
return x.EntityPlane.Weight.CompareTo(y.EntityPlane.Weight);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectAirPlane.Entites;
|
||||||
|
|
||||||
|
namespace ProjectAirPlane.Drawnings;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация сравнения двух объектов класса-прорисовки
|
||||||
|
/// </summary>
|
||||||
|
public class DrawningPlaneEqutables: IEqualityComparer<DrawningPlane?>
|
||||||
|
{
|
||||||
|
public bool Equals(DrawningPlane? x, DrawningPlane? y)
|
||||||
|
{
|
||||||
|
if (x == null || x.EntityPlane == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (y == null || y.EntityPlane == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (x.GetType().Name != y.GetType().Name)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (x.EntityPlane.Speed != y.EntityPlane.Speed)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (x.EntityPlane.Weight != y.EntityPlane.Weight)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (x.EntityPlane.BodyColor != y.EntityPlane.BodyColor)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (x is DrawningAirPlane && y is DrawningAirPlane)
|
||||||
|
{
|
||||||
|
EntityAirPlane _x = (EntityAirPlane)x.EntityPlane;
|
||||||
|
EntityAirPlane _y = (EntityAirPlane)x.EntityPlane;
|
||||||
|
if (_x.AdditionalColor != _y.AdditionalColor)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_x.DopBak != _y.DopBak)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_x.Radar != _y.Radar)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public int GetHashCode([DisallowNull] DrawningPlane obj)
|
||||||
|
{
|
||||||
|
return obj.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс, описывающий ошибку переполнения коллекции
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class ObjectIsEqualException : ApplicationException
|
||||||
|
{
|
||||||
|
public ObjectIsEqualException(int count) : base("В коллекции содержится равный элемент: " + count) { }
|
||||||
|
public ObjectIsEqualException() : base() { }
|
||||||
|
public ObjectIsEqualException(string message) : base(message) { }
|
||||||
|
public ObjectIsEqualException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
protected ObjectIsEqualException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||||
|
}
|
@ -52,6 +52,8 @@
|
|||||||
loadToolStripMenuItem = new ToolStripMenuItem();
|
loadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
saveFileDialog = new SaveFileDialog();
|
saveFileDialog = new SaveFileDialog();
|
||||||
openFileDialog = new OpenFileDialog();
|
openFileDialog = new OpenFileDialog();
|
||||||
|
buttonSortByType = new Button();
|
||||||
|
buttonSortByColor = new Button();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
panelCompanyTools.SuspendLayout();
|
panelCompanyTools.SuspendLayout();
|
||||||
panelStorage.SuspendLayout();
|
panelStorage.SuspendLayout();
|
||||||
@ -61,6 +63,7 @@
|
|||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
|
groupBoxTools.Controls.Add(buttonAddPlane);
|
||||||
groupBoxTools.Controls.Add(panelCompanyTools);
|
groupBoxTools.Controls.Add(panelCompanyTools);
|
||||||
groupBoxTools.Controls.Add(buttonCreateCompany);
|
groupBoxTools.Controls.Add(buttonCreateCompany);
|
||||||
groupBoxTools.Controls.Add(panelStorage);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
@ -68,31 +71,32 @@
|
|||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(686, 24);
|
groupBoxTools.Location = new Point(686, 24);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(195, 534);
|
groupBoxTools.Size = new Size(195, 611);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// panelCompanyTools
|
// panelCompanyTools
|
||||||
//
|
//
|
||||||
panelCompanyTools.Controls.Add(buttonAddPlane);
|
panelCompanyTools.Controls.Add(buttonSortByColor);
|
||||||
|
panelCompanyTools.Controls.Add(buttonSortByType);
|
||||||
panelCompanyTools.Controls.Add(maskedTextBox);
|
panelCompanyTools.Controls.Add(maskedTextBox);
|
||||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||||
panelCompanyTools.Controls.Add(buttonRemovePlane);
|
panelCompanyTools.Controls.Add(buttonRemovePlane);
|
||||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||||
panelCompanyTools.Enabled = false;
|
panelCompanyTools.Enabled = false;
|
||||||
panelCompanyTools.Location = new Point(3, 343);
|
panelCompanyTools.Location = new Point(3, 377);
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
panelCompanyTools.Size = new Size(189, 188);
|
panelCompanyTools.Size = new Size(189, 231);
|
||||||
panelCompanyTools.TabIndex = 8;
|
panelCompanyTools.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// buttonAddPlane
|
// buttonAddPlane
|
||||||
//
|
//
|
||||||
buttonAddPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonAddPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonAddPlane.Location = new Point(3, 13);
|
buttonAddPlane.Location = new Point(6, 343);
|
||||||
buttonAddPlane.Name = "buttonAddPlane";
|
buttonAddPlane.Name = "buttonAddPlane";
|
||||||
buttonAddPlane.Size = new Size(166, 28);
|
buttonAddPlane.Size = new Size(177, 28);
|
||||||
buttonAddPlane.TabIndex = 1;
|
buttonAddPlane.TabIndex = 1;
|
||||||
buttonAddPlane.Text = "Добавление самолёта";
|
buttonAddPlane.Text = "Добавление самолёта";
|
||||||
buttonAddPlane.UseVisualStyleBackColor = true;
|
buttonAddPlane.UseVisualStyleBackColor = true;
|
||||||
@ -100,10 +104,10 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBox
|
// maskedTextBox
|
||||||
//
|
//
|
||||||
maskedTextBox.Location = new Point(6, 57);
|
maskedTextBox.Location = new Point(3, 0);
|
||||||
maskedTextBox.Mask = "00";
|
maskedTextBox.Mask = "00";
|
||||||
maskedTextBox.Name = "maskedTextBox";
|
maskedTextBox.Name = "maskedTextBox";
|
||||||
maskedTextBox.Size = new Size(166, 23);
|
maskedTextBox.Size = new Size(177, 23);
|
||||||
maskedTextBox.TabIndex = 3;
|
maskedTextBox.TabIndex = 3;
|
||||||
maskedTextBox.ValidatingType = typeof(int);
|
maskedTextBox.ValidatingType = typeof(int);
|
||||||
maskedTextBox.MaskInputRejected += MaskedTextBox_MaskInputRejected;
|
maskedTextBox.MaskInputRejected += MaskedTextBox_MaskInputRejected;
|
||||||
@ -111,9 +115,9 @@
|
|||||||
// buttonRefresh
|
// buttonRefresh
|
||||||
//
|
//
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRefresh.Location = new Point(6, 156);
|
buttonRefresh.Location = new Point(3, 99);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonRefresh.Size = new Size(166, 25);
|
buttonRefresh.Size = new Size(177, 25);
|
||||||
buttonRefresh.TabIndex = 6;
|
buttonRefresh.TabIndex = 6;
|
||||||
buttonRefresh.Text = "Обновить";
|
buttonRefresh.Text = "Обновить";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
@ -122,9 +126,9 @@
|
|||||||
// buttonRemovePlane
|
// buttonRemovePlane
|
||||||
//
|
//
|
||||||
buttonRemovePlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRemovePlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRemovePlane.Location = new Point(7, 86);
|
buttonRemovePlane.Location = new Point(4, 29);
|
||||||
buttonRemovePlane.Name = "buttonRemovePlane";
|
buttonRemovePlane.Name = "buttonRemovePlane";
|
||||||
buttonRemovePlane.Size = new Size(166, 24);
|
buttonRemovePlane.Size = new Size(176, 24);
|
||||||
buttonRemovePlane.TabIndex = 4;
|
buttonRemovePlane.TabIndex = 4;
|
||||||
buttonRemovePlane.Text = "Удалить самолёт";
|
buttonRemovePlane.Text = "Удалить самолёт";
|
||||||
buttonRemovePlane.UseVisualStyleBackColor = true;
|
buttonRemovePlane.UseVisualStyleBackColor = true;
|
||||||
@ -133,9 +137,9 @@
|
|||||||
// buttonGoToCheck
|
// buttonGoToCheck
|
||||||
//
|
//
|
||||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonGoToCheck.Location = new Point(6, 125);
|
buttonGoToCheck.Location = new Point(3, 68);
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
buttonGoToCheck.Size = new Size(166, 25);
|
buttonGoToCheck.Size = new Size(177, 25);
|
||||||
buttonGoToCheck.TabIndex = 5;
|
buttonGoToCheck.TabIndex = 5;
|
||||||
buttonGoToCheck.Text = "Передать на тесты";
|
buttonGoToCheck.Text = "Передать на тесты";
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
@ -250,7 +254,7 @@
|
|||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 24);
|
pictureBox.Location = new Point(0, 24);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(686, 534);
|
pictureBox.Size = new Size(686, 611);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -294,11 +298,33 @@
|
|||||||
//
|
//
|
||||||
openFileDialog.Filter = "txt file | *.txt";
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
//
|
//
|
||||||
|
// buttonSortByType
|
||||||
|
//
|
||||||
|
buttonSortByType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonSortByType.Location = new Point(4, 130);
|
||||||
|
buttonSortByType.Name = "buttonSortByType";
|
||||||
|
buttonSortByType.Size = new Size(177, 42);
|
||||||
|
buttonSortByType.TabIndex = 7;
|
||||||
|
buttonSortByType.Text = "Сортировка по типу";
|
||||||
|
buttonSortByType.UseVisualStyleBackColor = true;
|
||||||
|
buttonSortByType.Click += ButtonSortByType_Click;
|
||||||
|
//
|
||||||
|
// buttonSortByColor
|
||||||
|
//
|
||||||
|
buttonSortByColor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonSortByColor.Location = new Point(4, 178);
|
||||||
|
buttonSortByColor.Name = "buttonSortByColor";
|
||||||
|
buttonSortByColor.Size = new Size(177, 35);
|
||||||
|
buttonSortByColor.TabIndex = 8;
|
||||||
|
buttonSortByColor.Text = "Сортирова по цвету";
|
||||||
|
buttonSortByColor.UseVisualStyleBackColor = true;
|
||||||
|
buttonSortByColor.Click += ButtonSortByColor_Click;
|
||||||
|
//
|
||||||
// FormPlaneCollection
|
// FormPlaneCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(881, 558);
|
ClientSize = new Size(881, 635);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Controls.Add(menuStrip);
|
Controls.Add(menuStrip);
|
||||||
@ -343,5 +369,7 @@
|
|||||||
private ToolStripMenuItem loadToolStripMenuItem;
|
private ToolStripMenuItem loadToolStripMenuItem;
|
||||||
private SaveFileDialog saveFileDialog;
|
private SaveFileDialog saveFileDialog;
|
||||||
private OpenFileDialog openFileDialog;
|
private OpenFileDialog openFileDialog;
|
||||||
|
private Button buttonSortByColor;
|
||||||
|
private Button buttonSortByType;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -87,7 +87,12 @@ public partial class FormPlaneCollection : Form
|
|||||||
catch (CollectionOverflowException ex)
|
catch (CollectionOverflowException ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
_logger.LogError("Ошибка : {Messsage}", ex.Message);
|
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||||
|
}
|
||||||
|
catch (ObjectIsEqualException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +223,7 @@ public partial class FormPlaneCollection : Form
|
|||||||
listBoxCollection.Items.Clear();
|
listBoxCollection.Items.Clear();
|
||||||
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
||||||
{
|
{
|
||||||
string? colName = _storageCollection.Keys?[i];
|
string? colName = _storageCollection.Keys?[i].Name;
|
||||||
if (!string.IsNullOrEmpty(colName))
|
if (!string.IsNullOrEmpty(colName))
|
||||||
{
|
{
|
||||||
listBoxCollection.Items.Add(colName);
|
listBoxCollection.Items.Add(colName);
|
||||||
@ -333,5 +338,25 @@ public partial class FormPlaneCollection : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ButtonSortByType_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ComparePlane(new DrawningPlaneCompareByType());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSortByColor_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ComparePlane(new DrawningPlaneCompareByColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ComparePlane(IComparer<DrawningPlane?> comparer)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_company.Sort(comparer);
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user