Лабораторная работа №8

This commit is contained in:
Glliza 2024-06-16 02:16:04 +04:00
parent 7624745b9d
commit 1c7cbfc84c
13 changed files with 423 additions and 82 deletions

View File

@ -64,7 +64,7 @@ public abstract class AbstractCompany
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningBus bus)
{
return company._collection.Insert(bus);
return company._collection.Insert(bus, new DrawiningBusEqutables());
}
/// <summary>
@ -107,6 +107,13 @@ public abstract class AbstractCompany
}
return bitmap;
}
/// <summary>
/// Сортировка
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
public void Sort(IComparer<DrawningBus?> comparer) => _collection?.CollectionSort(comparer);
/// <summary>
/// Вывод заднего фона
/// </summary>

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAirbus.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,5 @@
using System;
using ProjectAirbus.Drawning;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -28,7 +29,7 @@ public interface ICollectionGenericObjects<T>
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj);
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
@ -36,7 +37,7 @@ public interface ICollectionGenericObjects<T>
/// <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<T?>? comparer = null);
/// <summary>
/// Удаление объекта из коллекции с конкретной позиции
@ -62,4 +63,10 @@ public interface ICollectionGenericObjects<T>
/// </summary>
/// <returns>Поэлементый вывод элементов коллекции</returns>
IEnumerable<T?> GetItems();
/// <summary>
/// Сортировка коллекции
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
void CollectionSort(IComparer<T?> comparer);
}

View File

@ -1,4 +1,5 @@
using ProjectAirbus.Exceptions;
using ProjectAirbus.Drawning;
using ProjectAirbus.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
@ -29,7 +30,7 @@ internal class ListGenericObjects<T> : ICollectionGenericObjects<T>
{
get
{
return Count;
return _maxCount;
}
set
{
@ -57,28 +58,6 @@ internal class ListGenericObjects<T> : ICollectionGenericObjects<T>
return _collection[position];
}
public int Insert(T obj)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO вставка в конец набора
if (Count == _maxCount) throw new CollectionOverflowException(Count);
_collection.Add(obj);
return Count;
}
public int Insert(T obj, int position)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO проверка позиции
// TODO вставка по позиции
if (Count == _maxCount) throw new CollectionOverflowException(Count);
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
_collection.Insert(position, obj);
return position;
}
public T Remove(int position)
{
// TODO проверка позиции
@ -92,9 +71,52 @@ internal class ListGenericObjects<T> : ICollectionGenericObjects<T>
public IEnumerable<T?> GetItems()
{
for (int i = 0; i < Count; ++i)
for (int i = 0; i < _maxCount; ++i)
{
yield return _collection[i];
}
}
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
{
if (comparer != null)
{
if (_collection.Contains(obj, comparer))
{
throw new ObjectsEqualException();
}
}
if (_collection.Count >= _maxCount)
{
throw new CollectionOverflowException(MaxCount);
}
_collection.Add(obj);
return _collection.Count;
}
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
{
if (comparer != null)
{
if (_collection.Contains(obj, comparer))
{
throw new ObjectsEqualException(position);
}
}
if (position < 0 || position > _maxCount)
{
throw new PositionOutOfCollectionException(position);
}
if (_collection.Count >= _maxCount)
{
throw new CollectionOverflowException(MaxCount);
}
_collection.Insert(position, obj);
return position;
}
public void CollectionSort(IComparer<T?> comparer)
{
_collection.Sort(comparer);
}
}

View File

@ -1,4 +1,5 @@

