Лабораторная работа №8
This commit is contained in:
parent
eafedb0743
commit
ae3bdcd861
@ -0,0 +1,82 @@
|
|||||||
|
namespace ProjectBulldozer.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 bool IsEmpty()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Name) && CollectionType != CollectionType.None) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return Name.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
@ -19,12 +19,12 @@ internal class StorageCollection<T>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Словарь (хранилище) с коллекциями
|
/// Словарь (хранилище) с коллекциями
|
||||||
/// </summary>
|
/// </summary>
|
||||||
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Возвращение списка названий коллекций
|
/// Возвращение списка названий коллекций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> Keys => _storages.Keys.ToList();
|
public List<CollectionInfo> Keys => _storages.Keys.ToList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ключевое слово, с которого должен начинаться файл
|
/// Ключевое слово, с которого должен начинаться файл
|
||||||
@ -45,36 +45,36 @@ internal class StorageCollection<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public StorageCollection()
|
public StorageCollection()
|
||||||
{
|
{
|
||||||
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление коллекции в хранилище
|
/// Добавление коллекции в хранилище
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">Название коллекции</param>
|
/// <param name="collectionInfo">тип коллекции</param>
|
||||||
/// <param name="collectionType">тип коллекции</param>
|
public void AddCollection(CollectionInfo collectionInfo)
|
||||||
public void AddCollection(string name, CollectionType collectionType)
|
|
||||||
{
|
{
|
||||||
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
||||||
// TODO Прописать логику для добавления
|
// TODO Прописать логику для добавления
|
||||||
if (_storages.ContainsKey(name)) return;
|
if (_storages.ContainsKey(collectionInfo)) throw new CollectionAlreadyExistsException(collectionInfo);
|
||||||
if (collectionType == CollectionType.None) return;
|
if (collectionInfo.CollectionType == CollectionType.None)
|
||||||
else if (collectionType == CollectionType.Massive)
|
throw new CollectionTypeException("Пустой тип коллекции");
|
||||||
_storages[name] = new MassiveGenericObjects<T>();
|
if (collectionInfo.CollectionType == CollectionType.Massive)
|
||||||
else if (collectionType == CollectionType.List)
|
_storages[collectionInfo] = new MassiveGenericObjects<T>();
|
||||||
_storages[name] = new ListGenericObjects<T>();
|
else if (collectionInfo.CollectionType == CollectionType.List)
|
||||||
|
_storages[collectionInfo] = new ListGenericObjects<T>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление коллекции
|
/// Удаление коллекции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">Название коллекции</param>
|
/// <param name="collectionInfo">Название коллекции</param>
|
||||||
public void DelCollection(string name)
|
public void DelCollection(CollectionInfo collectionInfo)
|
||||||
{
|
{
|
||||||
// TODO Прописать логику для удаления коллекции
|
// TODO Прописать логику для удаления коллекции
|
||||||
if (_storages.ContainsKey(name))
|
if (_storages.ContainsKey(collectionInfo))
|
||||||
_storages.Remove(name);
|
_storages.Remove(collectionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -82,13 +82,13 @@ internal class StorageCollection<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">Название коллекции</param>
|
/// <param name="name">Название коллекции</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ICollectionGenericObjects<T>? this[string name]
|
public ICollectionGenericObjects<T>? this[CollectionInfo collectionInfo]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// TODO Продумать логику получения объекта
|
// TODO Продумать логику получения объекта
|
||||||
if (_storages.ContainsKey(name))
|
if (_storages.ContainsKey(collectionInfo))
|
||||||
return _storages[name];
|
return _storages[collectionInfo];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ internal class StorageCollection<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||||
public bool SaveData(string filename)
|
public void SaveData(string filename)
|
||||||
{
|
{
|
||||||
if (_storages.Count == 0)
|
if (_storages.Count == 0)
|
||||||
{
|
{
|
||||||
@ -113,7 +113,7 @@ internal class StorageCollection<T>
|
|||||||
using (StreamWriter writer = new StreamWriter(filename))
|
using (StreamWriter writer = new StreamWriter(filename))
|
||||||
{
|
{
|
||||||
writer.Write(_collectionKey);
|
writer.Write(_collectionKey);
|
||||||
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new();
|
StringBuilder sb = new();
|
||||||
sb.Append(Environment.NewLine);
|
sb.Append(Environment.NewLine);
|
||||||
@ -125,8 +125,6 @@ internal class StorageCollection<T>
|
|||||||
|
|
||||||
sb.Append(value.Key);
|
sb.Append(value.Key);
|
||||||
sb.Append(_separatorForKeyValue);
|
sb.Append(_separatorForKeyValue);
|
||||||
sb.Append(value.Value.GetCollectionType);
|
|
||||||
sb.Append(_separatorForKeyValue);
|
|
||||||
sb.Append(value.Value.MaxCount);
|
sb.Append(value.Value.MaxCount);
|
||||||
sb.Append(_separatorForKeyValue);
|
sb.Append(_separatorForKeyValue);
|
||||||
foreach (T? item in value.Value.GetItems())
|
foreach (T? item in value.Value.GetItems())
|
||||||
@ -144,8 +142,6 @@ internal class StorageCollection<T>
|
|||||||
writer.Write(sb);
|
writer.Write(sb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -153,68 +149,11 @@ internal class StorageCollection<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||||
public bool LoadData(string filename)
|
public void LoadData(string filename)
|
||||||
{
|
{
|
||||||
if (!File.Exists(filename))
|
if (!File.Exists(filename))
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (StreamReader fs = File.OpenText(filename))
|
|
||||||
{
|
|
||||||
string str = fs.ReadLine();
|
|
||||||
if (string.IsNullOrEmpty(str))
|
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException(filename);
|
throw new FileNotFoundException(filename);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!str.StartsWith(_collectionKey))
|
|
||||||
{
|
|
||||||
throw new FileFormatException(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
_storages.Clear();
|
|
||||||
string strs = "";
|
|
||||||
while ((strs = fs.ReadLine()) != null)
|
|
||||||
{
|
|
||||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (record.Length != 4)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
|
|
||||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
|
|
||||||
if (collection == null)
|
|
||||||
{
|
|
||||||
throw new CollectionTypeException("Не удалось определить тип коллекции:" + record[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
collection.MaxCount = Convert.ToInt32(record[2]);
|
|
||||||
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
foreach (string elem in set)
|
|
||||||
{
|
|
||||||
if (elem?.CreateDrawningMachine() is T ship)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
collection.Insert(ship);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
throw new FileFormatException(filename, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_storages.Add(record[0], collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!File.Exists(filename))
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using (StreamReader fs = File.OpenText(filename))
|
using (StreamReader fs = File.OpenText(filename))
|
||||||
@ -227,6 +166,7 @@ internal class StorageCollection<T>
|
|||||||
|
|
||||||
if (!str.StartsWith(_collectionKey))
|
if (!str.StartsWith(_collectionKey))
|
||||||
{
|
{
|
||||||
|
throw new FileFormatException(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
_storages.Clear();
|
_storages.Clear();
|
||||||
@ -234,41 +174,38 @@ internal class StorageCollection<T>
|
|||||||
while ((strs = fs.ReadLine()) != null)
|
while ((strs = fs.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (record.Length != 4)
|
if (record.Length != 3)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
|
CollectionInfo? collectionInfo =
|
||||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
|
CollectionInfo.GetCollectionInfo(record[0]) ??
|
||||||
if (collection == null)
|
throw new CollectionInfoException("Не удалось определить информацию коллекции:" + record[0]);
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
collection.MaxCount = Convert.ToInt32(record[2]);
|
ICollectionGenericObjects<T>? collection =
|
||||||
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
StorageCollection<T>.CreateCollection(collectionInfo.CollectionType) ??
|
||||||
|
throw new CollectionTypeException("Не удалось определить тип коллекции:" + record[1]);
|
||||||
|
collection.MaxCount = Convert.ToInt32(record[1]);
|
||||||
|
|
||||||
|
string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
||||||
foreach (string elem in set)
|
foreach (string elem in set)
|
||||||
{
|
{
|
||||||
if (elem?.CreateDrawningMachine() is T ship)
|
if (elem?.CreateDrawningMachine() is T macine)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (collection.Insert(ship) == -1)
|
collection.Insert(macine);
|
||||||
{
|
|
||||||
throw new CollectionTypeException("Объект не удалось добавить в коллекцию: " + record[3]);
|
|
||||||
}
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
catch (CollectionOverflowException ex)
|
|
||||||
{
|
{
|
||||||
throw ex.InnerException!;
|
throw new FileFormatException(filename, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_storages.Add(record[0], collection);
|
_storages.Add(collectionInfo, collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -276,7 +213,8 @@ internal class StorageCollection<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="collectionType"></param>
|
/// <param name="collectionType"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
|
private static ICollectionGenericObjects<T>?
|
||||||
|
CreateCollection(CollectionType collectionType)
|
||||||
{
|
{
|
||||||
return collectionType switch
|
return collectionType switch
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ProjectBulldozer.Drawnings;
|
namespace ProjectBulldozer.Drawnings;
|
||||||
|
|
||||||
internal class DrawingMachineCompareByColor : IComparer<DrawningTrackedMachine?>
|
internal class DrawningMachineCompareByColor : IComparer<DrawningTrackedMachine?>
|
||||||
{
|
{
|
||||||
public int Compare(DrawningTrackedMachine? x, DrawningTrackedMachine? y)
|
public int Compare(DrawningTrackedMachine? x, DrawningTrackedMachine? y)
|
||||||
{
|
{
|
@ -1,13 +1,15 @@
|
|||||||
using System.Runtime.Serialization;
|
using ProjectBulldozer.CollectionGenericObjects;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace ProjectBulldozer.Exceptions;
|
namespace ProjectBulldozer.Exceptions;
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class CollectionAlreadyExistsException : Exception
|
public class CollectionAlreadyExistsException : Exception
|
||||||
{
|
{
|
||||||
public CollectionAlreadyExistsException() : base() { }
|
public CollectionAlreadyExistsException() : base() { }
|
||||||
public CollectionAlreadyExistsException(string name) : base($"Коллекция {name} уже существует!") { }
|
public CollectionAlreadyExistsException(CollectionInfo collectionInfo) : base($"Коллекция {collectionInfo} уже существует!") { }
|
||||||
public CollectionAlreadyExistsException(string name, Exception exception) :
|
public CollectionAlreadyExistsException(string name, Exception exception) :
|
||||||
base($"Коллекция {name} уже существует!", exception) { }
|
base($"Коллекция {name} уже существует!", exception)
|
||||||
|
{ }
|
||||||
protected CollectionAlreadyExistsException(SerializationInfo info, StreamingContext
|
protected CollectionAlreadyExistsException(SerializationInfo info, StreamingContext
|
||||||
contex) : base(info, contex) { }
|
contex) : base(info, contex) { }
|
||||||
}
|
}
|
@ -30,6 +30,8 @@
|
|||||||
{
|
{
|
||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
panelCompanyTools = new Panel();
|
panelCompanyTools = new Panel();
|
||||||
|
buttonSortByColor = new Button();
|
||||||
|
buttonSortByType = new Button();
|
||||||
buttonAddMachine = new Button();
|
buttonAddMachine = new Button();
|
||||||
maskedTextBox = new MaskedTextBox();
|
maskedTextBox = new MaskedTextBox();
|
||||||
buttonRefresh = new Button();
|
buttonRefresh = new Button();
|
||||||
@ -68,13 +70,15 @@
|
|||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(749, 28);
|
groupBoxTools.Location = new Point(749, 28);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(231, 671);
|
groupBoxTools.Size = new Size(231, 694);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// panelCompanyTools
|
// panelCompanyTools
|
||||||
//
|
//
|
||||||
|
panelCompanyTools.Controls.Add(buttonSortByColor);
|
||||||
|
panelCompanyTools.Controls.Add(buttonSortByType);
|
||||||
panelCompanyTools.Controls.Add(buttonAddMachine);
|
panelCompanyTools.Controls.Add(buttonAddMachine);
|
||||||
panelCompanyTools.Controls.Add(maskedTextBox);
|
panelCompanyTools.Controls.Add(maskedTextBox);
|
||||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||||
@ -83,13 +87,33 @@
|
|||||||
panelCompanyTools.Enabled = false;
|
panelCompanyTools.Enabled = false;
|
||||||
panelCompanyTools.Location = new Point(3, 377);
|
panelCompanyTools.Location = new Point(3, 377);
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
panelCompanyTools.Size = new Size(225, 288);
|
panelCompanyTools.Size = new Size(225, 311);
|
||||||
panelCompanyTools.TabIndex = 9;
|
panelCompanyTools.TabIndex = 9;
|
||||||
//
|
//
|
||||||
|
// buttonSortByColor
|
||||||
|
//
|
||||||
|
buttonSortByColor.Location = new Point(3, 276);
|
||||||
|
buttonSortByColor.Name = "buttonSortByColor";
|
||||||
|
buttonSortByColor.Size = new Size(219, 29);
|
||||||
|
buttonSortByColor.TabIndex = 8;
|
||||||
|
buttonSortByColor.Text = "Сортировка по цвету";
|
||||||
|
buttonSortByColor.UseVisualStyleBackColor = true;
|
||||||
|
buttonSortByColor.Click += ButtonSortByColor_Click;
|
||||||
|
//
|
||||||
|
// buttonSortByType
|
||||||
|
//
|
||||||
|
buttonSortByType.Location = new Point(3, 241);
|
||||||
|
buttonSortByType.Name = "buttonSortByType";
|
||||||
|
buttonSortByType.Size = new Size(219, 29);
|
||||||
|
buttonSortByType.TabIndex = 7;
|
||||||
|
buttonSortByType.Text = "Сортировка по типу";
|
||||||
|
buttonSortByType.UseVisualStyleBackColor = true;
|
||||||
|
buttonSortByType.Click += ButtonSortByType_Click;
|
||||||
|
//
|
||||||
// buttonAddMachine
|
// buttonAddMachine
|
||||||
//
|
//
|
||||||
buttonAddMachine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonAddMachine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonAddMachine.Location = new Point(3, 28);
|
buttonAddMachine.Location = new Point(3, 4);
|
||||||
buttonAddMachine.Name = "buttonAddMachine";
|
buttonAddMachine.Name = "buttonAddMachine";
|
||||||
buttonAddMachine.Size = new Size(219, 49);
|
buttonAddMachine.Size = new Size(219, 49);
|
||||||
buttonAddMachine.TabIndex = 0;
|
buttonAddMachine.TabIndex = 0;
|
||||||
@ -100,7 +124,7 @@
|
|||||||
// maskedTextBox
|
// maskedTextBox
|
||||||
//
|
//
|
||||||
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
maskedTextBox.Location = new Point(3, 114);
|
maskedTextBox.Location = new Point(3, 77);
|
||||||
maskedTextBox.Mask = "00";
|
maskedTextBox.Mask = "00";
|
||||||
maskedTextBox.Name = "maskedTextBox";
|
maskedTextBox.Name = "maskedTextBox";
|
||||||
maskedTextBox.Size = new Size(219, 27);
|
maskedTextBox.Size = new Size(219, 27);
|
||||||
@ -110,7 +134,7 @@
|
|||||||
// buttonRefresh
|
// buttonRefresh
|
||||||
//
|
//
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRefresh.Location = new Point(3, 241);
|
buttonRefresh.Location = new Point(3, 194);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonRefresh.Size = new Size(219, 41);
|
buttonRefresh.Size = new Size(219, 41);
|
||||||
buttonRefresh.TabIndex = 6;
|
buttonRefresh.TabIndex = 6;
|
||||||
@ -121,9 +145,9 @@
|
|||||||
// buttonRemoveMachine
|
// buttonRemoveMachine
|
||||||
//
|
//
|
||||||
buttonRemoveMachine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRemoveMachine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRemoveMachine.Location = new Point(3, 147);
|
buttonRemoveMachine.Location = new Point(3, 110);
|
||||||
buttonRemoveMachine.Name = "buttonRemoveMachine";
|
buttonRemoveMachine.Name = "buttonRemoveMachine";
|
||||||
buttonRemoveMachine.Size = new Size(219, 41);
|
buttonRemoveMachine.Size = new Size(219, 31);
|
||||||
buttonRemoveMachine.TabIndex = 2;
|
buttonRemoveMachine.TabIndex = 2;
|
||||||
buttonRemoveMachine.Text = "Удалить машину";
|
buttonRemoveMachine.Text = "Удалить машину";
|
||||||
buttonRemoveMachine.UseVisualStyleBackColor = true;
|
buttonRemoveMachine.UseVisualStyleBackColor = true;
|
||||||
@ -132,9 +156,9 @@
|
|||||||
// buttonGoToCheck
|
// buttonGoToCheck
|
||||||
//
|
//
|
||||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonGoToCheck.Location = new Point(3, 194);
|
buttonGoToCheck.Location = new Point(3, 157);
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
buttonGoToCheck.Size = new Size(219, 41);
|
buttonGoToCheck.Size = new Size(219, 31);
|
||||||
buttonGoToCheck.TabIndex = 3;
|
buttonGoToCheck.TabIndex = 3;
|
||||||
buttonGoToCheck.Text = "Передать на тесты";
|
buttonGoToCheck.Text = "Передать на тесты";
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
@ -248,7 +272,7 @@
|
|||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 28);
|
pictureBox.Location = new Point(0, 28);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(749, 671);
|
pictureBox.Size = new Size(749, 694);
|
||||||
pictureBox.TabIndex = 5;
|
pictureBox.TabIndex = 5;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -297,7 +321,7 @@
|
|||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(980, 699);
|
ClientSize = new Size(980, 722);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Controls.Add(menuStrip);
|
Controls.Add(menuStrip);
|
||||||
@ -342,5 +366,7 @@
|
|||||||
private ToolStripMenuItem loadToolStripMenuItem;
|
private ToolStripMenuItem loadToolStripMenuItem;
|
||||||
private SaveFileDialog saveFileDialog;
|
private SaveFileDialog saveFileDialog;
|
||||||
private OpenFileDialog openFileDialog;
|
private OpenFileDialog openFileDialog;
|
||||||
|
private Button buttonSortByColor;
|
||||||
|
private Button buttonSortByType;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -205,7 +205,7 @@ public partial class FormMachineCollectoin : Form
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
|
_storageCollection.AddCollection(new CollectionInfo(textBoxCollectionName.Text, collectionType, "ХЗ"));
|
||||||
_logger.LogInformation("Добавление коллекции");
|
_logger.LogInformation("Добавление коллекции");
|
||||||
RerfreshListBoxItems();
|
RerfreshListBoxItems();
|
||||||
}
|
}
|
||||||
@ -236,7 +236,9 @@ public partial class FormMachineCollectoin : Form
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(listBoxCollection.SelectedItem.ToString()!);
|
||||||
|
_storageCollection.DelCollection(collectionInfo!);
|
||||||
|
_logger.LogInformation("Коллекция удалена");
|
||||||
RerfreshListBoxItems();
|
RerfreshListBoxItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,10 +250,10 @@ public partial class FormMachineCollectoin : Form
|
|||||||
listBoxCollection.Items.Clear();
|
listBoxCollection.Items.Clear();
|
||||||
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
||||||
{
|
{
|
||||||
string? colName = _storageCollection.Keys?[i];
|
CollectionInfo? col = _storageCollection.Keys?[i];
|
||||||
if (!string.IsNullOrEmpty(colName))
|
if (!col!.IsEmpty())
|
||||||
{
|
{
|
||||||
listBoxCollection.Items.Add(colName);
|
listBoxCollection.Items.Add(col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,7 +271,10 @@ public partial class FormMachineCollectoin : Form
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICollectionGenericObjects<DrawningTrackedMachine>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
ICollectionGenericObjects<DrawningTrackedMachine>? collection =
|
||||||
|
_storageCollection[
|
||||||
|
CollectionInfo.GetCollectionInfo(listBoxCollection.SelectedItem.ToString()!) ??
|
||||||
|
new CollectionInfo("", CollectionType.None, "")];
|
||||||
if (collection == null)
|
if (collection == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Коллекция не проинициализирована");
|
MessageBox.Show("Коллекция не проинициализирована");
|
||||||
@ -341,5 +346,40 @@ public partial class FormMachineCollectoin : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сортировка по типу
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonSortByType_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CompareCars(new DrawningMachineCompareByType());
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Сортировка по цвету
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonSortByColor_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CompareCars(new DrawningMachineCompareByColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сортировка по сравнителю
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="comparer">Сравнитель объектов</param>
|
||||||
|
private void CompareCars(IComparer<DrawningTrackedMachine?> comparer)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_company.Sort(comparer);
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,33 +8,6 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.4" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.4" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
|
||||||
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.1" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
|
|
||||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
|
|
||||||
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Settings.AppSettings" Version="2.2.2" />
|
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.Trace" Version="3.0.0" />
|
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
|
|
||||||
<PackageReference Include="System.Text.Json" Version="8.0.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
@ -43,6 +16,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
@ -51,9 +25,14 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="serilog.json">
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
</None>
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user