Compare commits

...

4 Commits

Author SHA1 Message Date
368032237a в 2024-08-30 02:22:43 +04:00
7ad41b0bc1 d 2024-08-30 02:14:58 +04:00
03bfa682f7 j 2024-08-30 02:02:32 +04:00
af27f69e86 c 2024-08-30 01:42:12 +04:00
20 changed files with 550 additions and 200 deletions

View File

@ -29,7 +29,7 @@ namespace ProjectBoat.CollectionGenericObjects
protected readonly int _pictureHeight;
/// <summary>
/// Коллекция крейсеров
/// Коллекция лодок
/// </summary>
protected ICollectionGenericObjects<DrawningBoat>? _collection = null;
@ -57,11 +57,11 @@ namespace ProjectBoat.CollectionGenericObjects
/// Перегрузка оператора сложения для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="сruiser">Добавляемый объект</param>
/// <param name="boat">Добавляемый объект</param>
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningBoat сruiser)
public static int operator +(AbstractCompany company, DrawningBoat boat)
{
return company._collection.Insert(сruiser);
return company._collection.Insert(boat, new DrawiningBoatEqutables());
}
/// <summary>
@ -109,6 +109,13 @@ namespace ProjectBoat.CollectionGenericObjects
}
return bitmap;
}
/// <summary>
/// Сортировка
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
public void Sort(IComparer<DrawningBoat?> comparer) => _collection?.CollectionSort(comparer);
/// <summary>
/// Вывод заднего фона
/// </summary>

View File

@ -0,0 +1,75 @@
namespace ProjectBoat.CollectionGenericObjects;
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>Объект или null</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();
}
}

View File

@ -1,4 +1,7 @@
namespace ProjectBoat.CollectionGenericObjects
using ProjectBoat.Drawnings;
using ProjectBoat.CollectionGenericObjects;
namespace ProjectBoat.CollectionGenericObjects
{
/// <summary>
/// Интерфейс описания действий для набора хранимых объектов
@ -21,8 +24,9 @@
/// Добавление объекта в коллекцию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// /// <param name="comparer">Cравнение двух объектов</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj);
int Insert(T obj, IEqualityComparer<DrawningBoat?>? comparer = null);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
@ -30,7 +34,7 @@
/// <param name="obj">Добавляемый объект</param>
/// <param name="position">Позиция</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj, int position);
int Insert(T obj, int position, IEqualityComparer<DrawningBoat?>? comparer = null);
/// <summary>
/// Удаление объекта из коллекции с конкретной позиции
@ -56,6 +60,12 @@
/// <returns>Поэлементый вывод элементов коллекции</returns>
IEnumerable<T?> GetItems();
/// <summary>
/// Сортировка коллекции
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
void CollectionSort(IComparer<T?> comparer);
}
}

View File

@ -1,4 +1,7 @@
using ProjectBoat.Exceptions;
using ProjectBoat.Drawnings;
using ProjectBoat.Exceptions;
using ProjectBoat.CollectionGenericObjects;
using ProjectBoat.Exceptions;
namespace ProjectBoat.CollectionGenericObjects
{
@ -41,30 +44,44 @@ namespace ProjectBoat.CollectionGenericObjects
}
public T? Get(int position)
{
// TODO проверка позиции
// TODO проверка позиции
// TODO выброc позиций, если выход за границы массива
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<DrawningBoat?>? comparer = null)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO выбром позиций, если переполнение
// TODO выброc позиций, если такой объект есть в коллекции
// TODO вставка в конец набора
for (int i = 0; i < Count; i++)
{
if (comparer.Equals((_collection[i] as DrawningBoat), (obj as DrawningBoat))) throw new ObjectAlreadyInCollectionException(i);
}
if (Count == _maxCount) throw new CollectionOverflowException(Count);
_collection.Add(obj);
return Count;
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<DrawningBoat?>? comparer = null)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO выброc позиций, если такой объект есть в коллекции
// TODO проверка позиции
// TODO вставка по позиции
for (int i = 0; i < Count; i++)
{
if (comparer.Equals((_collection[i] as DrawningBoat), (obj as DrawningBoat))) throw new ObjectAlreadyInCollectionException(i);
}
if (Count == _maxCount) throw new CollectionOverflowException(Count);
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
_collection.Insert(position, obj);
return position;
@ -73,9 +90,10 @@ namespace ProjectBoat.CollectionGenericObjects
public T Remove(int position)
{
// TODO проверка позиции
// TODO удаление объекта из списка
// TODO выбром позиций, если выход за границы массива
// TODO удаление объекта из списка
if (position >= _collection.Count || position < 0) throw new PositionOutOfCollectionException(position);
T obj = _collection[position];
_collection.RemoveAt(position);
return obj;
@ -88,5 +106,10 @@ namespace ProjectBoat.CollectionGenericObjects
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
_collection.Sort(comparer);
}
}
}

