Compare commits

...

3 Commits

Author SHA1 Message Date
e317642dda s 2024-08-30 02:44:09 +04:00
18228eeafd в 2024-08-30 00:45:20 +04:00
acd1b0cce2 d 2024-08-29 23:55:05 +04:00
27 changed files with 980 additions and 298 deletions

View File

@ -1,4 +1,5 @@
using ProjectLocomotive.Drawnings;
using ProjectLocomotive.Exceptions;
namespace ProjectLocomotive.CollectionGenericObjects
{
@ -35,7 +36,7 @@ namespace ProjectLocomotive.CollectionGenericObjects
/// <summary>
/// Вычисление максимального количества элементов, который можно разместить в окне
/// </summary>
private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
private int GetMaxCount => (_pictureWidth / _placeSizeWidth) * (_pictureHeight / _placeSizeHeight);
/// <summary>
/// Конструктор
@ -56,11 +57,11 @@ namespace ProjectLocomotive.CollectionGenericObjects
/// Перегрузка оператора сложения для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="сruiser">Добавляемый объект</param>
/// <param name="locomotive">Добавляемый объект</param>
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningLocomotive сruiser)
public static int operator +(AbstractCompany company, DrawningLocomotive locomotive)
{
return company._collection.Insert(сruiser);
return company._collection.Insert(locomotive, new DrawiningLocomotiveEqutables());
}
/// <summary>
@ -96,11 +97,26 @@ namespace ProjectLocomotive.CollectionGenericObjects
SetObjectsPosition();
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
{
DrawningLocomotive? obj = _collection?.Get(i);
obj?.DrawTransport(graphics);
try
{
DrawningLocomotive? obj = _collection?.Get(i);
obj?.DrawTransport(graphics);
}
catch (ObjectNotFoundException e)
{ }
catch (PositionOutOfCollectionException e)
{ }
}
return bitmap;
}
/// <summary>
/// Сортировка
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
public void Sort(IComparer<DrawningLocomotive?> comparer) => _collection?.CollectionSort(comparer);
/// <summary>
/// Вывод заднего фона
/// </summary>

View File

@ -0,0 +1,75 @@
namespace ProjectLocomotive.CollectionGenericObjects;
public class CollectionInfo : IEquatable<CollectionInfo>
{
/// <summary>
/// Название
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Тип
/// </summary>
public CollectionType CollectionType { get; private set; }
/// <summary>
/// Описание
/// </summary>
public string Description { get; private set; }
/// <summary>
/// Разделитель для записи информации по объекту в файл
/// </summary>
private static readonly string _separator = "-";
/// <summary>
/// Конструктор
/// </summary>
/// <param name="name">Название</param>
/// <param name="collectionType">Тип</param>
/// <param name="description">Описание</param>
public CollectionInfo(string name, CollectionType collectionType, string
description)
{
Name = name;
CollectionType = collectionType;
Description = description;
}
/// <summary>
/// Создание объекта из строки
/// </summary>
/// <param name="data">Строка</param>
/// <returns>Объект или null</returns>
public static CollectionInfo? GetCollectionInfo(string data)
{
string[] strs = data.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
if (strs.Length < 1 || strs.Length > 3)
{
return null;
}
return new CollectionInfo(strs[0], (CollectionType)Enum.Parse(typeof(CollectionType), strs[1]), strs.Length > 2 ? strs[2] : string.Empty);
}
public override string ToString()
{
return Name + _separator + CollectionType + _separator + Description;
}
public bool Equals(CollectionInfo? other)
{
return Name == other?.Name;
}
public override bool Equals(object? obj)
{
return Equals(obj as CollectionInfo);
}
public override int GetHashCode()
{
return Name.GetHashCode();
}
}

View File

@ -1,4 +1,7 @@
namespace ProjectLocomotive.CollectionGenericObjects
using ProjectLocomotive.Drawnings;
using ProjectLocomotive.CollectionGenericObjects;
namespace ProjectLocomotive.CollectionGenericObjects
{
/// <summary>
/// Интерфейс описания действий для набора хранимых объектов
@ -11,29 +14,35 @@
/// Количество объектов в коллекции
/// </summary>
int Count { get; }
/// <summary>
/// Установка максимального количества элементов
/// </summary>
int MaxCount { get; set; }
/// <summary>
/// Добавление объекта в коллекцию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// /// <param name="comparer">Cравнение двух объектов</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj);
int Insert(T obj, IEqualityComparer<DrawningLocomotive?>? comparer = null);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <param name="position">Позиция</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj, int position);
int Insert(T obj, int position, IEqualityComparer<DrawningLocomotive?>? comparer = null);
/// <summary>
/// Удаление объекта из коллекции с конкретной позиции
/// </summary>
/// <param name="position">Позиция</param>
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
T? Remove(int position);
/// <summary>
/// Получение объекта по позиции
/// </summary>
@ -51,6 +60,12 @@
/// <returns>Поэлементый вывод элементов коллекции</returns>
IEnumerable<T?> GetItems();
/// <summary>
/// Сортировка коллекции
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
void CollectionSort(IComparer<T?> comparer);
}
}

View File

@ -1,4 +1,9 @@
namespace ProjectLocomotive.CollectionGenericObjects
using ProjectLocomotive.Drawnings;
using ProjectLocomotive.Exceptions;
using ProjectLocomotive.CollectionGenericObjects;
using ProjectLocomotive.Exceptions;
namespace ProjectLocomotive.CollectionGenericObjects
{
/// <summary>
/// Параметризованный набор объектов
@ -29,6 +34,7 @@
}
public CollectionType GetCollectionType => CollectionType.List;
/// <summary>
/// Конструктор
/// </summary>
@ -39,26 +45,43 @@
public T? Get(int position)
{
// TODO проверка позиции
if (position >= Count || position < 0) return null;
// TODO выброc позиций, если выход за границы массива
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<DrawningLocomotive?>? comparer = null)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO выбром позиций, если переполнение
// TODO выброc позиций, если такой объект есть в коллекции
// TODO вставка в конец набора
if (Count == _maxCount) return -1;
for (int i = 0; i < Count; i++)
{
if (comparer.Equals((_collection[i] as DrawningLocomotive), (obj as DrawningLocomotive))) throw new ObjectAlreadyInCollectionException(i);
}
if (Count == _maxCount) throw new CollectionOverflowException(Count);
_collection.Add(obj);
return Count;
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<DrawningLocomotive?>? comparer = null)
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO выброc позиций, если такой объект есть в коллекции
// TODO проверка позиции
// TODO вставка по позиции
if (Count == _maxCount) return -1;
if (position >= Count || position < 0) return -1;
for (int i = 0; i < Count; i++)
{
if (comparer.Equals((_collection[i] as DrawningLocomotive), (obj as DrawningLocomotive))) throw new ObjectAlreadyInCollectionException(i);
}
if (Count == _maxCount) throw new CollectionOverflowException(Count);
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
_collection.Insert(position, obj);
return position;
@ -67,12 +90,15 @@
public T Remove(int position)
{
// TODO проверка позиции
// TODO выбром позиций, если выход за границы массива
// TODO удаление объекта из списка
if (position >= Count || position < 0) return null;
if (position >= _collection.Count || position < 0) throw new PositionOutOfCollectionException(position);
T obj = _collection[position];
_collection.RemoveAt(position);
return obj;
}
public IEnumerable<T?> GetItems()
{
for (int i = 0; i < _collection.Count; ++i)
@ -80,5 +106,10 @@
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
_collection.Sort(comparer);
}
}
}

