diff --git a/ProjectLiner/.vs/ProjectEvaluation/projectliner.metadata.v7.bin b/ProjectLiner/.vs/ProjectEvaluation/projectliner.metadata.v7.bin index d14171d..5606952 100644 Binary files a/ProjectLiner/.vs/ProjectEvaluation/projectliner.metadata.v7.bin and b/ProjectLiner/.vs/ProjectEvaluation/projectliner.metadata.v7.bin differ diff --git a/ProjectLiner/.vs/ProjectEvaluation/projectliner.projects.v7.bin b/ProjectLiner/.vs/ProjectEvaluation/projectliner.projects.v7.bin index 8f9021c..46ec9e3 100644 Binary files a/ProjectLiner/.vs/ProjectEvaluation/projectliner.projects.v7.bin and b/ProjectLiner/.vs/ProjectEvaluation/projectliner.projects.v7.bin differ diff --git a/ProjectLiner/.vs/ProjectLiner/DesignTimeBuild/.dtbcache.v2 b/ProjectLiner/.vs/ProjectLiner/DesignTimeBuild/.dtbcache.v2 index 3eedd43..ff0cefe 100644 Binary files a/ProjectLiner/.vs/ProjectLiner/DesignTimeBuild/.dtbcache.v2 and b/ProjectLiner/.vs/ProjectLiner/DesignTimeBuild/.dtbcache.v2 differ diff --git a/ProjectLiner/.vs/ProjectLiner/v17/.futdcache.v2 b/ProjectLiner/.vs/ProjectLiner/v17/.futdcache.v2 index e3e8403..0e041da 100644 Binary files a/ProjectLiner/.vs/ProjectLiner/v17/.futdcache.v2 and b/ProjectLiner/.vs/ProjectLiner/v17/.futdcache.v2 differ diff --git a/ProjectLiner/.vs/ProjectLiner/v17/DocumentLayout.json b/ProjectLiner/.vs/ProjectLiner/v17/DocumentLayout.json index 6a200ee..cda2a7f 100644 --- a/ProjectLiner/.vs/ProjectLiner/v17/DocumentLayout.json +++ b/ProjectLiner/.vs/ProjectLiner/v17/DocumentLayout.json @@ -3,21 +3,21 @@ "WorkspaceRootPath": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\", "Documents": [ { - "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\serilog.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}", - "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\serilog.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}" + "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\drawnings\\drawninglinercomparebycolor .cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\drawnings\\drawninglinercomparebycolor .cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\drawnings\\drawninglinercomparebytype.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\drawnings\\drawninglinercomparebytype.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\drawnings\\drawininglinerequtables.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\drawnings\\drawininglinerequtables.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" }, { "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" }, - { - "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\projectliner.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|", - "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\projectliner.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|" - }, - { - "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\formlinercollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\formlinercollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, { "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\collectiongenericobjects\\storagecollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\collectiongenericobjects\\storagecollection.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" @@ -30,10 +30,6 @@ "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\collectiongenericobjects\\massivegenericobjects.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\collectiongenericobjects\\massivegenericobjects.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" }, - { - "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\formlinerconfig.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\formlinerconfig.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, { "AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\collectiongenericobjects\\listgenericobjects.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\collectiongenericobjects\\listgenericobjects.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" @@ -50,7 +46,7 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 4, + "SelectedChildIndex": 2, "Children": [ { "$type": "Bookmark", @@ -62,67 +58,54 @@ }, { "$type": "Document", - "DocumentIndex": 1, - "Title": "Program.cs", - "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Program.cs", - "RelativeDocumentMoniker": "ProjectLiner\\Program.cs", - "ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Program.cs", - "RelativeToolTip": "ProjectLiner\\Program.cs", - "ViewState": "AQIAABkAAAAAAAAAAAAmwCUAAAAQAAAA", + "DocumentIndex": 0, + "Title": "DrawningLinerCompareByColor .cs", + "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Drawnings\\DrawningLinerCompareByColor .cs", + "RelativeDocumentMoniker": "ProjectLiner\\Drawnings\\DrawningLinerCompareByColor .cs", + "ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Drawnings\\DrawningLinerCompareByColor .cs", + "RelativeToolTip": "ProjectLiner\\Drawnings\\DrawningLinerCompareByColor .cs", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABIAAAAkAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-05-22T11:10:44.695Z", + "WhenOpened": "2024-05-22T11:44:30.653Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "DrawningLinerCompareByType.cs", + "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Drawnings\\DrawningLinerCompareByType.cs", + "RelativeDocumentMoniker": "ProjectLiner\\Drawnings\\DrawningLinerCompareByType.cs", + "ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Drawnings\\DrawningLinerCompareByType.cs", + "RelativeToolTip": "ProjectLiner\\Drawnings\\DrawningLinerCompareByType.cs", + "ViewState": "AQIAAAQAAAAAAAAAAAAzwBoAAAA7AAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-05-22T11:41:01.766Z", "EditorCaption": "" }, { "$type": "Document", "DocumentIndex": 2, - "Title": "ProjectLiner", - "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\ProjectLiner.csproj", - "RelativeDocumentMoniker": "ProjectLiner\\ProjectLiner.csproj", - "ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\ProjectLiner.csproj", - "RelativeToolTip": "ProjectLiner\\ProjectLiner.csproj", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|", - "WhenOpened": "2024-05-22T10:49:10.627Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 0, - "Title": "serilog.json", - "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\serilog.json", - "RelativeDocumentMoniker": "ProjectLiner\\serilog.json", - "ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\serilog.json", - "RelativeToolTip": "ProjectLiner\\serilog.json", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAsAAAAdAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|", - "WhenOpened": "2024-05-22T10:49:21.207Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 7, - "Title": "FormLinerConfig.cs", - "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLinerConfig.cs", - "RelativeDocumentMoniker": "ProjectLiner\\FormLinerConfig.cs", - "ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLinerConfig.cs", - "RelativeToolTip": "ProjectLiner\\FormLinerConfig.cs", - "ViewState": "AQIAAG4AAAAAAAAAAAAqwH0AAAAMAAAA", + "Title": "DrawiningLinerEqutables.cs", + "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Drawnings\\DrawiningLinerEqutables.cs", + "RelativeDocumentMoniker": "ProjectLiner\\Drawnings\\DrawiningLinerEqutables.cs", + "ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Drawnings\\DrawiningLinerEqutables.cs", + "RelativeToolTip": "ProjectLiner\\Drawnings\\DrawiningLinerEqutables.cs", + "ViewState": "AQIAAAAAAAAAAAAAAAAAADUAAAAFAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-05-22T09:38:03.779Z", + "WhenOpened": "2024-05-22T11:34:01.546Z", "EditorCaption": "" }, { "$type": "Document", "DocumentIndex": 3, - "Title": "FormLinerCollection.cs", - "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLinerCollection.cs", - "RelativeDocumentMoniker": "ProjectLiner\\FormLinerCollection.cs", - "ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLinerCollection.cs", - "RelativeToolTip": "ProjectLiner\\FormLinerCollection.cs", - "ViewState": "AQIAAN8AAAAAAAAAAAAmwPIAAABHAAAA", + "Title": "Program.cs", + "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Program.cs", + "RelativeDocumentMoniker": "ProjectLiner\\Program.cs", + "ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Program.cs", + "RelativeToolTip": "ProjectLiner\\Program.cs", + "ViewState": "AQIAAAYAAAAAAAAAAAAcwBkAAABJAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-05-22T09:31:35.635Z", + "WhenOpened": "2024-05-22T11:10:44.695Z", "EditorCaption": "" }, { @@ -153,7 +136,7 @@ }, { "$type": "Document", - "DocumentIndex": 9, + "DocumentIndex": 8, "Title": "ICollectionGenericObjects.cs", "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\CollectionGenericObjects\\ICollectionGenericObjects.cs", "RelativeDocumentMoniker": "ProjectLiner\\CollectionGenericObjects\\ICollectionGenericObjects.cs", @@ -166,7 +149,7 @@ }, { "$type": "Document", - "DocumentIndex": 8, + "DocumentIndex": 7, "Title": "ListGenericObjects.cs", "DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\CollectionGenericObjects\\ListGenericObjects.cs", "RelativeDocumentMoniker": "ProjectLiner\\CollectionGenericObjects\\ListGenericObjects.cs", diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs index 415f2ca..e448c88 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs @@ -50,7 +50,7 @@ public abstract class AbstractCompany /// public static int? operator +(AbstractCompany company, DrawningLiner ship) { - return company._collection?.Insert(ship) ?? null; + return company._collection?.Insert(ship, new DrawiningLinerEqutables()) ?? null; } /// /// Перегрузка оператора удаления для класса @@ -97,4 +97,10 @@ public abstract class AbstractCompany /// Расстановка объектов /// protected abstract void SetObjectsPosition(); + + /// + /// Сортировка + /// + /// Сравнитель объектов + public void Sort(IComparer comparer) => _collection?.CollectionSort(comparer); } diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionInfo.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionInfo.cs new file mode 100644 index 0000000..2b5bcb2 --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionInfo.cs @@ -0,0 +1,70 @@ +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner.CollectionGenericObjects; + +public class CollectionInfo : IEquatable +{ + /// + /// Название + /// + 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; + } + /// + /// Создание объекта из строки + /// + /// Строка + /// Объект или null + 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(); + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs index 33e4628..1692a3e 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -18,20 +18,20 @@ public interface ICollectionGenericObjects where T : class /// /// Добавляемый объект /// true - вставка прошла удачно, false - вставка не удалась -int Insert(T obj); + int Insert(T obj, IEqualityComparer? comparer = null); /// /// Добавление объекта в коллекцию на конкретную позицию /// /// Добавляемый объект /// Позиция /// true - вставка прошла удачно, false - вставка не удалась -int Insert(T obj, int position); + int Insert(T obj, int position, IEqualityComparer? comparer = null); /// /// Удаление объекта из коллекции с конкретной позиции /// /// Позиция /// true - удаление прошло удачно, false - удаление не удалось -T Remove(int position); + T Remove(int position); /// /// Получение объекта по позиции /// @@ -49,4 +49,10 @@ T Remove(int position); /// /// Поэлементый вывод элементов коллекции IEnumerable GetItems(); + + /// + /// Сортировка коллекции + /// + /// Сравнитель объектов + void CollectionSort(IComparer comparer); } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs index 037e28a..ac7f457 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs @@ -40,7 +40,7 @@ public class ListGenericObjects : ICollectionGenericObjects if (position >= Count || position < 0) throw new Exceptions.PositionOutOfCollectionException(); return _collection[position]; } - public int Insert(T obj) + public int Insert(T obj, IEqualityComparer? comparer = null) { // TODO проверка, что не превышено максимальное количество элементов // TODO вставка в конец набора @@ -48,7 +48,7 @@ public class ListGenericObjects : ICollectionGenericObjects _collection.Add(obj); return _collection.Count-1;//возможна проблема } - public int Insert(T obj, int position) + public int Insert(T obj, int position, IEqualityComparer? comparer = null) { // TODO проверка, что не превышено максимальное количество элементов // TODO проверка позиции @@ -74,4 +74,9 @@ public class ListGenericObjects : ICollectionGenericObjects yield return _collection[i]; } } + + public void CollectionSort(IComparer comparer) + { + _collection.Sort(comparer); + } } diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs index 89a6315..24ad1d4 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs @@ -54,7 +54,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects return _collection[position]; } - public int Insert(T obj) + public int Insert(T obj, IEqualityComparer? comparer = null) { // TODO вставка в свободное место набора for (int i = 0; i < Count; i++) @@ -68,7 +68,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects throw new CollectionOverflowException(Count); } - public int Insert(T obj, int position) + public int Insert(T obj, int position, IEqualityComparer? comparer = null) { if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position); if (_collection[position] == null) @@ -120,4 +120,9 @@ public class MassiveGenericObjects : ICollectionGenericObjects yield return _collection[i]; } } + + public void CollectionSort(IComparer comparer) + { + Array.Sort(_collection, comparer); + } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs index d2247f4..0341c80 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs @@ -1,39 +1,45 @@ -using ProjectLiner.Drawnings; +using System.Text; +using ProjectLiner.Drawnings; using ProjectLiner.Exceptions; -using System.Text; namespace ProjectLiner.CollectionGenericObjects; - +//хронилище коллекций +/// public class StorageCollection where T : DrawningLiner { + /// /// Словарь (хранилище) с коллекциями /// - readonly Dictionary> _storages; + readonly Dictionary> _storages; + /// /// Возвращение списка названий коллекций /// - public List Keys => _storages.Keys.ToList(); - /// - /// Ключевое слово, с которого должен начинаться файл - /// - private readonly string _collectionKey = "CollectionsStorage"; - /// - /// Разделитель для записи ключа и значения элемента словаря - /// - private readonly string _separatorForKeyValue = "|"; - /// - /// Разделитель для записей коллекции данных в файл - /// - private readonly string _separatorItems = ";"; + public List Keys => _storages.Keys.ToList(); + /// /// Конструктор /// public StorageCollection() { - _storages = new Dictionary>(); + _storages = new Dictionary>(); } + /// + /// Ключевое слово, с которого должен начинаться файл + /// + private readonly string _collectionKey = "CollectionsStorage"; + /// + /// Разделитель для записи ключа и значения элемента словаря + /// + private readonly string _separatorForKeyValue = "|"; + + /// + /// Разделитель для записей коллекции данных в файл + /// + private readonly string _separatorItems = ";"; + /// /// Добавление коллекции в хранилище /// @@ -43,19 +49,13 @@ public class StorageCollection { // TODO проверка, что name не пустой и нет в словаре записи с таким ключом // TODO Прописать логику для добавления - if (_storages.ContainsKey(name)) return; - switch (collectionType) - { - case CollectionType.None: - return; - case CollectionType.List: - _storages[name] = new ListGenericObjects(); - break; - case CollectionType.Massive: - _storages[name] = new MassiveGenericObjects(); - break; - - } + CollectionInfo collectionInfo = new CollectionInfo(name, collectionType, string.Empty); + if (_storages.ContainsKey(collectionInfo)) return; + if (collectionType == CollectionType.None) return; + else if (collectionType == CollectionType.Massive) + _storages[collectionInfo] = new MassiveGenericObjects(); + else if (collectionType == CollectionType.List) + _storages[collectionInfo] = new ListGenericObjects(); } /// /// Удаление коллекции @@ -63,34 +63,31 @@ public class StorageCollection /// Название коллекции public void DelCollection(string name) { - - // TODO Прописать логику для удаления коллекции - if (_storages.ContainsKey(name)) - _storages.Remove(name); + CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty); + if (_storages.ContainsKey(collectionInfo)) + _storages.Remove(collectionInfo); } + /// /// Доступ к коллекции /// /// Название коллекции /// - public ICollectionGenericObjects? this[string name] + public ICollectionGenericObjects this[string name] { get { - // TODO Продумать логику получения объекта - if (_storages.ContainsKey(name)) - return _storages[name]; - throw new Exceptions.ObjectNotFoundException(); - + CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty); + + if (_storages.ContainsKey(collectionInfo)) + return _storages[collectionInfo]; + + return null; + } } - /// - /// Сохранение информации по автомобилям в хранилище в файл - /// - /// Путь и имя файла - /// true - сохранение прошло успешно, false - ошибка при сохранении данных -public bool SaveData(string filename) + public void SaveData(string filename) { if (_storages.Count == 0) { @@ -100,118 +97,106 @@ public bool SaveData(string filename) { File.Delete(filename); } - StringBuilder sb = new(); - sb.Append(_collectionKey); - foreach (KeyValuePair> value in - _storages) + using (StreamWriter writer = new StreamWriter(filename)) { - sb.Append(Environment.NewLine); - // не сохраняем пустые коллекции - if (value.Value.Count == 0) + writer.Write(_collectionKey); + foreach (KeyValuePair> value in _storages) { - continue; - } - sb.Append(value.Key); - sb.Append(_separatorForKeyValue); - sb.Append(value.Value.GetCollectionType); - sb.Append(_separatorForKeyValue); - sb.Append(value.Value.MaxCount); - sb.Append(_separatorForKeyValue); - foreach (T? item in value.Value.GetItems()) - { - string data = item?.GetDataForSave() ?? string.Empty; - if (string.IsNullOrEmpty(data)) + StringBuilder sb = new(); + sb.Append(Environment.NewLine); + if (value.Value.Count == 0) { continue; } - sb.Append(data); - sb.Append(_separatorItems); + sb.Append(value.Key); + sb.Append(_separatorForKeyValue); + sb.Append(value.Value.MaxCount); + sb.Append(_separatorForKeyValue); + foreach (T? item in value.Value.GetItems()) + { + string data = item?.GetDataForSave() ?? string.Empty; + if (string.IsNullOrEmpty(data)) + { + continue; + } + sb.Append(data); + sb.Append(_separatorItems); + } + writer.Write(sb); } + } - using FileStream fs = new(filename, FileMode.Create); - byte[] info = new UTF8Encoding(true).GetBytes(sb.ToString()); - fs.Write(info, 0, info.Length); - return true; } + /// /// Загрузка информации по автомобилям в хранилище из файла /// /// Путь и имя файла /// true - загрузка прошла успешно, false - ошибка при загрузке данных - public bool LoadData(string filename) + public void LoadData(string filename) { if (!File.Exists(filename)) { throw new Exception("Файл не существует"); } - string bufferTextFromFile = ""; - using (FileStream fs = new(filename, FileMode.Open)) + using (StreamReader fs = File.OpenText(filename)) { - byte[] b = new byte[fs.Length]; - UTF8Encoding temp = new(true); - while (fs.Read(b, 0, b.Length) > 0) + string str = fs.ReadLine(); + if (str == null || str.Length == 0) { - bufferTextFromFile += temp.GetString(b); + throw new Exception("В файле нет данных"); } - } - string[] strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, - StringSplitOptions.RemoveEmptyEntries); - if (strs == null || strs.Length == 0) - { - throw new Exception("В файле нет данных"); - } - if (!strs[0].Equals(_collectionKey)) - { - throw new Exception("В файле неверные данные"); - } - _storages.Clear(); - foreach (string data in strs) - { - string[] record = data.Split(_separatorForKeyValue, - StringSplitOptions.RemoveEmptyEntries); - if (record.Length != 4) + if (!str.StartsWith(_collectionKey)) { - continue; + throw new Exception("В файле неверные данные"); } - CollectionType collectionType = - (CollectionType)Enum.Parse(typeof(CollectionType), record[1]); - ICollectionGenericObjects? collection = - StorageCollection.CreateCollection(collectionType)?? throw new Exception("Не удалось определить тип коллекции: " + record[1]); - - collection.MaxCount = Convert.ToInt32(record[2]); - string[] set = record[3].Split(_separatorItems, - StringSplitOptions.RemoveEmptyEntries); - foreach (string elem in set) + _storages.Clear(); + string strs = ""; + while ((strs = fs.ReadLine()) != null) { - if (elem?.CreateDrawningLiner() is T liner) + string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); + if (record.Length != 3) { - try + continue; + } + CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ?? throw new Exception("Не удалось определить информацию коллекции: " + record[0]); + + ICollectionGenericObjects? collection = StorageCollection.CreateCollection(collectionInfo.CollectionType); + if (collection == null) + { + throw new Exception("Не удалось создать коллекцию"); + } + collection.MaxCount = Convert.ToInt32(record[1]); + string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries); + foreach (string elem in set) + { + if (elem?.CreateDrawningLiner() is T liner) { try { - collection.Insert(liner); - }catch + if (collection.Insert(liner) == -1) + { + throw new Exception("Объект не удалось добавить в коллекцию: " + record[3]); + } + } + catch (CollectionOverflowException ex) { - throw new Exception("Объект не удалось добавить в коллекцию: " + record[3]); + throw new Exception("Коллекция переполнена", ex); } } - catch (CollectionOverflowException ex) - { - throw new Exception("Коллекция переполнена", ex); - } } + _storages.Add(collectionInfo, collection); } - _storages.Add(record[0], collection); } - return true; } + + /// /// Создание коллекции по типу /// /// /// - private static ICollectionGenericObjects? - CreateCollection(CollectionType collectionType) + private static ICollectionGenericObjects? CreateCollection(CollectionType collectionType) { return collectionType switch { diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawiningLinerEqutables.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawiningLinerEqutables.cs index 6422141..c3b0687 100644 --- a/ProjectLiner/ProjectLiner/Drawnings/DrawiningLinerEqutables.cs +++ b/ProjectLiner/ProjectLiner/Drawnings/DrawiningLinerEqutables.cs @@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis; namespace ProjectLiner.Drawnings; -public class DrawiningPlaneEqutables : IEqualityComparer +public class DrawiningLinerEqutables : IEqualityComparer { public bool Equals(DrawningLiner? x, DrawningLiner? y) { diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs index 3623811..cc91b73 100644 --- a/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs @@ -1,4 +1,9 @@ -namespace ProjectLiner +using static System.Net.Mime.MediaTypeNames; +using System.Drawing.Printing; +using System.Windows.Forms; +using System.Xml.Linq; + +namespace ProjectLiner { partial class FormLinerCollection { @@ -30,12 +35,13 @@ { groupBoxTools = new GroupBox(); panelCompanyTools = new Panel(); - buttonAddLiner = new Button(); - buttonRefresh = new Button(); - maskedTextBox = new MaskedTextBox(); - buttonGoToCheck = new Button(); - buttonRemoveLiner = new Button(); buttonCreateCompany = new Button(); + buttonAddLiner = new Button(); + comboBoxSelectorCompany = new ComboBox(); + buttonRefresh = new Button(); + buttonAddLBetterLiner = new Button(); + buttonRemoveLiner = new Button(); + maskedTextBox = new MaskedTextBox(); panelStorage = new Panel(); buttonCollectionDel = new Button(); listBoxCollection = new ListBox(); @@ -44,14 +50,17 @@ radioButtonMassive = new RadioButton(); textBoxCollectionName = new TextBox(); labelCollectionName = new Label(); - comboBoxSelectorCompany = new ComboBox(); + buttonTests = new Button(); pictureBox = new PictureBox(); + colorDialog1 = new ColorDialog(); menuStrip = new MenuStrip(); - FileToolStripMenuItem = new ToolStripMenuItem(); + fileToolStripMenuItem = new ToolStripMenuItem(); saveToolStripMenuItem = new ToolStripMenuItem(); loadToolStripMenuItem = new ToolStripMenuItem(); - saveFileDialog = new SaveFileDialog(); openFileDialog = new OpenFileDialog(); + saveFileDialog = new SaveFileDialog(); + buttonSortByColor = new Button(); + buttonSortByType = new Button(); groupBoxTools.SuspendLayout(); panelCompanyTools.SuspendLayout(); panelStorage.SuspendLayout(); @@ -62,94 +71,119 @@ // groupBoxTools // groupBoxTools.Controls.Add(panelCompanyTools); - groupBoxTools.Controls.Add(buttonCreateCompany); groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(887, 24); + groupBoxTools.Location = new Point(537, 28); + groupBoxTools.Margin = new Padding(3, 4, 3, 4); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(146, 597); + groupBoxTools.Padding = new Padding(3, 4, 3, 4); + groupBoxTools.Size = new Size(240, 724); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // // panelCompanyTools // + panelCompanyTools.Controls.Add(buttonSortByColor); + panelCompanyTools.Controls.Add(buttonSortByType); + panelCompanyTools.Controls.Add(buttonCreateCompany); panelCompanyTools.Controls.Add(buttonAddLiner); + panelCompanyTools.Controls.Add(comboBoxSelectorCompany); panelCompanyTools.Controls.Add(buttonRefresh); - panelCompanyTools.Controls.Add(maskedTextBox); - panelCompanyTools.Controls.Add(buttonGoToCheck); + panelCompanyTools.Controls.Add(buttonAddLBetterLiner); panelCompanyTools.Controls.Add(buttonRemoveLiner); - panelCompanyTools.Enabled = false; - panelCompanyTools.Location = new Point(6, 333); + panelCompanyTools.Controls.Add(maskedTextBox); + panelCompanyTools.Location = new Point(7, 384); + panelCompanyTools.Margin = new Padding(3, 4, 3, 4); panelCompanyTools.Name = "panelCompanyTools"; - panelCompanyTools.Size = new Size(200, 280); - panelCompanyTools.TabIndex = 2; - // - // buttonAddLiner - // - buttonAddLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddLiner.Location = new Point(3, 3); - buttonAddLiner.Name = "buttonAddSLiner"; - buttonAddLiner.Size = new Size(128, 38); - buttonAddLiner.TabIndex = 1; - buttonAddLiner.Text = "Добавление лайнера"; - buttonAddLiner.UseVisualStyleBackColor = true; - buttonAddLiner.Click += buttonAddShip_Click; - // - // buttonRefresh - // - buttonRefresh.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(3, 214); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(128, 40); - buttonRefresh.TabIndex = 6; - buttonRefresh.Text = "Обновить"; - buttonRefresh.UseVisualStyleBackColor = true; - buttonRefresh.Click += buttonRefresh_Click; - // - // maskedTextBox - // - maskedTextBox.Location = new Point(3, 93); - maskedTextBox.Mask = "00"; - maskedTextBox.Name = "maskedTextBox"; - maskedTextBox.Size = new Size(128, 23); - maskedTextBox.TabIndex = 3; - maskedTextBox.ValidatingType = typeof(int); - // - // buttonGoToCheck - // - buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(3, 168); - buttonGoToCheck.Name = "buttonGoToCheck"; - buttonGoToCheck.Size = new Size(128, 40); - buttonGoToCheck.TabIndex = 5; - buttonGoToCheck.Text = "Передать на тесты"; - buttonGoToCheck.UseVisualStyleBackColor = true; - buttonGoToCheck.Click += buttonGoToCheck_Click; - // - // buttonRemoveLiner - // - buttonRemoveLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRemoveLiner.Location = new Point(3, 122); - buttonRemoveLiner.Name = "buttonRemoveLiner"; - buttonRemoveLiner.Size = new Size(128, 40); - buttonRemoveLiner.TabIndex = 4; - buttonRemoveLiner.Text = "Удаление"; - buttonRemoveLiner.UseVisualStyleBackColor = true; - buttonRemoveLiner.Click += buttonRemoveLiner_Click; + panelCompanyTools.Size = new Size(219, 340); + panelCompanyTools.TabIndex = 8; // // buttonCreateCompany // - buttonCreateCompany.Location = new Point(6, 304); + buttonCreateCompany.Location = new Point(3, 43); + buttonCreateCompany.Margin = new Padding(3, 4, 3, 4); buttonCreateCompany.Name = "buttonCreateCompany"; - buttonCreateCompany.Size = new Size(128, 23); - buttonCreateCompany.TabIndex = 8; + buttonCreateCompany.Size = new Size(213, 32); + buttonCreateCompany.TabIndex = 7; buttonCreateCompany.Text = "Создать компанию"; buttonCreateCompany.UseVisualStyleBackColor = true; buttonCreateCompany.Click += buttonCreateCompany_Click; // + // buttonAddLiner + // + buttonAddLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddLiner.Location = new Point(3, 95); + buttonAddLiner.Margin = new Padding(3, 4, 3, 4); + buttonAddLiner.Name = "buttonAddLiner"; + buttonAddLiner.Size = new Size(212, 31); + buttonAddLiner.TabIndex = 1; + buttonAddLiner.Text = "Добавление лайнера"; + buttonAddLiner.UseVisualStyleBackColor = true; + buttonAddLiner.Click += buttonAddLiner_Click; + // + // comboBoxSelectorCompany + // + comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxSelectorCompany.FormattingEnabled = true; + comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); + comboBoxSelectorCompany.Location = new Point(3, 4); + comboBoxSelectorCompany.Margin = new Padding(3, 4, 3, 4); + comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; + comboBoxSelectorCompany.Size = new Size(212, 28); + comboBoxSelectorCompany.TabIndex = 0; + comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged; + // + // buttonRefresh + // + buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRefresh.Location = new Point(107, 290); + buttonRefresh.Margin = new Padding(3, 4, 3, 4); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(108, 50); + buttonRefresh.TabIndex = 5; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += buttonRefresh_Click; + // + // buttonAddBetterKiner + // + buttonAddLBetterLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddLBetterLiner.Location = new Point(3, 134); + buttonAddLBetterLiner.Margin = new Padding(3, 4, 3, 4); + buttonAddLBetterLiner.Name = "buttonAddBetterLiner"; + buttonAddLBetterLiner.Size = new Size(212, 31); + buttonAddLBetterLiner.TabIndex = 2; + buttonAddLBetterLiner.Text = "Добавление крутого лайнер"; + buttonAddLBetterLiner.UseVisualStyleBackColor = true; + // + // buttonRemoveLiner + // + buttonRemoveLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRemoveLiner.Location = new Point(0, 290); + buttonRemoveLiner.Margin = new Padding(3, 4, 3, 4); + buttonRemoveLiner.Name = "buttonRemoveLiner"; + buttonRemoveLiner.Size = new Size(108, 50); + buttonRemoveLiner.TabIndex = 3; + buttonRemoveLiner.Text = "Удаление лайнера"; + buttonRemoveLiner.UseVisualStyleBackColor = true; + buttonRemoveLiner.Click += buttonRemoveLiner_Click; + // + // maskedTextBox + // + maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + maskedTextBox.Location = new Point(3, 173); + maskedTextBox.Margin = new Padding(3, 4, 3, 4); + maskedTextBox.Mask = "00"; + maskedTextBox.Name = "maskedTextBox"; + maskedTextBox.Size = new Size(212, 27); + maskedTextBox.TabIndex = 2; + maskedTextBox.ValidatingType = typeof(int); + // // panelStorage // + panelStorage.Anchor = AnchorStyles.Top | AnchorStyles.Right; panelStorage.Controls.Add(buttonCollectionDel); panelStorage.Controls.Add(listBoxCollection); panelStorage.Controls.Add(buttonCollectionAdd); @@ -157,37 +191,39 @@ panelStorage.Controls.Add(radioButtonMassive); panelStorage.Controls.Add(textBoxCollectionName); panelStorage.Controls.Add(labelCollectionName); - panelStorage.Controls.Add(comboBoxSelectorCompany); - panelStorage.Dock = DockStyle.Top; - panelStorage.Location = new Point(3, 19); + panelStorage.Location = new Point(7, 29); + panelStorage.Margin = new Padding(3, 4, 3, 4); panelStorage.Name = "panelStorage"; - panelStorage.Size = new Size(140, 279); - panelStorage.TabIndex = 7; + panelStorage.Size = new Size(219, 347); + panelStorage.TabIndex = 6; // // buttonCollectionDel // - buttonCollectionDel.Location = new Point(3, 216); + buttonCollectionDel.Location = new Point(3, 311); + buttonCollectionDel.Margin = new Padding(3, 4, 3, 4); buttonCollectionDel.Name = "buttonCollectionDel"; - buttonCollectionDel.Size = new Size(132, 23); + buttonCollectionDel.Size = new Size(213, 32); buttonCollectionDel.TabIndex = 6; - buttonCollectionDel.Text = "Удалить коллецию"; + buttonCollectionDel.Text = "Удалить коллекцию"; buttonCollectionDel.UseVisualStyleBackColor = true; buttonCollectionDel.Click += buttonCollectionDel_Click; // // listBoxCollection // listBoxCollection.FormattingEnabled = true; - listBoxCollection.ItemHeight = 15; - listBoxCollection.Location = new Point(3, 101); + listBoxCollection.ItemHeight = 20; + listBoxCollection.Location = new Point(3, 157); + listBoxCollection.Margin = new Padding(3, 4, 3, 4); listBoxCollection.Name = "listBoxCollection"; - listBoxCollection.Size = new Size(134, 109); + listBoxCollection.Size = new Size(212, 144); listBoxCollection.TabIndex = 5; // // buttonCollectionAdd // - buttonCollectionAdd.Location = new Point(3, 72); + buttonCollectionAdd.Location = new Point(3, 119); + buttonCollectionAdd.Margin = new Padding(3, 4, 3, 4); buttonCollectionAdd.Name = "buttonCollectionAdd"; - buttonCollectionAdd.Size = new Size(128, 23); + buttonCollectionAdd.Size = new Size(213, 32); buttonCollectionAdd.TabIndex = 4; buttonCollectionAdd.Text = "Добавить коллекцию"; buttonCollectionAdd.UseVisualStyleBackColor = true; @@ -196,9 +232,10 @@ // radioButtonList // radioButtonList.AutoSize = true; - radioButtonList.Location = new Point(71, 47); + radioButtonList.Location = new Point(121, 85); + radioButtonList.Margin = new Padding(3, 4, 3, 4); radioButtonList.Name = "radioButtonList"; - radioButtonList.Size = new Size(66, 19); + radioButtonList.Size = new Size(80, 24); radioButtonList.TabIndex = 3; radioButtonList.TabStop = true; radioButtonList.Text = "Список"; @@ -207,9 +244,10 @@ // radioButtonMassive // radioButtonMassive.AutoSize = true; - radioButtonMassive.Location = new Point(3, 47); + radioButtonMassive.Location = new Point(26, 85); + radioButtonMassive.Margin = new Padding(3, 4, 3, 4); radioButtonMassive.Name = "radioButtonMassive"; - radioButtonMassive.Size = new Size(67, 19); + radioButtonMassive.Size = new Size(82, 24); radioButtonMassive.TabIndex = 2; radioButtonMassive.TabStop = true; radioButtonMassive.Text = "Массив"; @@ -217,90 +255,119 @@ // // textBoxCollectionName // - textBoxCollectionName.Location = new Point(3, 18); + textBoxCollectionName.Location = new Point(3, 39); + textBoxCollectionName.Margin = new Padding(3, 4, 3, 4); textBoxCollectionName.Name = "textBoxCollectionName"; - textBoxCollectionName.Size = new Size(128, 23); + textBoxCollectionName.Size = new Size(212, 27); textBoxCollectionName.TabIndex = 1; // // labelCollectionName // labelCollectionName.AutoSize = true; - labelCollectionName.Location = new Point(3, 0); + labelCollectionName.Location = new Point(31, 15); labelCollectionName.Name = "labelCollectionName"; - labelCollectionName.Size = new Size(125, 15); + labelCollectionName.Size = new Size(155, 20); labelCollectionName.TabIndex = 0; - labelCollectionName.Text = "Название коллекции:"; + labelCollectionName.Text = "Название коллекции"; // - // comboBoxSelectorCompany + // buttonTests // - comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; - comboBoxSelectorCompany.FormattingEnabled = true; - comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - comboBoxSelectorCompany.Location = new Point(3, 256); - comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; - comboBoxSelectorCompany.Size = new Size(128, 23); - comboBoxSelectorCompany.TabIndex = 0; - comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged; + buttonTests.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonTests.Location = new Point(349, 505); + buttonTests.Margin = new Padding(3, 4, 3, 4); + buttonTests.Name = "buttonTests"; + buttonTests.Size = new Size(171, 29); + buttonTests.TabIndex = 4; + buttonTests.Text = "Передать на Тесты"; + buttonTests.UseVisualStyleBackColor = true; + buttonTests.Click += buttonGoToCheck_Click; // // pictureBox // pictureBox.Dock = DockStyle.Fill; - pictureBox.Location = new Point(0, 24); + pictureBox.Location = new Point(0, 28); + pictureBox.Margin = new Padding(3, 4, 3, 4); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(887, 597); + pictureBox.Size = new Size(537, 724); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // // menuStrip // - menuStrip.Items.AddRange(new ToolStripItem[] { FileToolStripMenuItem }); + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(1033, 24); - menuStrip.TabIndex = 2; - menuStrip.Text = "menuStrip1"; + menuStrip.Size = new Size(777, 28); + menuStrip.TabIndex = 5; + menuStrip.Text = "menuStrip"; // - // FileToolStripMenuItem + // файлToolStripMenuItem // - FileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem }); - FileToolStripMenuItem.Name = "FileToolStripMenuItem"; - FileToolStripMenuItem.Size = new Size(48, 20); - FileToolStripMenuItem.Text = "Файл"; + fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem }); + fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + fileToolStripMenuItem.Size = new Size(59, 24); + fileToolStripMenuItem.Text = "Файл"; // // saveToolStripMenuItem // saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S; - saveToolStripMenuItem.Size = new Size(181, 22); + saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D; + saveToolStripMenuItem.Size = new Size(230, 26); saveToolStripMenuItem.Text = "Сохранение"; saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click; // // loadToolStripMenuItem // loadToolStripMenuItem.Name = "loadToolStripMenuItem"; - loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L; - loadToolStripMenuItem.Size = new Size(181, 22); + loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S; + loadToolStripMenuItem.Size = new Size(230, 26); loadToolStripMenuItem.Text = "Загрузка"; loadToolStripMenuItem.Click += loadToolStripMenuItem_Click; // - // saveFileDialog - // - saveFileDialog.Filter = "txt file | *.txt"; - // // openFileDialog // openFileDialog.Filter = "txt file | *.txt"; // - // FormShipCollection + // saveFileDialog // - AutoScaleDimensions = new SizeF(7F, 15F); + saveFileDialog.Filter = "txt file | *.txt"; + // + // buttonSortByColor + // + buttonSortByColor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonSortByColor.Location = new Point(107, 218); + buttonSortByColor.Margin = new Padding(3, 4, 3, 4); + buttonSortByColor.Name = "buttonSortByColor"; + buttonSortByColor.Size = new Size(108, 50); + buttonSortByColor.TabIndex = 9; + buttonSortByColor.Text = "Сортировать по цвету "; + buttonSortByColor.UseVisualStyleBackColor = true; + buttonSortByColor.Click += buttonSortByColor_Click; + // + // buttonSortByType + // + buttonSortByType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonSortByType.Location = new Point(-1, 218); + buttonSortByType.Margin = new Padding(3, 4, 3, 4); + buttonSortByType.Name = "buttonSortByType"; + buttonSortByType.Size = new Size(108, 50); + buttonSortByType.TabIndex = 8; + buttonSortByType.Text = "Сортировать по типу"; + buttonSortByType.UseVisualStyleBackColor = true; + buttonSortByType.Click += buttonSortByType_Click; + // + // FormWarmlyShipCollection + // + AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1033, 621); + ClientSize = new Size(777, 752); Controls.Add(pictureBox); Controls.Add(groupBoxTools); + Controls.Add(buttonTests); Controls.Add(menuStrip); MainMenuStrip = menuStrip; + Margin = new Padding(3, 4, 3, 4); Name = "FormLinerCollection"; Text = "Коллекция лайнеров"; groupBoxTools.ResumeLayout(false); @@ -320,26 +387,30 @@ private GroupBox groupBoxTools; private ComboBox comboBoxSelectorCompany; private Button buttonAddLiner; - private Button buttonGoToCheck; - private Button buttonRemoveLiner; private MaskedTextBox maskedTextBox; + private Button buttonAddLBetterLiner; private PictureBox pictureBox; + private Button buttonRemoveLiner; private Button buttonRefresh; + private Button buttonTests; + private ColorDialog colorDialog1; private Panel panelStorage; + private Label labelCollectionName; private RadioButton radioButtonList; private RadioButton radioButtonMassive; private TextBox textBoxCollectionName; - private Label labelCollectionName; + private Button buttonCollectionAdd; + private ListBox listBoxCollection; private Button buttonCreateCompany; private Button buttonCollectionDel; - private ListBox listBoxCollection; - private Button buttonCollectionAdd; private Panel panelCompanyTools; private MenuStrip menuStrip; - private ToolStripMenuItem FileToolStripMenuItem; + private ToolStripMenuItem fileToolStripMenuItem; private ToolStripMenuItem saveToolStripMenuItem; private ToolStripMenuItem loadToolStripMenuItem; - private SaveFileDialog saveFileDialog; private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; + private Button buttonSortByColor; + private Button buttonSortByType; } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.cs index f25dc76..66f71a0 100644 --- a/ProjectLiner/ProjectLiner/FormLinerCollection.cs +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.cs @@ -28,7 +28,7 @@ public partial class FormLinerCollection : Form { panelCompanyTools.Enabled = false; } - private void buttonAddShip_Click(object sender, EventArgs e) + private void buttonAddLiner_Click(object sender, EventArgs e) { FormLinerConfig form = new(); // TODO передать метод @@ -253,5 +253,25 @@ public partial class FormLinerCollection : Form } } + private void buttonSortByType_Click(object sender, EventArgs e) + { + CompareLiner(new DrawningLinerCompareByType()); + } + + private void buttonSortByColor_Click(object sender, EventArgs e) + { + CompareLiner(new DrawningLinerCompareByColor()); + } + private void CompareLiner(IComparer comparer) + { + if (_company == null) + { + return; + } + _company.Sort(comparer); + pictureBox.Image = _company.Show(); + } + + }