8 лаба

This commit is contained in:
Victoria_Isaeva 2024-06-04 16:09:19 +04:00
parent 81924c5d00
commit 4d472b3557
10 changed files with 256 additions and 239 deletions

View File

@ -1,5 +1,6 @@
using ProjectAirbus.Drawnings; using ProjectAirbus.Drawnings;
using ProjectAirbus.Exceptions; using ProjectAirbus.Exceptions;
using System.Numerics;
namespace ProjectAirbus.CollectionGenericObjects; namespace ProjectAirbus.CollectionGenericObjects;
@ -58,9 +59,9 @@ public abstract class AbstractCompany
/// <param name="company">Компания</param> /// <param name="company">Компания</param>
/// <param name="car">Добавляемый объект</param> /// <param name="car">Добавляемый объект</param>
/// <returns></returns> /// <returns></returns>
public static bool operator +(AbstractCompany company, DrawningBus bus) public static int? operator +(AbstractCompany company, DrawningBus bus)
{ {
return company._collection?.Insert(bus, new DrawiningBusEqutables()) ?? false; return company._collection?.Insert(bus, new DrawiningBusEqutables());
} }
/// <summary> /// <summary>

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAirbus.CollectionGenericObjects;
public class CollectionInfo : IEquatable<CollectionInfo>
{
public string Name { get; private set; }
public CollectionType CollectionType { get; private set; }
public string Description { get; private set; }
private static readonly string _separator = "-";
public CollectionInfo(string name, CollectionType collectionType, string description)
{
Name = name;
CollectionType = collectionType;
Description = description;
}
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

@ -12,15 +12,21 @@ public interface ICollectionGenericObjects<T>
where T : class where T : class
{ {
int Count { get; } int Count { get; }
int MaxCount{get;set;}
int Insert(T obj, IEqualityComparer<DrawningBus?>? comparer = null );
int Insert(T obj, int position, IEqualityComparer<DrawningBus?>? comparer = null);
T? Remove(int position);
T? Get(int position);
CollectionType GetCollectionType { get; }
IEnumerable<T> GetItems(); int MaxCount { set; get; }
void CollectionSort(IComparer<T> comparer);
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null);
T Remove(int position);
T? Get(int position);
CollectionType GetCollectionType { get; }
IEnumerable<T?> GetItems();
void CollectionSort(IComparer<T?> comparer);
} }

View File

@ -1,9 +1,8 @@
using ProjectAirbus.CollectionGenericObjects; using ProjectAirbus.CollectionGenericObjects;
using ProjectAirbus.Drawnings;
using ProjectAirbus.Exceptions; using ProjectAirbus.Exceptions;
using System.Linq; using System.Linq;
namespace ProjectAirBus.CollectionGenericObjects; namespace ProjectAirbus.CollectionGenericObjects;
/// <summary> /// <summary>
/// Параметризованный набор объектов /// Параметризованный набор объектов
@ -24,11 +23,22 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
public int Count => _collection.Count; public int Count => _collection.Count;
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } } public int MaxCount
{
public CollectionType GetCollectionType => CollectionType.List; get
{
return Count;
}
set
{
if (value > 0)
{
_maxCount = value;
}
}
}
public int MaxCount { get; set; } public CollectionType GetCollectionType => CollectionType.List;
/// <summary> /// <summary>
/// Конструктор /// Конструктор
@ -45,7 +55,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
return _collection[position]; return _collection[position];
} }
public int Insert(T obj, IEqualityComparer<DrawningBus?>? comparer = null) public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
{ {
// TODO выброс ошибки если переполнение // TODO выброс ошибки если переполнение
if (comparer != null) if (comparer != null)
@ -61,7 +71,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
return Count; return Count;
} }
public int Insert(T obj, int position, IEqualityComparer<DrawningBus?>? comparer = null) public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
{ {
// TODO выброс ошибки если переполнение // TODO выброс ошибки если переполнение
// TODO выброс ошибки если за границу // TODO выброс ошибки если за границу
@ -95,9 +105,8 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
yield return _collection[i]; yield return _collection[i];
} }
} }
public void CollectionSort(IComparer<T?> comparer) void ICollectionGenericObjects<T>.CollectionSort(IComparer<T?> comparer)
{ {
_collection.Sort(comparer); _collection.Sort(comparer);
} }
} }