View File

@ -1,4 +1,7 @@
using ProjectBoat.Exceptions;
using ProjectBoat.Drawnings;
using ProjectBoat.Exceptions;
using ProjectBoat.CollectionGenericObjects;
using ProjectBoat.Exceptions;
namespace ProjectBoat.CollectionGenericObjects
{
@ -55,34 +58,44 @@ namespace ProjectBoat.CollectionGenericObjects
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<DrawningBoat?>? comparer = null)
{
// TODO вставка в свободное место набора
// TODO выброc позиций, если переполнение
int index = 0;
while (index < Count && _collection[index] != null)
// TODO выброc позиций, если такой объект есть в коллекции
for (int i = 0; i < Count; i++)
{
index++;
if (comparer.Equals((_collection[i] as DrawningBoat), (obj as DrawningBoat))) throw new ObjectAlreadyInCollectionException(i);
}
if (index < Count)
for (int i = 0; i < Count; i++)
{
_collection[index] = obj;
return index;
if (_collection[i] == null)
{
_collection[i] = obj;
return i;
}
}
throw new CollectionOverflowException(Count);
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<DrawningBoat?>? comparer = null)
{
// TODO выброc позиций, если такой объект есть в коллекции
// TODO проверка позиции
// TODO выбром позиций, если выход за границы массива
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
// ищется свободное место после этой позиции и идет вставка туда
// если нет после, ищем до
// TODO вставка
// TODO выбром позиций, если переполнение
// TODO выбром позиций, если выход за границы массива
// TODO вставка
for (int i = 0; i < Count; i++)
{
if (comparer.Equals((_collection[i] as DrawningBoat), (obj as DrawningBoat))) throw new ObjectAlreadyInCollectionException(i);
}
if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position);
if (_collection[position] != null)
@ -143,5 +156,10 @@ namespace ProjectBoat.CollectionGenericObjects
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
Array.Sort(_collection, comparer);
}
}
}

View File

@ -1,5 +1,7 @@
using ProjectBoat.Drawnings;
using ProjectBoat.Exceptions;
using ProjectBoat.CollectionGenericObjects;
using ProjectBoat.Exceptions;
using System.Text;
namespace ProjectBoat.CollectionGenericObjects
@ -13,12 +15,12 @@ namespace ProjectBoat.CollectionGenericObjects
/// <summary>
/// Словарь (хранилище) с коллекциями
/// </summary>
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
/// <summary>
/// Возвращение списка названий коллекций
/// </summary>
public List<string> Keys => _storages.Keys.ToList();
public List<CollectionInfo> Keys => _storages.Keys.ToList();
/// <summary>
/// Ключевое слово, с которого должен начинаться файл
@ -40,7 +42,7 @@ namespace ProjectBoat.CollectionGenericObjects
/// </summary>
public StorageCollection()
{
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
}
/// <summary>
@ -48,29 +50,40 @@ namespace ProjectBoat.CollectionGenericObjects
/// </summary>
/// <param name="name">Название коллекции</param>
/// <param name="collectionType">тип коллекции</param>
public void AddCollection(string name, CollectionType collectionType)
public void AddCollection(CollectionInfo name)
{
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
// TODO Прописать логику для добавления
if (_storages.ContainsKey(name)) return;
if (name == null || _storages.ContainsKey(name))
{
return;
}
if (collectionType == CollectionType.None) return;
else if (collectionType == CollectionType.Massive)
_storages[name] = new MassiveGenericObjects<T>();
else if (collectionType == CollectionType.List)
_storages[name] = new ListGenericObjects<T>();
if (name.CollectionType == CollectionType.Massive)
{
_storages.Add(name, new MassiveGenericObjects<T>());
}
if (name.CollectionType == CollectionType.List)
{
_storages.Add(name, new ListGenericObjects<T>());
}
}
/// <summary>
/// Удаление коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
public void DelCollection(string name)
public void DelCollection(CollectionInfo name)
{
// TODO Прописать логику для удаления коллекции
if (_storages.ContainsKey(name))
_storages.Remove(name);
if (name == null || !_storages.ContainsKey(name))
{
return;
}
_storages.Remove(name);
}
/// <summary>
@ -78,19 +91,22 @@ namespace ProjectBoat.CollectionGenericObjects
/// </summary>
/// <param name="name">Название коллекции</param>
/// <returns></returns>
public ICollectionGenericObjects<T>? this[string name]
public ICollectionGenericObjects<T>? this[CollectionInfo name]
{
get
{
// TODO Продумать логику получения объекта
if (_storages.ContainsKey(name))
{
return _storages[name];
}
return null;
}
}
/// <summary>
/// Сохранение информации по автомобилям в хранилище в файл
/// Сохранение информации по самолетам в хранилище в файл
/// </summary>
/// <param name="filename">Путь и имя файла</param>
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
@ -111,7 +127,7 @@ namespace ProjectBoat.CollectionGenericObjects
using StreamWriter streamWriter = new StreamWriter(fs);
streamWriter.Write(_collectionKey);
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
{
streamWriter.Write(Environment.NewLine);
@ -122,8 +138,6 @@ namespace ProjectBoat.CollectionGenericObjects
streamWriter.Write(value.Key);
streamWriter.Write(_separatorForKeyValue);
streamWriter.Write(value.Value.GetCollectionType);
streamWriter.Write(_separatorForKeyValue);
streamWriter.Write(value.Value.MaxCount);
streamWriter.Write(_separatorForKeyValue);
@ -164,27 +178,25 @@ namespace ProjectBoat.CollectionGenericObjects
while ((str = sr.ReadLine()) != null)
{
string[] record = str.Split(_separatorForKeyValue);
if (record.Length != 4)
if (record.Length != 3)
{
continue;
}
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
if (collection == null)
{
throw new InvalidOperationException("Не удалось определить тип коллекции:" + record[1]);
}
collection.MaxCount = Convert.ToInt32(record[2]);
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ??
throw new Exception("Не удалось определить информацию коллекции: " + record[0]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionInfo.CollectionType) ??
throw new Exception("Не удалось создать коллекцию");
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)
{
if (elem?.CreateDrawningBoat() is T aircraft)
if (elem?.CreateDrawningBoat() is T boat)
{
try
{
if (collection.Insert(aircraft) == -1)
if (collection.Insert(boat, new DrawiningBoatEqutables()) == -1)
{
throw new InvalidOperationException("Объект не удалось добавить в коллекцию: " + record[3]);
}
@ -193,9 +205,13 @@ namespace ProjectBoat.CollectionGenericObjects
{
throw new CollectionOverflowException("Коллекция переполнена", ex);
}
catch (ObjectAlreadyInCollectionException ex)
{
throw new InvalidOperationException("Объект уже присутствует в коллекции", ex);
}
}
}
_storages.Add(record[0], collection);
_storages.Add(collectionInfo, collection);
}
}
}

