Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d299e84b4 | |||
| 0e4ad75bb6 | |||
| de6700f50c | |||
| 40c8209de7 |
@@ -0,0 +1,10 @@
|
|||||||
|
using ProectMilitaryAircraft.Draw;
|
||||||
|
|
||||||
|
namespace ProectMilitaryAircraft;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Делегат передачи объекта класса - прорисовки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aircraft"></param>
|
||||||
|
public delegate void AircraftDelegate(DrawningAircraft aircraft);
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ public abstract class AbstractCompany
|
|||||||
_pictureWidth = picWidth;
|
_pictureWidth = picWidth;
|
||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_collection = collection;
|
_collection = collection;
|
||||||
_collection.SetMaxCount = GetMaxCount;
|
_collection.MaxCount = GetMaxCount;
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -12,30 +12,82 @@ public class AircraftSharingService : AbstractCompany
|
|||||||
public AircraftSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningAircraft> collection) : base(picWidth, picHeight, collection)
|
public AircraftSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningAircraft> collection) : base(picWidth, picHeight, collection)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
private int? _startPosX;
|
||||||
|
private int? _startPosY;
|
||||||
|
private int? ObjPositionX;
|
||||||
|
private int? ObjPositionY;
|
||||||
|
private void DrawPlace(Graphics g)
|
||||||
|
{
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, _placeSizeWidth, _placeSizeHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawPosition(Graphics g)
|
||||||
|
{
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void DrawBackGround(Graphics g)
|
protected override void DrawBackGround(Graphics g)
|
||||||
{
|
{
|
||||||
Pen pen = new(Color.Black, 3);
|
_startPosX = 0;
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
_startPosY = 0;
|
||||||
|
for (int x = 0; x <= _pictureWidth; x = x + _placeSizeWidth)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; j++)
|
if ((_pictureWidth - _placeSizeWidth) > _startPosX)
|
||||||
{
|
{
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
for (int y = 0; y <= _pictureHeight; y = y + _placeSizeHeight)
|
||||||
|
{
|
||||||
|
if ((_pictureHeight - _placeSizeHeight) > _startPosY)
|
||||||
|
{
|
||||||
|
DrawPlace(g);
|
||||||
|
_startPosY = _startPosY + _placeSizeHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_startPosX = _startPosX + _placeSizeWidth;
|
||||||
|
_startPosY = 0;
|
||||||
}
|
}
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetObjectPosition(Graphics g)
|
protected override void SetObjectPosition(Graphics g)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < _collection?.Count; i++)
|
_startPosX = 5;
|
||||||
|
_startPosY = 5;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (int x = 0; x <= _pictureWidth; x = x + _placeSizeWidth)
|
||||||
|
{
|
||||||
|
if ((_pictureWidth - _placeSizeWidth) > _startPosX)
|
||||||
{
|
{
|
||||||
DrawningAircraft airplane = _collection?.Get(i);
|
ObjPositionX = _startPosX;
|
||||||
if (airplane != null)
|
|
||||||
{
|
for (int y = 0; y <= _pictureHeight; y = y + _placeSizeHeight)
|
||||||
int inRow = _pictureWidth / _placeSizeWidth;
|
{
|
||||||
airplane.SetPosition(((inRow - 1 - (i % inRow)) * _placeSizeWidth), ((_collection.Count / inRow - 1 - i / inRow) * _placeSizeHeight));
|
if ((_pictureHeight - _placeSizeHeight) > _startPosY)
|
||||||
airplane.DrawTransport(g);
|
{
|
||||||
|
ObjPositionY = _startPosY;
|
||||||
|
if (i < (_collection?.Count))
|
||||||
|
{
|
||||||
|
DrawningAircraft obj = _collection.Get(i);
|
||||||
|
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
obj.SetpictureSize(_pictureWidth, _pictureHeight);
|
||||||
|
obj.SetPosition(Convert.ToInt32(ObjPositionX), Convert.ToInt32(ObjPositionY));
|
||||||
|
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
_startPosY = _startPosY + _placeSizeHeight;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_startPosX = _startPosX + _placeSizeWidth;
|
||||||
|
|
||||||
|
_startPosY = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка максимального количества элементов
|
/// Установка максимального количества элементов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int SetMaxCount { set; }
|
int MaxCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию
|
/// Добавление объекта в коллекцию
|
||||||
@@ -53,4 +53,15 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>Объект</returns>
|
/// <returns>Объект</returns>
|
||||||
T? Get(int position);
|
T? Get(int position);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение типа коллекции
|
||||||
|
/// </summary>
|
||||||
|
CollectionType GetCollectionType { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объектов коллекции по одному
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Поэлементый вывод элементов коллекции</returns>
|
||||||
|
IEnumerable<T?> GetItems();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using ProectMilitaryAircraft.Exceptions;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -11,13 +12,13 @@ namespace ProectMilitaryAircraft.CollectionGenericObjects;
|
|||||||
/// Параметризованный набор объектов
|
/// Параметризованный набор объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">Параметр : ограничение - ссылочный тип</typeparam>
|
/// <typeparam name="T">Параметр : ограничение - ссылочный тип</typeparam>
|
||||||
public class ListgenericObjects<T>
|
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Список объектов, которые храниим
|
/// Список объектов, которые храним
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly List<T>? _collection;
|
private readonly List<T?> _collection;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Максимально допустимое число объектов в списке
|
/// Максимально допустимое число объектов в списке
|
||||||
@@ -26,93 +27,96 @@ public class ListgenericObjects<T>
|
|||||||
|
|
||||||
public int Count => _collection.Count;
|
public int Count => _collection.Count;
|
||||||
|
|
||||||
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
public int MaxCount
|
||||||
|
{
|
||||||
|
get => _maxCount;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > 0)
|
||||||
|
{
|
||||||
|
_maxCount = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectionType GetCollectionType => CollectionType.List;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ListgenericObjects(int count)
|
public ListGenericObjects()
|
||||||
{
|
{
|
||||||
_maxCount = count;
|
|
||||||
_collection = new();
|
_collection = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T? Get(int position)
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта из набора позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public T? this[int position]
|
|
||||||
{
|
{
|
||||||
get
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= _maxCount)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _collection?[position];
|
if (position < 0 || position >= Count)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
if (position > _maxCount)
|
||||||
set
|
{
|
||||||
{
|
new CollectionOverflowException();
|
||||||
if (!(position >= 0 && position < Count && _collection?.Count < _maxCount))
|
return null;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_collection?.Insert(position, value);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return _collection[position];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Insert(T obj)
|
public bool Insert(T obj)
|
||||||
{
|
{
|
||||||
if (_collection?.Count == _maxCount)
|
if (Count != _maxCount)
|
||||||
{
|
{
|
||||||
return false;
|
_collection.Add(obj);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if (_collection.Count == _maxCount)
|
||||||
Insert(obj, 0);
|
{
|
||||||
return true;
|
throw new CollectionOverflowException(_maxCount);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Insert(T obj, int position)
|
public bool Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
if (_collection?.Count == _maxCount)
|
if (position > 0 && position <= _maxCount && Count != _maxCount)
|
||||||
{
|
{
|
||||||
return false;
|
_collection.Insert(position, obj);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if (_collection.Count == _maxCount)
|
||||||
Insert(obj, 0);
|
{
|
||||||
return true;
|
throw new CollectionOverflowException(_maxCount);
|
||||||
|
}
|
||||||
|
if (!(Count >= 0 && Count <= Count))
|
||||||
|
{
|
||||||
|
throw new Exception("Неверная позиция для вставки");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (_collection[position] != null)
|
||||||
{
|
{
|
||||||
return false;
|
_collection.RemoveAt(position);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if (!(position >= 0 && position < Count))
|
||||||
_collection?.RemoveAt(position);
|
{
|
||||||
return true;
|
throw new ObjectNotFoundException(position);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public IEnumerable<T?> GetItems()
|
||||||
/// Проход по списку
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public IEnumerable<T?> GetTheAirplanes(int? maxTheAirplanes = null)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _collection?.Count; ++i)
|
for (int i = 0; i < _collection.Count; ++i)
|
||||||
{
|
{
|
||||||
yield return _collection?[i];
|
yield return _collection[i];
|
||||||
if (maxTheAirplanes.HasValue && i == maxTheAirplanes.Value)
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using ProectMilitaryAircraft.Draw;
|
||||||
|
using ProectMilitaryAircraft.Exceptions;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -11,75 +13,148 @@ namespace ProectMilitaryAircraft.CollectionGenericObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">Параметр : Ограничение - ссылочный тип</typeparam>
|
/// <typeparam name="T">Параметр : Ограничение - ссылочный тип</typeparam>
|
||||||
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||||
where T : class
|
where T : DrawningAircraft
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Массив объектов, которые храним
|
/// Массив объектов, которые храним
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private T?[] _massive;
|
private T?[] _collection;
|
||||||
public int Count => _massive.Length;
|
|
||||||
|
|
||||||
public int SetMaxCount { set { if (value > 0) { _massive = new T?[value]; } } }
|
public int Count => _collection.Length;
|
||||||
|
|
||||||
|
public int MaxCount {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _collection.Length;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > 0)
|
||||||
|
{
|
||||||
|
if (_collection.Length > 0)
|
||||||
|
{
|
||||||
|
Array.Resize(ref _collection, value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_collection = new T?[value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectionType GetCollectionType => CollectionType.Massive;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MassiveGenericObjects()
|
public MassiveGenericObjects()
|
||||||
{
|
{
|
||||||
_massive = Array.Empty<T>();
|
_collection = Array.Empty<T?>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count) return null;
|
if (position > MaxCount)
|
||||||
return _massive[position];
|
{
|
||||||
|
throw new CollectionOverflowException(MaxCount);
|
||||||
|
}
|
||||||
|
if (_collection == null)
|
||||||
|
{
|
||||||
|
throw new ObjectNotFoundException();
|
||||||
|
}
|
||||||
|
if (_collection[position] != null)
|
||||||
|
{
|
||||||
|
return _collection[position];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Insert(T obj)
|
public bool Insert(T obj)
|
||||||
{
|
{
|
||||||
int index = 0;
|
if (_collection.Length > Count)
|
||||||
while (_massive[index] != null)
|
|
||||||
{
|
{
|
||||||
index++;
|
throw new CollectionOverflowException(Count);
|
||||||
if (index == Count) { return true; } // false?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (index != 0)
|
for (int i = 0; i < _collection.Length; i++)
|
||||||
{
|
{
|
||||||
_massive[index] = _massive[index - 1];
|
if (_collection[i] == null)
|
||||||
index--;
|
{
|
||||||
|
_collection[i] = obj;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_massive[0] = obj;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Insert(T obj, int position)
|
public bool Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (_collection[position] == null)
|
||||||
{
|
{
|
||||||
return false;
|
_collection[position] = obj;
|
||||||
}
|
|
||||||
if (_massive[position] == null)
|
|
||||||
{
|
|
||||||
_massive[position] = obj;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int index = position;
|
if (position > Count)
|
||||||
while (_massive[index] != null) index++;
|
|
||||||
if (index == Count) return false;
|
|
||||||
for (int i = index; i > position; i--)
|
|
||||||
{
|
{
|
||||||
_massive[i] = _massive[i - 1];
|
throw new CollectionOverflowException(Count);
|
||||||
}
|
}
|
||||||
_massive[position] = obj;
|
|
||||||
return true;
|
if (!(position >= 0 && position <= Count))
|
||||||
|
{
|
||||||
|
throw new Exception("Неверная позиция для вставки");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_collection[position] != null)
|
||||||
|
{
|
||||||
|
for (int i = position; i < _collection.Length; i++)
|
||||||
|
{
|
||||||
|
if (_collection[i] == null)
|
||||||
|
{
|
||||||
|
_collection[i] = obj;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = position; i <= 0; i--)
|
||||||
|
{
|
||||||
|
if (_collection[i] == null)
|
||||||
|
{
|
||||||
|
_collection[i] = obj;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count) return false;
|
if (_collection[position] != null)
|
||||||
_massive[position] = null;
|
{
|
||||||
return true;
|
_collection[position] = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position >= 0 && position < Count)
|
||||||
|
{
|
||||||
|
throw new ObjectNotFoundException(position);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T?> GetItems()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _collection.Length; ++i)
|
||||||
|
{
|
||||||
|
yield return _collection[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using ProectMilitaryAircraft.MovementStrategy;
|
using ProectMilitaryAircraft.Draw;
|
||||||
|
using ProectMilitaryAircraft.Exceptions;
|
||||||
|
using ProectMilitaryAircraft.MovementStrategy;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -8,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
namespace ProectMilitaryAircraft.CollectionGenericObjects;
|
namespace ProectMilitaryAircraft.CollectionGenericObjects;
|
||||||
|
|
||||||
public class StorageCollection<T>
|
public class StorageCollection<T>
|
||||||
where T : class
|
where T : DrawningAircraft
|
||||||
{
|
{
|
||||||
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
||||||
|
|
||||||
@@ -19,6 +21,21 @@ public class StorageCollection<T>
|
|||||||
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ключевое слово, с которого должен начинаться файл
|
||||||
|
/// </summary>
|
||||||
|
private readonly string _collectionKey = "CollectionsStorage";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи ключа и значения элемента словаря
|
||||||
|
/// </summary>
|
||||||
|
private readonly string _separatorForKeyValue = "|";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записей коллекции данных в файл
|
||||||
|
/// </summary>
|
||||||
|
private readonly string _separatorItems = ";";
|
||||||
|
|
||||||
public void AddCollection (string name, CollectionType collectionType)
|
public void AddCollection (string name, CollectionType collectionType)
|
||||||
{
|
{
|
||||||
if (name != null && !_storages.ContainsKey(name))
|
if (name != null && !_storages.ContainsKey(name))
|
||||||
@@ -30,7 +47,7 @@ public class StorageCollection<T>
|
|||||||
}
|
}
|
||||||
if (collectionType == CollectionType.List)
|
if (collectionType == CollectionType.List)
|
||||||
{
|
{
|
||||||
_storages.Add(name, new MassiveGenericObjects<T>());
|
_storages.Add(name, new ListGenericObjects<T>());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -57,4 +74,145 @@ public class StorageCollection<T>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение информации по автомобилям в хранилище в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
public void SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (_storages.Count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("В хранилище отсутствует коллекции для сохранения");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new();
|
||||||
|
|
||||||
|
sb.Append(_collectionKey);
|
||||||
|
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
||||||
|
{
|
||||||
|
sb.Append(Environment.NewLine);
|
||||||
|
// не сохраняем пустые коллекции
|
||||||
|
if (value.Value.Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.Append(value.Key);
|
||||||
|
sb.Append(_separatorForKeyValue);
|
||||||
|
sb.Append(value.Value.GetCollectionType);
|
||||||
|
sb.Append(_separatorForKeyValue);
|
||||||
|
sb.Append(value.Value.Count);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using FileStream fs = new(filename, FileMode.Create);
|
||||||
|
byte[] info = new UTF8Encoding(true).GetBytes(sb.ToString());
|
||||||
|
fs.Write(info, 0, info.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка информации по автомобилям в хранилище из файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
public void LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
throw new Exception("Файл не существует");
|
||||||
|
}
|
||||||
|
|
||||||
|
string bufferTextFromFile = "";
|
||||||
|
using (FileStream fs = new(filename, FileMode.Open))
|
||||||
|
{
|
||||||
|
byte[] b = new byte[fs.Length];
|
||||||
|
UTF8Encoding temp = new(true);
|
||||||
|
while (fs.Read(b, 0, b.Length) > 0)
|
||||||
|
{
|
||||||
|
bufferTextFromFile += temp.GetString(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (strs == null || strs.Length == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("В файле нет данных");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strs[0].Equals(_collectionKey))
|
||||||
|
{
|
||||||
|
throw new Exception("В файле неверные данные");
|
||||||
|
}
|
||||||
|
|
||||||
|
_storages.Clear();
|
||||||
|
foreach (string data in strs)
|
||||||
|
{
|
||||||
|
string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (record.Length != 4)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
|
||||||
|
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
|
||||||
|
if (collection == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Не удалось определить тип коллекции:" + record[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
collection.MaxCount = Convert.ToInt32(record[2]);
|
||||||
|
|
||||||
|
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (string elem in set)
|
||||||
|
{
|
||||||
|
if (elem?.CreateDrawningCar() is T car)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!collection.Insert(car))
|
||||||
|
{
|
||||||
|
throw new Exception("Объект не удалось добавить в коллекцию: " + record[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (CollectionOverflowException ex)
|
||||||
|
{
|
||||||
|
throw new Exception("Коллекция переполнена", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_storages.Add(record[0], collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание коллекции по типу
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collectionType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
|
||||||
|
{
|
||||||
|
return collectionType switch
|
||||||
|
{
|
||||||
|
CollectionType.Massive => new MassiveGenericObjects<T>(),
|
||||||
|
CollectionType.List => new ListGenericObjects<T>(),
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class DrawningAircraft
|
|||||||
/// Верхняя координа прорисовки самолета
|
/// Верхняя координа прорисовки самолета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int? _startPosY;
|
protected int? _startPosY;
|
||||||
|
public DrawningAircraft aircraft;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки самолета
|
/// Ширина прорисовки самолета
|
||||||
@@ -68,14 +69,14 @@ public class DrawningAircraft
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Пустой конструктор
|
/// Пустой конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DrawningAircraft()
|
public DrawningAircraft()
|
||||||
{
|
{
|
||||||
_pictureWidth = null;
|
_pictureWidth = null;
|
||||||
_pictureHeight = null;
|
_pictureHeight = null;
|
||||||
_startPosX = null;
|
_startPosX = null;
|
||||||
_startPosY = null;
|
_startPosY = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -90,7 +91,7 @@ public class DrawningAircraft
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
EntityAircraft = new EntityAircraft(speed, weight, bodyColor);
|
EntityAircraft = new EntityAircraft(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +113,18 @@ public class DrawningAircraft
|
|||||||
_drawingMilitaryAircraftHeight = drawingMilitaryAircraftHeight;
|
_drawingMilitaryAircraftHeight = drawingMilitaryAircraftHeight;
|
||||||
EntityAircraft = new EntityAircraft(speed, weight, bodyColor);
|
EntityAircraft = new EntityAircraft(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор для Drawning
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed"></param>
|
||||||
|
/// <param name="weight"></param>
|
||||||
|
/// <param name="bodyColor"></param>
|
||||||
|
public DrawningAircraft(EntityAircraft entityAircraft)
|
||||||
|
{
|
||||||
|
EntityAircraft = entityAircraft;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка границ поля
|
/// Установка границ поля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -138,8 +151,12 @@ public class DrawningAircraft
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
|
||||||
// то надо изменить координаты, чтобы он оставался в этих границах
|
if (x > _pictureWidth || x < 0 || y > _pictureHeight || y < 0)
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
}
|
}
|
||||||
@@ -169,24 +186,21 @@ public class DrawningAircraft
|
|||||||
return true;
|
return true;
|
||||||
//Вправо
|
//Вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
#pragma warning disable CS8629 // Тип значения, допускающего NULL, может быть NULL.
|
|
||||||
if (_startPosX.Value + EntityAircraft.Step <= _pictureWidth.Value)
|
if (_startPosX.Value + _drawningMilitaryAircraftWidth + EntityAircraft.Step < _pictureWidth)
|
||||||
{
|
{
|
||||||
if (_startPosX + 98 <= _pictureWidth)
|
_startPosX += (int)EntityAircraft.Step;
|
||||||
_startPosX += (int)EntityAircraft.Step;
|
|
||||||
}
|
}
|
||||||
#pragma warning restore CS8629 // Тип значения, допускающего NULL, может быть NULL.
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//Влево
|
//Влево
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
#pragma warning disable CS8629 // Тип значения, допускающего NULL, может быть NULL.
|
|
||||||
if (_startPosY.Value + EntityAircraft.Step <= _pictureHeight.Value)
|
if (_startPosY.Value + _drawingMilitaryAircraftHeight + EntityAircraft.Step < _pictureHeight)
|
||||||
{
|
{
|
||||||
if (_startPosY + 90 <= _pictureHeight)
|
_startPosY += (int)EntityAircraft.Step;
|
||||||
_startPosY += (int)EntityAircraft.Step;
|
|
||||||
}
|
}
|
||||||
#pragma warning restore CS8629 // Тип значения, допускающего NULL, может быть NULL.
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace ProectMilitaryAircraft.Draw;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class DrawningMilitaryAircraft : DrawningAircraft
|
public class DrawningMilitaryAircraft : DrawningAircraft
|
||||||
{
|
{
|
||||||
|
private DrawningAircraft aircraft;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Констуктор
|
/// Констуктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -34,6 +36,25 @@ public class DrawningMilitaryAircraft : DrawningAircraft
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор для DrawningAircraft2
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed"></param>
|
||||||
|
/// <param name="weight"></param>
|
||||||
|
/// <param name="bodyColor"></param>
|
||||||
|
/// <param name="additionalColor"></param>
|
||||||
|
/// <param name="pin"></param>
|
||||||
|
/// <param name="rokets"></param>
|
||||||
|
/// <param name="symbolism"></param>
|
||||||
|
public DrawningMilitaryAircraft(EntityAircraft entityAircraft)
|
||||||
|
{
|
||||||
|
if (entityAircraft != null)
|
||||||
|
{
|
||||||
|
EntityAircraft = entityAircraft;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityAircraft is not EntityMilitaryAircraft airCraft || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityAircraft is not EntityMilitaryAircraft airCraft || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
@@ -44,33 +65,6 @@ public class DrawningMilitaryAircraft : DrawningAircraft
|
|||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush abr = new SolidBrush(airCraft.AdditionalColor);
|
Brush abr = new SolidBrush(airCraft.AdditionalColor);
|
||||||
|
|
||||||
Brush br = new SolidBrush(airCraft.BodyColor);
|
|
||||||
|
|
||||||
//крыло
|
|
||||||
g.FillRectangle(br, _startPosX.Value + 40, _startPosY.Value, 10, 80);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 40, _startPosY.Value, 10, 80);
|
|
||||||
|
|
||||||
//хвост
|
|
||||||
g.FillRectangle(br, _startPosX.Value + 5, _startPosY.Value + 27, 10, 5);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 27, 10, 5);
|
|
||||||
g.FillRectangle(br, _startPosX.Value + 5, _startPosY.Value + 47, 10, 5);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 47, 10, 5);
|
|
||||||
|
|
||||||
//Границы Самолета
|
|
||||||
|
|
||||||
g.FillRectangle(br, _startPosX.Value + 10, _startPosY.Value + 30, 50, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 30, 50, 20);
|
|
||||||
|
|
||||||
//Хвост (центр)
|
|
||||||
g.FillRectangle(br, _startPosX.Value + 2, _startPosY.Value + 37, 10, 5);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 2, _startPosY.Value + 37, 10, 5);
|
|
||||||
|
|
||||||
//Кабина
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 40, _startPosX.Value + 60, _startPosY.Value + 25);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 25, _startPosX.Value + 80, _startPosY.Value + 40);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 80, _startPosY.Value + 40, _startPosX.Value + 60, _startPosY.Value + 55);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 50, _startPosX.Value + 60, _startPosY.Value + 55);
|
|
||||||
|
|
||||||
base.DrawTransport(g);
|
base.DrawTransport(g);
|
||||||
|
|
||||||
//Ракеты
|
//Ракеты
|
||||||
@@ -116,7 +110,7 @@ public class DrawningMilitaryAircraft : DrawningAircraft
|
|||||||
//Носовая часть
|
//Носовая часть
|
||||||
g.FillEllipse(abr, _startPosX.Value + 78, _startPosY.Value + 37, 10, 5);
|
g.FillEllipse(abr, _startPosX.Value + 78, _startPosY.Value + 37, 10, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using ProectMilitaryAircraft.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProectMilitaryAircraft.Draw;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Расширение для класса EntityCar
|
||||||
|
/// </summary>
|
||||||
|
public static class ExtensionDrawningAircraft
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи информации по объекту в файл
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string _separatorForObject = ":";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из строки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Строка с данными для создания объекта</param>
|
||||||
|
/// <returns>Объект</returns>
|
||||||
|
public static DrawningAircraft? CreateDrawningCar(this string info)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(_separatorForObject);
|
||||||
|
EntityAircraft? aircraft = EntityMilitaryAircraft.CreateEntityMilitaryAircraft(strs);
|
||||||
|
if (aircraft != null)
|
||||||
|
{
|
||||||
|
return new DrawningMilitaryAircraft(aircraft);
|
||||||
|
}
|
||||||
|
|
||||||
|
aircraft = EntityAircraft.CreateEntityAircraft(strs);
|
||||||
|
if (aircraft != null)
|
||||||
|
{
|
||||||
|
return new DrawningAircraft(aircraft);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение данных для сохранения в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drawningAircraft">Сохраняемый объект</param>
|
||||||
|
/// <returns>Строка с данными по объекту</returns>
|
||||||
|
public static string GetDataForSave(this DrawningAircraft drawningAircraft)
|
||||||
|
{
|
||||||
|
string[]? array = drawningAircraft?.EntityAircraft?.GetStringRepresentation();
|
||||||
|
|
||||||
|
if (array == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Join(_separatorForObject, array);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,12 @@ namespace ProectMilitaryAircraft.Entities;
|
|||||||
/// Класс-сущность "Cамолет"
|
/// Класс-сущность "Cамолет"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EntityAircraft
|
public class EntityAircraft
|
||||||
{
|
{
|
||||||
|
public void SetBodyColor(Color color)
|
||||||
|
{
|
||||||
|
BodyColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Скорость
|
/// Скорость
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -24,7 +29,7 @@ public class EntityAircraft
|
|||||||
/// Основной цвет
|
/// Основной цвет
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color BodyColor { get; private set; }
|
public Color BodyColor { get; private set; }
|
||||||
public double Step => Speed * 100 / Weight;
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор сущности
|
/// Конструктор сущности
|
||||||
@@ -38,5 +43,29 @@ public class EntityAircraft
|
|||||||
Speed = speed;
|
Speed = speed;
|
||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение строк со значениями свойств объекта класса-сущности
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual string[] GetStringRepresentation()
|
||||||
|
{
|
||||||
|
return new[] { nameof(EntityAircraft), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из массива строк
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strs"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static EntityAircraft? CreateEntityAircraft(string[] strs)
|
||||||
|
{
|
||||||
|
if (strs.Length != 4 || strs[0] != nameof(EntityAircraft))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new EntityAircraft(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,11 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EntityMilitaryAircraft : EntityAircraft
|
public class EntityMilitaryAircraft : EntityAircraft
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public void SAdditionalColor(Color color)
|
||||||
|
{
|
||||||
|
AdditionalColor = color;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Доп. цвет
|
/// Доп. цвет
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -38,4 +43,27 @@ public class EntityMilitaryAircraft : EntityAircraft
|
|||||||
Rokets = rokets;
|
Rokets = rokets;
|
||||||
Symbolism = symbolism;
|
Symbolism = symbolism;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение строк со значениями свойств объекта класса-сущности
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override string[] GetStringRepresentation()
|
||||||
|
{
|
||||||
|
return new[] { nameof(EntityMilitaryAircraft), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, Pin.ToString(), Rokets.ToString(),Symbolism.ToString() };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из массива строк
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strs"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static EntityMilitaryAircraft? CreateEntityMilitaryAircraft(string[] strs)
|
||||||
|
{
|
||||||
|
if (strs.Length != 8 || strs[0] != nameof(EntityMilitaryAircraft))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new EntityMilitaryAircraft(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]), Convert.ToBoolean(strs[7]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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 ProectMilitaryAircraft.Exceptions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс, Описывающий ошибку переполнения коллекции
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class CollectionOverflowException : ApplicationException
|
||||||
|
{
|
||||||
|
public CollectionOverflowException(int count) : base("В коллекции превышено допустимое количество: " + count) { }
|
||||||
|
|
||||||
|
public CollectionOverflowException() : base() { }
|
||||||
|
|
||||||
|
public CollectionOverflowException(string message) : base(message) { }
|
||||||
|
|
||||||
|
public CollectionOverflowException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
|
||||||
|
protected CollectionOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||||
|
}
|
||||||
@@ -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 ProectMilitaryAircraft.Exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс, описывающий ошибку, что по указаной позиции нет элемента
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class ObjectNotFoundException : ApplicationException
|
||||||
|
{
|
||||||
|
public ObjectNotFoundException(int i) : base("Не найден объект по позиции " + i) { }
|
||||||
|
|
||||||
|
public ObjectNotFoundException() : base() { }
|
||||||
|
|
||||||
|
public ObjectNotFoundException(string message) : base(message) { }
|
||||||
|
|
||||||
|
public ObjectNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
|
||||||
|
protected ObjectNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||||
|
}
|
||||||
@@ -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 ProectMilitaryAircraft.Exceptions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс, описывающий ошибку выхода за границы коллекции
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class PositionOutOfCollectionException : ApplicationException
|
||||||
|
{
|
||||||
|
public PositionOutOfCollectionException(int i) : base("Выход за границы коллекции. Позиция " + i) { }
|
||||||
|
|
||||||
|
public PositionOutOfCollectionException() : base() { }
|
||||||
|
|
||||||
|
public PositionOutOfCollectionException(string message) : base(message) { }
|
||||||
|
|
||||||
|
public PositionOutOfCollectionException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
|
||||||
|
protected PositionOutOfCollectionException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||||
|
}
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
panelCompanyTools = new Panel();
|
panelCompanyTools = new Panel();
|
||||||
buttonAddAircraft = new Button();
|
buttonAddAircraft = new Button();
|
||||||
buttonAddMilitaryAircraft = new Button();
|
|
||||||
buttonRefresh = new Button();
|
buttonRefresh = new Button();
|
||||||
maskedTextBox = new MaskedTextBox();
|
maskedTextBox = new MaskedTextBox();
|
||||||
buttonGoToCheck = new Button();
|
buttonGoToCheck = new Button();
|
||||||
@@ -47,10 +46,17 @@
|
|||||||
labelCollectionName = new Label();
|
labelCollectionName = new Label();
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
saveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
loadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
saveFileDialog = new SaveFileDialog();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
panelCompanyTools.SuspendLayout();
|
panelCompanyTools.SuspendLayout();
|
||||||
panelStorage.SuspendLayout();
|
panelStorage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
@@ -60,9 +66,9 @@
|
|||||||
groupBoxTools.Controls.Add(panelStorage);
|
groupBoxTools.Controls.Add(panelStorage);
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
groupBoxTools.Location = new Point(607, 0);
|
groupBoxTools.Location = new Point(607, 24);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(194, 563);
|
groupBoxTools.Size = new Size(194, 560);
|
||||||
groupBoxTools.TabIndex = 0;
|
groupBoxTools.TabIndex = 0;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = " Инструменты";
|
groupBoxTools.Text = " Инструменты";
|
||||||
@@ -70,7 +76,6 @@
|
|||||||
// panelCompanyTools
|
// panelCompanyTools
|
||||||
//
|
//
|
||||||
panelCompanyTools.Controls.Add(buttonAddAircraft);
|
panelCompanyTools.Controls.Add(buttonAddAircraft);
|
||||||
panelCompanyTools.Controls.Add(buttonAddMilitaryAircraft);
|
|
||||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||||
panelCompanyTools.Controls.Add(maskedTextBox);
|
panelCompanyTools.Controls.Add(maskedTextBox);
|
||||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
@@ -92,17 +97,6 @@
|
|||||||
buttonAddAircraft.UseVisualStyleBackColor = true;
|
buttonAddAircraft.UseVisualStyleBackColor = true;
|
||||||
buttonAddAircraft.Click += ButtonAddAircraft_Click;
|
buttonAddAircraft.Click += ButtonAddAircraft_Click;
|
||||||
//
|
//
|
||||||
// buttonAddMilitaryAircraft
|
|
||||||
//
|
|
||||||
buttonAddMilitaryAircraft.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonAddMilitaryAircraft.Location = new Point(4, 45);
|
|
||||||
buttonAddMilitaryAircraft.Name = "buttonAddMilitaryAircraft";
|
|
||||||
buttonAddMilitaryAircraft.Size = new Size(178, 45);
|
|
||||||
buttonAddMilitaryAircraft.TabIndex = 2;
|
|
||||||
buttonAddMilitaryAircraft.Text = "Добавление военного самолета";
|
|
||||||
buttonAddMilitaryAircraft.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddMilitaryAircraft.Click += ButtonAddMilitaryAircraft_Click;
|
|
||||||
//
|
|
||||||
// buttonRefresh
|
// buttonRefresh
|
||||||
//
|
//
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
@@ -252,19 +246,61 @@
|
|||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 0);
|
pictureBox.Location = new Point(0, 24);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(607, 563);
|
pictureBox.Size = new Size(607, 560);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||||
|
menuStrip.Location = new Point(0, 0);
|
||||||
|
menuStrip.Name = "menuStrip";
|
||||||
|
menuStrip.Size = new Size(801, 24);
|
||||||
|
menuStrip.TabIndex = 2;
|
||||||
|
menuStrip.Text = "menuStrip";
|
||||||
|
//
|
||||||
|
// файлToolStripMenuItem
|
||||||
|
//
|
||||||
|
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
||||||
|
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||||
|
файлToolStripMenuItem.Size = new Size(48, 20);
|
||||||
|
файлToolStripMenuItem.Text = "Файл";
|
||||||
|
//
|
||||||
|
// saveToolStripMenuItem
|
||||||
|
//
|
||||||
|
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||||
|
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||||
|
saveToolStripMenuItem.Size = new Size(181, 22);
|
||||||
|
saveToolStripMenuItem.Text = "Сохранение";
|
||||||
|
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// loadToolStripMenuItem
|
||||||
|
//
|
||||||
|
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||||
|
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||||
|
loadToolStripMenuItem.Size = new Size(181, 22);
|
||||||
|
loadToolStripMenuItem.Text = "Загрузка";
|
||||||
|
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
// FormAircraftCollection
|
// FormAircraftCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(801, 563);
|
ClientSize = new Size(801, 584);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
Name = "FormAircraftCollection";
|
Name = "FormAircraftCollection";
|
||||||
Text = "Коллекция самолетов";
|
Text = "Коллекция самолетов";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
@@ -273,14 +309,16 @@
|
|||||||
panelStorage.ResumeLayout(false);
|
panelStorage.ResumeLayout(false);
|
||||||
panelStorage.PerformLayout();
|
panelStorage.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private GroupBox groupBoxTools;
|
private GroupBox groupBoxTools;
|
||||||
private ComboBox comboBoxSelectorCompany;
|
private ComboBox comboBoxSelectorCompany;
|
||||||
private Button buttonAddMilitaryAircraft;
|
|
||||||
private Button buttonAddAircraft;
|
private Button buttonAddAircraft;
|
||||||
private Button buttonRefresh;
|
private Button buttonRefresh;
|
||||||
private Button buttonGoToCheck;
|
private Button buttonGoToCheck;
|
||||||
@@ -297,5 +335,11 @@
|
|||||||
private Button buttonCreateCompany;
|
private Button buttonCreateCompany;
|
||||||
private Button buttonCollectionDel;
|
private Button buttonCollectionDel;
|
||||||
private Panel panelCompanyTools;
|
private Panel panelCompanyTools;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem файлToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem saveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem loadToolStripMenuItem;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using ProectMilitaryAircraft.CollectionGenericObjects;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProectMilitaryAircraft.CollectionGenericObjects;
|
||||||
using ProectMilitaryAircraft.Draw;
|
using ProectMilitaryAircraft.Draw;
|
||||||
|
using ProectMilitaryAircraft.Exceptions;
|
||||||
using ProectMilitaryAircraft.MovementStrategy;
|
using ProectMilitaryAircraft.MovementStrategy;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -28,14 +30,19 @@ public partial class FormAircraftCollection : Form
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private AbstractCompany? _company = null;
|
private AbstractCompany? _company = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Логер
|
||||||
|
/// </summary>
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FormAircraftCollection()
|
public FormAircraftCollection(ILogger<FormAircraftCollection> logger)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_storageCollection = new();
|
_storageCollection = new();
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Выбор компании
|
/// Выбор компании
|
||||||
@@ -44,74 +51,58 @@ public partial class FormAircraftCollection : Form
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ComboBoxSelectorCompany_SelectedValueChanged(object sender, EventArgs e)
|
private void ComboBoxSelectorCompany_SelectedValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
panelCompanyTools.Enabled = false;
|
panelCompanyTools.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание объекта класса-перемещения
|
/// Добавление самолета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type">Тип создаваемого объекта</param>
|
/// <param name="sender"></param>
|
||||||
private void CreateObj(string type)
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAddAircraft_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_company == null)
|
if (listBoxCollection.SelectedIndex == -1) return;
|
||||||
|
var obj = _storageCollection[listBoxCollection.SelectedItem?.ToString() ?? string.Empty];
|
||||||
|
if (obj == null) return;
|
||||||
|
|
||||||
|
FormAircraftConfig form = new();
|
||||||
|
form.Show();
|
||||||
|
form.AddEvent(SetAircraft);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление самолета в коллекцмю
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aircraft"></param>
|
||||||
|
private void SetAircraft(DrawningAircraft aircraft)
|
||||||
|
{
|
||||||
|
if (_company == null || aircraft == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Random rnd = new();
|
|
||||||
DrawningAircraft drawningAircraft;
|
try
|
||||||
switch (type)
|
|
||||||
{
|
{
|
||||||
case nameof(DrawningAircraft):
|
if (_company + aircraft )
|
||||||
drawningAircraft = new DrawningAircraft(rnd.Next(100, 300), rnd.Next(1000, 3000), GetColor(rnd), pictureBox.Width, pictureBox.Height);
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
break;
|
pictureBox.Image = _company.Show();
|
||||||
|
_logger.LogInformation("Объект добавлен", _company);
|
||||||
case nameof(DrawningMilitaryAircraft):
|
}
|
||||||
drawningAircraft = new DrawningMilitaryAircraft(rnd.Next(100, 300), rnd.Next(1000, 3000),
|
else
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
{
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), pictureBox.Width, pictureBox.Height);
|
_logger.LogError("Не удалось добавить объект");
|
||||||
break;
|
}
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (_company + drawningAircraft)
|
catch (CollectionOverflowException ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добаить объект");
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogError("Ошибка: {Message}. Не удалось добавить объект", ex.Message);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBox.Image = _company.Show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Color GetColor(Random random)
|
|
||||||
{
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление обычного самолета
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonAddAircraft_Click(object sender, EventArgs e) => CreateObj(nameof(DrawningAircraft));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление военного самолета
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonAddMilitaryAircraft_Click(object sender, EventArgs e) => CreateObj(nameof(DrawningMilitaryAircraft));
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление самолета
|
/// Удаление самолета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -130,14 +121,20 @@ public partial class FormAircraftCollection : Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||||||
if (_company - pos)
|
try
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
if (_company - pos)
|
||||||
pictureBox.Image = _company.Show();
|
{
|
||||||
|
MessageBox.Show("Объект удален");
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
_logger.LogInformation("Объект удален", _company);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,12 +153,22 @@ public partial class FormAircraftCollection : Form
|
|||||||
int counter = 100;
|
int counter = 100;
|
||||||
while (aircraft == null)
|
while (aircraft == null)
|
||||||
{
|
{
|
||||||
aircraft = _company.GetRandomObject();
|
try
|
||||||
counter--;
|
|
||||||
if (counter <= 0)
|
|
||||||
{
|
{
|
||||||
break;
|
aircraft = _company.GetRandomObject();
|
||||||
|
counter--;
|
||||||
|
if (counter <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Рандомный объект", _company);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aircraft == null) { return; }
|
if (aircraft == null) { return; }
|
||||||
@@ -206,7 +213,7 @@ public partial class FormAircraftCollection : Form
|
|||||||
{
|
{
|
||||||
collectionType = CollectionType.Massive;
|
collectionType = CollectionType.Massive;
|
||||||
}
|
}
|
||||||
else if (radioButtonList.Checked)
|
else if (radioButtonList.Checked)
|
||||||
{
|
{
|
||||||
collectionType = CollectionType.List;
|
collectionType = CollectionType.List;
|
||||||
}
|
}
|
||||||
@@ -238,7 +245,7 @@ public partial class FormAircraftCollection : Form
|
|||||||
private void RefreshListBoxItems()
|
private void RefreshListBoxItems()
|
||||||
{
|
{
|
||||||
listBoxCollection.Items.Clear();
|
listBoxCollection.Items.Clear();
|
||||||
for (int i =0; i < _storageCollection.Keys?.Count; i++)
|
for (int i = 0; i < _storageCollection.Keys?.Count; i++)
|
||||||
{
|
{
|
||||||
string? colName = _storageCollection.Keys?[i];
|
string? colName = _storageCollection.Keys?[i];
|
||||||
if (!string.IsNullOrEmpty(colName))
|
if (!string.IsNullOrEmpty(colName))
|
||||||
@@ -261,7 +268,7 @@ public partial class FormAircraftCollection : Form
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICollectionGenericObjects<DrawningAircraft>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString()?? string.Empty];
|
ICollectionGenericObjects<DrawningAircraft>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
||||||
if (collection == null)
|
if (collection == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Коллкция не проиницилизирована");
|
MessageBox.Show("Коллкция не проиницилизирована");
|
||||||
@@ -271,10 +278,59 @@ public partial class FormAircraftCollection : Form
|
|||||||
switch (comboBoxSelectorCompany.Text)
|
switch (comboBoxSelectorCompany.Text)
|
||||||
{
|
{
|
||||||
case "Хранилище":
|
case "Хранилище":
|
||||||
_company = new AircraftSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningAircraft>());
|
_company = new AircraftSharingService(pictureBox.Width, pictureBox.Height, collection);
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
panelCompanyTools.Enabled = true;
|
panelCompanyTools.Enabled = true;
|
||||||
|
RefreshListBoxItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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);
|
||||||
|
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
RefreshListBoxItems();
|
||||||
|
_logger.LogInformation("Загрузка из файла: {filename}", openFileDialog.FileName);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogError("Ошибка: {Message}", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,4 +117,16 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>16, 5</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>125, 5</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>260, 5</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>48</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
371
ProectMilitaryAircraft/ProectMilitaryAircraft/FormAircraftConfig.Designer.cs
generated
Normal file
371
ProectMilitaryAircraft/ProectMilitaryAircraft/FormAircraftConfig.Designer.cs
generated
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
namespace ProectMilitaryAircraft
|
||||||
|
{
|
||||||
|
partial class FormAircraftConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
groupBoxConfig = new GroupBox();
|
||||||
|
groupBoxColors = new GroupBox();
|
||||||
|
panelPurple = new Panel();
|
||||||
|
panelBlack = new Panel();
|
||||||
|
panelGray = new Panel();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelRed = new Panel();
|
||||||
|
checkBoxSymbolism = new CheckBox();
|
||||||
|
checkBoxRokets = new CheckBox();
|
||||||
|
checkBoxPin = new CheckBox();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
labelWeight = new Label();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
labelSpeed = new Label();
|
||||||
|
labelModifiedObject = new Label();
|
||||||
|
labelSimpleObject = new Label();
|
||||||
|
pictureBoxObject = new PictureBox();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
panelObject = new Panel();
|
||||||
|
labelAdditionalColor = new Label();
|
||||||
|
labelBodyColor = new Label();
|
||||||
|
groupBoxConfig.SuspendLayout();
|
||||||
|
groupBoxColors.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
|
panelObject.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBoxConfig
|
||||||
|
//
|
||||||
|
groupBoxConfig.Controls.Add(groupBoxColors);
|
||||||
|
groupBoxConfig.Controls.Add(checkBoxSymbolism);
|
||||||
|
groupBoxConfig.Controls.Add(checkBoxRokets);
|
||||||
|
groupBoxConfig.Controls.Add(checkBoxPin);
|
||||||
|
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBoxConfig.Controls.Add(labelWeight);
|
||||||
|
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBoxConfig.Controls.Add(labelSpeed);
|
||||||
|
groupBoxConfig.Controls.Add(labelModifiedObject);
|
||||||
|
groupBoxConfig.Controls.Add(labelSimpleObject);
|
||||||
|
groupBoxConfig.Dock = DockStyle.Left;
|
||||||
|
groupBoxConfig.Location = new Point(0, 0);
|
||||||
|
groupBoxConfig.Name = "groupBoxConfig";
|
||||||
|
groupBoxConfig.Size = new Size(496, 314);
|
||||||
|
groupBoxConfig.TabIndex = 0;
|
||||||
|
groupBoxConfig.TabStop = false;
|
||||||
|
groupBoxConfig.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// groupBoxColors
|
||||||
|
//
|
||||||
|
groupBoxColors.Controls.Add(panelPurple);
|
||||||
|
groupBoxColors.Controls.Add(panelBlack);
|
||||||
|
groupBoxColors.Controls.Add(panelGray);
|
||||||
|
groupBoxColors.Controls.Add(panelWhite);
|
||||||
|
groupBoxColors.Controls.Add(panelYellow);
|
||||||
|
groupBoxColors.Controls.Add(panelBlue);
|
||||||
|
groupBoxColors.Controls.Add(panelGreen);
|
||||||
|
groupBoxColors.Controls.Add(panelRed);
|
||||||
|
groupBoxColors.Location = new Point(308, 32);
|
||||||
|
groupBoxColors.Name = "groupBoxColors";
|
||||||
|
groupBoxColors.Size = new Size(154, 89);
|
||||||
|
groupBoxColors.TabIndex = 9;
|
||||||
|
groupBoxColors.TabStop = false;
|
||||||
|
groupBoxColors.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
panelPurple.BackColor = Color.Purple;
|
||||||
|
panelPurple.Location = new Point(114, 55);
|
||||||
|
panelPurple.Name = "panelPurple";
|
||||||
|
panelPurple.Size = new Size(30, 27);
|
||||||
|
panelPurple.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
panelBlack.BackColor = Color.Black;
|
||||||
|
panelBlack.Location = new Point(78, 55);
|
||||||
|
panelBlack.Name = "panelBlack";
|
||||||
|
panelBlack.Size = new Size(30, 27);
|
||||||
|
panelBlack.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
panelGray.BackColor = Color.Gray;
|
||||||
|
panelGray.Location = new Point(42, 55);
|
||||||
|
panelGray.Name = "panelGray";
|
||||||
|
panelGray.Size = new Size(30, 27);
|
||||||
|
panelGray.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(6, 55);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(30, 27);
|
||||||
|
panelWhite.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(114, 22);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(30, 27);
|
||||||
|
panelYellow.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.Blue;
|
||||||
|
panelBlue.Location = new Point(78, 22);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(30, 27);
|
||||||
|
panelBlue.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.Green;
|
||||||
|
panelGreen.Location = new Point(42, 22);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(30, 27);
|
||||||
|
panelGreen.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(6, 22);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(30, 27);
|
||||||
|
panelRed.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// checkBoxSymbolism
|
||||||
|
//
|
||||||
|
checkBoxSymbolism.AutoSize = true;
|
||||||
|
checkBoxSymbolism.Location = new Point(6, 155);
|
||||||
|
checkBoxSymbolism.Name = "checkBoxSymbolism";
|
||||||
|
checkBoxSymbolism.Size = new Size(200, 19);
|
||||||
|
checkBoxSymbolism.TabIndex = 8;
|
||||||
|
checkBoxSymbolism.Text = "Признак наличия \"Символики\"";
|
||||||
|
checkBoxSymbolism.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxRokets
|
||||||
|
//
|
||||||
|
checkBoxRokets.AutoSize = true;
|
||||||
|
checkBoxRokets.Location = new Point(6, 130);
|
||||||
|
checkBoxRokets.Name = "checkBoxRokets";
|
||||||
|
checkBoxRokets.Size = new Size(166, 19);
|
||||||
|
checkBoxRokets.TabIndex = 7;
|
||||||
|
checkBoxRokets.Text = "Признак наличия \"Ракет\"";
|
||||||
|
checkBoxRokets.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxPin
|
||||||
|
//
|
||||||
|
checkBoxPin.AutoSize = true;
|
||||||
|
checkBoxPin.Location = new Point(6, 105);
|
||||||
|
checkBoxPin.Name = "checkBoxPin";
|
||||||
|
checkBoxPin.Size = new Size(274, 19);
|
||||||
|
checkBoxPin.TabIndex = 6;
|
||||||
|
checkBoxPin.Text = "Признак наличия \"Штырь на носу самолета\"";
|
||||||
|
checkBoxPin.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.Location = new Point(74, 58);
|
||||||
|
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(83, 23);
|
||||||
|
numericUpDownWeight.TabIndex = 5;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// labelWeight
|
||||||
|
//
|
||||||
|
labelWeight.AutoSize = true;
|
||||||
|
labelWeight.Location = new Point(6, 60);
|
||||||
|
labelWeight.Name = "labelWeight";
|
||||||
|
labelWeight.Size = new Size(29, 15);
|
||||||
|
labelWeight.TabIndex = 4;
|
||||||
|
labelWeight.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.Location = new Point(74, 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(83, 23);
|
||||||
|
numericUpDownSpeed.TabIndex = 3;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// labelSpeed
|
||||||
|
//
|
||||||
|
labelSpeed.AutoSize = true;
|
||||||
|
labelSpeed.Location = new Point(6, 34);
|
||||||
|
labelSpeed.Name = "labelSpeed";
|
||||||
|
labelSpeed.Size = new Size(62, 15);
|
||||||
|
labelSpeed.TabIndex = 2;
|
||||||
|
labelSpeed.Text = "Скорость:";
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelModifiedObject.Location = new Point(382, 146);
|
||||||
|
labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
labelModifiedObject.Size = new Size(100, 34);
|
||||||
|
labelModifiedObject.TabIndex = 1;
|
||||||
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelSimpleObject.Location = new Point(276, 146);
|
||||||
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
labelSimpleObject.Size = new Size(100, 34);
|
||||||
|
labelSimpleObject.TabIndex = 0;
|
||||||
|
labelSimpleObject.Text = "Простой";
|
||||||
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
pictureBoxObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
pictureBoxObject.Location = new Point(3, 63);
|
||||||
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
pictureBoxObject.Size = new Size(224, 164);
|
||||||
|
pictureBoxObject.TabIndex = 1;
|
||||||
|
pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(505, 240);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 23);
|
||||||
|
buttonAdd.TabIndex = 2;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(605, 240);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(75, 23);
|
||||||
|
buttonCancel.TabIndex = 3;
|
||||||
|
buttonCancel.Text = "Отменить";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// panelObject
|
||||||
|
//
|
||||||
|
panelObject.AllowDrop = true;
|
||||||
|
panelObject.Controls.Add(labelAdditionalColor);
|
||||||
|
panelObject.Controls.Add(labelBodyColor);
|
||||||
|
panelObject.Controls.Add(pictureBoxObject);
|
||||||
|
panelObject.Location = new Point(502, 4);
|
||||||
|
panelObject.Name = "panelObject";
|
||||||
|
panelObject.Size = new Size(230, 230);
|
||||||
|
panelObject.TabIndex = 4;
|
||||||
|
panelObject.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelObject.DragEnter += PanelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// labelAdditionalColor
|
||||||
|
//
|
||||||
|
labelAdditionalColor.AllowDrop = true;
|
||||||
|
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelAdditionalColor.Location = new Point(145, 0);
|
||||||
|
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||||
|
labelAdditionalColor.Size = new Size(85, 46);
|
||||||
|
labelAdditionalColor.TabIndex = 3;
|
||||||
|
labelAdditionalColor.Text = "Доп. цвет";
|
||||||
|
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelAdditionalColor.DragDrop += LabelColor_DragDrop;
|
||||||
|
labelAdditionalColor.DragEnter += LabelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// labelBodyColor
|
||||||
|
//
|
||||||
|
labelBodyColor.AllowDrop = true;
|
||||||
|
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelBodyColor.Location = new Point(0, 0);
|
||||||
|
labelBodyColor.Name = "labelBodyColor";
|
||||||
|
labelBodyColor.Size = new Size(88, 46);
|
||||||
|
labelBodyColor.TabIndex = 2;
|
||||||
|
labelBodyColor.Text = "Цвет";
|
||||||
|
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelBodyColor.DragDrop += LabelColor_DragDrop;
|
||||||
|
labelBodyColor.DragEnter += LabelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// FormAircraftConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(810, 314);
|
||||||
|
Controls.Add(panelObject);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(groupBoxConfig);
|
||||||
|
Name = "FormAircraftConfig";
|
||||||
|
Text = "Созданиие объекта";
|
||||||
|
groupBoxConfig.ResumeLayout(false);
|
||||||
|
groupBoxConfig.PerformLayout();
|
||||||
|
groupBoxColors.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
|
panelObject.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxConfig;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private Label labelWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Label labelSpeed;
|
||||||
|
private CheckBox checkBoxPin;
|
||||||
|
private CheckBox checkBoxSymbolism;
|
||||||
|
private CheckBox checkBoxRokets;
|
||||||
|
private GroupBox groupBoxColors;
|
||||||
|
private Panel panelPurple;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelGray;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelRed;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Panel panelObject;
|
||||||
|
private Label labelAdditionalColor;
|
||||||
|
private Label labelBodyColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
using ProectMilitaryAircraft.Draw;
|
||||||
|
using ProectMilitaryAircraft.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ProectMilitaryAircraft;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Форма конфигурации объекта
|
||||||
|
/// </summary>
|
||||||
|
public partial class FormAircraftConfig : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Объект - прорисовка самолета
|
||||||
|
/// </summary>
|
||||||
|
private DrawningAircraft? _aircraft;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Событие для передачи объекта
|
||||||
|
/// </summary>
|
||||||
|
private event AircraftDelegate? _aircraftDelegate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public FormAircraftConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
panelRed.MouseDown += Panel_MouseDown;
|
||||||
|
panelGreen.MouseDown += Panel_MouseDown;
|
||||||
|
panelYellow.MouseDown += Panel_MouseDown;
|
||||||
|
panelWhite.MouseDown += Panel_MouseDown;
|
||||||
|
panelGray.MouseDown += Panel_MouseDown;
|
||||||
|
panelBlack.MouseDown += Panel_MouseDown;
|
||||||
|
panelBlue.MouseDown += Panel_MouseDown;
|
||||||
|
panelPurple.MouseDown += Panel_MouseDown;
|
||||||
|
buttonCancel.Click += (sender, e) => Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Привязка внешнего метода к событию
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aircraftDelegate"></param>
|
||||||
|
public void AddEvent(AircraftDelegate aircraftDelegate)
|
||||||
|
{
|
||||||
|
_aircraftDelegate += aircraftDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Отрисовка объекта
|
||||||
|
/// </summary>
|
||||||
|
private void DrawObject()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_aircraft?.SetpictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
_aircraft?.SetPosition(5, 5);
|
||||||
|
_aircraft?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Передаем информацию при нажатии на Label
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Проверка получаемой инф. (ее типа на соотв. требуемому)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Действия при приеме перетаскиваемой информации
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject":
|
||||||
|
_aircraft = new DrawningAircraft((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_aircraft = new DrawningMilitaryAircraft((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPin.Checked, checkBoxRokets.Checked, checkBoxSymbolism.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Передаем информацию принажатии на Panel
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void Panel_MouseDown(object? sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//todo прописать логику смены цветов для продвинутого объекта
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Передача объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_aircraft != null)
|
||||||
|
{
|
||||||
|
_aircraftDelegate?.Invoke(_aircraft);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_aircraft == null) return;
|
||||||
|
switch (((Label)sender).Name)
|
||||||
|
{
|
||||||
|
case "labelBodyColor":
|
||||||
|
_aircraft.EntityAircraft?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
case "labelAdditionalColor":
|
||||||
|
if (_aircraft == null) return;
|
||||||
|
(_aircraft.EntityAircraft as EntityMilitaryAircraft)?.SAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -8,6 +8,11 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
@@ -23,4 +28,10 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="nlog.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using NLog.Extensions.Logging;
|
||||||
|
|
||||||
namespace ProectMilitaryAircraft
|
namespace ProectMilitaryAircraft
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@@ -10,8 +14,28 @@ namespace ProectMilitaryAircraft
|
|||||||
{
|
{
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormAircraftCollection());
|
ServiceCollection services = new();
|
||||||
|
ConfigureServices(services);
|
||||||
|
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||||
|
{
|
||||||
|
Application.Run(serviceProvider.GetRequiredService<FormAircraftCollection>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSingleton<FormAircraftCollection>()
|
||||||
|
.AddLogging(option =>
|
||||||
|
{
|
||||||
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
|
option.AddNLog("nlog.config");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
15
ProectMilitaryAircraft/ProectMilitaryAircraft/nlog.config
Normal file
15
ProectMilitaryAircraft/ProectMilitaryAircraft/nlog.config
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?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="carlog-${shortdate}.log" />
|
||||||
|
</targets>
|
||||||
|
|
||||||
|
<rules>
|
||||||
|
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
||||||
|
</configuration>
|
||||||
Reference in New Issue
Block a user