View File

@ -1,4 +1,5 @@
using ProjectLocomotive.Drawnings;
using ProjectLocomotive.Exceptions;
namespace ProjectLocomotive.CollectionGenericObjects
{
@ -41,13 +42,17 @@ namespace ProjectLocomotive.CollectionGenericObjects
for (int i = 0; i < (_collection?.Count ?? 0); i++)
{
if (_collection.Get(i) != null)
try
{
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 10, curHeight * _placeSizeHeight + 10);
}
catch (ObjectNotFoundException) { }
catch (PositionOutOfCollectionException e) { }
if (curWidth > width - 2)
if (curWidth > width - 3)
curWidth--;
else
{

View File

@ -1,5 +1,7 @@
using ProjectLocomotive.Drawnings;
using ProjectLocomotive.Exceptions;
using ProjectLocomotive.CollectionGenericObjects;
using ProjectLocomotive.Exceptions;
namespace ProjectLocomotive.CollectionGenericObjects
{
@ -49,74 +51,102 @@ namespace ProjectLocomotive.CollectionGenericObjects
public T? Get(int position)
{
// TODO проверка позиции
if (position >= _collection.Length || position < 0)
{ return null; }
// TODO выбром позиций, если выход за границы массива
// TODO выбром позиций, если объект пустой
if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position);
if (_collection[position] == null) throw new ObjectNotFoundException(position);
return _collection[position];
}
public int Insert(T obj)
public int Insert(T obj, IEqualityComparer<DrawningLocomotive?>? comparer = null)
{
// TODO вставка в свободное место набора
int index = 0;
while (index < _collection.Length)
// TODO выброc позиций, если переполнение
// TODO выброc позиций, если такой объект есть в коллекции
for (int i = 0; i < Count; i++)
{
if (_collection[index] == null)
{
_collection[index] = obj;
return index;
}
index++;
if (comparer.Equals((_collection[i] as DrawningLocomotive), (obj as DrawningLocomotive))) throw new ObjectAlreadyInCollectionException(i);
}
return -1;
for (int i = 0; i < Count; i++)
{
if (_collection[i] == null)
{
_collection[i] = obj;
return i;
}
}
throw new CollectionOverflowException(Count);
}
public int Insert(T obj, int position)
public int Insert(T obj, int position, IEqualityComparer<DrawningLocomotive?>? comparer = null)
{
// TODO выброc позиций, если такой объект есть в коллекции
// TODO проверка позиции
// TODO выбром позиций, если выход за границы массива
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
// ищется свободное место после этой позиции и идет вставка туда
// если нет после, ищем до
// TODO выбром позиций, если переполнение
// TODO вставка
if (position >= _collection.Length || position < 0)
{ return -1; }
if (_collection[position] == null)
for (int i = 0; i < Count; i++)
{
_collection[position] = obj;
return position;
if (comparer.Equals((_collection[i] as DrawningLocomotive), (obj as DrawningLocomotive))) throw new ObjectAlreadyInCollectionException(i);
}
int index;
for (index = position + 1; index < _collection.Length; ++index)
if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position);
if (_collection[position] != null)
{
if (_collection[index] == null)
bool pushed = false;
for (int index = position + 1; index < Count; index++)
{
_collection[position] = obj;
return position;
if (_collection[index] == null)
{
position = index;
pushed = true;
break;
}
}
if (!pushed)
{
for (int index = position - 1; index >= 0; index--)
{
if (_collection[index] == null)
{
position = index;
pushed = true;
break;
}
}
}
if (!pushed)
{
throw new CollectionOverflowException(Count);
}
}
for (index = position - 1; index >= 0; --index)
{
if (_collection[index] == null)
{
_collection[position] = obj;
return position;
}
}
return -1;
_collection[position] = obj;
return position;
}
public T Remove(int position)
{
// TODO проверка позиции
// TODO удаление объекта из массива, присвоив элементу массива значение null
if (position >= _collection.Length || position < 0)
{ return null; }
T obj = _collection[position];
// TODO выбром позиций, если выход за границы массива
// TODO выбром позиций, если объект пустой
if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position);
if (_collection[position] == null) throw new ObjectNotFoundException(position);
T? temp = _collection[position];
_collection[position] = null;
return obj;
return temp;
}
public IEnumerable<T?> GetItems()
@ -126,5 +156,10 @@ namespace ProjectLocomotive.CollectionGenericObjects
yield return _collection[i];
}
}
public void CollectionSort(IComparer<T?> comparer)
{
Array.Sort(_collection, comparer);
}
}
}

View File