View File

@ -6,8 +6,6 @@ namespace ProjectAirbus.CollectionGenericObjects;
internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T> internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
where T : class where T : class
{ {
/// <summary> /// <summary>
/// Массив объектов, которые храним /// Массив объектов, которые храним
/// </summary> /// </summary>
@ -56,14 +54,14 @@ internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
return _collection[position]; return _collection[position];
} }
public int Insert(T obj, IEqualityComparer<DrawningBus?>? comparer = null) public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
{ {
// TODO выброс ошибки если переполнение // TODO выброс ошибки если переполнение
if (comparer != null) if (comparer != null)
{ {
foreach (T? item in _collection) foreach (T? item in _collection)
{ {
if ((comparer as IEqualityComparer<DrawingBus>).Equals(obj as DrawingBus, item as DrawingBus)) if ((comparer as IEqualityComparer<DrawningBus>).Equals(obj as DrawningBus, item as DrawningBus))
throw new ObjectIsEqualException(); throw new ObjectIsEqualException();
} }
} }
@ -81,13 +79,13 @@ internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
throw new CollectionOverflowException(Count); throw new CollectionOverflowException(Count);
} }
public int Insert(T obj, int position, IEqualityComparer<DrawningBus?>? comparer = null) public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
{ {
if (comparer != null) if (comparer != null)
{ {
foreach (T? item in _collection) foreach (T? item in _collection)
{ {
if ((comparer as IEqualityComparer<DrawingBus>).Equals(obj as DrawingBus, item as DrawingBus)) if ((comparer as IEqualityComparer<DrawningBus>).Equals(obj as DrawningBus, item as DrawningBus))
throw new ObjectIsEqualException(); throw new ObjectIsEqualException();
} }
} }

View File

@ -1,22 +1,18 @@
 using ProjectAirbus.CollectionGenericObjects;
using ProjectAirbus.CollectionGenericObjects;
using ProjectAirbus.Drawnings; using ProjectAirbus.Drawnings;
using ProjectAirbus.Exceptions; using ProjectAirbus.Exceptions;
using System.Text; using System.Text;
namespace ProjectAirbus.CollectionGenericObjects;
namespace ProjectAirBus.CollectionGenericObjects;
public class StorageCollection<T> public class StorageCollection<T>
where T : DrawningBus where T : DrawningBus
{ {
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages; readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
public List<string> Keys => _storages.Keys.ToList(); public List<CollectionInfo> Keys => _storages.Keys.ToList();
private readonly string _collectionKey = "CollectionStorage"; private readonly string _collectionKey = "CollectionStorage";
@ -26,7 +22,7 @@ public class StorageCollection<T>
public StorageCollection() public StorageCollection()
{ {
_storages = new Dictionary<string, ICollectionGenericObjects<T>>(); _storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
} }
@ -34,27 +30,22 @@ public class StorageCollection<T>
{ {
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом // TODO проверка, что name не пустой и нет в словаре записи с таким ключом
// TODO Прописать логику для добавления // TODO Прописать логику для добавления
if (name == null || _storages.ContainsKey(name)) { return; } CollectionInfo collectionInfo = new CollectionInfo(name, collectionType, string.Empty);
switch (collectionType) if (_storages.ContainsKey(collectionInfo)) return;
if (collectionType == CollectionType.None) return;
{ else if (collectionType == CollectionType.Massive)
case CollectionType.None: _storages[collectionInfo] = new MassiveGenericObjects<T>();
return; else if (collectionType == CollectionType.List)
case CollectionType.Massive: _storages[collectionInfo] = new ListGenericObjects<T>();
_storages[name] = new MassiveGenericObjects<T>();
return;
case CollectionType.List:
_storages[name] = new ListGenericObjects<T>();
return;
}
} }
public void DelCollection(string name) public void DelCollection(string name)
{ {
// TODO Прописать логику для удаления коллекции // TODO Прописать логику для удаления коллекции
if (_storages.ContainsKey(name)) CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
_storages.Remove(name); if (_storages.ContainsKey(collectionInfo))
_storages.Remove(collectionInfo);
} }
@ -62,9 +53,10 @@ public class StorageCollection<T>
{ {
get get
{ {
// TODO Продумать логику получения объекта CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
if (name == null || !_storages.ContainsKey(name)) { return null; } if (_storages.ContainsKey(collectionInfo))
return _storages[name]; return _storages[collectionInfo];
return null;
} }
} }
public void SaveData(string filename) public void SaveData(string filename)
@ -81,7 +73,7 @@ public class StorageCollection<T>
StringBuilder sb = new(); StringBuilder sb = new();
sb.Append(_collectionKey); sb.Append(_collectionKey);
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages) foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
{ {
sb.Append(Environment.NewLine); sb.Append(Environment.NewLine);
if (value.Value.Count == 0) if (value.Value.Count == 0)
@ -145,17 +137,19 @@ public class StorageCollection<T>
foreach (string data in strs) foreach (string data in strs)
{ {
string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); string[] record = data.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("Не удалось определить тип коллекции:" + record[1]);
} }
collection.MaxCount = Convert.ToInt32(record[2]); collection.MaxCount = Convert.ToInt32(record[1]);
string[] set = record[3].Split(_separatorItem, StringSplitOptions.RemoveEmptyEntries); string[] set = record[3].Split(_separatorItem, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set) foreach (string elem in set)
@ -176,7 +170,7 @@ public class StorageCollection<T>
} }
} }
_storages.Add(record[0], collection); _storages.Add(collectionInfo, collection);
} }