View File

@ -0,0 +1,54 @@
using System.Diagnostics.CodeAnalysis;
namespace ProjectBoat.Drawnings;
/// <summary>
/// Реализация сравнения двух объектов класса-прорисовки
/// </summary>
public class DrawiningBoatEqutables : IEqualityComparer<DrawningBoat?>
{
public bool Equals(DrawningBoat? x, DrawningBoat? y)
{
if (x == null || x.EntityBoat == null)
{
return false;
}
if (y == null || y.EntityBoat == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityBoat.Speed != y.EntityBoat.Speed)
{
return false;
}
if (x.EntityBoat.Weight != y.EntityBoat.Weight)
{
return false;
}
if (x.EntityBoat.BodyColor != y.EntityBoat.BodyColor)
{
return false;
}
if (x is DrawningMBoat && y is DrawningMBoat)
{
// TODO доделать логику сравнения дополнительных параметров
}
return true;
}
public int GetHashCode([DisallowNull] DrawningBoat obj)
{
return obj.GetHashCode();
}
}

View File

@ -28,11 +28,11 @@ public class DrawningBoat
protected int? _startPosY;
/// <summary>
/// Ширина прорисовки крейсера
/// Ширина прорисовки лодки
/// </summary>
private readonly int _drawningBoatWidth = 150;
/// <summary>
/// Высота прорисовки крейсера
/// Высота прорисовки лодки
/// </summary>
private readonly int _drawningBoatHeight = 50;
private readonly int _drawningEnginesWidth = 3;
@ -210,7 +210,7 @@ public class DrawningBoat
//границы круисера
//границы лодки
Point[] points = { new Point(_startPosX.Value, _startPosY.Value), new Point(_startPosX.Value + 105, _startPosY.Value), new Point(_startPosX.Value + 147, _startPosY.Value + 24), new Point(_startPosX.Value + 105, _startPosY.Value + 49), new Point(_startPosX.Value, _startPosY.Value + 49), new Point(_startPosX.Value, _startPosY.Value) };
g.FillPolygon(Brush, points);
g.DrawPolygon(pen2, points);
@ -223,7 +223,7 @@ public class DrawningBoat
//g.DrawLine(pen, _startPosX.Value, _startPosY.Value, _startPosX.Value, _startPosY.Value + 49);
//внутренности круисера
//внутренности лодки
g.DrawRectangle(pen2, _startPosX.Value + 25, _startPosY.Value + 10, 80, 30);

View File