@ -1,4 +1,7 @@
using ProjectLocomotive.Drawnings;
using ProjectLocomotive.Exceptions;
using ProjectLocomotive.CollectionGenericObjects;
using ProjectLocomotive.Exceptions;
using System.Text;
namespace ProjectLocomotive.CollectionGenericObjects
@ -12,12 +15,12 @@ namespace ProjectLocomotive.CollectionGenericObjects
/// <summary>
/// Словарь (хранилище) с коллекциями
/// </summary>
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
/// <summary>
/// Возвращение списка названий коллекций
/// </summary>
public List<string> Keys => _storages.Keys.ToList();
public List<CollectionInfo> Keys => _storages.Keys.ToList();
/// <summary>
/// Ключевое слово, с которого должен начинаться файл
@ -39,7 +42,7 @@ namespace ProjectLocomotive.CollectionGenericObjects
/// </summary>
public StorageCollection()
{
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
}
/// <summary>
@ -47,29 +50,40 @@ namespace ProjectLocomotive.CollectionGenericObjects
/// </summary>
/// <param name="name">Название коллекции</param>
/// <param name="collectionType">тип коллекции</param>
public void AddCollection(string name, CollectionType collectionType)
public void AddCollection(CollectionInfo name)
{
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
// TODO Прописать логику для добавления
if (_storages.ContainsKey(name)) return;
if (name == null || _storages.ContainsKey(name))
{
return;
}
if (collectionType == CollectionType.None) return;
else if (collectionType == CollectionType.Massive)
_storages[name] = new MassiveGenericObjects<T>();
else if (collectionType == CollectionType.List)
_storages[name] = new ListGenericObjects<T>();
if (name.CollectionType == CollectionType.Massive)
{
_storages.Add(name, new MassiveGenericObjects<T>());
}
if (name.CollectionType == CollectionType.List)
{
_storages.Add(name, new ListGenericObjects<T>());
}
}
/// <summary>
/// Удаление коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
public void DelCollection(string name)
public void DelCollection(CollectionInfo name)
{
// TODO Прописать логику для удаления коллекции
if (_storages.ContainsKey(name))
_storages.Remove(name);
if (name == null || !_storages.ContainsKey(name))
{
return;
}
_storages.Remove(name);
}
/// <summary>
@ -77,119 +91,128 @@ namespace ProjectLocomotive.CollectionGenericObjects
/// </summary>
/// <param name="name">Название коллекции</param>
/// <returns></returns>
public ICollectionGenericObjects<T>? this[string name]
public ICollectionGenericObjects<T>? this[CollectionInfo name]
{
get
{
// TODO Продумать логику получения объекта
if (_storages.ContainsKey(name))
{
return _storages[name];
}
return null;
}
}
/// <summary>
/// Сохранение информации по автомобилям в хранилище в файл
/// Сохранение информации по самолетам в хранилище в файл
/// </summary>
/// <param name="filename">Путь и имя файла</param>
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
public bool SaveData(string filename)
public void SaveData(string filename)
{
if (_storages.Count == 0)
{
return false;
throw new Exception("В хранилище отсутствуют коллекции для сохранения");
}
if (File.Exists(filename))
{
File.Delete(filename);
}
using (StreamWriter writer = new StreamWriter(filename))
using FileStream fs = new(filename, FileMode.Create);
using StreamWriter streamWriter = new StreamWriter(fs);
streamWriter.Write(_collectionKey);
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
{
writer.Write(_collectionKey);
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
streamWriter.Write(Environment.NewLine);
if (value.Value.Count == 0)
{
StringBuilder sb = new();
sb.Append(Environment.NewLine);
// не сохраняем пустые коллекции
if (value.Value.Count == 0)
continue;
}
streamWriter.Write(value.Key);
streamWriter.Write(_separatorForKeyValue);
streamWriter.Write(value.Value.MaxCount);
streamWriter.Write(_separatorForKeyValue);
foreach (T? item in value.Value.GetItems())
{
string data = item?.GetDataForSave() ?? string.Empty;
if (string.IsNullOrEmpty(data))
{
continue;
}
sb.Append(value.Key);
sb.Append(_separatorForKeyValue);
sb.Append(value.Value.GetCollectionType);
sb.Append(_separatorForKeyValue);
sb.Append(value.Value.MaxCount);
sb.Append(_separatorForKeyValue);
foreach (T? item in value.Value.GetItems())
{
string data = item?.GetDataForSave() ?? string.Empty;
if (string.IsNullOrEmpty(data))
{
continue;
}
sb.Append(data);
sb.Append(_separatorItems);
}
writer.Write(sb);
streamWriter.Write(data);
streamWriter.Write(_separatorItems);
}
}
return true;
}
/// <summary>
/// Загрузка информации по автомобилям в хранилище из файла
/// Загрузка информации по кораблям в хранилище из файла
/// </summary>
/// <param name="filename">Путь и имя файла</param>
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
public bool LoadData(string filename)
/// <param name="filename"></param>
public void LoadData(string filename)
{
if (!File.Exists(filename))
{
return false;
throw new FileNotFoundException("Файл не существует");
}
using (StreamReader fs = File.OpenText(filename))
using (StreamReader sr = new StreamReader(filename))
{
string str = fs.ReadLine();
if (str == null || str.Length == 0)
{
return false;
}
if (!str.StartsWith(_collectionKey))
{
return false;
}
string? str;
str = sr.ReadLine();
if (str != _collectionKey.ToString())
throw new FormatException("В файле неверные данные");
_storages.Clear();
string strs = "";
while ((strs = fs.ReadLine()) != null)
while ((str = sr.ReadLine()) != null)
{
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 4)
string[] record = str.Split(_separatorForKeyValue);
if (record.Length != 3)
{
continue;
}
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
if (collection == null)
{
return false;
}
collection.MaxCount = Convert.ToInt32(record[2]);
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
CollectionInfo? collectionInfo = CollectionInfo.GetCollectionInfo(record[0]) ??
throw new Exception("Не удалось определить информацию коллекции: " + record[0]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionInfo.CollectionType) ??
throw new Exception("Не удалось создать коллекцию");
collection.MaxCount = Convert.ToInt32(record[1]);
string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
if (elem?.CreateDrawningLocomotive() is T locomotive)
{
if (collection.Insert(locomotive) == -1)
try
{
return false;
if (collection.Insert(locomotive, new DrawiningLocomotiveEqutables()) == -1)
{
throw new InvalidOperationException("Объект не удалось добавить в коллекцию: " + record[3]);
}
}
catch (CollectionOverflowException ex)
{
throw new CollectionOverflowException("Коллекция переполнена", ex);
}
catch (ObjectAlreadyInCollectionException ex)
{
throw new InvalidOperationException("Объект уже присутствует в коллекции", ex);
}
}
}
_storages.Add(record[0], collection);
_storages.Add(collectionInfo, collection);
}
return true;
}
}

View File

@ -0,0 +1,54 @@
using System.Diagnostics.CodeAnalysis;
namespace ProjectLocomotive.Drawnings;
/// <summary>
/// Реализация сравнения двух объектов класса-прорисовки
/// </summary>
public class DrawiningLocomotiveEqutables : IEqualityComparer<DrawningLocomotive?>
{
public bool Equals(DrawningLocomotive? x, DrawningLocomotive? y)
{
if (x == null || x.EntityLocomotive == null)
{
return false;
}
if (y == null || y.EntityLocomotive == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityLocomotive.Speed != y.EntityLocomotive.Speed)
{
return false;
}
if (x.EntityLocomotive.Weight != y.EntityLocomotive.Weight)
{
return false;
}
if (x.EntityLocomotive.BodyColor != y.EntityLocomotive.BodyColor)
{
return false;
}
if (x is DrawningTLocomotive && y is DrawningTLocomotive)
{
// TODO доделать логику сравнения дополнительных параметров
}
return true;
}
public int GetHashCode([DisallowNull] DrawningLocomotive obj)
{
return obj.GetHashCode();
}
}