using ProjectAirbus.Drawning;
using ProjectAirbus.Exceptions;
namespace ProjectAirbus.CollectionGenericObjects;
@ -63,22 +64,29 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
{
// TODO вставка в свободное место набора
for (int i = 0; i < MaxCount; ++i)
if (comparer != null)
{
if (_collection[i] == null)
for (int i = 0; i < MaxCount; ++i)
{
_collection[i] = obj;
return i;
if ((comparer as IEqualityComparer<DrawningBus>).Equals(obj as DrawningBus, _collection[i] as DrawningBus))
{
throw new ObjectsEqualException(i);
}
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<T?>? comparer = null)
{
// TODO проверка позиции
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
@ -90,6 +98,19 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
{
throw new PositionOutOfCollectionException(Count);
}
if (comparer != null)
{
for (int i = 0; i < position; i++)
{
if (_collection[i] != null)
{
if ((comparer as IEqualityComparer<DrawningBus>).Equals(obj as DrawningBus, _collection[i] as DrawningBus))
{
throw new ObjectsEqualException(i);
}
}
}
}
if (_collection[position] == null)
{
_collection[position] = obj;
@ -139,4 +160,9 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
Array.Sort(_collection, comparer);
}
}

View File

@ -18,11 +18,11 @@ public class StorageCollection<T>
/// <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>
/// Ключевое слово, с которого должен начинаться файл
@ -42,7 +42,7 @@ public class StorageCollection<T>
/// </summary>
public StorageCollection()
{
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
}
/// <summary>
@ -55,15 +55,22 @@ public class StorageCollection<T>
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
// TODO Прописать логику для добавления
if (_storages.ContainsKey(name))
CollectionInfo info = new CollectionInfo(name, collectionType, string.Empty);
if (_storages.ContainsKey(info))
{
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>();
switch (collectionType)
{
case CollectionType.None:
return;
case CollectionType.Massive:
_storages.Add(info, new MassiveGenericObjects<T>());
break;
case CollectionType.List:
_storages.Add(info, new ListGenericObjects<T>());
break;
}
}
/// <summary>
/// Удаление коллекции
@ -73,8 +80,11 @@ public class StorageCollection<T>
{
// TODO Прописать логику для удаления коллекции
if (_storages.ContainsKey(name))
_storages.Remove(name);
CollectionInfo info = new CollectionInfo(name, CollectionType.None, string.Empty);
if (_storages.ContainsKey(info))
{
_storages.Remove(info);
}
}
/// <summary>
@ -86,9 +96,11 @@ public class StorageCollection<T>
{
get
{
// TODO Продумать логику получения объекта
if (_storages.ContainsKey(name))
return _storages[name];
CollectionInfo info = new CollectionInfo(name, CollectionType.None, string.Empty);
if (_storages.ContainsKey(info))
{
return _storages[info];
}
return null;
}
}
@ -99,7 +111,6 @@ public class StorageCollection<T>
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
public void SaveData(string filename)
{
if (_storages.Count == 0)
{
throw new Exception("В хранилище отсутствуют коллекции для сохранения");
@ -114,16 +125,14 @@ public class StorageCollection<T>
wr.Write(_collectionKey);
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
{
wr.Write(Environment.NewLine);
if (value.Value.Count == 0)
{
continue;
}
wr.Write(value.Key);
wr.Write(_separatorForKeyValue);
wr.Write(value.Value.GetCollectionType);
wr.Write(value.Key.ToString());
wr.Write(_separatorForKeyValue);
wr.Write(value.Value.MaxCount);
wr.Write(_separatorForKeyValue);
@ -171,18 +180,21 @@ public class StorageCollection<T>
while ((strs = rd.ReadLine()) != null)
{
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
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);
CollectionInfo? col_info = CollectionInfo.GetCollectionInfo(record[0]) ??
throw new Exception("Не удалось определить информацию коллекции: " + record[0]); ;
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(col_info.CollectionType) ??
throw new Exception("Не удалось создать коллекцию");
if (collection == null)
{
throw new Exception("Не удалось создать коллекции");
}
collection.MaxCount = Convert.ToInt32(record[2]);
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
collection.MaxCount = Convert.ToInt32(record[1]);
string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
if (elem?.CreateDrawningBus() is T bus)
@ -201,7 +213,7 @@ public class StorageCollection<T>
}
}
_storages.Add(record[0], collection);
_storages.Add(col_info, collection);
}
}

View File

@ -0,0 +1,64 @@
using ProjectAirbus.Entities;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAirbus.Drawning
{
public class DrawiningBusEqutables : IEqualityComparer<DrawningBus?>
{
public bool Equals(DrawningBus? x, DrawningBus? y)
{
if (x == null || x.EntityBus == null)
{
return false;
}
if (y == null || y.EntityBus == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityBus.Speed != y.EntityBus.Speed)
{
return false;
}
if (x.EntityBus.Weight != y.EntityBus.Weight)
{
return false;
}
if (x.EntityBus.BodyColor != y.EntityBus.BodyColor)
{
return false;
}
if (x is DrawningAirbus && y is DrawningAirbus)
{
EntityAirbus _x = (EntityAirbus)x.EntityBus;
EntityAirbus _y = (EntityAirbus)x.EntityBus;
if (_x.AdditionalColor != _y.AdditionalColor)
{
return false;
}
if (_x.Compartment != _y.Compartment)
{
return false;
}
if (_x.Engine != _y.Engine)
{
return false;
}
}
return true;
}
public int GetHashCode([DisallowNull] DrawningBus? obj)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAirbus.Drawning;
public class DrawningBusCompareByColor : IComparer<DrawningBus?>
{
public int Compare(DrawningBus? x, DrawningBus? y)
{
if (x == null || x.EntityBus == null)
{
return 1;
}
if (y == null || y.EntityBus == null)
{
return -1;
}
var bodycolorCompare = x.EntityBus.BodyColor.Name.CompareTo(y.EntityBus.BodyColor.Name);
if (bodycolorCompare != 0)
{
return bodycolorCompare;
}
var speedCompare = x.EntityBus.Speed.CompareTo(y.EntityBus.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityBus.Weight.CompareTo(y.EntityBus.Weight);
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAirbus.Drawning;
public class DrawningBusCompareByType : IComparer<DrawningBus?>
{
public int Compare(DrawningBus? x, DrawningBus? y)
{
if (x == null || x.EntityBus == null)
{
return -1;
}
if (y == null || y.EntityBus == null)
{
return 1;
}
if (x.GetType().Name != y.GetType().Name)
{
return x.GetType().Name.CompareTo(y.GetType().Name);
}
var speedCompare = x.EntityBus.Speed.CompareTo(y.EntityBus.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityBus.Weight.CompareTo(y.EntityBus.Weight);
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAirbus.Exceptions;
public class ObjectsEqualException : ApplicationException
{
public ObjectsEqualException(int i) : base("В коллекции находится такой же элемент на позиции " + i) { }
public ObjectsEqualException() : base("В коллекции находится такой же элемент") { }
public ObjectsEqualException(string message) : base(message) { }
public ObjectsEqualException(string message, Exception exception) : base(message, exception) { }
protected ObjectsEqualException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}

View File

@ -30,6 +30,8 @@
{
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonSortByType = new Button();
buttonSortByColor = new Button();
buttonAddBus = new Button();
buttonRemoveBus = new Button();
maskedTextBoxPosition = new MaskedTextBox();
@ -68,24 +70,46 @@
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(948, 24);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(200, 755);
groupBoxTools.Size = new Size(200, 650);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonSortByType);
panelCompanyTools.Controls.Add(buttonSortByColor);
panelCompanyTools.Controls.Add(buttonAddBus);
panelCompanyTools.Controls.Add(buttonRemoveBus);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Location = new Point(3, 428);
panelCompanyTools.Location = new Point(3, 351);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(194, 324);
panelCompanyTools.Size = new Size(194, 296);
panelCompanyTools.TabIndex = 8;
//
// buttonSortByType
//
buttonSortByType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonSortByType.Location = new Point(6, 187);
buttonSortByType.Name = "buttonSortByType";
buttonSortByType.Size = new Size(176, 28);
buttonSortByType.TabIndex = 8;
buttonSortByType.Text = "Сортировка по типу";
buttonSortByType.UseVisualStyleBackColor = true;
buttonSortByType.Click += buttonSortByType_Click;
//
// buttonSortByColor
//
buttonSortByColor.Location = new Point(6, 221);
buttonSortByColor.Name = "buttonSortByColor";
buttonSortByColor.Size = new Size(176, 28);
buttonSortByColor.TabIndex = 10;
buttonSortByColor.Text = "Сортировка по цвету";
buttonSortByColor.Click += buttonSortByColor_Click;
//
// buttonAddBus
//
buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@ -100,9 +124,9 @@
// buttonRemoveBus
//
buttonRemoveBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveBus.Location = new Point(6, 166);
buttonRemoveBus.Location = new Point(6, 85);
buttonRemoveBus.Name = "buttonRemoveBus";
buttonRemoveBus.Size = new Size(176, 43);
buttonRemoveBus.Size = new Size(176, 28);
buttonRemoveBus.TabIndex = 4;
buttonRemoveBus.Text = "Удалить аэробус";
buttonRemoveBus.UseVisualStyleBackColor = true;
@ -110,7 +134,7 @@
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Location = new Point(6, 122);
maskedTextBoxPosition.Location = new Point(6, 56);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(179, 23);
@ -120,9 +144,9 @@
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(6, 264);
buttonRefresh.Location = new Point(6, 119);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(176, 43);
buttonRefresh.Size = new Size(176, 28);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
@ -131,9 +155,9 @@
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(6, 215);
buttonGoToCheck.Location = new Point(6, 153);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(176, 43);
buttonGoToCheck.Size = new Size(176, 28);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
@ -141,7 +165,7 @@
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(6, 392);
buttonCreateCompany.Location = new Point(6, 322);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(188, 23);
buttonCreateCompany.TabIndex = 7;
@ -161,12 +185,12 @@
panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 19);
panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(194, 311);
panelStorage.Size = new Size(194, 268);
panelStorage.TabIndex = 7;
//
// buttonCollectionDell
//
buttonCollectionDell.Location = new Point(3, 263);
buttonCollectionDell.Location = new Point(3, 239);
buttonCollectionDell.Name = "buttonCollectionDell";
buttonCollectionDell.Size = new Size(188, 23);
buttonCollectionDell.TabIndex = 6;
@ -178,14 +202,14 @@
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 15;
listBoxCollection.Location = new Point(3, 120);
listBoxCollection.Location = new Point(3, 109);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(188, 124);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
buttonCollectionAdd.Location = new Point(3, 91);
buttonCollectionAdd.Location = new Point(3, 80);
buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(188, 23);
buttonCollectionAdd.TabIndex = 4;
@ -196,7 +220,7 @@
// radioButtonList
//
radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(119, 56);
radioButtonList.Location = new Point(119, 45);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(66, 19);
radioButtonList.TabIndex = 3;
@ -207,7 +231,7 @@
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(19, 56);
radioButtonMassive.Location = new Point(19, 45);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.TabIndex = 2;
@ -237,7 +261,7 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(6, 348);
comboBoxSelectorCompany.Location = new Point(6, 293);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(182, 23);
comboBoxSelectorCompany.TabIndex = 1;
@ -248,7 +272,7 @@
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 24);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(948, 755);
pictureBox.Size = new Size(948, 650);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
@ -297,7 +321,7 @@
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1148, 779);
ClientSize = new Size(1148, 674);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Controls.Add(menuStrip);
@ -342,5 +366,7 @@
private ToolStripMenuItem LoadToolStripMenuItem;
private SaveFileDialog saveFileDialog;
private OpenFileDialog openFileDialog;
private Button buttonSortByType;
private Button buttonSortByColor;
}
}

View File

@ -177,7 +177,7 @@ namespace ProjectAirbus
collectionType = CollectionType.List;
}
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
_logger.LogInformation("Коллекция добавлена " + textBoxCollectionName.Text);
_logger.LogInformation("Коллекция добавлена " + textBoxCollectionName.Text);
RerfreshListBoxItems();
}
@ -189,7 +189,7 @@ namespace ProjectAirbus
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);
@ -286,5 +286,25 @@ namespace ProjectAirbus
}
}
}
private void buttonSortByType_Click(object sender, EventArgs e)
{
CompareBus(new DrawningBusCompareByType());
}
private void CompareBus(IComparer<DrawningBus?> comparer)
{
if (_company == null)
{
return;
}
_company.Sort(comparer);
pictureBox.Image = _company.Show();
}
private void buttonSortByColor_Click(object sender, EventArgs e)
{
CompareBus(new DrawningBusCompareByColor());
}
}
}

View File

@ -126,4 +126,7 @@
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>261, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>73</value>
</metadata>
</root>