@ -0,0 +1,34 @@
using ProjectBoat.Entities;
namespace ProjectBoat.Drawnings;
/// <summary>
/// Сравнение по цвету, скорости, весу
/// </summary>
public class DrawningBoatCompareByColor : IComparer<DrawningBoat?>
{
public int Compare(DrawningBoat? x, DrawningBoat? y)
{
// TODO прописать логику сравения по цветам, скорости, весу
if (x == null || x.EntityBoat == null)
{
return 1;
}
if (y == null || y.EntityBoat == null)
{
return -1;
}
var bodycolorCompare = x.EntityBoat.BodyColor.Name.CompareTo(y.EntityBoat.BodyColor.Name);
if (bodycolorCompare != 0)
{
return bodycolorCompare;
}
var speedCompare = x.EntityBoat.Speed.CompareTo(y.EntityBoat.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityBoat.Weight.CompareTo(y.EntityBoat.Weight);
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat.Drawnings;
/// <summary>
/// Сравнение по типу, скорости, весу
/// </summary>
public class DrawningBoatCompareByType : IComparer<DrawningBoat?>
{
public int Compare(DrawningBoat? x, DrawningBoat? y)
{
if (x == null || x.EntityBoat == null)
{
return 1;
}
if (y == null || y.EntityBoat == null)
{
return -1;
}
if (x.GetType().Name != y.GetType().Name)
{
return x.GetType().Name.CompareTo(y.GetType().Name);
}
var speedCompare = x.EntityBoat.Speed.CompareTo(y.EntityBoat.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityBoat.Weight.CompareTo(y.EntityBoat.Weight);
}
}

View File

@ -1,7 +1,7 @@
namespace ProjectBoat.Entities;
/// <summary>
/// Класс-сущность "крейсер"
/// Класс-сущность "лодка"
/// </summary>
public class EntityBoat
{
@ -27,7 +27,7 @@ public class EntityBoat
/// </summary>
public double Step => Speed * 100 / Weight;
/// <summary>
/// Инициализация полей объекта-класса крейсера
/// Инициализация полей объекта-класса лодки
/// </summary>
/// <param name="speed">скорость</param>
/// <param name="weight">вес</param>

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat.Exceptions;
[Serializable]
internal class ObjectAlreadyInCollectionException : ApplicationException
{
public ObjectAlreadyInCollectionException(int index) : base("Такой объект уже присутствует в коллекции. Позиция " + index) { }
public ObjectAlreadyInCollectionException() : base() { }
public ObjectAlreadyInCollectionException(string message) : base(message) { }
public ObjectAlreadyInCollectionException(string message, Exception exception) : base(message, exception) { }
protected ObjectAlreadyInCollectionException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}

View File

@ -38,9 +38,9 @@
panelBlue = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxWeapon = new CheckBox();
checkBoxBoat = new CheckBox();
checkBoxHelicopterArea = new CheckBox();
checkBoxGlass = new CheckBox();
checkBoxOars = new CheckBox();
checkBoxMotor = new CheckBox();
numericUpDownWeight = new NumericUpDown();
labelWeight = new Label();
numericUpDownSpeed = new NumericUpDown();
@ -64,9 +64,9 @@
// groupBoxConfing
//
groupBoxConfing.Controls.Add(groupBoxColors);
groupBoxConfing.Controls.Add(checkBoxWeapon);
groupBoxConfing.Controls.Add(checkBoxBoat);
groupBoxConfing.Controls.Add(checkBoxHelicopterArea);
groupBoxConfing.Controls.Add(checkBoxGlass);
groupBoxConfing.Controls.Add(checkBoxOars);
groupBoxConfing.Controls.Add(checkBoxMotor);
groupBoxConfing.Controls.Add(numericUpDownWeight);
groupBoxConfing.Controls.Add(labelWeight);
groupBoxConfing.Controls.Add(numericUpDownSpeed);
@ -75,10 +75,8 @@
groupBoxConfing.Controls.Add(labelSimpleObject);
groupBoxConfing.Dock = DockStyle.Left;
groupBoxConfing.Location = new Point(0, 0);
groupBoxConfing.Margin = new Padding(3, 2, 3, 2);
groupBoxConfing.Name = "groupBoxConfing";
groupBoxConfing.Padding = new Padding(3, 2, 3, 2);
groupBoxConfing.Size = new Size(548, 196);
groupBoxConfing.Size = new Size(626, 262);
groupBoxConfing.TabIndex = 0;
groupBoxConfing.TabStop = false;
groupBoxConfing.Text = "Параметры";
@ -93,11 +91,9 @@
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(286, 20);
groupBoxColors.Margin = new Padding(3, 2, 3, 2);
groupBoxColors.Location = new Point(327, 26);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Padding = new Padding(3, 2, 3, 2);
groupBoxColors.Size = new Size(245, 116);
groupBoxColors.Size = new Size(280, 154);
groupBoxColors.TabIndex = 9;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
@ -105,154 +101,141 @@
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(190, 72);
panelPurple.Margin = new Padding(3, 2, 3, 2);
panelPurple.Location = new Point(217, 96);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(42, 35);
panelPurple.Size = new Size(48, 47);
panelPurple.TabIndex = 1;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(130, 72);
panelBlack.Margin = new Padding(3, 2, 3, 2);
panelBlack.Location = new Point(149, 96);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(42, 35);
panelBlack.Size = new Size(48, 47);
panelBlack.TabIndex = 1;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(72, 72);
panelGray.Margin = new Padding(3, 2, 3, 2);
panelGray.Location = new Point(82, 96);
panelGray.Name = "panelGray";
panelGray.Size = new Size(42, 35);
panelGray.Size = new Size(48, 47);
panelGray.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(15, 72);
panelWhite.Margin = new Padding(3, 2, 3, 2);
panelWhite.Location = new Point(17, 96);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(42, 35);
panelWhite.Size = new Size(48, 47);
panelWhite.TabIndex = 1;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(190, 23);
panelYellow.Margin = new Padding(3, 2, 3, 2);
panelYellow.Location = new Point(217, 31);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(42, 35);
panelYellow.Size = new Size(48, 47);
panelYellow.TabIndex = 1;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(130, 23);
panelBlue.Margin = new Padding(3, 2, 3, 2);
panelBlue.Location = new Point(149, 31);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(42, 35);
panelBlue.Size = new Size(48, 47);
panelBlue.TabIndex = 1;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(72, 23);
panelGreen.Margin = new Padding(3, 2, 3, 2);
panelGreen.Location = new Point(82, 31);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(42, 35);
panelGreen.Size = new Size(48, 47);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(15, 23);
panelRed.Margin = new Padding(3, 2, 3, 2);
panelRed.Location = new Point(17, 31);
panelRed.Name = "panelRed";
panelRed.Size = new Size(42, 35);
panelRed.Size = new Size(48, 47);
panelRed.TabIndex = 0;
//
// checkBoxWeapon
// checkBoxGlass
//
checkBoxWeapon.AutoSize = true;
checkBoxWeapon.Location = new Point(5, 163);
checkBoxWeapon.Margin = new Padding(3, 2, 3, 2);
checkBoxWeapon.Name = "checkBoxWeapon";
checkBoxWeapon.Size = new Size(162, 19);
checkBoxWeapon.TabIndex = 8;
checkBoxWeapon.Text = "Признак наличие стекла";
checkBoxWeapon.UseVisualStyleBackColor = true;
checkBoxGlass.AutoSize = true;
checkBoxGlass.Location = new Point(6, 217);
checkBoxGlass.Name = "checkBoxGlass";
checkBoxGlass.Size = new Size(202, 24);
checkBoxGlass.TabIndex = 8;
checkBoxGlass.Text = "Признак наличие стекла";
checkBoxGlass.UseVisualStyleBackColor = true;
//
// checkBoxBoat
// checkBoxOars
//
checkBoxBoat.AutoSize = true;
checkBoxBoat.Location = new Point(5, 127);
checkBoxBoat.Margin = new Padding(3, 2, 3, 2);
checkBoxBoat.Name = "checkBoxBoat";
checkBoxBoat.Size = new Size(157, 19);
checkBoxBoat.TabIndex = 7;
checkBoxBoat.Text = "Признак наличие весел";
checkBoxBoat.UseVisualStyleBackColor = true;
checkBoxOars.AutoSize = true;
checkBoxOars.Location = new Point(6, 169);
checkBoxOars.Name = "checkBoxOars";
checkBoxOars.Size = new Size(197, 24);
checkBoxOars.TabIndex = 7;
checkBoxOars.Text = "Признак наличие весел";
checkBoxOars.UseVisualStyleBackColor = true;
//
// checkBoxHelicopterArea
// checkBoxMotor
//
checkBoxHelicopterArea.AutoSize = true;
checkBoxHelicopterArea.Location = new Point(5, 92);
checkBoxHelicopterArea.Margin = new Padding(3, 2, 3, 2);
checkBoxHelicopterArea.Name = "checkBoxHelicopterArea";
checkBoxHelicopterArea.Size = new Size(167, 19);
checkBoxHelicopterArea.TabIndex = 6;
checkBoxHelicopterArea.Text = "Признак наличие мотора";
checkBoxHelicopterArea.UseVisualStyleBackColor = true;
checkBoxMotor.AutoSize = true;
checkBoxMotor.Location = new Point(6, 123);
checkBoxMotor.Name = "checkBoxMotor";
checkBoxMotor.Size = new Size(210, 24);
checkBoxMotor.TabIndex = 6;
checkBoxMotor.Text = "Признак наличие мотора";
checkBoxMotor.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(82, 51);
numericUpDownWeight.Margin = new Padding(3, 2, 3, 2);
numericUpDownWeight.Location = new Point(94, 68);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
numericUpDownWeight.Size = new Size(100, 23);
numericUpDownWeight.Size = new Size(114, 27);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(24, 52);
labelWeight.Location = new Point(27, 70);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(29, 15);
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 4;
labelWeight.Text = "Вес:";
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(82, 24);
numericUpDownSpeed.Margin = new Padding(3, 2, 3, 2);
numericUpDownSpeed.Location = new Point(94, 32);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
numericUpDownSpeed.Size = new Size(100, 23);
numericUpDownSpeed.Size = new Size(114, 27);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(10, 24);
labelSpeed.Location = new Point(12, 32);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(62, 15);
labelSpeed.Size = new Size(76, 20);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(416, 152);
labelModifiedObject.Location = new Point(476, 203);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(115, 34);
labelModifiedObject.Size = new Size(131, 44);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
@ -261,9 +244,9 @@
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(286, 152);
labelSimpleObject.Location = new Point(327, 203);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(114, 34);
labelSimpleObject.Size = new Size(130, 44);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
@ -271,19 +254,17 @@
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(10, 42);
pictureBoxObject.Margin = new Padding(3, 2, 3, 2);
pictureBoxObject.Location = new Point(11, 56);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(160, 94);
pictureBoxObject.Size = new Size(183, 125);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// buttonAdd
//
buttonAdd.Location = new Point(553, 159);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Location = new Point(632, 212);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(82, 22);
buttonAdd.Size = new Size(94, 29);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
@ -291,10 +272,9 @@
//
// buttonCancel
//
buttonCancel.Location = new Point(648, 159);
buttonCancel.Margin = new Padding(3, 2, 3, 2);
buttonCancel.Location = new Point(740, 212);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(82, 22);
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
@ -305,10 +285,9 @@
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(553, 9);
panelObject.Margin = new Padding(3, 2, 3, 2);
panelObject.Location = new Point(632, 12);
panelObject.Name = "panelObject";
panelObject.Size = new Size(179, 146);
panelObject.Size = new Size(205, 194);
panelObject.TabIndex = 4;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
@ -317,9 +296,9 @@
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(94, 8);
labelAdditionalColor.Location = new Point(108, 11);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(73, 28);
labelAdditionalColor.Size = new Size(83, 36);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
@ -330,9 +309,9 @@
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(10, 8);
labelBodyColor.Location = new Point(11, 11);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(73, 28);
labelBodyColor.Size = new Size(83, 36);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
@ -341,14 +320,13 @@
//
// FormBoatConfing
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(733, 196);
ClientSize = new Size(838, 262);
Controls.Add(panelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfing);
Margin = new Padding(3, 2, 3, 2);
Name = "FormBoatConfing";
Text = "Создание объекта";
groupBoxConfing.ResumeLayout(false);
@ -370,9 +348,9 @@
private NumericUpDown numericUpDownSpeed;
private Label labelSpeed;
private NumericUpDown numericUpDownWeight;
private CheckBox checkBoxHelicopterArea;
private CheckBox checkBoxBoat;
private CheckBox checkBoxWeapon;
private CheckBox checkBoxMotor;
private CheckBox checkBoxOars;
private CheckBox checkBoxGlass;
private GroupBox groupBoxColors;
private Panel panelPurple;
private Panel panelBlack;

View File

@ -9,7 +9,7 @@ namespace ProjectBoat
public partial class FormBoatConfing : Form
{
/// <summary>
/// Объект - прорисовка крейсера
/// Объект - прорисовка артиллерийской установки
/// </summary>
private DrawningBoat _boat;
@ -62,8 +62,8 @@ namespace ProjectBoat
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="sender"></param>labelSimpleObject
/// <param name="e"></param>labelSimpleObject
private void labelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
@ -95,7 +95,7 @@ namespace ProjectBoat
case "labelModifiedObject":
_boat = new
DrawningMBoat((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
Color.Black, checkBoxHelicopterArea.Checked, checkBoxBoat.Checked, checkBoxWeapon.Checked);
Color.Black, checkBoxMotor.Checked, checkBoxOars.Checked, checkBoxGlass.Checked);
break;
}
DrawObject();
@ -171,7 +171,6 @@ namespace ProjectBoat
BoatDelegate?.Invoke(_boat);
Close();
}
}
}
}

View File

@ -40,6 +40,8 @@
labelCollectionName = new Label();
comboBoxSelectorCompany = new ComboBox();
panelCompanyTools = new Panel();
buttonSortByColor = new Button();
buttonSortByType = new Button();
ButtonAddBoat = new Button();
buttonRefresh = new Button();
ButtonRemoveBoat = new Button();
@ -66,9 +68,9 @@
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Controls.Add(panelCompanyTools);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(631, 28);
groupBoxTools.Location = new Point(631, 30);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(222, 651);
groupBoxTools.Size = new Size(222, 658);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "инструменты";
@ -111,7 +113,6 @@
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 20;
listBoxCollection.Location = new Point(17, 137);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(186, 104);
@ -178,6 +179,8 @@
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonSortByColor);
panelCompanyTools.Controls.Add(buttonSortByType);
panelCompanyTools.Controls.Add(ButtonAddBoat);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(ButtonRemoveBoat);
@ -186,27 +189,49 @@
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 379);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(216, 274);
panelCompanyTools.Size = new Size(216, 275);
panelCompanyTools.TabIndex = 8;
//
// buttonSortByColor
//
buttonSortByColor.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSortByColor.Location = new Point(19, 241);
buttonSortByColor.Name = "buttonSortByColor";
buttonSortByColor.Size = new Size(186, 31);
buttonSortByColor.TabIndex = 7;
buttonSortByColor.Text = "Сортировка по цвету";
buttonSortByColor.UseVisualStyleBackColor = true;
buttonSortByColor.Click += ButtonSortByColor_Click;
//
// buttonSortByType
//
buttonSortByType.Anchor = AnchorStyles.Right;
buttonSortByType.Location = new Point(19, 199);
buttonSortByType.Name = "buttonSortByType";
buttonSortByType.Size = new Size(186, 37);
buttonSortByType.TabIndex = 6;
buttonSortByType.Text = "Сортировка по типу";
buttonSortByType.UseVisualStyleBackColor = true;
buttonSortByType.Click += ButtonSortByType_Click;
//
// ButtonAddBoat
//
ButtonAddBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
ButtonAddBoat.BackgroundImageLayout = ImageLayout.Center;
ButtonAddBoat.Location = new Point(18, 3);
ButtonAddBoat.Name = "ButtonAddBoat";
ButtonAddBoat.Size = new Size(186, 40);
ButtonAddBoat.Size = new Size(186, 52);
ButtonAddBoat.TabIndex = 1;
ButtonAddBoat.Text = "добваление крейсера";
ButtonAddBoat.Text = "добавление лодки";
ButtonAddBoat.UseVisualStyleBackColor = true;
ButtonAddBoat.Click += ButtonAddBoat_Click;
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRefresh.Location = new Point(18, 227);
buttonRefresh.Location = new Point(19, 164);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(186, 41);
buttonRefresh.Size = new Size(186, 29);
buttonRefresh.TabIndex = 5;
buttonRefresh.Text = "обновить";
buttonRefresh.UseVisualStyleBackColor = true;
@ -215,17 +240,17 @@
// ButtonRemoveBoat
//
ButtonRemoveBoat.Anchor = AnchorStyles.Right;
ButtonRemoveBoat.Location = new Point(18, 138);
ButtonRemoveBoat.Location = new Point(19, 99);
ButtonRemoveBoat.Name = "ButtonRemoveBoat";
ButtonRemoveBoat.Size = new Size(186, 40);
ButtonRemoveBoat.Size = new Size(186, 28);
ButtonRemoveBoat.TabIndex = 3;
ButtonRemoveBoat.Text = "удалить крейсер";
ButtonRemoveBoat.Text = "удалить лодку";
ButtonRemoveBoat.UseVisualStyleBackColor = true;
ButtonRemoveBoat.Click += ButtonRemoveBoat_Click;
//
// maskedTextBoxPosision
//
maskedTextBoxPosision.Location = new Point(17, 105);
maskedTextBoxPosision.Location = new Point(18, 60);
maskedTextBoxPosision.Mask = "00";
maskedTextBoxPosision.Name = "maskedTextBoxPosision";
maskedTextBoxPosision.Size = new Size(187, 27);
@ -235,9 +260,9 @@
// buttonGetToTest
//
buttonGetToTest.Anchor = AnchorStyles.Right;
buttonGetToTest.Location = new Point(18, 184);
buttonGetToTest.Location = new Point(18, 132);
buttonGetToTest.Name = "buttonGetToTest";
buttonGetToTest.Size = new Size(186, 40);
buttonGetToTest.Size = new Size(186, 27);
buttonGetToTest.TabIndex = 4;
buttonGetToTest.Text = "передать на тесты";
buttonGetToTest.UseVisualStyleBackColor = true;
@ -246,9 +271,9 @@
// pictureBoxBoat
//
pictureBoxBoat.Dock = DockStyle.Fill;
pictureBoxBoat.Location = new Point(0, 28);
pictureBoxBoat.Location = new Point(0, 30);
pictureBoxBoat.Name = "pictureBoxBoat";
pictureBoxBoat.Size = new Size(631, 651);
pictureBoxBoat.Size = new Size(631, 658);
pictureBoxBoat.TabIndex = 1;
pictureBoxBoat.TabStop = false;
//
@ -258,7 +283,8 @@
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(853, 28);
menuStrip.Padding = new Padding(6, 3, 0, 3);
menuStrip.Size = new Size(853, 30);
menuStrip.TabIndex = 2;
menuStrip.Text = "menuStrip1";
//
@ -297,13 +323,14 @@
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(853, 679);
ClientSize = new Size(853, 688);
Controls.Add(pictureBoxBoat);
Controls.Add(groupBoxTools);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormBoatsCollection";
Text = "FormBoatsCollection";
Load += FormBoatsCollection_Load;
groupBoxTools.ResumeLayout(false);
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
@ -342,5 +369,7 @@
private ToolStripMenuItem loadToolStripMenuItem;
private SaveFileDialog saveFileDialog;
private OpenFileDialog openFileDialog;
private Button buttonSortByColor;
private Button buttonSortByType;
}
}