View File

@ -0,0 +1,34 @@
using ProjectLocomotive.Entities;
namespace ProjectLocomotive.Drawnings;
/// <summary>
/// Сравнение по цвету, скорости, весу
/// </summary>
public class DrawningLocomotiveCompareByColor : IComparer<DrawningLocomotive?>
{
public int Compare(DrawningLocomotive? x, DrawningLocomotive? y)
{
// TODO прописать логику сравения по цветам, скорости, весу
if (x == null || x.EntityLocomotive == null)
{
return 1;
}
if (y == null || y.EntityLocomotive == null)
{
return -1;
}
var bodycolorCompare = x.EntityLocomotive.BodyColor.Name.CompareTo(y.EntityLocomotive.BodyColor.Name);
if (bodycolorCompare != 0)
{
return bodycolorCompare;
}
var speedCompare = x.EntityLocomotive.Speed.CompareTo(y.EntityLocomotive.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityLocomotive.Weight.CompareTo(y.EntityLocomotive.Weight);
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive.Drawnings;
/// <summary>
/// Сравнение по типу, скорости, весу
/// </summary>
public class DrawningLocomotiveCompareByType : IComparer<DrawningLocomotive?>
{
public int Compare(DrawningLocomotive? x, DrawningLocomotive? y)
{
if (x == null || x.EntityLocomotive == null)
{
return 1;
}
if (y == null || y.EntityLocomotive == null)
{
return -1;
}
if (x.GetType().Name != y.GetType().Name)
{
return x.GetType().Name.CompareTo(y.GetType().Name);
}
var speedCompare = x.EntityLocomotive.Speed.CompareTo(y.EntityLocomotive.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityLocomotive.Weight.CompareTo(y.EntityLocomotive.Weight);
}
}

View File

@ -56,9 +56,11 @@ namespace ProjectLocomotive.Drawnings
Point[] points4 = { new Point(_startPosX.Value + 20, _startPosY.Value), new Point(_startPosX.Value + 30, _startPosY.Value), new Point(_startPosX.Value + 30, _startPosY.Value - 7), new Point(_startPosX.Value + 32, _startPosY.Value - 9), new Point(_startPosX.Value + 30, _startPosY.Value - 11), new Point(_startPosX.Value + 20, _startPosY.Value - 11), new Point(_startPosX.Value + 18, _startPosY.Value - 9), new Point(_startPosX.Value + 20, _startPosY.Value - 7), new Point(_startPosX.Value + 20, _startPosY.Value) };
g.FillPolygon(wheelBrush, points4);
if (entityTLocomotive.Pipe)
{
Point[] points4 = { new Point(_startPosX.Value + 20, _startPosY.Value), new Point(_startPosX.Value + 30, _startPosY.Value), new Point(_startPosX.Value + 30, _startPosY.Value - 7), new Point(_startPosX.Value + 32, _startPosY.Value - 9), new Point(_startPosX.Value + 30, _startPosY.Value - 11), new Point(_startPosX.Value + 20, _startPosY.Value - 11), new Point(_startPosX.Value + 18, _startPosY.Value - 9), new Point(_startPosX.Value + 20, _startPosY.Value - 7), new Point(_startPosX.Value + 20, _startPosY.Value) };
g.FillPolygon(wheelBrush, points4);
}
if (entityTLocomotive.Fueltank)
{

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive.Exceptions;
/// <summary>
/// Класс, описывающий ошибку переполнения коллекции
/// </summary>
[Serializable]
internal 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) { }
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive.Exceptions;
[Serializable]
internal class ObjectAlreadyInCollectionException : ApplicationException
{
public ObjectAlreadyInCollectionException(int index) : base("Такой объект уже присутствует в коллекции. Позиция " + index) { }
public ObjectAlreadyInCollectionException() : base() { }
public ObjectAlreadyInCollectionException(string message) : base(message) { }
public ObjectAlreadyInCollectionException(string message, Exception exception) : base(message, exception) { }
protected ObjectAlreadyInCollectionException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive.Exceptions;
/// <summary>
/// Класс, описывающий ошибку, что по указанной позиции нет элемента
/// </summary>
[Serializable]
internal 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) { }
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive.Exceptions;
/// <summary>
/// Класс, описывающий ошибку выхода за границы коллекции
/// </summary>
[Serializable]
internal 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) { }
}

View File

@ -48,6 +48,7 @@
pictureBoxLocomotive.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBoxLocomotive.TabIndex = 0;
pictureBoxLocomotive.TabStop = false;
pictureBoxLocomotive.Click += pictureBoxLocomotive_Click;
//
// buttonUp
//

View File

@ -41,7 +41,7 @@ namespace ProjectLocomotive
}
/// <summary>
/// Метод прорисовки круисера
/// Метод прорисовки поезда
/// </summary>
private void Draw()
{
@ -135,5 +135,9 @@ namespace ProjectLocomotive
}
}
private void pictureBoxLocomotive_Click(object sender, EventArgs e)
{
}
}
}

View File

