Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f990ff490f | |||
| 9a51457f08 |
@@ -38,8 +38,7 @@ public abstract class AbstractCompany
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вычисление максимального количества элементов, который можно разместить в окне
|
/// Вычисление максимального количества элементов, который можно разместить в окне
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int GetMaxCount => (_pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight)) -4 ;
|
private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@@ -52,7 +51,7 @@ public abstract class AbstractCompany
|
|||||||
_pictureWidth = picWidth;
|
_pictureWidth = picWidth;
|
||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_collection = collection;
|
_collection = collection;
|
||||||
_collection.MaxCount = GetMaxCount;
|
_collection.SetMaxCount = GetMaxCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -61,10 +60,11 @@ public abstract class AbstractCompany
|
|||||||
/// <param name="company">Компания</param>
|
/// <param name="company">Компания</param>
|
||||||
/// <param name="car">Добавляемый объект</param>
|
/// <param name="car">Добавляемый объект</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static int operator +(AbstractCompany company, DrawningTrackedCar trackedCar)
|
public static int operator +(AbstractCompany company, DrawningTrackedCar TrackedCar)
|
||||||
{
|
{
|
||||||
return company._collection.Insert(trackedCar, new DrawiningTrackedCarEqutables());
|
return company._collection.Insert(TrackedCar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора удаления для класса
|
/// Перегрузка оператора удаления для класса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -98,20 +98,14 @@ public abstract class AbstractCompany
|
|||||||
|
|
||||||
SetObjectsPosition();
|
SetObjectsPosition();
|
||||||
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
|
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
DrawningTrackedCar? obj = _collection?.Get(i);
|
DrawningTrackedCar? obj = _collection?.Get(i);
|
||||||
obj?.DrawTransport(graphics);
|
obj?.DrawTransport(graphics);
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод заднего фона
|
/// Вывод заднего фона
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -122,8 +116,4 @@ public abstract class AbstractCompany
|
|||||||
/// Расстановка объектов
|
/// Расстановка объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void SetObjectsPosition();
|
protected abstract void SetObjectsPosition();
|
||||||
/// </summary>
|
|
||||||
/// <param name="comparer">Сравнитель объектов</param>
|
|
||||||
public void Sort(IComparer<DrawningTrackedCar?> comparer) => _collection?.CollectionSort(comparer);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.CollectionGenericObjects;
|
|
||||||
|
|
||||||
public class CollectionInfo : IEquatable<CollectionInfo>
|
|
||||||
{
|
|
||||||
public string Name { get; private set; }
|
|
||||||
public CollectionType CollectionType { get; private set; }
|
|
||||||
public string Description { get; private set; }
|
|
||||||
private static readonly string _separator = "-";
|
|
||||||
public CollectionInfo(string name, CollectionType collectionType, string description)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
CollectionType = collectionType;
|
|
||||||
Description = description;
|
|
||||||
}
|
|
||||||
public static CollectionInfo? GetCollectionInfo(string data)
|
|
||||||
{
|
|
||||||
string[] strs = data.Split(_separator,
|
|
||||||
StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (strs.Length < 1 || strs.Length > 3)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new CollectionInfo(strs[0],
|
|
||||||
(CollectionType)Enum.Parse(typeof(CollectionType), strs[1]), strs.Length > 2 ?
|
|
||||||
strs[2] : string.Empty);
|
|
||||||
}
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return Name + _separator + CollectionType + _separator + Description;
|
|
||||||
}
|
|
||||||
public bool Equals(CollectionInfo? other)
|
|
||||||
{
|
|
||||||
return Name == other?.Name;
|
|
||||||
}
|
|
||||||
public override bool Equals(object? obj)
|
|
||||||
{
|
|
||||||
return Equals(obj as CollectionInfo);
|
|
||||||
}
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return Name.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,24 +14,22 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка максимального количества элементов
|
/// Установка максимального количества элементов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int MaxCount { get; set; }
|
int SetMaxCount { set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию
|
/// Добавление объекта в коллекцию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
/// <param name="obj">Добавляемый объект</param>
|
||||||
/// /// /// <param name="comparer">Cравнение двух объектов</param>
|
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
||||||
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
|
int Insert(T obj);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию на конкретную позицию
|
/// Добавление объекта в коллекцию на конкретную позицию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
/// <param name="obj">Добавляемый объект</param>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// /// <param name="comparer">Cравнение двух объектов</param>
|
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
||||||
int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null);
|
int Insert(T obj, int position);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из коллекции с конкретной позиции
|
/// Удаление объекта из коллекции с конкретной позиции
|
||||||
@@ -45,19 +43,5 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>Объект</returns>
|
/// <returns>Объект</returns>
|
||||||
T Get(int position);
|
T? Get(int position);
|
||||||
/// <summary>
|
|
||||||
/// Получение типа коллекции
|
|
||||||
/// </summary>
|
|
||||||
CollectionType GetCollectionType { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объектов коллекции по одному
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Поэлементый вывод элементов коллекции</returns>
|
|
||||||
IEnumerable<T?> GetItems();
|
|
||||||
/// Сортировка коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="comparer">Сравнитель объектов</param>
|
|
||||||
void CollectionSort(IComparer<T?> comparer);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
using ProjectByldozer.Exceptions;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.CollectionGenericObjects;
|
namespace ProjectByldozer.CollectionGenericObjects;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -20,21 +18,10 @@ public class ListGenericObjects<T>: ICollectionGenericObjects<T>
|
|||||||
/// Максимально допустимое число объектов в списке
|
/// Максимально допустимое число объектов в списке
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _maxCount;
|
private int _maxCount;
|
||||||
public CollectionType GetCollectionType => CollectionType.List;
|
|
||||||
|
|
||||||
public int Count => _collection.Count;
|
public int Count => _collection.Count;
|
||||||
|
|
||||||
public int MaxCount
|
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
||||||
{
|
|
||||||
get => _maxCount;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value > 0)
|
|
||||||
{
|
|
||||||
_maxCount = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@@ -46,36 +33,27 @@ public class ListGenericObjects<T>: ICollectionGenericObjects<T>
|
|||||||
|
|
||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
//TODO выброс ошибки если выход за границу
|
// TODO проверка позиции
|
||||||
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
if (position >= Count || position < 0) return null;
|
||||||
return _collection[position];
|
return _collection[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
|
public int Insert(T obj)
|
||||||
{
|
{
|
||||||
if (comparer != null)
|
// TODO проверка, что не превышено максимальное количество элементов
|
||||||
{
|
// TODO вставка в конец набора
|
||||||
if (_collection.Contains(obj, comparer))
|
if (Count == _maxCount) return -1;
|
||||||
{
|
|
||||||
throw new ObjectIsEqualException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Count == _maxCount) throw new CollectionOverflowException(Count);
|
|
||||||
_collection.Add(obj);
|
_collection.Add(obj);
|
||||||
return Count;
|
return Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
|
public int Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
if (comparer != null)
|
// TODO проверка, что не превышено максимальное количество элементов
|
||||||
{
|
// TODO проверка позиции
|
||||||
if (_collection.Contains(obj, comparer))
|
// TODO вставка по позиции
|
||||||
{
|
if (Count == _maxCount) return -1;
|
||||||
throw new ObjectIsEqualException();
|
if (position >= Count || position < 0) return -1;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Count == _maxCount) throw new CollectionOverflowException(Count);
|
|
||||||
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
|
||||||
_collection.Insert(position, obj);
|
_collection.Insert(position, obj);
|
||||||
return position;
|
return position;
|
||||||
|
|
||||||
@@ -83,26 +61,14 @@ public class ListGenericObjects<T>: ICollectionGenericObjects<T>
|
|||||||
|
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO если выброс за границу
|
// TODO проверка позиции
|
||||||
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
// TODO удаление объекта из списка
|
||||||
|
if (position >= Count || position < 0) return null;
|
||||||
T obj = _collection[position];
|
T obj = _collection[position];
|
||||||
_collection.RemoveAt(position);
|
_collection.RemoveAt(position);
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<T?> GetItems()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < Count; ++i)
|
|
||||||
{
|
|
||||||
yield return _collection[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ICollectionGenericObjects<T>.CollectionSort(IComparer<T?> comparer)
|
|
||||||
{
|
|
||||||
_collection.Sort(comparer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using ProjectByldozer.Drawnings;
|
namespace ProjectByldozer.CollectionGenericObjects;
|
||||||
using ProjectByldozer.Exceptions;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.CollectionGenericObjects;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Параметризованный набор объектов
|
/// Параметризованный набор объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -13,16 +10,11 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
/// Массив объектов, которые храним
|
/// Массив объектов, которые храним
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private T?[] _collection;
|
private T?[] _collection;
|
||||||
public CollectionType GetCollectionType => CollectionType.Massive;
|
|
||||||
|
|
||||||
public int Count => _collection.Length;
|
public int Count => _collection.Length;
|
||||||
|
|
||||||
public int MaxCount
|
public int SetMaxCount
|
||||||
{
|
{
|
||||||
get
|
|
||||||
{
|
|
||||||
return _collection.Length;
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value > 0)
|
if (value > 0)
|
||||||
@@ -39,7 +31,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -50,23 +41,15 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
|
|
||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
// TODO выброс ошибки если выход за границу
|
// TODO проверка позиции
|
||||||
// TODO выброс ошибки если объект пустой
|
if (position >= _collection.Length || position < 0)
|
||||||
if (position >= _collection.Length || position < 0) throw new PositionOutOfCollectionException(position);
|
{ return null; }
|
||||||
if (_collection[position] == null) throw new ObjectNotFoundException(position);
|
|
||||||
return _collection[position];
|
return _collection[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
|
public int Insert(T obj)
|
||||||
{
|
{
|
||||||
if (comparer != null)
|
// TODO вставка в свободное место набора
|
||||||
{
|
|
||||||
foreach (T? item in _collection)
|
|
||||||
{
|
|
||||||
if ((comparer as IEqualityComparer<DrawningTrackedCar>).Equals(obj as DrawningTrackedCar, item as DrawningTrackedCar))
|
|
||||||
throw new ObjectIsEqualException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (index < _collection.Length)
|
while (index < _collection.Length)
|
||||||
{
|
{
|
||||||
@@ -75,70 +58,57 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection[index] = obj;
|
_collection[index] = obj;
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
++index;
|
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
throw new CollectionOverflowException(Count);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
|
public int Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
if (comparer != null)
|
// TODO проверка позиции
|
||||||
{
|
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||||
foreach (T? item in _collection)
|
// ищется свободное место после этой позиции и идет вставка туда
|
||||||
{
|
// если нет после, ищем до
|
||||||
if ((comparer as IEqualityComparer<DrawningTrackedCar>).Equals(obj as DrawningTrackedCar, item as DrawningTrackedCar))
|
// TODO вставка
|
||||||
throw new ObjectIsEqualException();
|
if (position >= _collection.Length || position < 0)
|
||||||
}
|
{ return -1; }
|
||||||
}
|
|
||||||
if (position >= _collection.Length || position < 0) throw new PositionOutOfCollectionException(position);
|
|
||||||
if (_collection[position] == null)
|
if (_collection[position] == null)
|
||||||
{
|
{
|
||||||
_collection[position] = obj;
|
_collection[position] = obj;
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
int index = position + 1;
|
int index;
|
||||||
while (index < _collection.Length)
|
|
||||||
|
for (index = position + 1; index < _collection.Length; ++index)
|
||||||
{
|
{
|
||||||
if (_collection[index] == null)
|
if (_collection[index] == null)
|
||||||
{
|
{
|
||||||
_collection[index] = obj;
|
_collection[position] = obj;
|
||||||
return index;
|
return position;
|
||||||
}
|
}
|
||||||
++index;
|
|
||||||
}
|
}
|
||||||
index = position - 1;
|
|
||||||
while (index >= 0)
|
for (index = position - 1; index >= 0; --index)
|
||||||
{
|
{
|
||||||
if (_collection[index] == null)
|
if (_collection[index] == null)
|
||||||
{
|
{
|
||||||
_collection[index] = obj;
|
_collection[position] = obj;
|
||||||
return index;
|
return position;
|
||||||
}
|
}
|
||||||
--index;
|
|
||||||
}
|
}
|
||||||
throw new CollectionOverflowException(Count);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO выброс ошибки если выход за границу
|
// TODO проверка позиции
|
||||||
// TODO выброс ошибки если объект пустой
|
// TODO удаление объекта из массива, присвоив элементу массива значение null
|
||||||
if (position >= _collection.Length || position < 0) throw new PositionOutOfCollectionException(position);
|
if (position >= _collection.Length || position < 0)
|
||||||
if (_collection[position] == null) throw new ObjectNotFoundException(position);
|
{ return null; }
|
||||||
T obj = _collection[position];
|
T obj = _collection[position];
|
||||||
_collection[position] = null;
|
_collection[position] = null;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<T?> GetItems()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _collection.Length; ++i)
|
|
||||||
{
|
|
||||||
yield return _collection[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void ICollectionGenericObjects<T>.CollectionSort(IComparer<T?> comparer)
|
|
||||||
{
|
|
||||||
Array.Sort(_collection, comparer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,46 +1,29 @@
|
|||||||
|
|
||||||
|
|
||||||
using ProjectByldozer.Drawnings;
|
|
||||||
using ProjectByldozer.Exceptions;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.CollectionGenericObjects;
|
namespace ProjectByldozer.CollectionGenericObjects;
|
||||||
|
|
||||||
// Класс-хранилище коллекций
|
// Класс-хранилище коллекций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public class StorageCollection<T>
|
public class StorageCollection<T>
|
||||||
where T : DrawningTrackedCar
|
where T : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Словарь (хранилище) с коллекциями
|
/// Словарь (хранилище) с коллекциями
|
||||||
/// </summary>
|
/// </summary>
|
||||||
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
|
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Возвращение списка названий коллекций
|
/// Возвращение списка названий коллекций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectionInfo> Keys => _storages.Keys.ToList();
|
public List<string> Keys => _storages.Keys.ToList();
|
||||||
/// <summary>
|
|
||||||
/// Ключевое слово, с которого должен начинаться файл
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _collectionKey = "CollectionsStorage";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записи ключа и значения элемента словаря
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _separatorForKeyValue = "|";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записей коллекции данных в файл
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _separatorItems = ";";
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public StorageCollection()
|
public StorageCollection()
|
||||||
{
|
{
|
||||||
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
|
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -50,13 +33,16 @@ public class StorageCollection<T>
|
|||||||
/// <param name="collectionType">тип коллекции</param>
|
/// <param name="collectionType">тип коллекции</param>
|
||||||
public void AddCollection(string name, CollectionType collectionType)
|
public void AddCollection(string name, CollectionType collectionType)
|
||||||
{
|
{
|
||||||
CollectionInfo collectionInfo = new CollectionInfo(name, collectionType, string.Empty);
|
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
||||||
if (_storages.ContainsKey(collectionInfo)) return;
|
// TODO Прописать логику для добавления
|
||||||
|
|
||||||
|
if (_storages.ContainsKey(name)) return;
|
||||||
|
|
||||||
if (collectionType == CollectionType.None) return;
|
if (collectionType == CollectionType.None) return;
|
||||||
else if (collectionType == CollectionType.Massive)
|
else if (collectionType == CollectionType.Massive)
|
||||||
_storages[collectionInfo] = new MassiveGenericObjects<T>();
|
_storages[name] = new MassiveGenericObjects<T>();
|
||||||
else if (collectionType == CollectionType.List)
|
else if (collectionType == CollectionType.List)
|
||||||
_storages[collectionInfo] = new ListGenericObjects<T>();
|
_storages[name] = new ListGenericObjects<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -65,9 +51,10 @@ public class StorageCollection<T>
|
|||||||
/// <param name="name">Название коллекции</param>
|
/// <param name="name">Название коллекции</param>
|
||||||
public void DelCollection(string name)
|
public void DelCollection(string name)
|
||||||
{
|
{
|
||||||
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
|
// TODO Прописать логику для удаления коллекции
|
||||||
if (_storages.ContainsKey(collectionInfo))
|
|
||||||
_storages.Remove(collectionInfo);
|
if (_storages.ContainsKey(name))
|
||||||
|
_storages.Remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -79,147 +66,10 @@ public class StorageCollection<T>
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
CollectionInfo collectionInfo = new CollectionInfo(name, CollectionType.None, string.Empty);
|
// TODO Продумать логику получения объекта
|
||||||
if (_storages.ContainsKey(collectionInfo))
|
if (_storages.ContainsKey(name))
|
||||||
return _storages[collectionInfo];
|
return _storages[name];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение информации по автомобилям в хранилище в файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение информации по автомобилям в хранилище в файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
|
||||||
public void SaveData(string filename)
|
|
||||||
{
|
|
||||||
if (_storages.Count == 0)
|
|
||||||
{
|
|
||||||
throw new Exception("В хранилище отсутствуют коллекции для сохранения");
|
|
||||||
}
|
}
|
||||||
if (File.Exists(filename))
|
|
||||||
{
|
|
||||||
File.Delete(filename);
|
|
||||||
}
|
|
||||||
using (StreamWriter writer = new StreamWriter(filename))
|
|
||||||
{
|
|
||||||
writer.Write(_collectionKey);
|
|
||||||
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
|
|
||||||
{
|
|
||||||
writer.Write(Environment.NewLine);
|
|
||||||
if (value.Value.Count == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
writer.Write(value.Key);
|
|
||||||
writer.Write(_separatorForKeyValue);
|
|
||||||
writer.Write(value.Value.MaxCount);
|
|
||||||
writer.Write(_separatorForKeyValue);
|
|
||||||
foreach (T? item in value.Value.GetItems())
|
|
||||||
{
|
|
||||||
string data = item?.GetDataForSave() ?? string.Empty;
|
|
||||||
if (string.IsNullOrEmpty(data))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
writer.Write(data);
|
|
||||||
writer.Write(_separatorItems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Загрузка информации по автомобилям в хранилище из файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
|
||||||
/// <summary>
|
|
||||||
/// Загрузка информации по автомобилям в хранилище из файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
|
||||||
public void LoadData(string filename)
|
|
||||||
{
|
|
||||||
if (!File.Exists(filename))
|
|
||||||
{
|
|
||||||
throw new Exception("Файл не существует");
|
|
||||||
}
|
|
||||||
using (StreamReader fs = File.OpenText(filename))
|
|
||||||
{
|
|
||||||
string str = fs.ReadLine();
|
|
||||||
if (str == null || str.Length == 0)
|
|
||||||
{
|
|
||||||
throw new Exception("В файле нет данных");
|
|
||||||
}
|
|
||||||
if (!str.StartsWith(_collectionKey))
|
|
||||||
{
|
|
||||||
throw new Exception("В файле неверные данные");
|
|
||||||
}
|
|
||||||
_storages.Clear();
|
|
||||||
string strs = "";
|
|
||||||
while ((strs = fs.ReadLine()) != null)
|
|
||||||
{
|
|
||||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (record.Length != 3)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ??
|
|
||||||
throw new Exception("Не удалось определить информацию коллекции: " + record[0]);
|
|
||||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionInfo.CollectionType) ??
|
|
||||||
throw new Exception("Не удалось создать коллекцию");
|
|
||||||
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?.CreateDrawningTrackedCar() is T ship)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (collection.Insert(ship) == -1)
|
|
||||||
{
|
|
||||||
throw new Exception("Объект не удалось добавить в коллекцию: " + record[3]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (CollectionOverflowException ex)
|
|
||||||
{
|
|
||||||
throw new Exception("Коллекция переполнена", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_storages.Add(collectionInfo, collection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание коллекции по типу
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collectionType"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
|
|
||||||
{
|
|
||||||
return collectionType switch
|
|
||||||
{
|
|
||||||
CollectionType.Massive => new MassiveGenericObjects<T>(),
|
|
||||||
CollectionType.List => new ListGenericObjects<T>(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
using ProjectByldozer.Drawnings;
|
using ProjectByldozer.Drawnings;
|
||||||
using ProjectByldozer.Exceptions;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.CollectionGenericObjects;
|
namespace ProjectByldozer.CollectionGenericObjects;
|
||||||
public class TrackedCarGarage : AbstractCompany
|
public class TrackedCarGarage : AbstractCompany
|
||||||
{
|
{
|
||||||
@@ -37,30 +35,29 @@ public class TrackedCarGarage : AbstractCompany
|
|||||||
int height = _pictureHeight / _placeSizeHeight;
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
|
|
||||||
int curWidth = width - 1;
|
int curWidth = width - 1;
|
||||||
int curHeight = 0;
|
int curHeight = height - 1;
|
||||||
|
|
||||||
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
||||||
{
|
{
|
||||||
try
|
if (_collection.Get(i) != null)
|
||||||
{
|
{
|
||||||
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
|
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
|
||||||
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 20, curHeight * _placeSizeHeight + 4);
|
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 20, curHeight * _placeSizeHeight + 2);
|
||||||
}
|
}
|
||||||
catch (ObjectNotFoundException) { }
|
|
||||||
catch (PositionOutOfCollectionException) { }
|
|
||||||
if (curWidth > 0)
|
if (curWidth > 0)
|
||||||
curWidth--;
|
curWidth--;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
curWidth = width - 1;
|
curWidth = width - 1;
|
||||||
curHeight++;
|
curHeight--;
|
||||||
}
|
}
|
||||||
if (curHeight > height)
|
|
||||||
|
if (curHeight < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
using ProjectByldozer.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.Drawnings;
|
|
||||||
|
|
||||||
public class DrawiningTrackedCarEqutables : IEqualityComparer<DrawningTrackedCar?>
|
|
||||||
{
|
|
||||||
public bool Equals(DrawningTrackedCar? x, DrawningTrackedCar? y)
|
|
||||||
{
|
|
||||||
if (x == null || x.EntityTrackedCar == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (y == null || y.EntityTrackedCar == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.GetType().Name != y.GetType().Name)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.EntityTrackedCar.Speed != y.EntityTrackedCar.Speed)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.EntityTrackedCar.Weight != y.EntityTrackedCar.Weight)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.EntityTrackedCar.BodyColor != y.EntityTrackedCar.BodyColor)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x is DrawningByldozer && y is DrawningByldozer)
|
|
||||||
{
|
|
||||||
EntityByldozer _x = (EntityByldozer)x.EntityTrackedCar;
|
|
||||||
EntityByldozer _y = (EntityByldozer)x.EntityTrackedCar;
|
|
||||||
if (_x.AdditionalColor != _y.AdditionalColor)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (_x.Dump != _y.Dump)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (_x.Bakingpowder != _y.Bakingpowder)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (_x.Pipe != _y.Pipe)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public int GetHashCode([DisallowNull] DrawningTrackedCar obj)
|
|
||||||
{
|
|
||||||
return obj.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,23 +22,6 @@ public class DrawningByldozer : DrawningTrackedCar
|
|||||||
{
|
{
|
||||||
EntityTrackedCar = new EntityByldozer(speed, weight, bodyColor, additionalColor, dump, bakingpowder, pipe);
|
EntityTrackedCar = new EntityByldozer(speed, weight, bodyColor, additionalColor, dump, bakingpowder, pipe);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Конструктор для
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed"></param>
|
|
||||||
/// <param name="weight"></param>
|
|
||||||
/// <param name="bodyColor"></param>
|
|
||||||
/// <param name="additionalColor"></param>
|
|
||||||
/// <param name="pin"></param>
|
|
||||||
/// <param name="rokets"></param>
|
|
||||||
/// <param name="symbolism"></param>
|
|
||||||
public DrawningByldozer(EntityTrackedCar entityTrackedCar)
|
|
||||||
{
|
|
||||||
if (entityTrackedCar != null)
|
|
||||||
{
|
|
||||||
EntityTrackedCar = entityTrackedCar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class DrawningTrackedCar
|
|||||||
/// Высота объекта
|
/// Высота объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int GetHeight => _drawningTrackedCarHeight;
|
public int GetHeight => _drawningTrackedCarHeight;
|
||||||
public DrawningTrackedCar()
|
private DrawningTrackedCar()
|
||||||
{
|
{
|
||||||
_pictureWidth = null;
|
_pictureWidth = null;
|
||||||
_pictureHeight = null;
|
_pictureHeight = null;
|
||||||
@@ -95,16 +95,7 @@ public class DrawningTrackedCar
|
|||||||
this._drawningTrackedCarWidth = _drawningShipWidth;
|
this._drawningTrackedCarWidth = _drawningShipWidth;
|
||||||
this._drawningTrackedCarHeight = _drawnShipHeight;
|
this._drawningTrackedCarHeight = _drawnShipHeight;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Конструктор для Drawning
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed"></param>
|
|
||||||
/// <param name="weight"></param>
|
|
||||||
/// <param name="bodyColor"></param>
|
|
||||||
public DrawningTrackedCar(EntityTrackedCar entityTrackedCar)
|
|
||||||
{
|
|
||||||
EntityTrackedCar = entityTrackedCar;
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка границ поля
|
/// Установка границ поля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.Drawnings
|
|
||||||
{
|
|
||||||
public class DrawningTrackedCarCompareByColor : IComparer<DrawningTrackedCar?>
|
|
||||||
{
|
|
||||||
public int Compare(DrawningTrackedCar? x, DrawningTrackedCar? y)
|
|
||||||
{
|
|
||||||
if (x == null || x.EntityTrackedCar == null)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y == null || y.EntityTrackedCar == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
var bodycolorCompare = x.EntityTrackedCar.BodyColor.Name.CompareTo(y.EntityTrackedCar.BodyColor.Name);
|
|
||||||
if (bodycolorCompare != 0)
|
|
||||||
{
|
|
||||||
return bodycolorCompare;
|
|
||||||
}
|
|
||||||
var speedCompare = x.EntityTrackedCar.Speed.CompareTo(y.EntityTrackedCar.Speed);
|
|
||||||
if (speedCompare != 0)
|
|
||||||
{
|
|
||||||
return speedCompare;
|
|
||||||
}
|
|
||||||
return x.EntityTrackedCar.Weight.CompareTo(y.EntityTrackedCar.Weight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.Drawnings
|
|
||||||
{
|
|
||||||
public class DrawningTrackedCarCompareByType : IComparer<DrawningTrackedCar?>
|
|
||||||
{
|
|
||||||
public int Compare(DrawningTrackedCar? x, DrawningTrackedCar? y)
|
|
||||||
{
|
|
||||||
if (x == null || x.EntityTrackedCar == null)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y == null || y.EntityTrackedCar == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x.GetType().Name != y.GetType().Name)
|
|
||||||
{
|
|
||||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
var speedCompare = x.EntityTrackedCar.Speed.CompareTo(y.EntityTrackedCar.Speed);
|
|
||||||
if (speedCompare != 0)
|
|
||||||
{
|
|
||||||
return speedCompare;
|
|
||||||
}
|
|
||||||
return x.EntityTrackedCar.Weight.CompareTo(y.EntityTrackedCar.Weight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ProjectByldozer.Entities;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.Drawnings;
|
|
||||||
|
|
||||||
public static class ExtensionDrawningTrackedCar
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записи информации по объекту в файл
|
|
||||||
/// </summary>
|
|
||||||
private static readonly string _separatorForObject = ":";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из строки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info">Строка с данными для создания объекта</param>
|
|
||||||
/// <returns>Объект</returns>
|
|
||||||
public static DrawningTrackedCar? CreateDrawningTrackedCar(this string info)
|
|
||||||
{
|
|
||||||
string[] strs = info.Split(_separatorForObject);
|
|
||||||
EntityTrackedCar? Trackedcar = EntityByldozer.CreateEntityByldozer(strs);
|
|
||||||
if (Trackedcar != null)
|
|
||||||
{
|
|
||||||
return new DrawningByldozer(Trackedcar);
|
|
||||||
}
|
|
||||||
|
|
||||||
Trackedcar = EntityTrackedCar.CreateEntityTrackedCar(strs);
|
|
||||||
if (Trackedcar != null)
|
|
||||||
{
|
|
||||||
return new DrawningTrackedCar(Trackedcar);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение данных для сохранения в файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="drawningCar">Сохраняемый объект</param>
|
|
||||||
/// <returns>Строка с данными по объекту</returns>
|
|
||||||
public static string GetDataForSave(this DrawningTrackedCar drawningTrackedCar)
|
|
||||||
{
|
|
||||||
string[]? array = drawningTrackedCar?.EntityTrackedCar?.GetStringRepresentation();
|
|
||||||
|
|
||||||
if (array == null)
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Join(_separatorForObject, array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -52,28 +52,4 @@ public class EntityByldozer : EntityTrackedCar
|
|||||||
Bakingpowder = bakingpowder;
|
Bakingpowder = bakingpowder;
|
||||||
Pipe = pipe;
|
Pipe = pipe;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Получение строк со значениями свойств объекта класса-сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override string[] GetStringRepresentation()
|
|
||||||
{
|
|
||||||
return new[] { nameof(EntityByldozer), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name,
|
|
||||||
Dump.ToString(), Bakingpowder.ToString(), Pipe.ToString() };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из массива строк
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="strs"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static EntityByldozer? CreateEntityByldozer(string[] strs)
|
|
||||||
{
|
|
||||||
if (strs.Length != 8 || strs[0] != nameof(EntityByldozer))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new EntityByldozer(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]),
|
|
||||||
Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]), Convert.ToBoolean(strs[7]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -43,30 +43,5 @@ public class EntityTrackedCar
|
|||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
|
|
||||||
}
|
}
|
||||||
//TODO Прописать метод
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение строк со значениями свойств объекта класса-сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public virtual string[] GetStringRepresentation()
|
|
||||||
{
|
|
||||||
return new[] { nameof(EntityTrackedCar), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из массива строк
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="strs"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static EntityTrackedCar? CreateEntityTrackedCar(string[] strs)
|
|
||||||
{
|
|
||||||
if (strs.Length != 4 || strs[0] != nameof(EntityTrackedCar))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EntityTrackedCar(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.Exceptions;
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, описывающий ошибку переполнения коллекции
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class CollectionOverflowException: ApplicationException
|
|
||||||
{
|
|
||||||
|
|
||||||
public CollectionOverflowException(int count) : base("В коллекции превышено допустимое количество: " + count) { }
|
|
||||||
public CollectionOverflowException() : base() { }
|
|
||||||
public CollectionOverflowException(string message) : base(message) { }
|
|
||||||
public CollectionOverflowException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected CollectionOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.Exceptions;
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, описывающий ошибку переполнения коллекции
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class ObjectIsEqualException : ApplicationException
|
|
||||||
{
|
|
||||||
public ObjectIsEqualException(int count) : base("В коллекции содержится равный элемент: " + count) { }
|
|
||||||
public ObjectIsEqualException() : base() { }
|
|
||||||
public ObjectIsEqualException(string message) : base(message) { }
|
|
||||||
public ObjectIsEqualException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected ObjectIsEqualException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace ProjectByldozer.Exceptions;
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, описывающий ошибку, что по указанной позиции нет элемента
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class ObjectNotFoundException : ApplicationException
|
|
||||||
{
|
|
||||||
public ObjectNotFoundException(int i) : base("Не найден объект по позиции " + i) { }
|
|
||||||
public ObjectNotFoundException() : base() { }
|
|
||||||
public ObjectNotFoundException(string message) : base(message) { }
|
|
||||||
public ObjectNotFoundException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected ObjectNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
|
|
||||||
namespace ProjectByldozer.Exceptions;
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, описывающий ошибку выхода за границы коллекции
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class PositionOutOfCollectionException : ApplicationException
|
|
||||||
{
|
|
||||||
|
|
||||||
public PositionOutOfCollectionException(int i) : base("Выход за границы коллекции.Позиция " + i) { }
|
|
||||||
public PositionOutOfCollectionException() : base() { }
|
|
||||||
public PositionOutOfCollectionException(string message) : base(message) { }
|
|
||||||
public PositionOutOfCollectionException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected PositionOutOfCollectionException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
}
|
|
||||||
@@ -29,12 +29,6 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
panelCompanyTools = new Panel();
|
|
||||||
buttonAddTrackedCar = new Button();
|
|
||||||
buttonRefresh = new Button();
|
|
||||||
buttonGoToCheck = new Button();
|
|
||||||
maskedTextBox = new MaskedTextBox();
|
|
||||||
buttonDelCar = new Button();
|
|
||||||
comboBoxSelectionCompany = new ComboBox();
|
comboBoxSelectionCompany = new ComboBox();
|
||||||
buttonCreateCompany = new Button();
|
buttonCreateCompany = new Button();
|
||||||
panelStorage = new Panel();
|
panelStorage = new Panel();
|
||||||
@@ -45,111 +39,39 @@
|
|||||||
radioButtonMassiv = new RadioButton();
|
radioButtonMassiv = new RadioButton();
|
||||||
textBoxCollectionName = new TextBox();
|
textBoxCollectionName = new TextBox();
|
||||||
labelCollectionName = new Label();
|
labelCollectionName = new Label();
|
||||||
|
buttonRefresh = new Button();
|
||||||
|
buttonGoToCheck = new Button();
|
||||||
|
buttonDelCar = new Button();
|
||||||
|
maskedTextBox = new MaskedTextBox();
|
||||||
|
buttonAddTrackedCar = new Button();
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
menuStrip = new MenuStrip();
|
panelCompanyTools = new Panel();
|
||||||
файлToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
saveToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
loadToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
openFileDialog = new OpenFileDialog();
|
|
||||||
saveFileDialog = new SaveFileDialog();
|
|
||||||
buttonSortByColor = new Button();
|
|
||||||
buttonSortByType = new Button();
|
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
panelCompanyTools.SuspendLayout();
|
|
||||||
panelStorage.SuspendLayout();
|
panelStorage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
menuStrip.SuspendLayout();
|
panelCompanyTools.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
groupBoxTools.Controls.Add(panelCompanyTools);
|
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectionCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectionCompany);
|
||||||
groupBoxTools.Controls.Add(buttonCreateCompany);
|
groupBoxTools.Controls.Add(buttonCreateCompany);
|
||||||
groupBoxTools.Controls.Add(panelStorage);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(778, 24);
|
groupBoxTools.Location = new Point(778, 0);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(209, 494);
|
groupBoxTools.Size = new Size(209, 501);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// panelCompanyTools
|
|
||||||
//
|
|
||||||
panelCompanyTools.Controls.Add(buttonSortByColor);
|
|
||||||
panelCompanyTools.Controls.Add(buttonAddTrackedCar);
|
|
||||||
panelCompanyTools.Controls.Add(buttonSortByType);
|
|
||||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
|
||||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
|
||||||
panelCompanyTools.Controls.Add(maskedTextBox);
|
|
||||||
panelCompanyTools.Controls.Add(buttonDelCar);
|
|
||||||
panelCompanyTools.Enabled = false;
|
|
||||||
panelCompanyTools.Location = new Point(3, 264);
|
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
|
||||||
panelCompanyTools.Size = new Size(208, 230);
|
|
||||||
panelCompanyTools.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// buttonAddTrackedCar
|
|
||||||
//
|
|
||||||
buttonAddTrackedCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonAddTrackedCar.Location = new Point(3, 17);
|
|
||||||
buttonAddTrackedCar.Name = "buttonAddTrackedCar";
|
|
||||||
buttonAddTrackedCar.Size = new Size(205, 31);
|
|
||||||
buttonAddTrackedCar.TabIndex = 1;
|
|
||||||
buttonAddTrackedCar.Text = "Добавление машины";
|
|
||||||
buttonAddTrackedCar.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddTrackedCar.Click += ButtonAddTrackedCar_Click;
|
|
||||||
//
|
|
||||||
// buttonRefresh
|
|
||||||
//
|
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonRefresh.Location = new Point(2, 144);
|
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
|
||||||
buttonRefresh.Size = new Size(208, 25);
|
|
||||||
buttonRefresh.TabIndex = 6;
|
|
||||||
buttonRefresh.Text = "Обновить";
|
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
|
||||||
buttonRefresh.Click += ButtonRefresh_Click;
|
|
||||||
//
|
|
||||||
// buttonGoToCheck
|
|
||||||
//
|
|
||||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonGoToCheck.Location = new Point(3, 112);
|
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
|
||||||
buttonGoToCheck.Size = new Size(205, 26);
|
|
||||||
buttonGoToCheck.TabIndex = 5;
|
|
||||||
buttonGoToCheck.Text = "Передать на тесты";
|
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
|
||||||
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBox
|
|
||||||
//
|
|
||||||
maskedTextBox.Location = new Point(6, 54);
|
|
||||||
maskedTextBox.Mask = "00";
|
|
||||||
maskedTextBox.Name = "maskedTextBox";
|
|
||||||
maskedTextBox.Size = new Size(205, 23);
|
|
||||||
maskedTextBox.TabIndex = 3;
|
|
||||||
maskedTextBox.ValidatingType = typeof(int);
|
|
||||||
//
|
|
||||||
// buttonDelCar
|
|
||||||
//
|
|
||||||
buttonDelCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonDelCar.Location = new Point(3, 83);
|
|
||||||
buttonDelCar.Name = "buttonDelCar";
|
|
||||||
buttonDelCar.Size = new Size(205, 23);
|
|
||||||
buttonDelCar.TabIndex = 4;
|
|
||||||
buttonDelCar.Text = "Удаление машины";
|
|
||||||
buttonDelCar.UseVisualStyleBackColor = true;
|
|
||||||
buttonDelCar.Click += ButtonDelCar_Click;
|
|
||||||
//
|
|
||||||
// comboBoxSelectionCompany
|
// comboBoxSelectionCompany
|
||||||
//
|
//
|
||||||
comboBoxSelectionCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
comboBoxSelectionCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
comboBoxSelectionCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxSelectionCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxSelectionCompany.FormattingEnabled = true;
|
comboBoxSelectionCompany.FormattingEnabled = true;
|
||||||
comboBoxSelectionCompany.Items.AddRange(new object[] { "Хранилище" });
|
comboBoxSelectionCompany.Items.AddRange(new object[] { "Хранилище" });
|
||||||
comboBoxSelectionCompany.Location = new Point(5, 209);
|
comboBoxSelectionCompany.Location = new Point(3, 238);
|
||||||
comboBoxSelectionCompany.Name = "comboBoxSelectionCompany";
|
comboBoxSelectionCompany.Name = "comboBoxSelectionCompany";
|
||||||
comboBoxSelectionCompany.Size = new Size(203, 23);
|
comboBoxSelectionCompany.Size = new Size(203, 23);
|
||||||
comboBoxSelectionCompany.TabIndex = 0;
|
comboBoxSelectionCompany.TabIndex = 0;
|
||||||
@@ -157,7 +79,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCreateCompany
|
// buttonCreateCompany
|
||||||
//
|
//
|
||||||
buttonCreateCompany.Location = new Point(5, 238);
|
buttonCreateCompany.Location = new Point(3, 267);
|
||||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||||
buttonCreateCompany.Size = new Size(203, 20);
|
buttonCreateCompany.Size = new Size(203, 20);
|
||||||
buttonCreateCompany.TabIndex = 8;
|
buttonCreateCompany.TabIndex = 8;
|
||||||
@@ -177,12 +99,12 @@
|
|||||||
panelStorage.Dock = DockStyle.Top;
|
panelStorage.Dock = DockStyle.Top;
|
||||||
panelStorage.Location = new Point(3, 19);
|
panelStorage.Location = new Point(3, 19);
|
||||||
panelStorage.Name = "panelStorage";
|
panelStorage.Name = "panelStorage";
|
||||||
panelStorage.Size = new Size(203, 184);
|
panelStorage.Size = new Size(203, 214);
|
||||||
panelStorage.TabIndex = 7;
|
panelStorage.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// buttonCollectionDel
|
// buttonCollectionDel
|
||||||
//
|
//
|
||||||
buttonCollectionDel.Location = new Point(2, 152);
|
buttonCollectionDel.Location = new Point(3, 182);
|
||||||
buttonCollectionDel.Name = "buttonCollectionDel";
|
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||||
buttonCollectionDel.Size = new Size(191, 20);
|
buttonCollectionDel.Size = new Size(191, 20);
|
||||||
buttonCollectionDel.TabIndex = 6;
|
buttonCollectionDel.TabIndex = 6;
|
||||||
@@ -196,7 +118,7 @@
|
|||||||
listBoxCollection.ItemHeight = 15;
|
listBoxCollection.ItemHeight = 15;
|
||||||
listBoxCollection.Location = new Point(3, 112);
|
listBoxCollection.Location = new Point(3, 112);
|
||||||
listBoxCollection.Name = "listBoxCollection";
|
listBoxCollection.Name = "listBoxCollection";
|
||||||
listBoxCollection.Size = new Size(191, 34);
|
listBoxCollection.Size = new Size(191, 64);
|
||||||
listBoxCollection.TabIndex = 5;
|
listBoxCollection.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// buttonCjllecyionAdd
|
// buttonCjllecyionAdd
|
||||||
@@ -247,97 +169,98 @@
|
|||||||
labelCollectionName.TabIndex = 0;
|
labelCollectionName.TabIndex = 0;
|
||||||
labelCollectionName.Text = "Название коллекции";
|
labelCollectionName.Text = "Название коллекции";
|
||||||
//
|
//
|
||||||
|
// buttonRefresh
|
||||||
|
//
|
||||||
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonRefresh.Location = new Point(3, 181);
|
||||||
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
|
buttonRefresh.Size = new Size(208, 25);
|
||||||
|
buttonRefresh.TabIndex = 6;
|
||||||
|
buttonRefresh.Text = "Обновить";
|
||||||
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
|
buttonRefresh.Click += ButtonRefresh_Click;
|
||||||
|
//
|
||||||
|
// buttonGoToCheck
|
||||||
|
//
|
||||||
|
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonGoToCheck.Location = new Point(3, 149);
|
||||||
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
|
buttonGoToCheck.Size = new Size(205, 26);
|
||||||
|
buttonGoToCheck.TabIndex = 5;
|
||||||
|
buttonGoToCheck.Text = "Передать на тесты";
|
||||||
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
|
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
||||||
|
//
|
||||||
|
// buttonDelCar
|
||||||
|
//
|
||||||
|
buttonDelCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonDelCar.Location = new Point(3, 120);
|
||||||
|
buttonDelCar.Name = "buttonDelCar";
|
||||||
|
buttonDelCar.Size = new Size(205, 23);
|
||||||
|
buttonDelCar.TabIndex = 4;
|
||||||
|
buttonDelCar.Text = "Удаление машины";
|
||||||
|
buttonDelCar.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelCar.Click += ButtonDelCar_Click;
|
||||||
|
//
|
||||||
|
// maskedTextBox
|
||||||
|
//
|
||||||
|
maskedTextBox.Location = new Point(3, 91);
|
||||||
|
maskedTextBox.Mask = "00";
|
||||||
|
maskedTextBox.Name = "maskedTextBox";
|
||||||
|
maskedTextBox.Size = new Size(205, 23);
|
||||||
|
maskedTextBox.TabIndex = 3;
|
||||||
|
maskedTextBox.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// buttonAddTrackedCar
|
||||||
|
//
|
||||||
|
buttonAddTrackedCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonAddTrackedCar.Location = new Point(3, 17);
|
||||||
|
buttonAddTrackedCar.Name = "buttonAddTrackedCar";
|
||||||
|
buttonAddTrackedCar.Size = new Size(205, 31);
|
||||||
|
buttonAddTrackedCar.TabIndex = 1;
|
||||||
|
buttonAddTrackedCar.Text = "Добавление машины";
|
||||||
|
buttonAddTrackedCar.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddTrackedCar.Click += ButtonAddTrackedCar_Click;
|
||||||
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 24);
|
pictureBox.Location = new Point(0, 0);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(778, 494);
|
pictureBox.Size = new Size(778, 501);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
// menuStrip
|
// panelCompanyTools
|
||||||
//
|
//
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
panelCompanyTools.Controls.Add(buttonAddTrackedCar);
|
||||||
menuStrip.Location = new Point(0, 0);
|
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||||
menuStrip.Name = "menuStrip";
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
menuStrip.Size = new Size(987, 24);
|
panelCompanyTools.Controls.Add(maskedTextBox);
|
||||||
menuStrip.TabIndex = 10;
|
panelCompanyTools.Controls.Add(buttonDelCar);
|
||||||
menuStrip.Text = "menuStrip";
|
panelCompanyTools.Enabled = false;
|
||||||
//
|
panelCompanyTools.Location = new Point(776, 293);
|
||||||
// файлToolStripMenuItem
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
//
|
panelCompanyTools.Size = new Size(208, 208);
|
||||||
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
panelCompanyTools.TabIndex = 9;
|
||||||
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
|
||||||
файлToolStripMenuItem.Size = new Size(48, 20);
|
|
||||||
файлToolStripMenuItem.Text = "Файл";
|
|
||||||
//
|
|
||||||
// saveToolStripMenuItem
|
|
||||||
//
|
|
||||||
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
|
||||||
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
|
||||||
saveToolStripMenuItem.Size = new Size(181, 22);
|
|
||||||
saveToolStripMenuItem.Text = "Сохранение";
|
|
||||||
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// loadToolStripMenuItem
|
|
||||||
//
|
|
||||||
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
|
||||||
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
|
||||||
loadToolStripMenuItem.Size = new Size(181, 22);
|
|
||||||
loadToolStripMenuItem.Text = "Загрузка";
|
|
||||||
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// openFileDialog
|
|
||||||
//
|
|
||||||
openFileDialog.Filter = "txt file | *.txt";
|
|
||||||
//
|
|
||||||
// saveFileDialog
|
|
||||||
//
|
|
||||||
saveFileDialog.FileName = "txt file | *.txt";
|
|
||||||
//
|
|
||||||
// buttonSortByColor
|
|
||||||
//
|
|
||||||
buttonSortByColor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonSortByColor.Location = new Point(2, 202);
|
|
||||||
buttonSortByColor.Name = "buttonSortByColor";
|
|
||||||
buttonSortByColor.Size = new Size(208, 25);
|
|
||||||
buttonSortByColor.TabIndex = 11;
|
|
||||||
buttonSortByColor.Text = "Сортировка по цвету";
|
|
||||||
buttonSortByColor.UseVisualStyleBackColor = true;
|
|
||||||
buttonSortByColor.Click += ButtonSortByColor_Click;
|
|
||||||
//
|
|
||||||
// buttonSortByType
|
|
||||||
//
|
|
||||||
buttonSortByType.Location = new Point(2, 175);
|
|
||||||
buttonSortByType.Name = "buttonSortByType";
|
|
||||||
buttonSortByType.Size = new Size(203, 31);
|
|
||||||
buttonSortByType.TabIndex = 12;
|
|
||||||
buttonSortByType.Text = "Сортировка по типу";
|
|
||||||
buttonSortByType.UseVisualStyleBackColor = true;
|
|
||||||
buttonSortByType.Click += ButtonSortByType_Click;
|
|
||||||
//
|
//
|
||||||
// FormCarCollection
|
// FormCarCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(987, 518);
|
ClientSize = new Size(987, 501);
|
||||||
|
Controls.Add(panelCompanyTools);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Controls.Add(menuStrip);
|
|
||||||
MainMenuStrip = menuStrip;
|
|
||||||
Name = "FormCarCollection";
|
Name = "FormCarCollection";
|
||||||
Text = "коллекция бульдозеров";
|
Text = "коллекция бульдозеров";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
panelCompanyTools.ResumeLayout(false);
|
|
||||||
panelCompanyTools.PerformLayout();
|
|
||||||
panelStorage.ResumeLayout(false);
|
panelStorage.ResumeLayout(false);
|
||||||
panelStorage.PerformLayout();
|
panelStorage.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
menuStrip.ResumeLayout(false);
|
panelCompanyTools.ResumeLayout(false);
|
||||||
menuStrip.PerformLayout();
|
panelCompanyTools.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -360,13 +283,5 @@
|
|||||||
private Button buttonCreateCompany;
|
private Button buttonCreateCompany;
|
||||||
private Button buttonCollectionDel;
|
private Button buttonCollectionDel;
|
||||||
private Panel panelCompanyTools;
|
private Panel panelCompanyTools;
|
||||||
private MenuStrip menuStrip;
|
|
||||||
private ToolStripMenuItem файлToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem saveToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem loadToolStripMenuItem;
|
|
||||||
private OpenFileDialog openFileDialog;
|
|
||||||
private SaveFileDialog saveFileDialog;
|
|
||||||
private Button buttonSortByColor;
|
|
||||||
private Button buttonSortByType;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using ProjectByldozer.CollectionGenericObjects;
|
||||||
using ProjectByldozer.CollectionGenericObjects;
|
|
||||||
using ProjectByldozer.Drawnings;
|
using ProjectByldozer.Drawnings;
|
||||||
using ProjectByldozer.Exceptions;
|
|
||||||
|
|
||||||
namespace ProjectByldozer;
|
namespace ProjectByldozer;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -10,24 +9,23 @@ namespace ProjectByldozer;
|
|||||||
|
|
||||||
public partial class FormCarCollection : Form
|
public partial class FormCarCollection : Form
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Компания
|
|
||||||
/// </summary>
|
|
||||||
private AbstractCompany? _company = null;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Хранилище коллекций
|
/// Хранилище коллекций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly StorageCollection<DrawningTrackedCar> _storageCollection;
|
private readonly StorageCollection<DrawningTrackedCar> _storageCollection;
|
||||||
private readonly ILogger _logger;
|
/// <summary>
|
||||||
|
/// Компания
|
||||||
|
/// </summary>
|
||||||
|
private AbstractCompany? _company = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FormCarCollection(ILogger<FormCarCollection> logger)
|
public FormCarCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_storageCollection = new();
|
_storageCollection = new();
|
||||||
_logger = logger;
|
|
||||||
_logger.LogInformation("Форма загрузилась");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBoxSelectionCompany_SelectedIndexChanged(object sender, EventArgs e)
|
private void ComboBoxSelectionCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
@@ -35,14 +33,18 @@ public partial class FormCarCollection : Form
|
|||||||
panelCompanyTools.Enabled = false;
|
panelCompanyTools.Enabled = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// /// Добавление машины
|
/// /// Добавление машины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAddTrackedCar_Click(object sender, EventArgs e)
|
private void ButtonAddTrackedCar_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
FormCarConfig form = new();
|
FormCarConfig form = new();
|
||||||
// TODO передать метод
|
// TODO передать метод
|
||||||
|
|
||||||
form.Show();
|
form.Show();
|
||||||
form.AddEvent(SetTrackedCar);
|
form.AddEvent(SetTrackedCar);
|
||||||
|
|
||||||
@@ -52,36 +54,22 @@ public partial class FormCarCollection : Form
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name=" Trackedcar"></param>
|
/// <param name=" Trackedcar"></param>
|
||||||
private void SetTrackedCar(DrawningTrackedCar? Trackedcar)
|
private void SetTrackedCar(DrawningTrackedCar? Trackedcar)
|
||||||
{
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (_company == null || Trackedcar == null)
|
if (_company == null || Trackedcar == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_company + Trackedcar != -1)
|
if (_company + Trackedcar != -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
_logger.LogInformation("Добавлен объект: " + Trackedcar.GetDataForSave());
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
catch (ObjectNotFoundException) { }
|
|
||||||
catch (CollectionOverflowException ex)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
catch (ObjectIsEqualException ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void ButtonDelCar_Click(object sender, EventArgs e)
|
private void ButtonDelCar_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@@ -90,28 +78,22 @@ public partial class FormCarCollection : Form
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_company - pos != null)
|
if (_company - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
_logger.LogInformation("Удален объект по позиции " + pos);
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonGoToCheck_Click(object sender, EventArgs e)
|
private void ButtonGoToCheck_Click(object sender, EventArgs e)
|
||||||
@@ -123,8 +105,6 @@ public partial class FormCarCollection : Form
|
|||||||
|
|
||||||
DrawningTrackedCar? trackedcar = null;
|
DrawningTrackedCar? trackedcar = null;
|
||||||
int counter = 100;
|
int counter = 100;
|
||||||
try
|
|
||||||
{
|
|
||||||
while (trackedcar == null)
|
while (trackedcar == null)
|
||||||
{
|
{
|
||||||
trackedcar = _company.GetRandomObject();
|
trackedcar = _company.GetRandomObject();
|
||||||
@@ -134,16 +114,16 @@ public partial class FormCarCollection : Form
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trackedcar == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
FormByldozer form = new()
|
FormByldozer form = new()
|
||||||
{
|
{
|
||||||
SetTrackedCar = trackedcar
|
SetTrackedCar = trackedcar
|
||||||
};
|
};
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,8 +149,6 @@ public partial class FormCarCollection : Form
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
|
||||||
{
|
|
||||||
CollectionType collectionType = CollectionType.None;
|
CollectionType collectionType = CollectionType.None;
|
||||||
if (radioButtonMassiv.Checked)
|
if (radioButtonMassiv.Checked)
|
||||||
{
|
{
|
||||||
@@ -182,12 +160,6 @@ public partial class FormCarCollection : Form
|
|||||||
}
|
}
|
||||||
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
|
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
|
||||||
RerfreshListBoxItems();
|
RerfreshListBoxItems();
|
||||||
_logger.LogInformation("Коллекция добавлена " + textBoxCollectionName.Text);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RerfreshListBoxItems()
|
private void RerfreshListBoxItems()
|
||||||
@@ -195,7 +167,7 @@ public partial class FormCarCollection : 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].Name;
|
string? colName = _storageCollection.Keys?[i];
|
||||||
if (!string.IsNullOrEmpty(colName))
|
if (!string.IsNullOrEmpty(colName))
|
||||||
{
|
{
|
||||||
listBoxCollection.Items.Add(colName);
|
listBoxCollection.Items.Add(colName);
|
||||||
@@ -214,20 +186,12 @@ public partial class FormCarCollection : Form
|
|||||||
MessageBox.Show("Коллекция не выбрана");
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
||||||
RerfreshListBoxItems();
|
RerfreshListBoxItems();
|
||||||
_logger.LogInformation("Коллекция: " + listBoxCollection.SelectedItem.ToString() + " удалена");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -258,61 +222,5 @@ public partial class FormCarCollection : Form
|
|||||||
RerfreshListBoxItems();
|
RerfreshListBoxItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
|
|
||||||
{
|
|
||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_storageCollection.SaveData(saveFileDialog.FileName);
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
_logger.LogInformation("Сохранение в файл: {filename}", saveFileDialog.FileName);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_storageCollection.LoadData(openFileDialog.FileName);
|
|
||||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
RerfreshListBoxItems();
|
|
||||||
_logger.LogInformation("Загрузка из файла: {filename}", openFileDialog.FileName);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSortByType_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CompareTrackedaCar(new DrawningTrackedCarCompareByType());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSortByColor_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CompareTrackedaCar(new DrawningTrackedCarCompareByColor());
|
|
||||||
}
|
|
||||||
private void CompareTrackedaCar(IComparer<DrawningTrackedCar?> comparer)
|
|
||||||
{
|
|
||||||
if (_company == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_company.Sort(comparer);
|
|
||||||
pictureBox.Image = _company.Show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,16 +117,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 3</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>125, 3</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>265, 3</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>25</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
||||||
@@ -15,6 +15,7 @@ public partial class FormCarConfig : Form
|
|||||||
/// Событие для передачи объекта
|
/// Событие для передачи объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private event Action<DrawningTrackedCar>? TrackedCarDelegate;
|
private event Action<DrawningTrackedCar>? TrackedCarDelegate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// конструктор
|
/// конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -48,7 +49,7 @@ public partial class FormCarConfig : Form
|
|||||||
// TODO отправка цвета в Drag&Drop
|
// TODO отправка цвета в Drag&Drop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
||||||
|
|
||||||
|
|
||||||
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
|
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Serilog;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
|
|
||||||
namespace ProjectByldozer
|
namespace ProjectByldozer
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@@ -18,30 +12,7 @@ namespace ProjectByldozer
|
|||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
|
|
||||||
ServiceCollection services = new();
|
Application.Run(new FormCarCollection());
|
||||||
ConfigureServices(services);
|
|
||||||
using ServiceProvider serviceProvider = services.BuildServiceProvider();
|
|
||||||
Application.Run(serviceProvider.GetRequiredService<FormCarCollection>());
|
|
||||||
|
|
||||||
}
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
|
||||||
{
|
|
||||||
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
|
||||||
string pathNeed = "";
|
|
||||||
for (int i = 0; i < path.Length - 3; i++)
|
|
||||||
{
|
|
||||||
pathNeed += path[i] + "\\";
|
|
||||||
}
|
|
||||||
services.AddSingleton<FormCarCollection>()
|
|
||||||
.AddLogging(option =>
|
|
||||||
{
|
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
|
||||||
option.AddSerilog(new LoggerConfiguration()
|
|
||||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
|
||||||
.AddJsonFile($"{pathNeed}serilog.json")
|
|
||||||
.Build())
|
|
||||||
.CreateLogger());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,18 +8,6 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.10" />
|
|
||||||
<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>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
@@ -35,10 +23,4 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="serilog.json">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"Serilog": {
|
|
||||||
"Using": [ "Serilog.Sinks.File" ],
|
|
||||||
"MinimumLevel": "Debug",
|
|
||||||
"WriteTo": [
|
|
||||||
{
|
|
||||||
"Name": "File",
|
|
||||||
"Args": { "path": "log.log" }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"Properties": {
|
|
||||||
"Application": "Sample"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user