EndOfLab08

This commit is contained in:
BroPlasmaNinja 2024-06-13 17:25:58 +04:00
parent 2f4ca8150c
commit 090d04ba0f
14 changed files with 480 additions and 329 deletions

View File

@ -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",

View File

@ -50,7 +50,7 @@ public abstract class AbstractCompany
/// <returns></returns>
public static int? operator +(AbstractCompany company, DrawningLiner ship)
{
return company._collection?.Insert(ship) ?? null;
return company._collection?.Insert(ship, new DrawiningLinerEqutables()) ?? null;
}
/// <summary>
/// Перегрузка оператора удаления для класса
@ -97,4 +97,10 @@ public abstract class AbstractCompany
/// Расстановка объектов
/// </summary>
protected abstract void SetObjectsPosition();
/// <summary>
/// Сортировка
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
public void Sort(IComparer<DrawningLiner?> comparer) => _collection?.CollectionSort(comparer);
}

View File

@ -0,0 +1,70 @@
using System.Text;
using System.Threading.Tasks;
namespace ProjectLiner.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

@ -18,14 +18,14 @@ public interface ICollectionGenericObjects<T> where T : class
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj);
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
/// </summary>
/// <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>
/// Удаление объекта из коллекции с конкретной позиции
/// </summary>
@ -49,4 +49,10 @@ T Remove(int position);
/// </summary>
/// <returns>Поэлементый вывод элементов коллекции</returns>
IEnumerable<T?> GetItems();
/// <summary>
/// Сортировка коллекции
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
void CollectionSort(IComparer<T?> comparer);
}

View File

@ -40,7 +40,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
if (position >= Count || position < 0) throw new Exceptions.PositionOutOfCollectionException();
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO вставка в конец набора
@ -48,7 +48,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
_collection.Add(obj);
return _collection.Count-1;//возможна проблема
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO проверка позиции
@ -74,4 +74,9 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
_collection.Sort(comparer);
}
}

View File

@ -54,7 +54,7 @@ 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 < Count; i++)
@ -68,7 +68,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
throw new CollectionOverflowException(Count);
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
{
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
if (_collection[position] == null)
@ -120,4 +120,9 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
Array.Sort(_collection, comparer);
}
}

View File

@ -1,20 +1,31 @@
using ProjectLiner.Drawnings;
using System.Text;
using ProjectLiner.Drawnings;
using ProjectLiner.Exceptions;
using System.Text;
namespace ProjectLiner.CollectionGenericObjects;
//хронилище коллекций
/// <typeparam name="T"></typeparam>
public class StorageCollection<T>
where T : DrawningLiner
{
/// <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>
/// Конструктор
/// </summary>
public StorageCollection()
{
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
}
/// <summary>
/// Ключевое слово, с которого должен начинаться файл
/// </summary>
@ -23,17 +34,12 @@ public class StorageCollection<T>
/// Разделитель для записи ключа и значения элемента словаря
/// </summary>
private readonly string _separatorForKeyValue = "|";
/// <summary>
/// Разделитель для записей коллекции данных в файл
/// </summary>
private readonly string _separatorItems = ";";
/// <summary>
/// Конструктор
/// </summary>
public StorageCollection()
{
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
}
/// <summary>
/// Добавление коллекции в хранилище
/// </summary>
@ -43,19 +49,13 @@ public class StorageCollection<T>
{
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
// TODO Прописать логику для добавления
if (_storages.ContainsKey(name)) return;
switch (collectionType)
{
case CollectionType.None:
return;
case CollectionType.List:
_storages[name] = new ListGenericObjects<T>();
break;
case CollectionType.Massive:
_storages[name] = new MassiveGenericObjects<T>();
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<T>();
else if (collectionType == CollectionType.List)
_storages[collectionInfo] = new ListGenericObjects<T>();
}
/// <summary>
/// Удаление коллекции
@ -63,34 +63,31 @@ public class StorageCollection<T>
/// <param name="name">Название коллекции</param>
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);
}
/// <summary>
/// Доступ к коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
/// <returns></returns>
public ICollectionGenericObjects<T>? this[string name]
public ICollectionGenericObjects<T> 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;
}
}
/// <summary>
/// Сохранение информации по автомобилям в хранилище в файл
/// </summary>
/// <param name="filename">Путь и имя файла</param>
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
public bool SaveData(string filename)
public void SaveData(string filename)
{
if (_storages.Count == 0)
{
@ -100,21 +97,19 @@ public bool SaveData(string filename)
{
File.Delete(filename);
}
StringBuilder sb = new();
sb.Append(_collectionKey);
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in
_storages)
using (StreamWriter writer = new StreamWriter(filename))
{
writer.Write(_collectionKey);
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
{
StringBuilder sb = new();
sb.Append(Environment.NewLine);
// не сохраняем пустые коллекции
if (value.Value.Count == 0)
{
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())
@ -127,70 +122,59 @@ public bool SaveData(string filename)
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;
}
}
/// <summary>
/// Загрузка информации по автомобилям в хранилище из файла
/// </summary>
/// <param name="filename">Путь и имя файла</param>
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
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)
{
bufferTextFromFile += temp.GetString(b);
}
}
string[] strs = bufferTextFromFile.Split(new char[] { '\n', '\r' },
StringSplitOptions.RemoveEmptyEntries);
if (strs == null || strs.Length == 0)
string str = fs.ReadLine();
if (str == null || str.Length == 0)
{
throw new Exception("В файле нет данных");
}
if (!strs[0].Equals(_collectionKey))
if (!str.StartsWith(_collectionKey))
{
throw new Exception("В файле неверные данные");
}
_storages.Clear();
foreach (string data in strs)
string strs = "";
while ((strs = fs.ReadLine()) != null)
{
string[] record = data.Split(_separatorForKeyValue,
StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 4)
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 3)
{
continue;
}
CollectionType collectionType =
(CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
ICollectionGenericObjects<T>? collection =
StorageCollection<T>.CreateCollection(collectionType)?? throw new Exception("Не удалось определить тип коллекции: " + record[1]);
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ?? throw new Exception("Не удалось определить информацию коллекции: " + record[0]);
collection.MaxCount = Convert.ToInt32(record[2]);
string[] set = record[3].Split(_separatorItems,
StringSplitOptions.RemoveEmptyEntries);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.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
{
try
{
collection.Insert(liner);
}catch
if (collection.Insert(liner) == -1)
{
throw new Exception("Объект не удалось добавить в коллекцию: " + record[3]);
}
@ -201,17 +185,18 @@ public bool SaveData(string filename)
}
}
}
_storages.Add(record[0], collection);
_storages.Add(collectionInfo, collection);
}
return true;
}
}
/// <summary>
/// Создание коллекции по типу
/// </summary>
/// <param name="collectionType"></param>
/// <returns></returns>
private static ICollectionGenericObjects<T>?
CreateCollection(CollectionType collectionType)
private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
{
return collectionType switch
{

View File

@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis;
namespace ProjectLiner.Drawnings;
public class DrawiningPlaneEqutables : IEqualityComparer<DrawningLiner?>
public class DrawiningLinerEqutables : IEqualityComparer<DrawningLiner?>
{
public bool Equals(DrawningLiner? x, DrawningLiner? y)
{

View File

@ -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;
}
}

View File

@ -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<DrawningLiner?> comparer)
{
if (_company == null)
{
return;
}
_company.Sort(comparer);
pictureBox.Image = _company.Show();
}
}