@ -75,10 +75,8 @@
groupBoxConfing.Controls.Add(labelSimpleObject);
groupBoxConfing.Dock = DockStyle.Left;
groupBoxConfing.Location = new Point(0, 0);
groupBoxConfing.Margin = new Padding(3, 2, 3, 2);
groupBoxConfing.Name = "groupBoxConfing";
groupBoxConfing.Padding = new Padding(3, 2, 3, 2);
groupBoxConfing.Size = new Size(548, 196);
groupBoxConfing.Size = new Size(626, 262);
groupBoxConfing.TabIndex = 0;
groupBoxConfing.TabStop = false;
groupBoxConfing.Text = "Параметры";
@ -93,11 +91,9 @@
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(286, 20);
groupBoxColors.Margin = new Padding(3, 2, 3, 2);
groupBoxColors.Location = new Point(327, 26);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Padding = new Padding(3, 2, 3, 2);
groupBoxColors.Size = new Size(245, 116);
groupBoxColors.Size = new Size(280, 154);
groupBoxColors.TabIndex = 9;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
@ -105,82 +101,73 @@
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(190, 72);
panelPurple.Margin = new Padding(3, 2, 3, 2);
panelPurple.Location = new Point(217, 96);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(42, 35);
panelPurple.Size = new Size(48, 47);
panelPurple.TabIndex = 1;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(130, 72);
panelBlack.Margin = new Padding(3, 2, 3, 2);
panelBlack.Location = new Point(149, 96);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(42, 35);
panelBlack.Size = new Size(48, 47);
panelBlack.TabIndex = 1;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(72, 72);
panelGray.Margin = new Padding(3, 2, 3, 2);
panelGray.Location = new Point(82, 96);
panelGray.Name = "panelGray";
panelGray.Size = new Size(42, 35);
panelGray.Size = new Size(48, 47);
panelGray.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(15, 72);
panelWhite.Margin = new Padding(3, 2, 3, 2);
panelWhite.Location = new Point(17, 96);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(42, 35);
panelWhite.Size = new Size(48, 47);
panelWhite.TabIndex = 1;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(190, 23);
panelYellow.Margin = new Padding(3, 2, 3, 2);
panelYellow.Location = new Point(217, 31);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(42, 35);
panelYellow.Size = new Size(48, 47);
panelYellow.TabIndex = 1;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(130, 23);
panelBlue.Margin = new Padding(3, 2, 3, 2);
panelBlue.Location = new Point(149, 31);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(42, 35);
panelBlue.Size = new Size(48, 47);
panelBlue.TabIndex = 1;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(72, 23);
panelGreen.Margin = new Padding(3, 2, 3, 2);
panelGreen.Location = new Point(82, 31);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(42, 35);
panelGreen.Size = new Size(48, 47);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(15, 23);
panelRed.Margin = new Padding(3, 2, 3, 2);
panelRed.Location = new Point(17, 31);
panelRed.Name = "panelRed";
panelRed.Size = new Size(42, 35);
panelRed.Size = new Size(48, 47);
panelRed.TabIndex = 0;
//
// checkBoxHeadlight
//
checkBoxHeadlight.AutoSize = true;
checkBoxHeadlight.Location = new Point(5, 163);
checkBoxHeadlight.Margin = new Padding(3, 2, 3, 2);
checkBoxHeadlight.Location = new Point(6, 217);
checkBoxHeadlight.Name = "checkBoxHeadlight";
checkBoxHeadlight.Size = new Size(168, 19);
checkBoxHeadlight.Size = new Size(211, 24);
checkBoxHeadlight.TabIndex = 8;
checkBoxHeadlight.Text = "Признак наличие фонаря";
checkBoxHeadlight.UseVisualStyleBackColor = true;
@ -188,22 +175,19 @@
// checkBoxFueltank
//
checkBoxFueltank.AutoSize = true;
checkBoxFueltank.Location = new Point(5, 127);
checkBoxFueltank.Margin = new Padding(3, 2, 3, 2);
checkBoxFueltank.Location = new Point(6, 169);
checkBoxFueltank.Name = "checkBoxFueltank";
checkBoxFueltank.Size = new Size(167, 19);
checkBoxFueltank.Size = new Size(276, 24);
checkBoxFueltank.TabIndex = 7;
checkBoxFueltank.Text = "Признак топлтвного бака";
checkBoxFueltank.Text = "Признак наличие топливного бака";
checkBoxFueltank.UseVisualStyleBackColor = true;
checkBoxFueltank.CheckedChanged += checkBoxFueltank_CheckedChanged;
//
// checkBoxPipe
//
checkBoxPipe.AutoSize = true;
checkBoxPipe.Location = new Point(5, 92);
checkBoxPipe.Margin = new Padding(3, 2, 3, 2);
checkBoxPipe.Location = new Point(6, 123);
checkBoxPipe.Name = "checkBoxPipe";
checkBoxPipe.Size = new Size(160, 19);
checkBoxPipe.Size = new Size(200, 24);
checkBoxPipe.TabIndex = 6;
checkBoxPipe.Text = "Признак наличие трубы";
checkBoxPipe.UseVisualStyleBackColor = true;
@ -211,50 +195,48 @@
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(82, 51);
numericUpDownWeight.Margin = new Padding(3, 2, 3, 2);
numericUpDownWeight.Location = new Point(94, 68);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
numericUpDownWeight.Size = new Size(100, 23);
numericUpDownWeight.Size = new Size(114, 27);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(24, 52);
labelWeight.Location = new Point(27, 70);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(29, 15);
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 4;
labelWeight.Text = "Вес:";
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(82, 24);
numericUpDownSpeed.Margin = new Padding(3, 2, 3, 2);
numericUpDownSpeed.Location = new Point(94, 32);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
numericUpDownSpeed.Size = new Size(100, 23);
numericUpDownSpeed.Size = new Size(114, 27);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(10, 24);
labelSpeed.Location = new Point(12, 32);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(62, 15);
labelSpeed.Size = new Size(76, 20);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(416, 152);
labelModifiedObject.Location = new Point(476, 203);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(115, 34);
labelModifiedObject.Size = new Size(131, 44);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
@ -263,9 +245,9 @@
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(286, 152);
labelSimpleObject.Location = new Point(327, 203);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(114, 34);
labelSimpleObject.Size = new Size(130, 44);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
@ -273,19 +255,18 @@
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(10, 42);
pictureBoxObject.Margin = new Padding(3, 2, 3, 2);
pictureBoxObject.Location = new Point(11, 56);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(160, 94);
pictureBoxObject.Size = new Size(183, 125);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
pictureBoxObject.Click += pictureBoxObject_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(553, 159);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Location = new Point(632, 212);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(82, 22);
buttonAdd.Size = new Size(94, 29);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
@ -293,10 +274,9 @@
//
// buttonCancel
//
buttonCancel.Location = new Point(648, 159);
buttonCancel.Margin = new Padding(3, 2, 3, 2);
buttonCancel.Location = new Point(740, 212);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(82, 22);
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
@ -307,10 +287,9 @@
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(553, 9);
panelObject.Margin = new Padding(3, 2, 3, 2);
panelObject.Location = new Point(632, 12);
panelObject.Name = "panelObject";
panelObject.Size = new Size(179, 146);
panelObject.Size = new Size(205, 194);
panelObject.TabIndex = 4;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
@ -319,9 +298,9 @@
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(94, 8);
labelAdditionalColor.Location = new Point(108, 11);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(73, 28);
labelAdditionalColor.Size = new Size(83, 36);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
@ -332,9 +311,9 @@
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(10, 8);
labelBodyColor.Location = new Point(11, 11);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(73, 28);
labelBodyColor.Size = new Size(83, 36);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
@ -343,14 +322,13 @@
//
// FormLocomotiveConfing
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(733, 196);
ClientSize = new Size(838, 262);
Controls.Add(panelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfing);
Margin = new Padding(3, 2, 3, 2);
Name = "FormLocomotiveConfing";
Text = "Создание объекта";
groupBoxConfing.ResumeLayout(false);

View File

