Compare commits
No commits in common. "080b215b76ae63b2f4f6e9e2bb8edf43a9a24e5c" and "953f08de46705b1bf2ef6a3b2dc54952b8d3c006" have entirely different histories.
080b215b76
...
953f08de46
@ -1,12 +1,7 @@
|
||||
using ProjectTank.Drawnings;
|
||||
using ProjectTank.CollectionGenericObjects;
|
||||
using ProjectTank.Exceptions;
|
||||
|
||||
namespace ProjectTank.CollectionGenericObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Абстракция компании, хранящий коллекцию самолётов
|
||||
/// </summary>
|
||||
public abstract class AbstractCompany
|
||||
{
|
||||
/// <summary>
|
||||
@ -30,22 +25,23 @@ public abstract class AbstractCompany
|
||||
protected readonly int _pictureHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Коллекция самолётов
|
||||
/// Коллекция машин
|
||||
/// </summary>
|
||||
protected ICollectionGenericObjects<DrawningTank2>? _collection = null;
|
||||
|
||||
/// <summary>
|
||||
/// Вычисление максимального количества элементов, который можно разместить в окне
|
||||
/// </summary>
|
||||
private int GetMaxCount => (_pictureWidth / _placeSizeWidth) * (_pictureHeight / _placeSizeHeight);
|
||||
private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="picWidth">Ширина окна</param>
|
||||
/// <param name="picHeight">Высота окна</param>
|
||||
/// <param name="collection">Коллекция самолётов</param>
|
||||
public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTank2> collection)
|
||||
/// <param name="collection">Коллекция машин</param>
|
||||
public AbstractCompany(int picWidth, int picHeight,
|
||||
ICollectionGenericObjects<DrawningTank2> collection)
|
||||
{
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
@ -57,7 +53,7 @@ public abstract class AbstractCompany
|
||||
/// Перегрузка оператора сложения для класса
|
||||
/// </summary>
|
||||
/// <param name="company">Компания</param>
|
||||
/// <param name="tank2">Добавляемый объект</param>
|
||||
/// <param name="trackedMachine">Добавляемый объект</param>
|
||||
/// <returns></returns>
|
||||
public static int operator +(AbstractCompany company, DrawningTank2 tank2)
|
||||
{
|
||||
@ -70,9 +66,9 @@ public abstract class AbstractCompany
|
||||
/// <param name="company">Компания</param>
|
||||
/// <param name="position">Номер удаляемого объекта</param>
|
||||
/// <returns></returns>
|
||||
public static DrawningTank2? operator -(AbstractCompany company, int position)
|
||||
public static DrawningTank2 operator -(AbstractCompany company, int position)
|
||||
{
|
||||
return company._collection?.Remove(position);
|
||||
return company._collection.Remove(position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -94,19 +90,11 @@ public abstract class AbstractCompany
|
||||
Bitmap bitmap = new(_pictureWidth, _pictureHeight);
|
||||
Graphics graphics = Graphics.FromImage(bitmap);
|
||||
DrawBackgound(graphics);
|
||||
|
||||
SetObjectsPosition();
|
||||
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
DrawningTank2? obj = _collection?.Get(i);
|
||||
obj?.DrawTransport(graphics);
|
||||
}
|
||||
catch (ObjectNotFoundException)
|
||||
{
|
||||
|
||||
}
|
||||
DrawningTank2? obj = _collection?.Get(i);
|
||||
obj?.DrawTransport(graphics);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
@ -116,9 +104,8 @@ public abstract class AbstractCompany
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
protected abstract void DrawBackgound(Graphics g);
|
||||
|
||||
/// <summary>
|
||||
/// Расстановка объектов
|
||||
/// </summary>
|
||||
protected abstract void SetObjectsPosition();
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,5 @@
|
||||
using ProjectTank.CollectionGenericObjects;
|
||||
using ProjectTank.Exceptions;
|
||||
namespace ProjectTank.CollectionGenericObjects;
|
||||
|
||||
namespace ProjectTank.CollectionGenericObjects;
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
||||
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
where T : class
|
||||
{
|
||||
@ -13,6 +7,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
/// Список объектов, которые храним
|
||||
/// </summary>
|
||||
private readonly List<T?> _collection;
|
||||
|
||||
/// <summary>
|
||||
/// Максимально допустимое число объектов в списке
|
||||
/// </summary>
|
||||
@ -22,7 +17,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collection.Count;
|
||||
return Count;
|
||||
}
|
||||
set
|
||||
{
|
||||
@ -42,28 +37,37 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
{
|
||||
_collection = new();
|
||||
}
|
||||
|
||||
public T? Get(int position)
|
||||
{
|
||||
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position);
|
||||
if (_collection[position] == null) throw new ObjectNotFoundException();
|
||||
// TODO проверка позиции
|
||||
if (position >= Count || position < 0) return null;
|
||||
return _collection[position];
|
||||
}
|
||||
public int Insert(T obj)
|
||||
{
|
||||
if (Count + 1 > _maxCount) throw new CollectionOverflowException(Count);
|
||||
// TODO проверка, что не превышено максимальное количество элементов
|
||||
// TODO вставка в конец набора
|
||||
|
||||
if (Count + 1 > _maxCount) return -1;
|
||||
_collection.Add(obj);
|
||||
return Count;
|
||||
}
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
if (Count + 1 > _maxCount) throw new CollectionOverflowException(Count);
|
||||
if (position < 0 || position > Count) throw new PositionOutOfCollectionException(position);
|
||||
// TODO проверка, что не превышено максимальное количество элементов
|
||||
// TODO проверка позиции
|
||||
// TODO вставка по позиции
|
||||
if (Count + 1 > _maxCount) return -1;
|
||||
if (position < 0 || position > Count) return -1;
|
||||
_collection.Insert(position, obj);
|
||||
return position;
|
||||
return 1;
|
||||
}
|
||||
public T? Remove(int position)
|
||||
{
|
||||
if (position < 0 || position > Count) throw new PositionOutOfCollectionException(position);
|
||||
// TODO проверка позиции
|
||||
// TODO удаление объекта из списка
|
||||
if (position < 0 || position > Count) return null;
|
||||
T? temp = _collection[position];
|
||||
_collection.RemoveAt(position);
|
||||
return temp;
|
||||
@ -76,4 +80,4 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
yield return _collection[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,6 @@
|
||||
|
||||
using ProjectTank.CollectionGenericObjects;
|
||||
using ProjectTank.Exceptions;
|
||||
namespace ProjectTank.CollectionGenericObjects;
|
||||
|
||||
namespace ProjectTank.CollectionGenericObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
||||
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
@ -55,9 +47,12 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
public T? Get(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position);
|
||||
if (_collection[position] == null) throw new ObjectNotFoundException(position);
|
||||
return _collection[position];
|
||||
if (position <= Count)
|
||||
{
|
||||
return _collection[position];
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
public int Insert(T obj)
|
||||
{
|
||||
@ -70,7 +65,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
return i;
|
||||
}
|
||||
}
|
||||
throw new CollectionOverflowException(Count);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int Insert(T obj, int position)
|
||||
@ -80,55 +75,39 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
// ищется свободное место после этой позиции и идет туда
|
||||
// если нет после, ищем до
|
||||
// TODO вставка
|
||||
if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position);
|
||||
|
||||
if (_collection[position] != null)
|
||||
if (position < Count)
|
||||
{
|
||||
bool pushed = false;
|
||||
for (int index = position + 1; index < Count; index++)
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
if (_collection[index] == null)
|
||||
{
|
||||
position = index;
|
||||
pushed = true;
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!pushed)
|
||||
if (_collection[position] == null)
|
||||
{
|
||||
for (int index = position - 1; index >= 0; index--)
|
||||
_collection[position] = obj;
|
||||
return position;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
if (_collection[index] == null)
|
||||
if (_collection[i] == null)
|
||||
{
|
||||
position = index;
|
||||
pushed = true;
|
||||
break;
|
||||
_collection[i] = obj;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pushed)
|
||||
{
|
||||
throw new CollectionOverflowException(Count);
|
||||
}
|
||||
}
|
||||
|
||||
// вставка
|
||||
_collection[position] = obj;
|
||||
return position;
|
||||
return -1;
|
||||
}
|
||||
public T? Remove(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO удаление объекта из массива, присвоив элементу массива значение null
|
||||
if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(position);
|
||||
|
||||
if (_collection[position] == null) throw new ObjectNotFoundException(position);
|
||||
|
||||
T? temp = _collection[position];
|
||||
if (position >= Count || position < 0) return null;
|
||||
T? myObject = _collection[position];
|
||||
_collection[position] = null;
|
||||
return temp;
|
||||
return myObject;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetItems()
|
||||
@ -140,3 +119,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,4 @@
|
||||
using ProjectTank.Drawnings;
|
||||
using ProjectTank.CollectionGenericObjects;
|
||||
using ProjectTank.Exceptions;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace ProjectTank.CollectionGenericObjects;
|
||||
@ -10,7 +7,7 @@ namespace ProjectTank.CollectionGenericObjects;
|
||||
/// Класс-хранилище коллекций
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class StorageCollection<T>
|
||||
internal class StorageCollection<T>
|
||||
where T : DrawningTank2
|
||||
{
|
||||
/// <summary>
|
||||
@ -24,20 +21,19 @@ public class StorageCollection<T>
|
||||
public List<string> Keys => _storages.Keys.ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Ключевое слово, с которого должен начинаться файл
|
||||
/// </summary>
|
||||
private readonly string _collectionKey = "CollectionsStorage";
|
||||
|
||||
/// Ключевое слово, с которого должен начинаться файл
|
||||
/// </summary>
|
||||
private readonly string _collectionKey = "CollectionsStorage";
|
||||
/// <summary>
|
||||
/// Разделитель для записи ключа и значения элемента словаря
|
||||
/// </summary>
|
||||
private readonly string _separatorForKeyValue = "|";
|
||||
|
||||
/// <summary>
|
||||
/// Разделитель для записей коллекции данных в файл
|
||||
/// </summary>
|
||||
private readonly string _separatorItems = ";";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -53,13 +49,15 @@ public class StorageCollection<T>
|
||||
/// <param name="collectionType">тип коллекции</param>
|
||||
public void AddCollection(string name, CollectionType collectionType)
|
||||
{
|
||||
|
||||
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
||||
// TODO Прописать логику для добавления
|
||||
if (_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>();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -68,6 +66,7 @@ public class StorageCollection<T>
|
||||
/// <param name="name">Название коллекции</param>
|
||||
public void DelCollection(string name)
|
||||
{
|
||||
// TODO Прописать логику для удаления коллекции
|
||||
if (_storages.ContainsKey(name))
|
||||
_storages.Remove(name);
|
||||
}
|
||||
@ -81,6 +80,7 @@ public class StorageCollection<T>
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO Продумать логику получения объекта
|
||||
if (_storages.ContainsKey(name))
|
||||
return _storages[name];
|
||||
return null;
|
||||
@ -88,14 +88,15 @@ public class StorageCollection<T>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение информации по самолётам в хранилище в файл
|
||||
/// Сохранение информации по автомобилям в хранилище в файл
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
public void SaveData(string filename)
|
||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (_storages.Count == 0)
|
||||
{
|
||||
throw new InvalidDataException("В хранилище отсутствуют коллекции для сохранения");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (File.Exists(filename))
|
||||
@ -135,18 +136,22 @@ public class StorageCollection<T>
|
||||
}
|
||||
writer.Write(sb);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка информации по самолётам в хранилище из файла
|
||||
/// Загрузка информации по автомобилям в хранилище из файла
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
public void LoadData(string filename)
|
||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new FileNotFoundException($"{filename} не существует");
|
||||
return false;
|
||||
}
|
||||
|
||||
using (StreamReader fs = File.OpenText(filename))
|
||||
@ -154,11 +159,11 @@ public class StorageCollection<T>
|
||||
string str = fs.ReadLine();
|
||||
if (str == null || str.Length == 0)
|
||||
{
|
||||
throw new FileFormatException("Файл не подходит");
|
||||
return false;
|
||||
}
|
||||
if (!str.StartsWith(_collectionKey))
|
||||
{
|
||||
throw new IOException("В файле неверные данные");
|
||||
return false;
|
||||
}
|
||||
_storages.Clear();
|
||||
string strs = "";
|
||||
@ -173,7 +178,7 @@ public class StorageCollection<T>
|
||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
|
||||
if (collection == null)
|
||||
{
|
||||
throw new InvalidCastException("Не удалось определить тип коллекции:" + record[1]);
|
||||
return false;
|
||||
}
|
||||
collection.MaxCount = Convert.ToInt32(record[2]);
|
||||
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
||||
@ -181,24 +186,17 @@ public class StorageCollection<T>
|
||||
{
|
||||
if (elem?.CreateDrawningTank2() is T tank2)
|
||||
{
|
||||
try
|
||||
if (collection.Insert(tank2) == -1)
|
||||
{
|
||||
if (collection.Insert(tank2) == -1)
|
||||
{
|
||||
throw new InvalidOperationException("Объект не удалось добавить в коллекцию: " + record[3]);
|
||||
}
|
||||
}
|
||||
catch (CollectionOverflowException ex)
|
||||
{
|
||||
throw new DataException("Коллекция переполнена", ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_storages.Add(record[0], collection);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание коллекции по типу
|
||||
/// </summary>
|
||||
@ -214,4 +212,3 @@ public class StorageCollection<T>
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
using ProjectTank.Drawnings;
|
||||
using ProjectTank.CollectionGenericObjects;
|
||||
using ProjectTank.Exceptions;
|
||||
using ProjectTank.Entities;
|
||||
using System;
|
||||
|
||||
namespace ProjectTank.CollectionGenericObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Реализация абстрактной компании - СимбирФлот
|
||||
/// Реализация абстрактной компании - аренда поезда
|
||||
/// </summary>
|
||||
public class TankBase : AbstractCompany
|
||||
{
|
||||
@ -18,12 +18,7 @@ public class TankBase : AbstractCompany
|
||||
public TankBase(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTank2> collection) : base(picWidth, picHeight, collection)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовка хранилища
|
||||
/// </summary>
|
||||
/// <param name="g">Графика</param>
|
||||
int pamat_i = 0;
|
||||
int pamat_j = 0;
|
||||
|
||||
protected override void DrawBackgound(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black);
|
||||
@ -36,40 +31,24 @@ public class TankBase : AbstractCompany
|
||||
}
|
||||
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * (_pictureHeight / _placeSizeHeight)), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * (_pictureHeight / _placeSizeHeight)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Установка объекта в Хранилище
|
||||
/// </summary>
|
||||
protected override void SetObjectsPosition()
|
||||
{
|
||||
|
||||
int n = 0;
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
|
||||
{
|
||||
try
|
||||
{
|
||||
DrawningTank2? tank2 = _collection?.Get(n);
|
||||
if (tank2 != null)
|
||||
{
|
||||
tank2.SetPictureSize(_pictureWidth, _pictureHeight);
|
||||
tank2.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
|
||||
}
|
||||
}
|
||||
catch (PositionOutOfCollectionException e)
|
||||
{
|
||||
|
||||
}
|
||||
catch (ObjectNotFoundException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DrawningTank2? drawningTank2 = _collection?.Get(n);
|
||||
n++;
|
||||
if (drawningTank2 != null)
|
||||
{
|
||||
drawningTank2.SetPictureSize(_pictureWidth, _pictureHeight);
|
||||
drawningTank2.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ProjectTank.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) { }
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ProjectTank.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) { }
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ProjectTank.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) { }
|
||||
}
|
106
ProjectTank/ProjectTank/FormTankCollection.Designer.cs
generated
106
ProjectTank/ProjectTank/FormTankCollection.Designer.cs
generated
@ -68,11 +68,9 @@ namespace ProjectTank
|
||||
groupBoxTools.Controls.Add(panelStorage);
|
||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||
groupBoxTools.Dock = DockStyle.Right;
|
||||
groupBoxTools.Location = new Point(856, 24);
|
||||
groupBoxTools.Margin = new Padding(3, 2, 3, 2);
|
||||
groupBoxTools.Location = new Point(931, 28);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Padding = new Padding(3, 2, 3, 2);
|
||||
groupBoxTools.Size = new Size(191, 543);
|
||||
groupBoxTools.Size = new Size(218, 659);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
@ -86,19 +84,17 @@ namespace ProjectTank
|
||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||
panelCompanyTools.Enabled = false;
|
||||
panelCompanyTools.Location = new Point(3, 333);
|
||||
panelCompanyTools.Margin = new Padding(3, 2, 3, 2);
|
||||
panelCompanyTools.Location = new Point(3, 379);
|
||||
panelCompanyTools.Name = "panelCompanyTools";
|
||||
panelCompanyTools.Size = new Size(185, 208);
|
||||
panelCompanyTools.Size = new Size(212, 277);
|
||||
panelCompanyTools.TabIndex = 9;
|
||||
//
|
||||
// buttonDelTank
|
||||
//
|
||||
buttonDelTank.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonDelTank.Location = new Point(3, 90);
|
||||
buttonDelTank.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonDelTank.Location = new Point(3, 120);
|
||||
buttonDelTank.Name = "buttonDelTank";
|
||||
buttonDelTank.Size = new Size(177, 37);
|
||||
buttonDelTank.Size = new Size(203, 49);
|
||||
buttonDelTank.TabIndex = 4;
|
||||
buttonDelTank.Text = "Удалить танка ";
|
||||
buttonDelTank.UseVisualStyleBackColor = true;
|
||||
@ -107,10 +103,9 @@ namespace ProjectTank
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRefresh.Location = new Point(4, 169);
|
||||
buttonRefresh.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonRefresh.Location = new Point(4, 225);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(176, 37);
|
||||
buttonRefresh.Size = new Size(202, 49);
|
||||
buttonRefresh.TabIndex = 6;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
@ -119,21 +114,19 @@ namespace ProjectTank
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
maskedTextBox.Location = new Point(4, 65);
|
||||
maskedTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
maskedTextBox.Location = new Point(4, 87);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(176, 23);
|
||||
maskedTextBox.Size = new Size(202, 27);
|
||||
maskedTextBox.TabIndex = 3;
|
||||
maskedTextBox.ValidatingType = typeof(int);
|
||||
//
|
||||
// buttonAddTank
|
||||
//
|
||||
buttonAddTank.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonAddTank.Location = new Point(3, 2);
|
||||
buttonAddTank.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonAddTank.Location = new Point(3, 3);
|
||||
buttonAddTank.Name = "buttonAddTank";
|
||||
buttonAddTank.Size = new Size(178, 37);
|
||||
buttonAddTank.Size = new Size(205, 49);
|
||||
buttonAddTank.TabIndex = 1;
|
||||
buttonAddTank.Text = "Добавление бронированной машины";
|
||||
buttonAddTank.UseVisualStyleBackColor = true;
|
||||
@ -142,10 +135,9 @@ namespace ProjectTank
|
||||
// buttonGoToCheck
|
||||
//
|
||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonGoToCheck.Location = new Point(3, 130);
|
||||
buttonGoToCheck.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonGoToCheck.Location = new Point(3, 173);
|
||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||
buttonGoToCheck.Size = new Size(177, 37);
|
||||
buttonGoToCheck.Size = new Size(203, 49);
|
||||
buttonGoToCheck.TabIndex = 5;
|
||||
buttonGoToCheck.Text = "Передать на тесты";
|
||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||
@ -153,10 +145,9 @@ namespace ProjectTank
|
||||
//
|
||||
// buttonCreateCompany
|
||||
//
|
||||
buttonCreateCompany.Location = new Point(5, 254);
|
||||
buttonCreateCompany.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonCreateCompany.Location = new Point(6, 339);
|
||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||
buttonCreateCompany.Size = new Size(180, 26);
|
||||
buttonCreateCompany.Size = new Size(206, 34);
|
||||
buttonCreateCompany.TabIndex = 8;
|
||||
buttonCreateCompany.Text = "Создать компанию";
|
||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||
@ -172,18 +163,16 @@ namespace ProjectTank
|
||||
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(185, 207);
|
||||
panelStorage.Size = new Size(212, 276);
|
||||
panelStorage.TabIndex = 7;
|
||||
//
|
||||
// buttonCollectinDel
|
||||
//
|
||||
buttonCollectinDel.Location = new Point(3, 181);
|
||||
buttonCollectinDel.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonCollectinDel.Location = new Point(3, 241);
|
||||
buttonCollectinDel.Name = "buttonCollectinDel";
|
||||
buttonCollectinDel.Size = new Size(180, 22);
|
||||
buttonCollectinDel.Size = new Size(206, 29);
|
||||
buttonCollectinDel.TabIndex = 6;
|
||||
buttonCollectinDel.Text = "Удалить коллекцию";
|
||||
buttonCollectinDel.UseVisualStyleBackColor = true;
|
||||
@ -192,19 +181,17 @@ namespace ProjectTank
|
||||
// listBoxCollection
|
||||
//
|
||||
listBoxCollection.FormattingEnabled = true;
|
||||
listBoxCollection.ItemHeight = 15;
|
||||
listBoxCollection.Location = new Point(3, 98);
|
||||
listBoxCollection.Margin = new Padding(3, 2, 3, 2);
|
||||
listBoxCollection.ItemHeight = 20;
|
||||
listBoxCollection.Location = new Point(3, 131);
|
||||
listBoxCollection.Name = "listBoxCollection";
|
||||
listBoxCollection.Size = new Size(181, 79);
|
||||
listBoxCollection.Size = new Size(206, 104);
|
||||
listBoxCollection.TabIndex = 5;
|
||||
//
|
||||
// buttonCollectionAdd
|
||||
//
|
||||
buttonCollectionAdd.Location = new Point(3, 72);
|
||||
buttonCollectionAdd.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonCollectionAdd.Location = new Point(3, 96);
|
||||
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||
buttonCollectionAdd.Size = new Size(180, 22);
|
||||
buttonCollectionAdd.Size = new Size(206, 29);
|
||||
buttonCollectionAdd.TabIndex = 4;
|
||||
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||
@ -213,10 +200,9 @@ namespace ProjectTank
|
||||
// radioButtonList
|
||||
//
|
||||
radioButtonList.AutoSize = true;
|
||||
radioButtonList.Location = new Point(93, 50);
|
||||
radioButtonList.Margin = new Padding(3, 2, 3, 2);
|
||||
radioButtonList.Location = new Point(106, 66);
|
||||
radioButtonList.Name = "radioButtonList";
|
||||
radioButtonList.Size = new Size(66, 19);
|
||||
radioButtonList.Size = new Size(80, 24);
|
||||
radioButtonList.TabIndex = 3;
|
||||
radioButtonList.TabStop = true;
|
||||
radioButtonList.Text = "Список";
|
||||
@ -225,10 +211,9 @@ namespace ProjectTank
|
||||
// radioButtonMassive
|
||||
//
|
||||
radioButtonMassive.AutoSize = true;
|
||||
radioButtonMassive.Location = new Point(16, 50);
|
||||
radioButtonMassive.Margin = new Padding(3, 2, 3, 2);
|
||||
radioButtonMassive.Location = new Point(18, 66);
|
||||
radioButtonMassive.Name = "radioButtonMassive";
|
||||
radioButtonMassive.Size = new Size(67, 19);
|
||||
radioButtonMassive.Size = new Size(82, 24);
|
||||
radioButtonMassive.TabIndex = 2;
|
||||
radioButtonMassive.TabStop = true;
|
||||
radioButtonMassive.Text = "Массив";
|
||||
@ -236,18 +221,17 @@ namespace ProjectTank
|
||||
//
|
||||
// textBoxCollectionName
|
||||
//
|
||||
textBoxCollectionName.Location = new Point(3, 25);
|
||||
textBoxCollectionName.Margin = new Padding(3, 2, 3, 2);
|
||||
textBoxCollectionName.Location = new Point(3, 33);
|
||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||
textBoxCollectionName.Size = new Size(181, 23);
|
||||
textBoxCollectionName.Size = new Size(206, 27);
|
||||
textBoxCollectionName.TabIndex = 1;
|
||||
//
|
||||
// labelCollectionName
|
||||
//
|
||||
labelCollectionName.AutoSize = true;
|
||||
labelCollectionName.Location = new Point(24, 8);
|
||||
labelCollectionName.Location = new Point(27, 10);
|
||||
labelCollectionName.Name = "labelCollectionName";
|
||||
labelCollectionName.Size = new Size(125, 15);
|
||||
labelCollectionName.Size = new Size(158, 20);
|
||||
labelCollectionName.TabIndex = 0;
|
||||
labelCollectionName.Text = "Название коллекции:";
|
||||
//
|
||||
@ -257,20 +241,18 @@ namespace ProjectTank
|
||||
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
||||
comboBoxSelectorCompany.Location = new Point(5, 229);
|
||||
comboBoxSelectorCompany.Margin = new Padding(3, 2, 3, 2);
|
||||
comboBoxSelectorCompany.Location = new Point(6, 305);
|
||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||
comboBoxSelectorCompany.Size = new Size(181, 23);
|
||||
comboBoxSelectorCompany.Size = new Size(206, 28);
|
||||
comboBoxSelectorCompany.TabIndex = 0;
|
||||
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Location = new Point(0, 24);
|
||||
pictureBox.Margin = new Padding(3, 2, 3, 2);
|
||||
pictureBox.Location = new Point(0, 28);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(856, 543);
|
||||
pictureBox.Size = new Size(931, 659);
|
||||
pictureBox.TabIndex = 1;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
@ -280,8 +262,7 @@ namespace ProjectTank
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(5, 2, 0, 2);
|
||||
menuStrip.Size = new Size(1047, 24);
|
||||
menuStrip.Size = new Size(1149, 28);
|
||||
menuStrip.TabIndex = 6;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
@ -289,14 +270,14 @@ namespace ProjectTank
|
||||
//
|
||||
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
||||
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||
файлToolStripMenuItem.Size = new Size(48, 20);
|
||||
файлToolStripMenuItem.Size = new Size(59, 24);
|
||||
файлToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
saveToolStripMenuItem.Size = new Size(181, 22);
|
||||
saveToolStripMenuItem.Size = new Size(227, 26);
|
||||
saveToolStripMenuItem.Text = "Сохранение";
|
||||
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||
//
|
||||
@ -304,7 +285,7 @@ namespace ProjectTank
|
||||
//
|
||||
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||
loadToolStripMenuItem.Size = new Size(181, 22);
|
||||
loadToolStripMenuItem.Size = new Size(227, 26);
|
||||
loadToolStripMenuItem.Text = "Загрузка";
|
||||
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||
//
|
||||
@ -318,14 +299,13 @@ namespace ProjectTank
|
||||
//
|
||||
// FormTankCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1047, 567);
|
||||
ClientSize = new Size(1149, 687);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormTankCollection";
|
||||
Text = "Коллекция танков";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
|
@ -1,16 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectTank.CollectionGenericObjects;
|
||||
using ProjectTank.CollectionGenericObjects;
|
||||
using ProjectTank.Drawnings;
|
||||
using ProjectTank.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProjectTank;
|
||||
|
||||
@ -20,29 +9,24 @@ namespace ProjectTank;
|
||||
public partial class FormTankCollection : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Хранилише коллекций
|
||||
/// </summary>
|
||||
private readonly StorageCollection<DrawningTank2> _storageCollection;
|
||||
/// Хранилише коллекций
|
||||
/// </summary>
|
||||
private readonly StorageCollection<DrawningTank2> _storageCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Компания
|
||||
/// </summary>
|
||||
private AbstractCompany? _company = null;
|
||||
|
||||
/// <summary>
|
||||
/// Логер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormTankCollection(ILogger<FormTankCollection> logger)
|
||||
public FormTankCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storageCollection = new();
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выбор компании
|
||||
/// </summary>
|
||||
@ -60,9 +44,10 @@ public partial class FormTankCollection : Form
|
||||
/// <param name="e"></param>
|
||||
public void ButtonAddTank_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormTankConfig form = new FormTankConfig();
|
||||
form.Show();
|
||||
|
||||
FormTankConfig form = new();
|
||||
form.AddEvent(SetMachine);
|
||||
form.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -75,18 +60,14 @@ public partial class FormTankCollection : Form
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
if (_company + tank2 != -1)
|
||||
{
|
||||
var res = _company + tank2;
|
||||
MessageBox.Show("Объект добавлен");
|
||||
_logger.LogInformation($"Объект добавлен под индексом {res}");
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
catch (CollectionOverflowException ex)
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"Объект не добавлен: {ex.Message}", "Результат", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
_logger.LogError($"Ошибка: {ex.Message}", ex.Message);
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +82,6 @@ public partial class FormTankCollection : Form
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
|
||||
{
|
||||
_logger.LogError("Удаление объекта из несуществующей коллекции");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -111,22 +91,14 @@ public partial class FormTankCollection : Form
|
||||
}
|
||||
|
||||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||||
try
|
||||
if (_company - pos != null)
|
||||
{
|
||||
object decrementObject = _company - pos;
|
||||
MessageBox.Show("Объект удален");
|
||||
_logger.LogInformation($"Удален объект по позиции {pos}");
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
catch (ObjectNotFoundException)
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Объект не найден");
|
||||
_logger.LogError($"Удаление не найденного объекта в позиции {pos} ");
|
||||
}
|
||||
catch (PositionOutOfCollectionException)
|
||||
{
|
||||
MessageBox.Show("Удаление вне рамках коллекции");
|
||||
_logger.LogError($"Удаление объекта за пределами коллекции {pos} ");
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,43 +109,41 @@ public partial class FormTankCollection : Form
|
||||
/// <param name="e"></param>
|
||||
private void ButtonGoToCheck_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DrawningTank2? tank = null;
|
||||
int counter = 100;
|
||||
while (tank == null)
|
||||
{
|
||||
tank = _company.GetRandomObject();
|
||||
counter--;
|
||||
if (counter <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tank == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FormTank form = new()
|
||||
{
|
||||
SetTank = tank
|
||||
};
|
||||
form.ShowDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
DrawningTank2? tank = null;
|
||||
int counter = 100;
|
||||
while (tank == null)
|
||||
{
|
||||
tank = _company.GetRandomObject();
|
||||
counter--;
|
||||
if (counter <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tank == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FormTank form = new()
|
||||
{
|
||||
SetTank = tank
|
||||
};
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перерисовка коллекции
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||||
/// <summary>
|
||||
/// Перерисовка коллекции
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
@ -193,7 +163,6 @@ public partial class FormTankCollection : Form
|
||||
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogError("Не заполненная коллекция");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -208,7 +177,6 @@ public partial class FormTankCollection : Form
|
||||
}
|
||||
|
||||
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
|
||||
_logger.LogInformation($"Добавлена коллекция: {textBoxCollectionName.Text}");
|
||||
RerfreshListBoxItems();
|
||||
|
||||
}
|
||||
@ -223,16 +191,13 @@ public partial class FormTankCollection : Form
|
||||
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Коллекция не выбрана");
|
||||
_logger.LogError("Удаление невыбранной коллекции");
|
||||
return;
|
||||
}
|
||||
string name = listBoxCollection.SelectedItem.ToString() ?? string.Empty;
|
||||
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
||||
_logger.LogInformation($"Удалена коллекция: {name}");
|
||||
RerfreshListBoxItems();
|
||||
}
|
||||
|
||||
@ -263,7 +228,6 @@ public partial class FormTankCollection : Form
|
||||
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Коллекция не выбрана");
|
||||
_logger.LogError("Создание компании невыбранной коллекции");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -271,11 +235,9 @@ public partial class FormTankCollection : Form
|
||||
if (collection == null)
|
||||
{
|
||||
MessageBox.Show("Коллекция не проинициализирована");
|
||||
_logger.LogError("Не удалось инициализировать коллекцию");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (comboBoxSelectorCompany.Text)
|
||||
{
|
||||
case "Хранилище":
|
||||
@ -295,16 +257,13 @@ public partial class FormTankCollection : Form
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
if (_storageCollection.SaveData(saveFileDialog.FileName))
|
||||
{
|
||||
_storageCollection.SaveData(saveFileDialog.FileName);
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation("Сохранение в файл: {filename}", saveFileDialog.FileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
else
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,17 +279,16 @@ public partial class FormTankCollection : Form
|
||||
// TODO продумать логику
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
if (_storageCollection.LoadData(openFileDialog.FileName))
|
||||
{
|
||||
_storageCollection.LoadData(openFileDialog.FileName);
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
_logger.LogInformation("Загрузка из файла: {filename}", openFileDialog.FileName);
|
||||
MessageBox.Show("Загрузка прошла успешно",
|
||||
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
RerfreshListBoxItems();
|
||||
}
|
||||
catch (Exception ex)
|
||||
else
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||
MessageBox.Show("Не сохранилось", "Результат",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
119
ProjectTank/ProjectTank/FormTankConfig.Designer.cs
generated
119
ProjectTank/ProjectTank/FormTankConfig.Designer.cs
generated
@ -77,10 +77,8 @@ namespace ProjectTank
|
||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
||||
groupBoxConfig.Dock = DockStyle.Left;
|
||||
groupBoxConfig.Location = new Point(0, 0);
|
||||
groupBoxConfig.Margin = new Padding(3, 2, 3, 2);
|
||||
groupBoxConfig.Name = "groupBoxConfig";
|
||||
groupBoxConfig.Padding = new Padding(3, 2, 3, 2);
|
||||
groupBoxConfig.Size = new Size(551, 249);
|
||||
groupBoxConfig.Size = new Size(630, 274);
|
||||
groupBoxConfig.TabIndex = 0;
|
||||
groupBoxConfig.TabStop = false;
|
||||
groupBoxConfig.Text = "Параметры";
|
||||
@ -95,11 +93,9 @@ namespace ProjectTank
|
||||
groupBoxColors.Controls.Add(panelBlue);
|
||||
groupBoxColors.Controls.Add(panelGreen);
|
||||
groupBoxColors.Controls.Add(panelRed);
|
||||
groupBoxColors.Location = new Point(270, 9);
|
||||
groupBoxColors.Margin = new Padding(3, 2, 3, 2);
|
||||
groupBoxColors.Location = new Point(308, 12);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Padding = new Padding(3, 2, 3, 2);
|
||||
groupBoxColors.Size = new Size(256, 107);
|
||||
groupBoxColors.Size = new Size(293, 143);
|
||||
groupBoxColors.TabIndex = 8;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "Цвета";
|
||||
@ -107,82 +103,73 @@ namespace ProjectTank
|
||||
// panelGray
|
||||
//
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(74, 61);
|
||||
panelGray.Margin = new Padding(3, 2, 3, 2);
|
||||
panelGray.Location = new Point(85, 81);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(43, 34);
|
||||
panelGray.Size = new Size(49, 45);
|
||||
panelGray.TabIndex = 7;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(132, 61);
|
||||
panelBlack.Margin = new Padding(3, 2, 3, 2);
|
||||
panelBlack.Location = new Point(151, 81);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(43, 34);
|
||||
panelBlack.Size = new Size(49, 45);
|
||||
panelBlack.TabIndex = 6;
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(192, 61);
|
||||
panelPurple.Margin = new Padding(3, 2, 3, 2);
|
||||
panelPurple.Location = new Point(220, 81);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(43, 34);
|
||||
panelPurple.Size = new Size(49, 45);
|
||||
panelPurple.TabIndex = 5;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(14, 61);
|
||||
panelWhite.Margin = new Padding(3, 2, 3, 2);
|
||||
panelWhite.Location = new Point(16, 81);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(43, 34);
|
||||
panelWhite.Size = new Size(49, 45);
|
||||
panelWhite.TabIndex = 4;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(192, 20);
|
||||
panelYellow.Margin = new Padding(3, 2, 3, 2);
|
||||
panelYellow.Location = new Point(220, 26);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(43, 34);
|
||||
panelYellow.Size = new Size(49, 45);
|
||||
panelYellow.TabIndex = 3;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(132, 20);
|
||||
panelBlue.Margin = new Padding(3, 2, 3, 2);
|
||||
panelBlue.Location = new Point(151, 26);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(43, 34);
|
||||
panelBlue.Size = new Size(49, 45);
|
||||
panelBlue.TabIndex = 2;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.Green;
|
||||
panelGreen.Location = new Point(74, 20);
|
||||
panelGreen.Margin = new Padding(3, 2, 3, 2);
|
||||
panelGreen.Location = new Point(85, 26);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(43, 34);
|
||||
panelGreen.Size = new Size(49, 45);
|
||||
panelGreen.TabIndex = 1;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(14, 20);
|
||||
panelRed.Margin = new Padding(3, 2, 3, 2);
|
||||
panelRed.Location = new Point(16, 26);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(43, 34);
|
||||
panelRed.Size = new Size(49, 45);
|
||||
panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxGunTurret
|
||||
//
|
||||
checkBoxGunTurret.AutoSize = true;
|
||||
checkBoxGunTurret.Location = new Point(5, 86);
|
||||
checkBoxGunTurret.Margin = new Padding(3, 2, 3, 2);
|
||||
checkBoxGunTurret.Location = new Point(6, 114);
|
||||
checkBoxGunTurret.Name = "checkBoxGunTurret";
|
||||
checkBoxGunTurret.Size = new Size(237, 19);
|
||||
checkBoxGunTurret.Size = new Size(299, 24);
|
||||
checkBoxGunTurret.TabIndex = 9;
|
||||
checkBoxGunTurret.Text = "Признак наличия зенитного пулемёта";
|
||||
checkBoxGunTurret.UseVisualStyleBackColor = true;
|
||||
@ -190,60 +177,57 @@ namespace ProjectTank
|
||||
// checkBoxMachineGun
|
||||
//
|
||||
checkBoxMachineGun.AutoSize = true;
|
||||
checkBoxMachineGun.Location = new Point(5, 108);
|
||||
checkBoxMachineGun.Margin = new Padding(3, 2, 3, 2);
|
||||
checkBoxMachineGun.Location = new Point(6, 144);
|
||||
checkBoxMachineGun.Name = "checkBoxMachineGun";
|
||||
checkBoxMachineGun.Size = new Size(224, 19);
|
||||
checkBoxMachineGun.Size = new Size(281, 24);
|
||||
checkBoxMachineGun.TabIndex = 8;
|
||||
checkBoxMachineGun.Text = "Признак наличия башни с орудием";
|
||||
checkBoxMachineGun.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(82, 52);
|
||||
numericUpDownWeight.Margin = new Padding(3, 2, 3, 2);
|
||||
numericUpDownWeight.Location = new Point(94, 70);
|
||||
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(104, 23);
|
||||
numericUpDownWeight.Size = new Size(119, 27);
|
||||
numericUpDownWeight.TabIndex = 5;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(10, 54);
|
||||
labelWeight.Location = new Point(12, 72);
|
||||
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(104, 23);
|
||||
numericUpDownSpeed.Size = new Size(119, 27);
|
||||
numericUpDownSpeed.TabIndex = 3;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(10, 26);
|
||||
labelSpeed.Location = new Point(12, 34);
|
||||
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(400, 121);
|
||||
labelModifiedObject.Location = new Point(457, 161);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(126, 30);
|
||||
labelModifiedObject.Size = new Size(144, 39);
|
||||
labelModifiedObject.TabIndex = 1;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -252,9 +236,9 @@ namespace ProjectTank
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(270, 121);
|
||||
labelSimpleObject.Location = new Point(308, 161);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(121, 30);
|
||||
labelSimpleObject.Size = new Size(138, 39);
|
||||
labelSimpleObject.TabIndex = 0;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -262,19 +246,17 @@ namespace ProjectTank
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(17, 49);
|
||||
pictureBoxObject.Margin = new Padding(3, 2, 3, 2);
|
||||
pictureBoxObject.Location = new Point(19, 65);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(217, 133);
|
||||
pictureBoxObject.Size = new Size(222, 152);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(559, 206);
|
||||
buttonAdd.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonAdd.Location = new Point(655, 233);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(121, 23);
|
||||
buttonAdd.Size = new Size(94, 29);
|
||||
buttonAdd.TabIndex = 2;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
@ -282,10 +264,9 @@ namespace ProjectTank
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(700, 206);
|
||||
buttonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonCancel.Location = new Point(784, 233);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(109, 23);
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
@ -296,10 +277,9 @@ namespace ProjectTank
|
||||
panelObject.Controls.Add(labelAdditionalColor);
|
||||
panelObject.Controls.Add(labelBodyColor);
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Location = new Point(556, 5);
|
||||
panelObject.Margin = new Padding(3, 2, 3, 2);
|
||||
panelObject.Location = new Point(636, 7);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(253, 197);
|
||||
panelObject.Size = new Size(258, 220);
|
||||
panelObject.TabIndex = 4;
|
||||
panelObject.DragDrop += PanelObject_DragDrop;
|
||||
panelObject.DragEnter += PanelObject_DragEnter;
|
||||
@ -308,9 +288,9 @@ namespace ProjectTank
|
||||
//
|
||||
labelAdditionalColor.AllowDrop = true;
|
||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdditionalColor.Location = new Point(139, 12);
|
||||
labelAdditionalColor.Location = new Point(148, 13);
|
||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
labelAdditionalColor.Size = new Size(95, 30);
|
||||
labelAdditionalColor.Size = new Size(93, 39);
|
||||
labelAdditionalColor.TabIndex = 12;
|
||||
labelAdditionalColor.Text = "Доп. цвет";
|
||||
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -321,9 +301,9 @@ namespace ProjectTank
|
||||
//
|
||||
labelBodyColor.AllowDrop = true;
|
||||
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelBodyColor.Location = new Point(17, 12);
|
||||
labelBodyColor.Location = new Point(19, 13);
|
||||
labelBodyColor.Name = "labelBodyColor";
|
||||
labelBodyColor.Size = new Size(99, 30);
|
||||
labelBodyColor.Size = new Size(93, 39);
|
||||
labelBodyColor.TabIndex = 11;
|
||||
labelBodyColor.Text = "Цвет";
|
||||
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -332,14 +312,13 @@ namespace ProjectTank
|
||||
//
|
||||
// FormTankConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(821, 249);
|
||||
ClientSize = new Size(900, 274);
|
||||
Controls.Add(panelObject);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(groupBoxConfig);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormTankConfig";
|
||||
Text = "Создание объекта";
|
||||
groupBoxConfig.ResumeLayout(false);
|
||||
|
@ -1,49 +1,20 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Serilog;
|
||||
using System;
|
||||
using ProjectTank;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||
{
|
||||
Application.Run(serviceProvider.GetRequiredService<FormTankCollection>());
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormTankCollection>().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}serilog.json", optional: false, reloadOnChange: true)
|
||||
.Build();
|
||||
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(logger);
|
||||
});
|
||||
Application.Run(new FormTankCollection());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -8,18 +8,6 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||
<PackageReference Include="Serilog" Version="4.0.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
|
@ -1,20 +0,0 @@
|
||||
{
|
||||
"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": "Tank"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user