View File

@ -0,0 +1,13 @@
using System.Runtime.Serialization;
namespace ProjectAirbus.Exceptions;
[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) { }
}

View File

@ -30,6 +30,8 @@
{ {
groupBoxTools = new GroupBox(); groupBoxTools = new GroupBox();
panelCompanyTools = new Panel(); panelCompanyTools = new Panel();
buttonSortByColor = new Button();
buttonSortByType = new Button();
buttonRefresh = new Button(); buttonRefresh = new Button();
comboBoxSelectorCompany = new ComboBox(); comboBoxSelectorCompany = new ComboBox();
buttonGoToChek = new Button(); buttonGoToChek = new Button();
@ -64,34 +66,63 @@
groupBoxTools.Controls.Add(panelCompanyTools); groupBoxTools.Controls.Add(panelCompanyTools);
groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(825, 28); groupBoxTools.Location = new Point(722, 24);
groupBoxTools.Margin = new Padding(3, 2, 3, 2);
groupBoxTools.Name = "groupBoxTools"; groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(303, 581); groupBoxTools.Padding = new Padding(3, 2, 3, 2);
groupBoxTools.Size = new Size(265, 519);
groupBoxTools.TabIndex = 0; groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false; groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты"; groupBoxTools.Text = "Инструменты";
// //
// panelCompanyTools // panelCompanyTools
// //
panelCompanyTools.Controls.Add(buttonSortByColor);
panelCompanyTools.Controls.Add(buttonSortByType);
panelCompanyTools.Controls.Add(buttonRefresh); panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(comboBoxSelectorCompany);
panelCompanyTools.Controls.Add(buttonGoToChek); panelCompanyTools.Controls.Add(buttonGoToChek);
panelCompanyTools.Controls.Add(buttonAddBus); panelCompanyTools.Controls.Add(buttonAddBus);
panelCompanyTools.Controls.Add(buttonDelBus); panelCompanyTools.Controls.Add(buttonDelBus);
panelCompanyTools.Controls.Add(maskedTextBox); panelCompanyTools.Controls.Add(maskedTextBox);
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, 301);
panelCompanyTools.Margin = new Padding(3, 2, 3, 2);
panelCompanyTools.Name = "panelCompanyTools"; panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(297, 235); panelCompanyTools.Size = new Size(259, 216);
panelCompanyTools.TabIndex = 2; panelCompanyTools.TabIndex = 2;
// //
// buttonSortByColor
//
buttonSortByColor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonSortByColor.Location = new Point(10, 182);
buttonSortByColor.Margin = new Padding(3, 2, 3, 2);
buttonSortByColor.Name = "buttonSortByColor";
buttonSortByColor.Size = new Size(240, 26);
buttonSortByColor.TabIndex = 8;
buttonSortByColor.Text = "Сортировать по цвету";
buttonSortByColor.UseVisualStyleBackColor = true;
buttonSortByColor.Click += buttonSortByColor_Click;
//
// buttonSortByType
//
buttonSortByType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonSortByType.Location = new Point(10, 152);
buttonSortByType.Margin = new Padding(3, 2, 3, 2);
buttonSortByType.Name = "buttonSortByType";
buttonSortByType.Size = new Size(240, 26);
buttonSortByType.TabIndex = 7;
buttonSortByType.Text = "Сортировать по типу";
buttonSortByType.UseVisualStyleBackColor = true;
buttonSortByType.Click += buttonSortByType_Click;
//
// buttonRefresh // buttonRefresh
// //
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(10, 191); buttonRefresh.Location = new Point(9, 122);
buttonRefresh.Margin = new Padding(3, 2, 3, 2);
buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(275, 35); buttonRefresh.Size = new Size(240, 26);
buttonRefresh.TabIndex = 6; buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить "; buttonRefresh.Text = "Обновить ";
buttonRefresh.UseVisualStyleBackColor = true; buttonRefresh.UseVisualStyleBackColor = true;
@ -103,18 +134,20 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true; comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(11, 3); comboBoxSelectorCompany.Location = new Point(12, 240);
comboBoxSelectorCompany.Margin = new Padding(3, 2, 3, 2);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(267, 28); comboBoxSelectorCompany.Size = new Size(233, 23);
comboBoxSelectorCompany.TabIndex = 0; comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged; comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
// //
// buttonGoToChek // buttonGoToChek
// //
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToChek.Location = new Point(12, 150); buttonGoToChek.Location = new Point(10, 91);
buttonGoToChek.Margin = new Padding(3, 2, 3, 2);
buttonGoToChek.Name = "buttonGoToChek"; buttonGoToChek.Name = "buttonGoToChek";
buttonGoToChek.Size = new Size(273, 37); buttonGoToChek.Size = new Size(238, 28);
buttonGoToChek.TabIndex = 5; buttonGoToChek.TabIndex = 5;
buttonGoToChek.Text = "Передать на тесты"; buttonGoToChek.Text = "Передать на тесты";
buttonGoToChek.UseVisualStyleBackColor = true; buttonGoToChek.UseVisualStyleBackColor = true;
@ -123,9 +156,10 @@
// buttonAddBus // buttonAddBus
// //
buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddBus.Location = new Point(11, 37); buttonAddBus.Location = new Point(10, 7);
buttonAddBus.Margin = new Padding(3, 2, 3, 2);
buttonAddBus.Name = "buttonAddBus"; buttonAddBus.Name = "buttonAddBus";
buttonAddBus.Size = new Size(270, 33); buttonAddBus.Size = new Size(235, 25);
buttonAddBus.TabIndex = 1; buttonAddBus.TabIndex = 1;
buttonAddBus.Text = "Добавление самолета"; buttonAddBus.Text = "Добавление самолета";
buttonAddBus.UseVisualStyleBackColor = true; buttonAddBus.UseVisualStyleBackColor = true;
@ -134,9 +168,10 @@
// buttonDelBus // buttonDelBus
// //
buttonDelBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonDelBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonDelBus.Location = new Point(11, 109); buttonDelBus.Location = new Point(10, 61);
buttonDelBus.Margin = new Padding(3, 2, 3, 2);
buttonDelBus.Name = "buttonDelBus"; buttonDelBus.Name = "buttonDelBus";
buttonDelBus.Size = new Size(272, 35); buttonDelBus.Size = new Size(237, 26);
buttonDelBus.TabIndex = 4; buttonDelBus.TabIndex = 4;
buttonDelBus.Text = "Удалить самолет"; buttonDelBus.Text = "Удалить самолет";
buttonDelBus.UseVisualStyleBackColor = true; buttonDelBus.UseVisualStyleBackColor = true;
@ -144,10 +179,11 @@
// //
// maskedTextBox // maskedTextBox
// //
maskedTextBox.Location = new Point(11, 76); maskedTextBox.Location = new Point(10, 36);
maskedTextBox.Margin = new Padding(3, 2, 3, 2);
maskedTextBox.Mask = "00"; maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox"; maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(276, 27); maskedTextBox.Size = new Size(242, 23);
maskedTextBox.TabIndex = 3; maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int); maskedTextBox.ValidatingType = typeof(int);
// //
@ -156,22 +192,25 @@
panelStorage.Controls.Add(buttonCreateCompany); panelStorage.Controls.Add(buttonCreateCompany);
panelStorage.Controls.Add(buttonCollectionDel); panelStorage.Controls.Add(buttonCollectionDel);
panelStorage.Controls.Add(listBoxCollection); panelStorage.Controls.Add(listBoxCollection);
panelStorage.Controls.Add(comboBoxSelectorCompany);
panelStorage.Controls.Add(buttonCollectionAdd); panelStorage.Controls.Add(buttonCollectionAdd);
panelStorage.Controls.Add(radioButtonList); panelStorage.Controls.Add(radioButtonList);
panelStorage.Controls.Add(radioButtonMassive); panelStorage.Controls.Add(radioButtonMassive);
panelStorage.Controls.Add(textBoxCollectionName); panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName); panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top; panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 23); panelStorage.Location = new Point(3, 18);
panelStorage.Margin = new Padding(3, 2, 3, 2);
panelStorage.Name = "panelStorage"; panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(297, 317); panelStorage.Size = new Size(259, 279);
panelStorage.TabIndex = 2; panelStorage.TabIndex = 2;
// //
// buttonCreateCompany // buttonCreateCompany
// //
buttonCreateCompany.Location = new Point(12, 288); buttonCreateCompany.Location = new Point(11, 214);
buttonCreateCompany.Margin = new Padding(3, 2, 3, 2);
buttonCreateCompany.Name = "buttonCreateCompany"; buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(270, 29); buttonCreateCompany.Size = new Size(236, 22);
buttonCreateCompany.TabIndex = 7; buttonCreateCompany.TabIndex = 7;
buttonCreateCompany.Text = "Создать компанию "; buttonCreateCompany.Text = "Создать компанию ";
buttonCreateCompany.UseVisualStyleBackColor = true; buttonCreateCompany.UseVisualStyleBackColor = true;
@ -179,9 +218,10 @@
// //
// buttonCollectionDel // buttonCollectionDel
// //
buttonCollectionDel.Location = new Point(12, 251); buttonCollectionDel.Location = new Point(10, 188);
buttonCollectionDel.Margin = new Padding(3, 2, 3, 2);
buttonCollectionDel.Name = "buttonCollectionDel"; buttonCollectionDel.Name = "buttonCollectionDel";
buttonCollectionDel.Size = new Size(270, 29); buttonCollectionDel.Size = new Size(236, 22);
buttonCollectionDel.TabIndex = 6; buttonCollectionDel.TabIndex = 6;
buttonCollectionDel.Text = "Удалить коллекцию"; buttonCollectionDel.Text = "Удалить коллекцию";
buttonCollectionDel.UseVisualStyleBackColor = true; buttonCollectionDel.UseVisualStyleBackColor = true;
@ -190,16 +230,19 @@
// listBoxCollection // listBoxCollection
// //
listBoxCollection.FormattingEnabled = true; listBoxCollection.FormattingEnabled = true;
listBoxCollection.Location = new Point(12, 141); listBoxCollection.ItemHeight = 15;
listBoxCollection.Location = new Point(10, 106);
listBoxCollection.Margin = new Padding(3, 2, 3, 2);
listBoxCollection.Name = "listBoxCollection"; listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(264, 104); listBoxCollection.Size = new Size(232, 79);
listBoxCollection.TabIndex = 5; listBoxCollection.TabIndex = 5;
// //
// buttonCollectionAdd // buttonCollectionAdd
// //
buttonCollectionAdd.Location = new Point(12, 96); buttonCollectionAdd.Location = new Point(10, 72);
buttonCollectionAdd.Margin = new Padding(3, 2, 3, 2);
buttonCollectionAdd.Name = "buttonCollectionAdd"; buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(270, 29); buttonCollectionAdd.Size = new Size(236, 22);
buttonCollectionAdd.TabIndex = 4; buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию"; buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true; buttonCollectionAdd.UseVisualStyleBackColor = true;
@ -208,9 +251,10 @@
// radioButtonList // radioButtonList
// //
radioButtonList.AutoSize = true; radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(202, 66); radioButtonList.Location = new Point(177, 50);
radioButtonList.Margin = new Padding(3, 2, 3, 2);
radioButtonList.Name = "radioButtonList"; radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(80, 24); radioButtonList.Size = new Size(66, 19);
radioButtonList.TabIndex = 3; radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true; radioButtonList.TabStop = true;
radioButtonList.Text = "Список"; radioButtonList.Text = "Список";
@ -219,9 +263,10 @@
// radioButtonMassive // radioButtonMassive
// //
radioButtonMassive.AutoSize = true; radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(12, 66); radioButtonMassive.Location = new Point(10, 50);
radioButtonMassive.Margin = new Padding(3, 2, 3, 2);
radioButtonMassive.Name = "radioButtonMassive"; radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(82, 24); radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.TabIndex = 2; radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true; radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив"; radioButtonMassive.Text = "Массив";
@ -229,26 +274,28 @@
// //
// textBoxCollectionName // textBoxCollectionName
// //
textBoxCollectionName.Location = new Point(12, 33); textBoxCollectionName.Location = new Point(10, 25);
textBoxCollectionName.Margin = new Padding(3, 2, 3, 2);
textBoxCollectionName.Name = "textBoxCollectionName"; textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(270, 27); textBoxCollectionName.Size = new Size(237, 23);
textBoxCollectionName.TabIndex = 1; textBoxCollectionName.TabIndex = 1;
// //
// labelCollectionName // labelCollectionName
// //
labelCollectionName.AutoSize = true; labelCollectionName.AutoSize = true;
labelCollectionName.Location = new Point(12, 10); labelCollectionName.Location = new Point(10, 8);
labelCollectionName.Name = "labelCollectionName"; labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(158, 20); labelCollectionName.Size = new Size(125, 15);
labelCollectionName.TabIndex = 0; labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:"; labelCollectionName.Text = "Название коллекции:";
// //
// pictureBox1 // pictureBox1
// //
pictureBox1.Dock = DockStyle.Fill; pictureBox1.Dock = DockStyle.Fill;
pictureBox1.Location = new Point(0, 28); pictureBox1.Location = new Point(0, 24);
pictureBox1.Margin = new Padding(3, 2, 3, 2);
pictureBox1.Name = "pictureBox1"; pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new Size(825, 581); pictureBox1.Size = new Size(722, 519);
pictureBox1.TabIndex = 1; pictureBox1.TabIndex = 1;
pictureBox1.TabStop = false; pictureBox1.TabStop = false;
// //
@ -258,7 +305,8 @@
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip.Location = new Point(0, 0); menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip"; menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1128, 28); menuStrip.Padding = new Padding(5, 2, 0, 2);
menuStrip.Size = new Size(987, 24);
menuStrip.TabIndex = 2; menuStrip.TabIndex = 2;
menuStrip.Text = "menuStrip1"; menuStrip.Text = "menuStrip1";
// //
@ -266,14 +314,14 @@
// //
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem }); файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
файлToolStripMenuItem.Name = айлToolStripMenuItem"; файлToolStripMenuItem.Name = айлToolStripMenuItem";
файлToolStripMenuItem.Size = new Size(59, 24); файлToolStripMenuItem.Size = new Size(48, 20);
файлToolStripMenuItem.Text = "Файл"; файлToolStripMenuItem.Text = "Файл";
// //
// saveToolStripMenuItem // saveToolStripMenuItem
// //
saveToolStripMenuItem.Name = "saveToolStripMenuItem"; saveToolStripMenuItem.Name = "saveToolStripMenuItem";
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S; saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
saveToolStripMenuItem.Size = new Size(231, 26); saveToolStripMenuItem.Size = new Size(184, 22);
saveToolStripMenuItem.Text = "Сохранение "; saveToolStripMenuItem.Text = "Сохранение ";
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click; saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
// //
@ -281,7 +329,7 @@
// //
loadToolStripMenuItem.Name = "loadToolStripMenuItem"; loadToolStripMenuItem.Name = "loadToolStripMenuItem";
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L; loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
loadToolStripMenuItem.Size = new Size(231, 26); loadToolStripMenuItem.Size = new Size(184, 22);
loadToolStripMenuItem.Text = "Загрузка"; loadToolStripMenuItem.Text = "Загрузка";
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click; loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
// //
@ -295,14 +343,15 @@
// //
// FormBusCollection // FormBusCollection
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1128, 609); ClientSize = new Size(987, 543);
Controls.Add(pictureBox1); Controls.Add(pictureBox1);
Controls.Add(groupBoxTools); Controls.Add(groupBoxTools);
Controls.Add(menuStrip); Controls.Add(menuStrip);
FormBorderStyle = FormBorderStyle.FixedSingle; FormBorderStyle = FormBorderStyle.FixedSingle;
MainMenuStrip = menuStrip; MainMenuStrip = menuStrip;
Margin = new Padding(3, 2, 3, 2);
Name = "FormBusCollection"; Name = "FormBusCollection";
Text = "Коллекция самолетов "; Text = "Коллекция самолетов ";
groupBoxTools.ResumeLayout(false); groupBoxTools.ResumeLayout(false);
@ -343,6 +392,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;
} }
} }

View File

@ -2,7 +2,6 @@
using ProjectAirbus.CollectionGenericObjects; using ProjectAirbus.CollectionGenericObjects;
using ProjectAirbus.Drawnings; using ProjectAirbus.Drawnings;
using ProjectAirbus.Exceptions; using ProjectAirbus.Exceptions;
using ProjectAirBus.CollectionGenericObjects;
using System.Windows.Forms; using System.Windows.Forms;
namespace ProjectAirbus; namespace ProjectAirbus;
@ -214,7 +213,7 @@ public partial class FormBusCollection : 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);
@ -293,4 +292,24 @@ public partial class FormBusCollection : Form
} }
} }
} }
private void buttonSortByType_Click(object sender, EventArgs e)
{
ComparePlane(new DrawningBusCompareByType());
}
private void buttonSortByColor_Click(object sender, EventArgs e)
{
ComparePlane(new DrawningBusCompareByColor());
}
private void ComparePlane(IComparer<DrawningBus?> comparer)
{
if (_company == null)
{
return;
}
_company.Sort(comparer);
pictureBox1.Image = _company.Show();
}
} }

View File

@ -1,132 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>145, 17</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>310, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>