@ -62,8 +62,8 @@ namespace ProjectLocomotive
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="sender"></param>labelSimpleObject
/// <param name="e"></param>labelSimpleObject
private void labelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
@ -171,6 +171,10 @@ namespace ProjectLocomotive
LocomotiveDelegate?.Invoke(_locomotive);
Close();
}
}
private void pictureBoxObject_Click(object sender, EventArgs e)
{
}
@ -178,10 +182,5 @@ namespace ProjectLocomotive
{
}
private void checkBoxFueltank_CheckedChanged(object sender, EventArgs e)
{
}
}
}

View File

@ -40,16 +40,25 @@
labelCollectionName = new Label();
comboBoxSelectorCompany = new ComboBox();
panelCompanyTools = new Panel();
buttonSortByColor = new Button();
buttonSortByType = new Button();
ButtonAddLocomotive = new Button();
buttonRefresh = new Button();
ButtonRemoveLocomotive = new Button();
maskedTextBoxPosision = new MaskedTextBox();
buttonGetToTest = new Button();
pictureBoxLocomotive = new PictureBox();
menuStrip = new MenuStrip();
файлToolStripMenuItem = new ToolStripMenuItem();
saveToolStripMenuItem = new ToolStripMenuItem();
loadToolStripMenuItem = new ToolStripMenuItem();
saveFileDialog = new SaveFileDialog();
openFileDialog = new OpenFileDialog();
groupBoxTools.SuspendLayout();
panelStorage.SuspendLayout();
panelCompanyTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
@ -59,21 +68,18 @@
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Controls.Add(panelCompanyTools);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(522, 0);
groupBoxTools.Margin = new Padding(3, 2, 3, 2);
groupBoxTools.Location = new Point(631, 30);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Padding = new Padding(3, 2, 3, 2);
groupBoxTools.Size = new Size(182, 490);
groupBoxTools.Size = new Size(222, 658);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "инструменты";
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(18, 259);
buttonCreateCompany.Margin = new Padding(3, 2, 3, 2);
buttonCreateCompany.Location = new Point(21, 345);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(163, 20);
buttonCreateCompany.Size = new Size(186, 27);
buttonCreateCompany.TabIndex = 7;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
@ -89,18 +95,16 @@
panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 18);
panelStorage.Margin = new Padding(3, 2, 3, 2);
panelStorage.Location = new Point(3, 23);
panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(176, 212);
panelStorage.Size = new Size(216, 283);
panelStorage.TabIndex = 6;
//
// buttonCollectionDel
//
buttonCollectionDel.Location = new Point(15, 185);
buttonCollectionDel.Margin = new Padding(3, 2, 3, 2);
buttonCollectionDel.Location = new Point(17, 247);
buttonCollectionDel.Name = "buttonCollectionDel";
buttonCollectionDel.Size = new Size(163, 20);
buttonCollectionDel.Size = new Size(186, 27);
buttonCollectionDel.TabIndex = 6;
buttonCollectionDel.Text = "Удалить коллекцию";
buttonCollectionDel.UseVisualStyleBackColor = true;
@ -109,19 +113,16 @@
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 15;
listBoxCollection.Location = new Point(15, 103);
listBoxCollection.Margin = new Padding(3, 2, 3, 2);
listBoxCollection.Location = new Point(17, 137);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(163, 79);
listBoxCollection.Size = new Size(186, 104);
listBoxCollection.TabIndex = 5;
//
// buttonCollecctionAdd
//
buttonCollecctionAdd.Location = new Point(15, 78);
buttonCollecctionAdd.Margin = new Padding(3, 2, 3, 2);
buttonCollecctionAdd.Location = new Point(17, 104);
buttonCollecctionAdd.Name = "buttonCollecctionAdd";
buttonCollecctionAdd.Size = new Size(163, 20);
buttonCollecctionAdd.Size = new Size(186, 27);
buttonCollecctionAdd.TabIndex = 4;
buttonCollecctionAdd.Text = "Добавить коллекцию";
buttonCollecctionAdd.UseVisualStyleBackColor = true;
@ -130,10 +131,9 @@
// radioButtonList
//
radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(108, 56);
radioButtonList.Margin = new Padding(3, 2, 3, 2);
radioButtonList.Location = new Point(123, 75);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(66, 19);
radioButtonList.Size = new Size(80, 24);
radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
@ -142,10 +142,9 @@
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(15, 56);
radioButtonMassive.Margin = new Padding(3, 2, 3, 2);
radioButtonMassive.Location = new Point(17, 75);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.Size = new Size(82, 24);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив";
@ -153,18 +152,17 @@
//
// textBoxCollectionName
//
textBoxCollectionName.Location = new Point(15, 24);
textBoxCollectionName.Margin = new Padding(3, 2, 3, 2);
textBoxCollectionName.Location = new Point(17, 32);
textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(163, 23);
textBoxCollectionName.Size = new Size(186, 27);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
labelCollectionName.Location = new Point(23, 7);
labelCollectionName.Location = new Point(26, 9);
labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(122, 15);
labelCollectionName.Size = new Size(155, 20);
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции";
//
@ -173,35 +171,56 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(18, 233);
comboBoxSelectorCompany.Margin = new Padding(3, 2, 3, 2);
comboBoxSelectorCompany.Location = new Point(21, 311);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(163, 23);
comboBoxSelectorCompany.Size = new Size(186, 28);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1;
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonSortByColor);
panelCompanyTools.Controls.Add(buttonSortByType);
panelCompanyTools.Controls.Add(ButtonAddLocomotive);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(ButtonRemoveLocomotive);
panelCompanyTools.Controls.Add(maskedTextBoxPosision);
panelCompanyTools.Controls.Add(buttonGetToTest);
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 284);
panelCompanyTools.Margin = new Padding(3, 2, 3, 2);
panelCompanyTools.Location = new Point(3, 379);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(189, 206);
panelCompanyTools.Size = new Size(216, 275);
panelCompanyTools.TabIndex = 8;
//
// buttonSortByColor
//
buttonSortByColor.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSortByColor.Location = new Point(19, 241);
buttonSortByColor.Name = "buttonSortByColor";
buttonSortByColor.Size = new Size(186, 31);
buttonSortByColor.TabIndex = 7;
buttonSortByColor.Text = "Сортировка по цвету";
buttonSortByColor.UseVisualStyleBackColor = true;
buttonSortByColor.Click += ButtonSortByColor_Click;
//
// buttonSortByType
//
buttonSortByType.Anchor = AnchorStyles.Right;
buttonSortByType.Location = new Point(19, 199);
buttonSortByType.Name = "buttonSortByType";
buttonSortByType.Size = new Size(186, 37);
buttonSortByType.TabIndex = 6;
buttonSortByType.Text = "Сортировка по типу";
buttonSortByType.UseVisualStyleBackColor = true;
buttonSortByType.Click += ButtonSortByType_Click;
//
// ButtonAddLocomotive
//
ButtonAddLocomotive.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
ButtonAddLocomotive.BackgroundImageLayout = ImageLayout.Center;
ButtonAddLocomotive.Location = new Point(16, 2);
ButtonAddLocomotive.Margin = new Padding(3, 2, 3, 2);
ButtonAddLocomotive.Location = new Point(18, 3);
ButtonAddLocomotive.Name = "ButtonAddLocomotive";
ButtonAddLocomotive.Size = new Size(163, 55);
ButtonAddLocomotive.Size = new Size(186, 52);
ButtonAddLocomotive.TabIndex = 1;
ButtonAddLocomotive.Text = "добваление поезда";
ButtonAddLocomotive.UseVisualStyleBackColor = true;
@ -210,10 +229,9 @@
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRefresh.Location = new Point(16, 170);
buttonRefresh.Margin = new Padding(3, 2, 3, 2);
buttonRefresh.Location = new Point(19, 164);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(163, 31);
buttonRefresh.Size = new Size(186, 29);
buttonRefresh.TabIndex = 5;
buttonRefresh.Text = "обновить";
buttonRefresh.UseVisualStyleBackColor = true;
@ -222,10 +240,9 @@
// ButtonRemoveLocomotive
//
ButtonRemoveLocomotive.Anchor = AnchorStyles.Right;
ButtonRemoveLocomotive.Location = new Point(16, 88);
ButtonRemoveLocomotive.Margin = new Padding(3, 2, 3, 2);
ButtonRemoveLocomotive.Location = new Point(19, 99);
ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive";
ButtonRemoveLocomotive.Size = new Size(163, 46);
ButtonRemoveLocomotive.Size = new Size(186, 28);
ButtonRemoveLocomotive.TabIndex = 3;
ButtonRemoveLocomotive.Text = "удалить поезд";
ButtonRemoveLocomotive.UseVisualStyleBackColor = true;
@ -233,21 +250,19 @@
//
// maskedTextBoxPosision
//
maskedTextBoxPosision.Location = new Point(16, 61);
maskedTextBoxPosision.Margin = new Padding(3, 2, 3, 2);
maskedTextBoxPosision.Location = new Point(18, 60);
maskedTextBoxPosision.Mask = "00";
maskedTextBoxPosision.Name = "maskedTextBoxPosision";
maskedTextBoxPosision.Size = new Size(164, 23);
maskedTextBoxPosision.Size = new Size(187, 27);
maskedTextBoxPosision.TabIndex = 2;
maskedTextBoxPosision.ValidatingType = typeof(int);
//
// buttonGetToTest
//
buttonGetToTest.Anchor = AnchorStyles.Right;
buttonGetToTest.Location = new Point(16, 138);
buttonGetToTest.Margin = new Padding(3, 2, 3, 2);
buttonGetToTest.Location = new Point(18, 132);
buttonGetToTest.Name = "buttonGetToTest";
buttonGetToTest.Size = new Size(163, 30);
buttonGetToTest.Size = new Size(186, 27);
buttonGetToTest.TabIndex = 4;
buttonGetToTest.Text = "передать на тесты";
buttonGetToTest.UseVisualStyleBackColor = true;
@ -256,30 +271,77 @@
// pictureBoxLocomotive
//
pictureBoxLocomotive.Dock = DockStyle.Fill;
pictureBoxLocomotive.Location = new Point(0, 0);
pictureBoxLocomotive.Margin = new Padding(3, 2, 3, 2);
pictureBoxLocomotive.Location = new Point(0, 30);
pictureBoxLocomotive.Name = "pictureBoxLocomotive";
pictureBoxLocomotive.Size = new Size(522, 490);
pictureBoxLocomotive.Size = new Size(631, 658);
pictureBoxLocomotive.TabIndex = 1;
pictureBoxLocomotive.TabStop = false;
pictureBoxLocomotive.Click += pictureBoxLocomotive_Click;
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Padding = new Padding(6, 3, 0, 3);
menuStrip.Size = new Size(853, 30);
menuStrip.TabIndex = 2;
menuStrip.Text = "menuStrip1";
//
// файлToolStripMenuItem
//
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
файлToolStripMenuItem.Name = айлToolStripMenuItem";
файлToolStripMenuItem.Size = new Size(59, 24);
файлToolStripMenuItem.Text = "Файл";
//
// saveToolStripMenuItem
//
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
saveToolStripMenuItem.Size = new Size(227, 26);
saveToolStripMenuItem.Text = "Сохранение";
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
//
// loadToolStripMenuItem
//
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
loadToolStripMenuItem.Size = new Size(227, 26);
loadToolStripMenuItem.Text = "Загрузка";
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
//
// saveFileDialog
//
saveFileDialog.Filter = "txt file|*.txt";
//
// openFileDialog
//
openFileDialog.Filter = "txt file|*.txt";
//
// FormLocomotivesCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(704, 490);
ClientSize = new Size(853, 688);
Controls.Add(pictureBoxLocomotive);
Controls.Add(groupBoxTools);
Margin = new Padding(3, 2, 3, 2);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormLocomotivesCollection";
Text = "FormLocomotivesCollection";
Load += FormLocomotivesCollection_Load;
groupBoxTools.ResumeLayout(false);
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
@ -302,5 +364,13 @@
private Button buttonCreateCompany;
private Button buttonCollectionDel;
private Panel panelCompanyTools;
private MenuStrip menuStrip;
private ToolStripMenuItem файлToolStripMenuItem;
private ToolStripMenuItem saveToolStripMenuItem;
private ToolStripMenuItem loadToolStripMenuItem;
private SaveFileDialog saveFileDialog;
private OpenFileDialog openFileDialog;
private Button buttonSortByColor;
private Button buttonSortByType;
}
}