View File

@ -1,9 +1,11 @@
using Microsoft.Extensions.Logging;
using ProjectBoat.CollectionGenericObjects;
using ProjectBoat.Drawnings;
using System.Windows.Forms;
namespace ProjectBoat
{
public partial class FormBoatsCollection : Form
{
/// <summary>
@ -42,7 +44,7 @@ namespace ProjectBoat
}
/// <summary>
/// добавление крейсера
/// добавление артиллерийской установки
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@ -56,7 +58,7 @@ namespace ProjectBoat
}
/// <summary>
/// Добавление крейсера в коллекцию
/// Добавление артиллерийской установки в коллекцию
/// </summary>
/// <param name="boat"></param>
private void SetBoat(DrawningBoat? boat)
@ -174,17 +176,11 @@ namespace ProjectBoat
collectionType = CollectionType.List;
}
try
{
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
_logger.LogInformation("Добавление коллекции");
RerfreshListBoxItems();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogError($"Ошибка: {ex.Message}", ex.Message);
}
CollectionInfo collectionInfo = new CollectionInfo(textBoxCollectionName.Text, collectionType, string.Empty);
_storageCollection.AddCollection(collectionInfo);
_logger.LogInformation("Добавление коллекции");
RerfreshListBoxItems();
}
/// <summary>
@ -203,7 +199,10 @@ namespace ProjectBoat
{
return;
}
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
CollectionInfo collectionInfo = new CollectionInfo(listBoxCollection.SelectedItem.ToString(), CollectionType.None, string.Empty);
_storageCollection.DelCollection(collectionInfo);
_logger.LogInformation("Коллекция удалена");
RerfreshListBoxItems();
}
@ -216,7 +215,7 @@ namespace ProjectBoat
listBoxCollection.Items.Clear();
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
{
string? colName = _storageCollection.Keys?[i];
string? colName = _storageCollection.Keys?[i].Name;
if (!string.IsNullOrEmpty(colName))
{
listBoxCollection.Items.Add(colName);
@ -237,8 +236,8 @@ namespace ProjectBoat
return;
}
ICollectionGenericObjects<DrawningBoat>? collection =
_storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
CollectionInfo collectionInfo = new CollectionInfo(listBoxCollection.SelectedItem.ToString(), CollectionType.None, string.Empty);
ICollectionGenericObjects<DrawningBoat>? collection = _storageCollection[collectionInfo];
if (collection == null)
{
MessageBox.Show("Коллекция не проинициализирована");
@ -253,6 +252,7 @@ namespace ProjectBoat
break;
}
panelCompanyTools.Enabled = true;
RerfreshListBoxItems();
}
@ -302,5 +302,44 @@ namespace ProjectBoat
}
}
}
/// <summary>
/// Сортировка по типу
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSortByType_Click(object sender, EventArgs e)
{
CompareBoats(new DrawningBoatCompareByType());
}
/// <summary>
/// Сортировка по цвету
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSortByColor_Click(object sender, EventArgs e)
{
CompareBoats(new DrawningBoatCompareByColor());
}
/// <summary>
/// Сортировка по сравнителю
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
private void CompareBoats(IComparer<DrawningBoat?> comparer)
{
if (_company == null)
{
return;
}
_company.Sort(comparer);
pictureBoxBoat.Image = _company.Show();
}
private void FormBoatsCollection_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -41,7 +41,7 @@ namespace ProjectBoat
}
/// <summary>
/// Метод прорисовки круисера
/// Метод прорисовки лодки
/// </summary>
private void Draw()
{

View File

@ -8,4 +8,15 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.12" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.2" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
</ItemGroup>
</Project>