View File

@ -1,4 +1,5 @@
using ProjectLocomotive.CollectionGenericObjects;
using Microsoft.Extensions.Logging;
using ProjectLocomotive.CollectionGenericObjects;
using ProjectLocomotive.Drawnings;
using System.Windows.Forms;
@ -16,13 +17,19 @@ namespace ProjectLocomotive
/// </summary>
private AbstractCompany? _company = null;
/// <summary>
/// Логер
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Конструктор
/// </summary>
public FormLocomotivesCollection()
public FormLocomotivesCollection(ILogger<FormLocomotivesCollection> logger)
{
InitializeComponent();
_storageCollection = new();
_logger = logger;
}
/// <summary>
@ -35,6 +42,11 @@ namespace ProjectLocomotive
panelCompanyTools.Enabled = false;
}
/// <summary>
/// добавление артиллерийской установки
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
{
FormLocomotiveConfing form = new();
@ -45,24 +57,27 @@ namespace ProjectLocomotive
}
/// <summary>
/// Добавление поезда в коллекцию
/// Добавление артиллерийской установки в коллекцию
/// </summary>
/// <param name="locomotive"></param>
private void SetLocomotive(DrawningLocomotive locomotive)
private void SetLocomotive(DrawningLocomotive? locomotive)
{
if (_company == null || locomotive == null)
{
return;
}
if (_company + locomotive != -1)
try
{
var res = _company + locomotive;
MessageBox.Show("Объект добавлен");
_logger.LogInformation($"Объект добавлен под индексом {res}");
pictureBoxLocomotive.Image = _company.Show();
}
else
catch (Exception ex)
{
MessageBox.Show("Не удалось добавить объект");
MessageBox.Show($"Объект не добавлен: {ex.Message}", "Результат", MessageBoxButtons.OK,
MessageBoxIcon.Error);
_logger.LogError($"Ошибка: {ex.Message}", ex.Message);
}
}
@ -83,14 +98,18 @@ namespace ProjectLocomotive
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosision.Text);
if (_company - pos != null)
try
{
MessageBox.Show("объект удален");
var res = _company - pos;
MessageBox.Show("Объект удален");
_logger.LogInformation($"Объект удален под индексом {pos}");
pictureBoxLocomotive.Image = _company.Show();
}
else
catch (Exception ex)
{
MessageBox.Show("не удалось удалить объект");
MessageBox.Show(ex.Message, "Не удалось удалить объект",
MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogError($"Ошибка: {ex.Message}", ex.Message);
}
}
@ -143,8 +162,7 @@ namespace ProjectLocomotive
{
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
{
MessageBox.Show("Не все данные заполнены", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
CollectionType collectionType = CollectionType.None;
@ -156,7 +174,11 @@ namespace ProjectLocomotive
{
collectionType = CollectionType.List;
}
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
CollectionInfo collectionInfo = new CollectionInfo(textBoxCollectionName.Text, collectionType, string.Empty);
_storageCollection.AddCollection(collectionInfo);
_logger.LogInformation("Добавление коллекции");
RerfreshListBoxItems();
}
@ -176,7 +198,11 @@ namespace ProjectLocomotive
{
return;
}
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
CollectionInfo collectionInfo = new CollectionInfo(listBoxCollection.SelectedItem.ToString(), CollectionType.None, string.Empty);
_storageCollection.DelCollection(collectionInfo);
_logger.LogInformation("Коллекция удалена");
RerfreshListBoxItems();
}
@ -188,7 +214,7 @@ namespace ProjectLocomotive
listBoxCollection.Items.Clear();
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
{
string? colName = _storageCollection.Keys?[i];
string? colName = _storageCollection.Keys?[i].Name;
if (!string.IsNullOrEmpty(colName))
{
listBoxCollection.Items.Add(colName);
@ -197,7 +223,7 @@ namespace ProjectLocomotive
}
/// <summary>
///
/// Создание компании
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@ -208,23 +234,116 @@ namespace ProjectLocomotive
MessageBox.Show("Коллекция не выбрана");
return;
}
ICollectionGenericObjects<DrawningLocomotive>? collection =
_storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
CollectionInfo collectionInfo = new CollectionInfo(listBoxCollection.SelectedItem.ToString(), CollectionType.None, string.Empty);
ICollectionGenericObjects<DrawningLocomotive>? collection = _storageCollection[collectionInfo];
if (collection == null)
{
MessageBox.Show("Коллекция не проинициализирована");
return;
}
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new LocomotiveDockingService(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height, collection);
_logger.LogInformation("Компания создана");
break;
}
panelCompanyTools.Enabled = true;
RerfreshListBoxItems();
}
/// <summary>
/// Обработка нажатия "Сохранение"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
}
}
/// <summary>
/// Обработка нажатия "Загрузка"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
_storageCollection.LoadData(openFileDialog.FileName);
RerfreshListBoxItems();
MessageBox.Show("Загрузка прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
_logger.LogInformation("Загрузка из файла: {filename}", openFileDialog.FileName);
}
catch (Exception ex)
{
MessageBox.Show("Загрузка не выполнена", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogError("Ошибка: {Message}", ex.Message);
}
}
}
/// <summary>
/// Сортировка по типу
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSortByType_Click(object sender, EventArgs e)
{
CompareLocomotives(new DrawningLocomotiveCompareByType());
}
/// <summary>
/// Сортировка по цвету
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSortByColor_Click(object sender, EventArgs e)
{
CompareLocomotives(new DrawningLocomotiveCompareByColor());
}
/// <summary>
/// Сортировка по сравнителю
/// </summary>
/// <param name="comparer">Сравнитель объектов</param>
private void CompareLocomotives(IComparer<DrawningLocomotive?> comparer)
{
if (_company == null)
{
return;
}
_company.Sort(comparer);
pictureBoxLocomotive.Image = _company.Show();
}
private void FormLocomotivesCollection_Load(object sender, EventArgs e)
{
}
private void pictureBoxLocomotive_Click(object sender, EventArgs e)
{
}
}
}

View File

@ -117,4 +117,16 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 1</value>
</metadata>
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>145, 1</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>310, 1</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>

View File

@ -1,3 +1,8 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
namespace ProjectLocomotive
{
internal static class Program
@ -10,7 +15,31 @@ namespace ProjectLocomotive
{
// To customize application configuration such as set high DPI settings or default font, see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormLocomotivesCollection());
ServiceCollection services = new();
ConfigureServices(services);
using ServiceProvider serviceProvider = services.BuildServiceProvider();
Application.Run(serviceProvider.GetRequiredService<FormLocomotivesCollection>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddSingleton<FormLocomotivesCollection>().AddLogging(option =>
{
string[] path = Directory.GetCurrentDirectory().Split('\\');
string pathNeed = "";
for (int i = 0; i < path.Length - 3; i++)
{
pathNeed += path[i] + "\\";
}
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path: $"{pathNeed}serilogConfig.json", optional: false, reloadOnChange: true)
.Build();
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
option.SetMinimumLevel(LogLevel.Information);
option.AddSerilog(logger);
});
}
}
}

View File

@ -8,4 +8,15 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
<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.12" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.2" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" internalLogLevel="Info">
<targets>
<target xsi:type="File" name="tofile" fileName="locomotivelog-
${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>

View File

@ -0,0 +1,20 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Information",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/log_.log",
"rollingInterval": "Day",
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "locomotive"
}
}
}