z
This commit is contained in:
parent
eed42ea361
commit
d4623e82cd
@ -1,7 +1,7 @@
|
||||
using ProjectCruiser.Drawnings;
|
||||
using ProjectCruiser.Exceptions;
|
||||
using ProjectPlane.Drawnings;
|
||||
using ProjectPlane.Exceptions;
|
||||
|
||||
namespace ProjectCruiser.CollectionGenericObjects
|
||||
namespace ProjectPlane.CollectionGenericObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Абстракция компании, хранящий коллекцию автомобилей
|
||||
@ -29,9 +29,9 @@ namespace ProjectCruiser.CollectionGenericObjects
|
||||
protected readonly int _pictureHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Коллекция крейсеров
|
||||
/// Коллекция самолетов
|
||||
/// </summary>
|
||||
protected ICollectionGenericObjects<DrawningCruiser>? _collection = null;
|
||||
protected ICollectionGenericObjects<DrawningPlane>? _collection = null;
|
||||
|
||||
/// <summary>
|
||||
/// Вычисление максимального количества элементов, который можно разместить в окне
|
||||
@ -45,7 +45,7 @@ namespace ProjectCruiser.CollectionGenericObjects
|
||||
/// <param name="picHeight">Высота окна</param>
|
||||
/// <param name="collection">Коллекция автомобилей</param>
|
||||
public AbstractCompany(int picWidth, int picHeight,
|
||||
ICollectionGenericObjects<DrawningCruiser> collection)
|
||||
ICollectionGenericObjects<DrawningPlane> collection)
|
||||
{
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
@ -59,7 +59,7 @@ namespace ProjectCruiser.CollectionGenericObjects
|
||||
/// <param name="company">Компания</param>
|
||||
/// <param name="сruiser">Добавляемый объект</param>
|
||||
/// <returns></returns>
|
||||
public static int operator +(AbstractCompany company, DrawningCruiser сruiser)
|
||||
public static int operator +(AbstractCompany company, DrawningPlane сruiser)
|
||||
{
|
||||
return company._collection.Insert(сruiser);
|
||||
}
|
||||
@ -70,7 +70,7 @@ namespace ProjectCruiser.CollectionGenericObjects
|
||||
/// <param name="company">Компания</param>
|
||||
/// <param name="position">Номер удаляемого объекта</param>
|
||||
/// <returns></returns>
|
||||
public static DrawningCruiser operator -(AbstractCompany company, int position)
|
||||
public static DrawningPlane operator -(AbstractCompany company, int position)
|
||||
{
|
||||
return company._collection?.Remove(position);
|
||||
}
|
||||
@ -79,7 +79,7 @@ namespace ProjectCruiser.CollectionGenericObjects
|
||||
/// Получение случайного объекта из коллекции
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DrawningCruiser? GetRandomObject()
|
||||
public DrawningPlane? GetRandomObject()
|
||||
{
|
||||
Random rnd = new();
|
||||
return _collection?.Get(rnd.Next(GetMaxCount));
|
||||
@ -99,7 +99,7 @@ namespace ProjectCruiser.CollectionGenericObjects
|
||||
{
|
||||
try
|
||||
{
|
||||
DrawningCruiser? obj = _collection?.Get(i);
|
||||
DrawningPlane? obj = _collection?.Get(i);
|
||||
obj?.DrawTransport(graphics);
|
||||
}
|
||||
catch (ObjectNotFoundException e)
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.CollectionGenericObjects
|
||||
namespace ProjectPlane.CollectionGenericObjects
|
||||
{
|
||||
public enum CollectionType
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
using ProjectCruiser.Drawnings;
|
||||
using ProjectCruiser.Exceptions;
|
||||
using ProjectPlane.Drawnings;
|
||||
using ProjectPlane.Exceptions;
|
||||
|
||||
namespace ProjectCruiser.CollectionGenericObjects
|
||||
namespace ProjectPlane.CollectionGenericObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Реализация абстрактной компании - каршеринг
|
||||
/// </summary>
|
||||
public class CruiserDockingService : AbstractCompany
|
||||
public class PlaneDockingService : AbstractCompany
|
||||
{
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
@ -14,8 +14,8 @@ namespace ProjectCruiser.CollectionGenericObjects
|
||||
/// <param name="picWidth"></param>
|
||||
/// <param name="picHeight"></param>
|
||||
/// <param name="collection"></param>
|
||||
public CruiserDockingService(int picWidth, int picHeight,
|
||||
ICollectionGenericObjects<DrawningCruiser> collection) : base(picWidth, picHeight, collection)
|
||||
public PlaneDockingService(int picWidth, int picHeight,
|
||||
ICollectionGenericObjects<DrawningPlane> collection) : base(picWidth, picHeight, collection)
|
||||
{
|
||||
}
|
||||
protected override void DrawBackgound(Graphics g)
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.CollectionGenericObjects
|
||||
namespace ProjectPlane.CollectionGenericObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Интерфейс описания действий для набора хранимых объектов
|
||||
|
@ -1,6 +1,6 @@
|
||||
using ProjectCruiser.Exceptions;
|
||||
using ProjectPlane.Exceptions;
|
||||
|
||||
namespace ProjectCruiser.CollectionGenericObjects
|
||||
namespace ProjectPlane.CollectionGenericObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
|
@ -1,6 +1,6 @@
|
||||
using ProjectCruiser.Exceptions;
|
||||
using ProjectPlane.Exceptions;
|
||||
|
||||
namespace ProjectCruiser.CollectionGenericObjects
|
||||
namespace ProjectPlane.CollectionGenericObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
|
@ -1,14 +1,14 @@
|
||||
using ProjectCruiser.Drawnings;
|
||||
using ProjectCruiser.Exceptions;
|
||||
using ProjectPlane.Drawnings;
|
||||
using ProjectPlane.Exceptions;
|
||||
using System.Text;
|
||||
|
||||
namespace ProjectCruiser.CollectionGenericObjects
|
||||
namespace ProjectPlane.CollectionGenericObjects
|
||||
{
|
||||
// Класс-хранилище коллекций
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class StorageCollection<T>
|
||||
where T : DrawningCruiser
|
||||
where T : DrawningPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с коллекциями
|
||||
@ -180,7 +180,7 @@ namespace ProjectCruiser.CollectionGenericObjects
|
||||
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
if (elem?.CreateDrawningCruiser() is T aircraft)
|
||||
if (elem?.CreateDrawningPlane() is T aircraft)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
using ProjectCruiser.Drawnings;
|
||||
using ProjectPlane.Drawnings;
|
||||
|
||||
namespace ProjectCruiser;
|
||||
namespace ProjectPlane;
|
||||
|
||||
/// <summary>
|
||||
/// Делегат передачи объекта класса-прорисвоки
|
||||
/// </summary>
|
||||
/// <param name="cruiser"></param>
|
||||
public delegate void CruiserDelegate(DrawningCruiser cruiser);
|
||||
/// <param name="plane"></param>
|
||||
public delegate void PlaneDelegate(DrawningPlane plane);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.Drawnings;
|
||||
namespace ProjectPlane.Drawnings;
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
/// </summary>
|
||||
|
@ -1,15 +1,15 @@
|
||||
using ProjectCruiser.Entities;
|
||||
using ProjectPlane.Entities;
|
||||
|
||||
namespace ProjectCruiser.Drawnings;
|
||||
namespace ProjectPlane.Drawnings;
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningCruiser
|
||||
public class DrawningPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityCruiser? EntityCruiser { get; protected set; }
|
||||
public EntityPlane? EntityPlane { get; protected set; }
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
@ -19,22 +19,22 @@ public class DrawningCruiser
|
||||
/// </summary>
|
||||
private int? _pictureHeight;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки крейсера
|
||||
/// Левая координата прорисовки самолета
|
||||
/// </summary>
|
||||
protected int? _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната прорисовки крейсера
|
||||
/// Верхняя кооридната прорисовки самолета
|
||||
/// </summary>
|
||||
protected int? _startPosY;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина прорисовки крейсера
|
||||
/// Ширина прорисовки самолета
|
||||
/// </summary>
|
||||
private readonly int _drawningCruiserWidth = 150;
|
||||
private readonly int _drawningPlaneWidth = 150;
|
||||
/// <summary>
|
||||
/// Высота прорисовки крейсера
|
||||
/// Высота прорисовки самолета
|
||||
/// </summary>
|
||||
private readonly int _drawningCruiserHeight = 50;
|
||||
private readonly int _drawningPlaneHeight = 50;
|
||||
private readonly int _drawningEnginesWidth = 3;
|
||||
|
||||
/// <summary>
|
||||
@ -48,16 +48,16 @@ public class DrawningCruiser
|
||||
/// <summary>
|
||||
/// Ширина объекта
|
||||
/// </summary>
|
||||
public int GetWidth => _drawningCruiserWidth;
|
||||
public int GetWidth => _drawningPlaneWidth;
|
||||
/// <summary>
|
||||
/// Высота объекта
|
||||
/// </summary>
|
||||
public int GetHeight => _drawningCruiserHeight;
|
||||
public int GetHeight => _drawningPlaneHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Пустой онструктор
|
||||
/// </summary>
|
||||
public DrawningCruiser()
|
||||
public DrawningPlane()
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
@ -71,28 +71,28 @@ public class DrawningCruiser
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
public DrawningCruiser(int speed, double weight, Color bodyColor) : this()
|
||||
public DrawningPlane(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
EntityCruiser = new EntityCruiser(speed, weight, bodyColor);
|
||||
EntityPlane = new EntityPlane(speed, weight, bodyColor);
|
||||
}
|
||||
/// <summary>
|
||||
/// Конструктор для наследников
|
||||
/// </summary>
|
||||
/// <param name="drawningCarWidth">Ширина прорисовки автомобиля</param>
|
||||
/// <param name="drawningCarHeight">Высота прорисовки автомобиля</param>
|
||||
protected DrawningCruiser(int drawningCarWidth, int drawningCarHeight) : this()
|
||||
protected DrawningPlane(int drawningCarWidth, int drawningCarHeight) : this()
|
||||
{
|
||||
_drawningCruiserWidth = drawningCarWidth;
|
||||
_drawningPlaneWidth = drawningCarWidth;
|
||||
_pictureHeight = drawningCarHeight;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// конструктор
|
||||
/// </summary>
|
||||
/// <param name="entityCruiser"></param>
|
||||
public DrawningCruiser(EntityCruiser entityCruiser)
|
||||
/// <param name="entityPlane"></param>
|
||||
public DrawningPlane(EntityPlane entityPlane)
|
||||
{
|
||||
EntityCruiser = entityCruiser;
|
||||
EntityPlane = entityPlane;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -106,7 +106,7 @@ public class DrawningCruiser
|
||||
// TODO проверка, что объект "влезает" в размеры поля
|
||||
// если влезает, сохраняем границы и корректируем позицию объекта,если она была уже установлена
|
||||
|
||||
if (_drawningCruiserHeight > height || _drawningCruiserWidth > width)
|
||||
if (_drawningPlaneHeight > height || _drawningPlaneWidth > width)
|
||||
{
|
||||
return false;
|
||||
|
||||
@ -134,10 +134,10 @@ public class DrawningCruiser
|
||||
return;
|
||||
}
|
||||
|
||||
if (x < 0 || x + _drawningCruiserWidth > _pictureWidth || y < 0 || y + _drawningCruiserHeight > _pictureHeight)
|
||||
if (x < 0 || x + _drawningPlaneWidth > _pictureWidth || y < 0 || y + _drawningPlaneHeight > _pictureHeight)
|
||||
{
|
||||
_startPosX = _pictureWidth - _drawningCruiserWidth;
|
||||
_startPosY = _pictureHeight - _drawningCruiserHeight;
|
||||
_startPosX = _pictureWidth - _drawningPlaneWidth;
|
||||
_startPosY = _pictureHeight - _drawningPlaneHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -153,7 +153,7 @@ public class DrawningCruiser
|
||||
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityCruiser == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
if (EntityPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -161,31 +161,31 @@ public class DrawningCruiser
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityCruiser.Step - _drawningEnginesWidth > 0)
|
||||
if (_startPosX.Value - EntityPlane.Step - _drawningEnginesWidth > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityCruiser.Step;
|
||||
_startPosX -= (int)EntityPlane.Step;
|
||||
}
|
||||
return true;
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityCruiser.Step > 0)
|
||||
if (_startPosY.Value - EntityPlane.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityCruiser.Step;
|
||||
_startPosY -= (int)EntityPlane.Step;
|
||||
}
|
||||
return true;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
//TODO прописать логику сдвига в право
|
||||
if (_startPosX.Value + EntityCruiser.Step + _drawningCruiserWidth < _pictureWidth)
|
||||
if (_startPosX.Value + EntityPlane.Step + _drawningPlaneWidth < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityCruiser.Step;
|
||||
_startPosX += (int)EntityPlane.Step;
|
||||
}
|
||||
return true;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + EntityCruiser.Step + _drawningCruiserHeight < _pictureHeight)
|
||||
if (_startPosY.Value + EntityPlane.Step + _drawningPlaneHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityCruiser.Step;
|
||||
_startPosY += (int)EntityPlane.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
@ -199,15 +199,15 @@ public class DrawningCruiser
|
||||
/// <param name="g"></param>
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityCruiser == null || !_startPosX.HasValue ||
|
||||
if (EntityPlane == null || !_startPosX.HasValue ||
|
||||
!_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(EntityCruiser.BodyColor, 2);
|
||||
Pen pen = new(EntityPlane.BodyColor, 2);
|
||||
Brush additionalBrush = new SolidBrush(Color.Black);
|
||||
|
||||
//границы круисера
|
||||
//границы самолета
|
||||
g.DrawLine(pen, _startPosX.Value, _startPosY.Value, _startPosX.Value + 105, _startPosY.Value);
|
||||
g.DrawLine(pen, _startPosX.Value + 105, _startPosY.Value, _startPosX.Value + 147, _startPosY.Value + 24);
|
||||
|
||||
@ -216,7 +216,7 @@ public class DrawningCruiser
|
||||
|
||||
g.DrawLine(pen, _startPosX.Value, _startPosY.Value, _startPosX.Value, _startPosY.Value + 49);
|
||||
|
||||
//внутренности круисера
|
||||
//внутренности самолета
|
||||
g.DrawEllipse(pen, _startPosX.Value + 94, _startPosY.Value + 14, 19, 19);
|
||||
|
||||
g.DrawRectangle(pen, _startPosX.Value + 63, _startPosY.Value + 11, 21, 28);
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Drawing.Drawing2D;
|
||||
using ProjectCruiser.Entities;
|
||||
using ProjectPlane.Entities;
|
||||
|
||||
namespace ProjectCruiser.Drawnings
|
||||
namespace ProjectPlane.Drawnings
|
||||
{
|
||||
public class DrawningMilitaryCruiser : DrawningCruiser
|
||||
public class DrawningSeaPlane : DrawningPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
@ -12,48 +12,48 @@ namespace ProjectCruiser.Drawnings
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="helicopterArea">Признак наличия вертолетной площадки</param>
|
||||
/// <param name="boat">Признак наличия шлюпок</param>
|
||||
/// <param name="weapon">Признак наличия пушки</param>
|
||||
/// <param name="line">Признак наличия линии</param>
|
||||
/// <param name="boat">Признак наличия шлюпки</param>
|
||||
/// <param name="floats">Признак наличия поплавков</param>
|
||||
|
||||
public DrawningMilitaryCruiser(int speed, double weight, Color bodyColor, Color additionalColor, bool helicopterArea, bool boat, bool weapon)
|
||||
public DrawningSeaPlane(int speed, double weight, Color bodyColor, Color additionalColor, bool line, bool boat, bool floats)
|
||||
: base(150, 50)
|
||||
{
|
||||
EntityCruiser = new EntityMilitaryCruiser(speed, weight, bodyColor, additionalColor, helicopterArea, boat, weapon);
|
||||
EntityPlane = new EntitySeaPlane(speed, weight, bodyColor, additionalColor, line, boat, floats);
|
||||
}
|
||||
|
||||
public DrawningMilitaryCruiser(EntityCruiser entityCruiser)
|
||||
public DrawningSeaPlane(EntityPlane entityPlane)
|
||||
{
|
||||
if (entityCruiser != null)
|
||||
if (entityPlane != null)
|
||||
{
|
||||
EntityCruiser = entityCruiser;
|
||||
EntityPlane = entityPlane;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityCruiser == null || EntityCruiser is not EntityMilitaryCruiser entityMilitaryCruiser || !_startPosX.HasValue ||
|
||||
if (EntityPlane == null || EntityPlane is not EntitySeaPlane entitySeaPlane || !_startPosX.HasValue ||
|
||||
!_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(entityMilitaryCruiser.BodyColor, 2);
|
||||
Pen pen = new(entitySeaPlane.BodyColor, 2);
|
||||
Brush additionalBrush = new SolidBrush(Color.Black);
|
||||
Brush weaponBrush = new SolidBrush(Color.Black);
|
||||
Brush weaponBrush2 = new SolidBrush(entityMilitaryCruiser.AdditionalColor);
|
||||
Brush helicopterAreaBrush = new HatchBrush(HatchStyle.ZigZag, entityMilitaryCruiser.AdditionalColor, Color.FromArgb(163, 163, 163));
|
||||
Brush boatBrush = new SolidBrush(entityMilitaryCruiser.AdditionalColor);
|
||||
Brush floatsBrush = new SolidBrush(Color.Black);
|
||||
Brush floatsBrush2 = new SolidBrush(entitySeaPlane.AdditionalColor);
|
||||
Brush lineBrush = new HatchBrush(HatchStyle.ZigZag, entitySeaPlane.AdditionalColor, Color.FromArgb(163, 163, 163));
|
||||
Brush boatBrush = new SolidBrush(entitySeaPlane.AdditionalColor);
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
if (entityMilitaryCruiser.HelicopterArea)
|
||||
if (entitySeaPlane.Line)
|
||||
{
|
||||
g.FillEllipse(helicopterAreaBrush, _startPosX.Value + 5, _startPosY.Value + 9, 25, 30);
|
||||
g.FillEllipse(lineBrush, _startPosX.Value + 5, _startPosY.Value + 9, 25, 30);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 5, _startPosY.Value + 9, 25, 30);
|
||||
}
|
||||
|
||||
if (entityMilitaryCruiser.Boat)
|
||||
if (entitySeaPlane.Boat)
|
||||
{
|
||||
g.DrawEllipse(pen, _startPosX.Value + 34, _startPosY.Value + 2, 30, 7);
|
||||
g.FillEllipse(boatBrush, _startPosX.Value + 34, _startPosY.Value + 2, 30, 7);
|
||||
@ -62,12 +62,12 @@ namespace ProjectCruiser.Drawnings
|
||||
g.FillEllipse(boatBrush, _startPosX.Value + 34, _startPosY.Value + 39, 30, 7);
|
||||
}
|
||||
|
||||
if (entityMilitaryCruiser.Weapon)
|
||||
if (entitySeaPlane.Floats)
|
||||
{
|
||||
g.DrawEllipse(pen, _startPosX.Value + 97, _startPosY.Value + 36, 10, 10);
|
||||
g.FillEllipse(weaponBrush2, _startPosX.Value + 97, _startPosY.Value + 36, 10, 10);
|
||||
g.FillEllipse(floatsBrush2, _startPosX.Value + 97, _startPosY.Value + 36, 10, 10);
|
||||
|
||||
g.FillRectangle(weaponBrush, _startPosX.Value + 107, _startPosY.Value + 40, 15, 5);
|
||||
g.FillRectangle(floatsBrush, _startPosX.Value + 107, _startPosY.Value + 40, 15, 5);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using ProjectCruiser.Entities;
|
||||
using ProjectPlane.Entities;
|
||||
|
||||
namespace ProjectCruiser.Drawnings
|
||||
namespace ProjectPlane.Drawnings
|
||||
{
|
||||
public static class ExtentionDrawningCruiser
|
||||
public static class ExtentionDrawningPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
@ -14,19 +14,19 @@ namespace ProjectCruiser.Drawnings
|
||||
/// </summary>
|
||||
/// <param name="info">Строка с данными для создания объекта</param>
|
||||
/// <returns>Объект</returns>
|
||||
public static DrawningCruiser? CreateDrawningCruiser(this string info)
|
||||
public static DrawningPlane? CreateDrawningPlane(this string info)
|
||||
{
|
||||
string[] strs = info.Split(_separatorForObject);
|
||||
EntityCruiser? cruiser = EntityMilitaryCruiser.CreateEntityMilitaryCruiser(strs);
|
||||
if (cruiser != null)
|
||||
EntityPlane? plane = EntitySeaPlane.CreateEntitySeaPlane(strs);
|
||||
if (plane != null)
|
||||
{
|
||||
return new DrawningMilitaryCruiser(cruiser);
|
||||
return new DrawningSeaPlane(plane);
|
||||
}
|
||||
|
||||
cruiser = EntityCruiser.CreateEntityCruiser(strs);
|
||||
if (cruiser != null)
|
||||
plane = EntityPlane.CreateEntityPlane(strs);
|
||||
if (plane != null)
|
||||
{
|
||||
return new DrawningCruiser(cruiser);
|
||||
return new DrawningPlane(plane);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -36,9 +36,9 @@ namespace ProjectCruiser.Drawnings
|
||||
/// </summary>
|
||||
/// <param name="drawningCrusier">Сохраняемый объект</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawningCruiser drawningCrusier)
|
||||
public static string GetDataForSave(this DrawningPlane drawningCrusier)
|
||||
{
|
||||
string[]? array = drawningCrusier?.EntityCruiser?.GetStringRepresentation();
|
||||
string[]? array = drawningCrusier?.EntityPlane?.GetStringRepresentation();
|
||||
if (array == null)
|
||||
{
|
||||
return string.Empty;
|
||||
|
@ -1,9 +1,9 @@
|
||||
namespace ProjectCruiser.Entities;
|
||||
namespace ProjectPlane.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность "крейсер"
|
||||
/// Класс-сущность "самолет"
|
||||
/// </summary>
|
||||
public class EntityCruiser
|
||||
public class EntityPlane
|
||||
{
|
||||
//свойства
|
||||
/// <summary>
|
||||
@ -31,12 +31,12 @@ public class EntityCruiser
|
||||
public double Step => Speed * 100 / Weight;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса крейсера
|
||||
/// Инициализация полей объекта-класса самолета
|
||||
/// </summary>
|
||||
/// <param name="speed">скорость</param>
|
||||
/// <param name="weight">вес</param>
|
||||
/// <param name="bodyColor">основной цвет</param>
|
||||
public EntityCruiser(int speed, double weight, Color bodyColor)
|
||||
public EntityPlane(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
@ -49,7 +49,7 @@ public class EntityCruiser
|
||||
/// <returns></returns>
|
||||
public virtual string[] GetStringRepresentation()
|
||||
{
|
||||
return new[] { nameof(EntityCruiser), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
||||
return new[] { nameof(EntityPlane), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -57,13 +57,13 @@ public class EntityCruiser
|
||||
/// </summary>
|
||||
/// <param name="strs"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityCruiser? CreateEntityCruiser(string[] strs)
|
||||
public static EntityPlane? CreateEntityPlane(string[] strs)
|
||||
{
|
||||
if (strs.Length != 4 || strs[0] != nameof(EntityCruiser))
|
||||
if (strs.Length != 4 || strs[0] != nameof(EntityPlane))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new EntityCruiser(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||
return new EntityPlane(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
namespace ProjectCruiser.Entities
|
||||
namespace ProjectPlane.Entities
|
||||
{
|
||||
internal class EntityMilitaryCruiser : EntityCruiser
|
||||
internal class EntitySeaPlane : EntityPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Признак (опция) наличие вертолетной площадки
|
||||
/// Признак (опция) наличие линии
|
||||
/// </summary>
|
||||
public bool HelicopterArea { get; private set; }
|
||||
public bool Line { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Признак (опция) наличие шлюпок
|
||||
/// Признак (опция) наличие шлюпки
|
||||
/// </summary>
|
||||
public bool Boat { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Признак (опция) наличие пушки
|
||||
/// Признак (опция) наличие поплавков
|
||||
/// </summary>
|
||||
public bool Weapon { get; private set; }
|
||||
public bool Floats { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
@ -26,12 +26,12 @@
|
||||
AdditionalColor = color;
|
||||
}
|
||||
|
||||
public EntityMilitaryCruiser(int speed, double weight, Color bodyColor, Color additionalColor, bool helicopterArea, bool boat, bool weapon) : base(speed, weight, bodyColor)
|
||||
public EntitySeaPlane(int speed, double weight, Color bodyColor, Color additionalColor, bool line, bool boat, bool floats) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
HelicopterArea = helicopterArea;
|
||||
Line = line;
|
||||
Boat = boat;
|
||||
Weapon = weapon;
|
||||
Floats = floats;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -40,8 +40,8 @@
|
||||
/// <returns></returns>
|
||||
public override string[] GetStringRepresentation()
|
||||
{
|
||||
return new[] { nameof(EntityCruiser), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name,
|
||||
HelicopterArea.ToString(), Boat.ToString(), Weapon.ToString() };
|
||||
return new[] { nameof(EntityPlane), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name,
|
||||
Line.ToString(), Boat.ToString(), Floats.ToString() };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -49,13 +49,13 @@
|
||||
/// </summary>
|
||||
/// <param name="strs"></param>
|
||||
/// <returns></returns>
|
||||
public static EntityCruiser? CreateEntityMilitaryCruiser(string[] strs)
|
||||
public static EntityPlane? CreateEntitySeaPlane(string[] strs)
|
||||
{
|
||||
if (strs.Length != 8 || strs[0] != nameof(EntityCruiser))
|
||||
if (strs.Length != 8 || strs[0] != nameof(EntityPlane))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EntityMilitaryCruiser(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]),
|
||||
return new EntitySeaPlane(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]));
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCruiser.Exceptions;
|
||||
namespace ProjectPlane.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Класс, описывающий ошибку переполнения коллекции
|
||||
|
@ -5,7 +5,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCruiser.Exceptions;
|
||||
namespace ProjectPlane.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Класс, описывающий ошибку, что по указанной позиции нет элемента
|
||||
|
@ -5,7 +5,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCruiser.Exceptions;
|
||||
namespace ProjectPlane.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Класс, описывающий ошибку выхода за границы коллекции
|
||||
|
38
ProjectPlane/ProjectPlane/FormCruiser.Designer.cs
generated
38
ProjectPlane/ProjectPlane/FormCruiser.Designer.cs
generated
@ -1,6 +1,6 @@
|
||||
namespace ProjectCruiser
|
||||
namespace ProjectPlane
|
||||
{
|
||||
partial class FormCruiser
|
||||
partial class FormPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -28,26 +28,26 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormCruiser));
|
||||
pictureBoxCruiser = new PictureBox();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormPlane));
|
||||
pictureBoxPlane = new PictureBox();
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonLeft = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStrategyStep = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxPlane).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxCruiser
|
||||
// pictureBoxPlane
|
||||
//
|
||||
pictureBoxCruiser.Dock = DockStyle.Fill;
|
||||
pictureBoxCruiser.Location = new Point(0, 0);
|
||||
pictureBoxCruiser.Name = "pictureBoxCruiser";
|
||||
pictureBoxCruiser.Size = new Size(800, 450);
|
||||
pictureBoxCruiser.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxCruiser.TabIndex = 0;
|
||||
pictureBoxCruiser.TabStop = false;
|
||||
pictureBoxPlane.Dock = DockStyle.Fill;
|
||||
pictureBoxPlane.Location = new Point(0, 0);
|
||||
pictureBoxPlane.Name = "pictureBoxPlane";
|
||||
pictureBoxPlane.Size = new Size(800, 450);
|
||||
pictureBoxPlane.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxPlane.TabIndex = 0;
|
||||
pictureBoxPlane.TabStop = false;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
@ -118,7 +118,7 @@
|
||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
||||
buttonStrategyStep.Click += ButtonStrategyStep_Click;
|
||||
//
|
||||
// FormCruiser
|
||||
// FormPlane
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
@ -129,18 +129,18 @@
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(pictureBoxCruiser);
|
||||
Name = "FormCruiser";
|
||||
Text = "FormCruiser";
|
||||
Controls.Add(pictureBoxPlane);
|
||||
Name = "FormPlane";
|
||||
Text = "FormPlane";
|
||||
Click += ButtonMove_Click;
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxPlane).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCruiser;
|
||||
private PictureBox pictureBoxPlane;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
|
@ -1,14 +1,14 @@
|
||||
using ProjectCruiser.Drawnings;
|
||||
using ProjectCruiser.MovementStrategy;
|
||||
using ProjectPlane.Drawnings;
|
||||
using ProjectPlane.MovementStrategy;
|
||||
|
||||
namespace ProjectCruiser
|
||||
namespace ProjectPlane
|
||||
{
|
||||
public partial class FormCruiser : Form
|
||||
public partial class FormPlane : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле-объект для прорисовки объекта
|
||||
/// </summary>
|
||||
private DrawningCruiser? _drawningCruiser;
|
||||
private DrawningPlane? _drawningPlane;
|
||||
|
||||
/// <summary>
|
||||
/// Стратегия перемещения
|
||||
@ -18,13 +18,13 @@ namespace ProjectCruiser
|
||||
/// <summary>
|
||||
/// Получение объекта
|
||||
/// </summary>
|
||||
public DrawningCruiser SetCruiser
|
||||
public DrawningPlane SetPlane
|
||||
{
|
||||
set
|
||||
{
|
||||
_drawningCruiser = value;
|
||||
_drawningCruiser.SetPictureSize(pictureBoxCruiser.Width,
|
||||
pictureBoxCruiser.Height);
|
||||
_drawningPlane = value;
|
||||
_drawningPlane.SetPictureSize(pictureBoxPlane.Width,
|
||||
pictureBoxPlane.Height);
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_strategy = null;
|
||||
Draw();
|
||||
@ -34,26 +34,26 @@ namespace ProjectCruiser
|
||||
/// <summary>
|
||||
/// Конструктор формы
|
||||
/// </summary>
|
||||
public FormCruiser()
|
||||
public FormPlane()
|
||||
{
|
||||
InitializeComponent();
|
||||
_strategy = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод прорисовки круисера
|
||||
/// Метод прорисовки самолета
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
if (_drawningPlane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxCruiser.Width,
|
||||
pictureBoxCruiser.Height);
|
||||
Bitmap bmp = new(pictureBoxPlane.Width,
|
||||
pictureBoxPlane.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningCruiser.DrawTransport(gr);
|
||||
pictureBoxCruiser.Image = bmp;
|
||||
_drawningPlane.DrawTransport(gr);
|
||||
pictureBoxPlane.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -63,7 +63,7 @@ namespace ProjectCruiser
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
if (_drawningPlane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -72,17 +72,17 @@ namespace ProjectCruiser
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _drawningCruiser.MoveTransport(DirectionType.Up);
|
||||
result = _drawningPlane.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _drawningCruiser.MoveTransport(DirectionType.Down);
|
||||
result = _drawningPlane.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _drawningCruiser.MoveTransport(DirectionType.Left);
|
||||
result = _drawningPlane.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result =
|
||||
_drawningCruiser.MoveTransport(DirectionType.Right);
|
||||
_drawningPlane.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
if (result)
|
||||
@ -98,7 +98,7 @@ namespace ProjectCruiser
|
||||
/// <param name="e"></param>
|
||||
private void ButtonStrategyStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
if (_drawningPlane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -116,7 +116,7 @@ namespace ProjectCruiser
|
||||
{
|
||||
return;
|
||||
}
|
||||
_strategy.SetData(new MoveableCruiser(_drawningCruiser), pictureBoxCruiser.Width, pictureBoxCruiser.Height);
|
||||
_strategy.SetData(new MoveablePlane(_drawningPlane), pictureBoxPlane.Width, pictureBoxPlane.Height);
|
||||
}
|
||||
|
||||
if (_strategy == null)
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace ProjectCruiser
|
||||
namespace ProjectPlane
|
||||
{
|
||||
partial class FormCruiserConfing
|
||||
partial class FormPlaneConfing
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -38,9 +38,9 @@
|
||||
panelBlue = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelRed = new Panel();
|
||||
checkBoxWeapon = new CheckBox();
|
||||
checkBoxFloats = new CheckBox();
|
||||
checkBoxBoat = new CheckBox();
|
||||
checkBoxHelicopterArea = new CheckBox();
|
||||
checkBoxLine = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
@ -64,9 +64,9 @@
|
||||
// groupBoxConfing
|
||||
//
|
||||
groupBoxConfing.Controls.Add(groupBoxColors);
|
||||
groupBoxConfing.Controls.Add(checkBoxWeapon);
|
||||
groupBoxConfing.Controls.Add(checkBoxFloats);
|
||||
groupBoxConfing.Controls.Add(checkBoxBoat);
|
||||
groupBoxConfing.Controls.Add(checkBoxHelicopterArea);
|
||||
groupBoxConfing.Controls.Add(checkBoxLine);
|
||||
groupBoxConfing.Controls.Add(numericUpDownWeight);
|
||||
groupBoxConfing.Controls.Add(labelWeight);
|
||||
groupBoxConfing.Controls.Add(numericUpDownSpeed);
|
||||
@ -162,15 +162,15 @@
|
||||
panelRed.Size = new Size(48, 47);
|
||||
panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxWeapon
|
||||
// checkBoxFloats
|
||||
//
|
||||
checkBoxWeapon.AutoSize = true;
|
||||
checkBoxWeapon.Location = new Point(6, 217);
|
||||
checkBoxWeapon.Name = "checkBoxWeapon";
|
||||
checkBoxWeapon.Size = new Size(202, 24);
|
||||
checkBoxWeapon.TabIndex = 8;
|
||||
checkBoxWeapon.Text = "Признак наличие пушки";
|
||||
checkBoxWeapon.UseVisualStyleBackColor = true;
|
||||
checkBoxFloats.AutoSize = true;
|
||||
checkBoxFloats.Location = new Point(6, 217);
|
||||
checkBoxFloats.Name = "checkBoxFloats";
|
||||
checkBoxFloats.Size = new Size(202, 24);
|
||||
checkBoxFloats.TabIndex = 8;
|
||||
checkBoxFloats.Text = "Признак наличие пушки";
|
||||
checkBoxFloats.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxBoat
|
||||
//
|
||||
@ -182,15 +182,15 @@
|
||||
checkBoxBoat.Text = "Признак наличие шлюпок";
|
||||
checkBoxBoat.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxHelicopterArea
|
||||
// checkBoxLine
|
||||
//
|
||||
checkBoxHelicopterArea.AutoSize = true;
|
||||
checkBoxHelicopterArea.Location = new Point(6, 123);
|
||||
checkBoxHelicopterArea.Name = "checkBoxHelicopterArea";
|
||||
checkBoxHelicopterArea.Size = new Size(321, 24);
|
||||
checkBoxHelicopterArea.TabIndex = 6;
|
||||
checkBoxHelicopterArea.Text = "Признак наличие вертолетной площадки";
|
||||
checkBoxHelicopterArea.UseVisualStyleBackColor = true;
|
||||
checkBoxLine.AutoSize = true;
|
||||
checkBoxLine.Location = new Point(6, 123);
|
||||
checkBoxLine.Name = "checkBoxLine";
|
||||
checkBoxLine.Size = new Size(321, 24);
|
||||
checkBoxLine.TabIndex = 6;
|
||||
checkBoxLine.Text = "Признак наличие вертолетной площадки";
|
||||
checkBoxLine.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
@ -318,7 +318,7 @@
|
||||
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
|
||||
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
|
||||
//
|
||||
// FormCruiserConfing
|
||||
// FormPlaneConfing
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
@ -327,7 +327,7 @@
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(groupBoxConfing);
|
||||
Name = "FormCruiserConfing";
|
||||
Name = "FormPlaneConfing";
|
||||
Text = "Создание объекта";
|
||||
groupBoxConfing.ResumeLayout(false);
|
||||
groupBoxConfing.PerformLayout();
|
||||
@ -348,9 +348,9 @@
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelSpeed;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private CheckBox checkBoxHelicopterArea;
|
||||
private CheckBox checkBoxLine;
|
||||
private CheckBox checkBoxBoat;
|
||||
private CheckBox checkBoxWeapon;
|
||||
private CheckBox checkBoxFloats;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
|
@ -1,36 +1,36 @@
|
||||
using ProjectCruiser.Drawnings;
|
||||
using ProjectCruiser.Entities;
|
||||
using ProjectPlane.Drawnings;
|
||||
using ProjectPlane.Entities;
|
||||
|
||||
namespace ProjectCruiser
|
||||
namespace ProjectPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма конфигурации объекта
|
||||
/// </summary>
|
||||
public partial class FormCruiserConfing : Form
|
||||
public partial class FormPlaneConfing : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Объект - прорисовка крейсера
|
||||
/// Объект - прорисовка самолета
|
||||
/// </summary>
|
||||
private DrawningCruiser _cruiser;
|
||||
private DrawningPlane _plane;
|
||||
|
||||
/// <summary>
|
||||
/// Событие для передачи объекта
|
||||
/// </summary>
|
||||
private event Action<DrawningCruiser>? CruiserDelegate;
|
||||
private event Action<DrawningPlane>? PlaneDelegate;
|
||||
|
||||
/// <summary>
|
||||
/// Привязка внешнего метода к событию
|
||||
/// </summary>
|
||||
/// <param name="carDelegate"></param>
|
||||
public void AddEvent(Action<DrawningCruiser> cruiserDelegate)
|
||||
public void AddEvent(Action<DrawningPlane> planeDelegate)
|
||||
{
|
||||
CruiserDelegate += cruiserDelegate;
|
||||
PlaneDelegate += planeDelegate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormCruiserConfing()
|
||||
public FormPlaneConfing()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@ -53,9 +53,9 @@ namespace ProjectCruiser
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_cruiser?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
_cruiser?.SetPosition(15, 15);
|
||||
_cruiser?.DrawTransport(gr);
|
||||
_plane?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
_plane?.SetPosition(15, 15);
|
||||
_plane?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
@ -90,12 +90,12 @@ namespace ProjectCruiser
|
||||
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_cruiser = new DrawningCruiser((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
|
||||
_plane = new DrawningPlane((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_cruiser = new
|
||||
DrawningMilitaryCruiser((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
|
||||
Color.Black, checkBoxHelicopterArea.Checked, checkBoxBoat.Checked, checkBoxWeapon.Checked);
|
||||
_plane = new
|
||||
DrawningSeaPlane((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
|
||||
Color.Black, checkBoxLine.Checked, checkBoxBoat.Checked, checkBoxFloats.Checked);
|
||||
break;
|
||||
}
|
||||
DrawObject();
|
||||
@ -128,16 +128,16 @@ namespace ProjectCruiser
|
||||
|
||||
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_cruiser != null)
|
||||
if (_plane != null)
|
||||
{
|
||||
_cruiser.EntityCruiser.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
_plane.EntityPlane.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawObject();
|
||||
}
|
||||
}
|
||||
|
||||
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_cruiser is DrawningCruiser)
|
||||
if (_plane is DrawningPlane)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
@ -152,9 +152,9 @@ namespace ProjectCruiser
|
||||
|
||||
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_cruiser.EntityCruiser is EntityMilitaryCruiser militaryCruiser)
|
||||
if (_plane.EntityPlane is EntitySeaPlane seaPlane)
|
||||
{
|
||||
militaryCruiser.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||
seaPlane.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawObject();
|
||||
}
|
||||
@ -166,9 +166,9 @@ namespace ProjectCruiser
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_cruiser != null)
|
||||
if (_plane != null)
|
||||
{
|
||||
CruiserDelegate?.Invoke(_cruiser);
|
||||
PlaneDelegate?.Invoke(_plane);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace ProjectCruiser
|
||||
namespace ProjectPlane
|
||||
{
|
||||
partial class FormCruisersCollection
|
||||
partial class FormPlanesCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -40,12 +40,12 @@
|
||||
labelCollectionName = new Label();
|
||||
comboBoxSelectorCompany = new ComboBox();
|
||||
panelCompanyTools = new Panel();
|
||||
ButtonAddCruiser = new Button();
|
||||
ButtonAddPlane = new Button();
|
||||
buttonRefresh = new Button();
|
||||
ButtonRemoveCruiser = new Button();
|
||||
ButtonRemovePlane = new Button();
|
||||
maskedTextBoxPosision = new MaskedTextBox();
|
||||
buttonGetToTest = new Button();
|
||||
pictureBoxCruiser = new PictureBox();
|
||||
pictureBoxPlane = new PictureBox();
|
||||
menuStrip = new MenuStrip();
|
||||
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||
saveToolStripMenuItem = new ToolStripMenuItem();
|
||||
@ -55,7 +55,7 @@
|
||||
groupBoxTools.SuspendLayout();
|
||||
panelStorage.SuspendLayout();
|
||||
panelCompanyTools.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxPlane).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -178,9 +178,9 @@
|
||||
//
|
||||
// panelCompanyTools
|
||||
//
|
||||
panelCompanyTools.Controls.Add(ButtonAddCruiser);
|
||||
panelCompanyTools.Controls.Add(ButtonAddPlane);
|
||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||
panelCompanyTools.Controls.Add(ButtonRemoveCruiser);
|
||||
panelCompanyTools.Controls.Add(ButtonRemovePlane);
|
||||
panelCompanyTools.Controls.Add(maskedTextBoxPosision);
|
||||
panelCompanyTools.Controls.Add(buttonGetToTest);
|
||||
panelCompanyTools.Enabled = false;
|
||||
@ -189,17 +189,17 @@
|
||||
panelCompanyTools.Size = new Size(216, 274);
|
||||
panelCompanyTools.TabIndex = 8;
|
||||
//
|
||||
// ButtonAddCruiser
|
||||
// ButtonAddPlane
|
||||
//
|
||||
ButtonAddCruiser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
ButtonAddCruiser.BackgroundImageLayout = ImageLayout.Center;
|
||||
ButtonAddCruiser.Location = new Point(18, 3);
|
||||
ButtonAddCruiser.Name = "ButtonAddCruiser";
|
||||
ButtonAddCruiser.Size = new Size(186, 40);
|
||||
ButtonAddCruiser.TabIndex = 1;
|
||||
ButtonAddCruiser.Text = "добваление крейсера";
|
||||
ButtonAddCruiser.UseVisualStyleBackColor = true;
|
||||
ButtonAddCruiser.Click += ButtonAddCruiser_Click;
|
||||
ButtonAddPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
ButtonAddPlane.BackgroundImageLayout = ImageLayout.Center;
|
||||
ButtonAddPlane.Location = new Point(18, 3);
|
||||
ButtonAddPlane.Name = "ButtonAddPlane";
|
||||
ButtonAddPlane.Size = new Size(186, 40);
|
||||
ButtonAddPlane.TabIndex = 1;
|
||||
ButtonAddPlane.Text = "добваление самолета";
|
||||
ButtonAddPlane.UseVisualStyleBackColor = true;
|
||||
ButtonAddPlane.Click += ButtonAddPlane_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
@ -212,16 +212,16 @@
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += ButtonRefresh_Click;
|
||||
//
|
||||
// ButtonRemoveCruiser
|
||||
// ButtonRemovePlane
|
||||
//
|
||||
ButtonRemoveCruiser.Anchor = AnchorStyles.Right;
|
||||
ButtonRemoveCruiser.Location = new Point(18, 138);
|
||||
ButtonRemoveCruiser.Name = "ButtonRemoveCruiser";
|
||||
ButtonRemoveCruiser.Size = new Size(186, 40);
|
||||
ButtonRemoveCruiser.TabIndex = 3;
|
||||
ButtonRemoveCruiser.Text = "удалить крейсер";
|
||||
ButtonRemoveCruiser.UseVisualStyleBackColor = true;
|
||||
ButtonRemoveCruiser.Click += ButtonRemoveCruiser_Click;
|
||||
ButtonRemovePlane.Anchor = AnchorStyles.Right;
|
||||
ButtonRemovePlane.Location = new Point(18, 138);
|
||||
ButtonRemovePlane.Name = "ButtonRemovePlane";
|
||||
ButtonRemovePlane.Size = new Size(186, 40);
|
||||
ButtonRemovePlane.TabIndex = 3;
|
||||
ButtonRemovePlane.Text = "удалить самолет";
|
||||
ButtonRemovePlane.UseVisualStyleBackColor = true;
|
||||
ButtonRemovePlane.Click += ButtonRemovePlane_Click;
|
||||
//
|
||||
// maskedTextBoxPosision
|
||||
//
|
||||
@ -243,14 +243,14 @@
|
||||
buttonGetToTest.UseVisualStyleBackColor = true;
|
||||
buttonGetToTest.Click += ButtonGetToTest_Click;
|
||||
//
|
||||
// pictureBoxCruiser
|
||||
// pictureBoxPlane
|
||||
//
|
||||
pictureBoxCruiser.Dock = DockStyle.Fill;
|
||||
pictureBoxCruiser.Location = new Point(0, 28);
|
||||
pictureBoxCruiser.Name = "pictureBoxCruiser";
|
||||
pictureBoxCruiser.Size = new Size(631, 651);
|
||||
pictureBoxCruiser.TabIndex = 1;
|
||||
pictureBoxCruiser.TabStop = false;
|
||||
pictureBoxPlane.Dock = DockStyle.Fill;
|
||||
pictureBoxPlane.Location = new Point(0, 28);
|
||||
pictureBoxPlane.Name = "pictureBoxPlane";
|
||||
pictureBoxPlane.Size = new Size(631, 651);
|
||||
pictureBoxPlane.TabIndex = 1;
|
||||
pictureBoxPlane.TabStop = false;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
@ -293,23 +293,23 @@
|
||||
//
|
||||
openFileDialog.Filter = "txt file|*.txt";
|
||||
//
|
||||
// FormCruisersCollection
|
||||
// FormPlanesCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(853, 679);
|
||||
Controls.Add(pictureBoxCruiser);
|
||||
Controls.Add(pictureBoxPlane);
|
||||
Controls.Add(groupBoxTools);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormCruisersCollection";
|
||||
Text = "FormCruisersCollection";
|
||||
Name = "FormPlanesCollection";
|
||||
Text = "FormPlanesCollection";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
panelStorage.ResumeLayout(false);
|
||||
panelStorage.PerformLayout();
|
||||
panelCompanyTools.ResumeLayout(false);
|
||||
panelCompanyTools.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxPlane).EndInit();
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
@ -320,11 +320,11 @@
|
||||
|
||||
private GroupBox groupBoxTools;
|
||||
private ComboBox comboBoxSelectorCompany;
|
||||
private Button ButtonAddCruiser;
|
||||
private Button ButtonRemoveCruiser;
|
||||
private Button ButtonAddPlane;
|
||||
private Button ButtonRemovePlane;
|
||||
private Button buttonRefresh;
|
||||
private Button buttonGetToTest;
|
||||
private PictureBox pictureBoxCruiser;
|
||||
private PictureBox pictureBoxPlane;
|
||||
private MaskedTextBox maskedTextBoxPosision;
|
||||
private Panel panelStorage;
|
||||
private TextBox textBoxCollectionName;
|
||||
|
@ -1,15 +1,15 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectCruiser.CollectionGenericObjects;
|
||||
using ProjectCruiser.Drawnings;
|
||||
using ProjectPlane.CollectionGenericObjects;
|
||||
using ProjectPlane.Drawnings;
|
||||
|
||||
namespace ProjectCruiser
|
||||
namespace ProjectPlane
|
||||
{
|
||||
public partial class FormCruisersCollection : Form
|
||||
public partial class FormPlanesCollection : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Хранилише коллекций
|
||||
/// </summary>
|
||||
private readonly StorageCollection<DrawningCruiser> _storageCollection;
|
||||
private readonly StorageCollection<DrawningPlane> _storageCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Компания
|
||||
@ -24,7 +24,7 @@ namespace ProjectCruiser
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormCruisersCollection(ILogger<FormCruisersCollection> logger)
|
||||
public FormPlanesCollection(ILogger<FormPlanesCollection> logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storageCollection = new();
|
||||
@ -42,35 +42,35 @@ namespace ProjectCruiser
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// добавление крейсера
|
||||
/// добавление самолета
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddCruiser_Click(object sender, EventArgs e)
|
||||
private void ButtonAddPlane_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCruiserConfing form = new();
|
||||
FormPlaneConfing form = new();
|
||||
// TODO передать метод
|
||||
|
||||
form.Show();
|
||||
form.AddEvent(SetCruiser);
|
||||
form.AddEvent(SetPlane);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление крейсера в коллекцию
|
||||
/// Добавление самолета в коллекцию
|
||||
/// </summary>
|
||||
/// <param name="cruiser"></param>
|
||||
private void SetCruiser(DrawningCruiser? cruiser)
|
||||
/// <param name="plane"></param>
|
||||
private void SetPlane(DrawningPlane? plane)
|
||||
{
|
||||
if (_company == null || cruiser == null)
|
||||
if (_company == null || plane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var res = _company + cruiser;
|
||||
var res = _company + plane;
|
||||
MessageBox.Show("Объект добавлен");
|
||||
_logger.LogInformation($"Объект добавлен под индексом {res}");
|
||||
pictureBoxCruiser.Image = _company.Show();
|
||||
pictureBoxPlane.Image = _company.Show();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -85,7 +85,7 @@ namespace ProjectCruiser
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveCruiser_Click(object sender, EventArgs e)
|
||||
private void ButtonRemovePlane_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosision.Text) || _company == null)
|
||||
{
|
||||
@ -102,7 +102,7 @@ namespace ProjectCruiser
|
||||
var res = _company - pos;
|
||||
MessageBox.Show("Объект удален");
|
||||
_logger.LogInformation($"Объект удален под индексом {pos}");
|
||||
pictureBoxCruiser.Image = _company.Show();
|
||||
pictureBoxPlane.Image = _company.Show();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -119,24 +119,24 @@ namespace ProjectCruiser
|
||||
return;
|
||||
}
|
||||
|
||||
DrawningCruiser? cruiser = null;
|
||||
DrawningPlane? plane = null;
|
||||
int counter = 100;
|
||||
while (cruiser == null)
|
||||
while (plane == null)
|
||||
{
|
||||
cruiser = _company.GetRandomObject();
|
||||
plane = _company.GetRandomObject();
|
||||
counter--;
|
||||
if (counter <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cruiser == null)
|
||||
if (plane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormCruiser form = new()
|
||||
FormPlane form = new()
|
||||
{
|
||||
SetCruiser = cruiser
|
||||
SetPlane = plane
|
||||
};
|
||||
form.ShowDialog();
|
||||
|
||||
@ -149,7 +149,7 @@ namespace ProjectCruiser
|
||||
return;
|
||||
}
|
||||
|
||||
pictureBoxCruiser.Image = _company.Show();
|
||||
pictureBoxPlane.Image = _company.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -237,7 +237,7 @@ namespace ProjectCruiser
|
||||
return;
|
||||
}
|
||||
|
||||
ICollectionGenericObjects<DrawningCruiser>? collection =
|
||||
ICollectionGenericObjects<DrawningPlane>? collection =
|
||||
_storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
||||
if (collection == null)
|
||||
{
|
||||
@ -248,7 +248,7 @@ namespace ProjectCruiser
|
||||
switch (comboBoxSelectorCompany.Text)
|
||||
{
|
||||
case "Хранилище":
|
||||
_company = new CruiserDockingService(pictureBoxCruiser.Width, pictureBoxCruiser.Height, collection);
|
||||
_company = new PlaneDockingService(pictureBoxPlane.Width, pictureBoxPlane.Height, collection);
|
||||
_logger.LogInformation("Компания создана");
|
||||
break;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.MovementStrategy
|
||||
namespace ProjectPlane.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-стратегия перемещения объекта
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.MovementStrategy
|
||||
namespace ProjectPlane.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Интерфейс для работы с перемещаемым объектом
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.MovementStrategy
|
||||
namespace ProjectPlane.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Стратегия перемещения объекта к краю экрана
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.MovementStrategy
|
||||
namespace ProjectPlane.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Стратегия перемещения объекта в центр экрана
|
||||
|
@ -1,45 +1,45 @@
|
||||
using ProjectCruiser.Drawnings;
|
||||
using ProjectPlane.Drawnings;
|
||||
|
||||
namespace ProjectCruiser.MovementStrategy
|
||||
namespace ProjectPlane.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// класс реалтзация для IMoveableObject с использованием DrawningCruiser
|
||||
/// класс реалтзация для IMoveableObject с использованием DrawningPlane
|
||||
/// </summary>
|
||||
public class MoveableCruiser : IMoveableObject
|
||||
public class MoveablePlane : IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле-объект класса DrawningCruiser или его наследника
|
||||
/// Поле-объект класса DrawningPlane или его наследника
|
||||
/// </summary>
|
||||
private readonly DrawningCruiser? _cruiser = null;
|
||||
private readonly DrawningPlane? _plane = null;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="cruiser">Объект класса DrawningCruiser</param>
|
||||
public MoveableCruiser(DrawningCruiser cruiser)
|
||||
/// <param name="plane">Объект класса DrawningPlane</param>
|
||||
public MoveablePlane(DrawningPlane plane)
|
||||
{
|
||||
_cruiser = cruiser;
|
||||
_plane = plane;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cruiser == null || _cruiser.EntityCruiser == null ||
|
||||
!_cruiser.GetPosX.HasValue || !_cruiser.GetPosY.HasValue)
|
||||
if (_plane == null || _plane.EntityPlane == null ||
|
||||
!_plane.GetPosX.HasValue || !_plane.GetPosY.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_cruiser.GetPosX.Value,
|
||||
_cruiser.GetPosY.Value, _cruiser.GetWidth, _cruiser.GetHeight);
|
||||
return new ObjectParameters(_plane.GetPosX.Value,
|
||||
_plane.GetPosY.Value, _plane.GetWidth, _plane.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_cruiser?.EntityCruiser?.Step ?? 0);
|
||||
public int GetStep => (int)(_plane?.EntityPlane?.Step ?? 0);
|
||||
public bool TryMoveObject(MovementDirection direction)
|
||||
{
|
||||
if (_cruiser == null || _cruiser.EntityCruiser == null)
|
||||
if (_plane == null || _plane.EntityPlane == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _cruiser.MoveTransport(GetDirectionType(direction));
|
||||
return _plane.MoveTransport(GetDirectionType(direction));
|
||||
}
|
||||
/// <summary>
|
||||
/// Конвертация из MovementDirection в DirectionType
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.MovementStrategy
|
||||
namespace ProjectPlane.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.MovementStrategy
|
||||
namespace ProjectPlane.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметры-координаты объекта
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectCruiser.MovementStrategy
|
||||
namespace ProjectPlane.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Статус выполнения операции перемещения
|
||||
|
@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace ProjectCruiser
|
||||
namespace ProjectPlane
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
@ -18,12 +18,12 @@ namespace ProjectCruiser
|
||||
ServiceCollection services = new();
|
||||
ConfigureServices(services);
|
||||
using ServiceProvider serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(serviceProvider.GetRequiredService<FormCruisersCollection>());
|
||||
Application.Run(serviceProvider.GetRequiredService<FormPlanesCollection>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormCruisersCollection>().AddLogging(option =>
|
||||
services.AddSingleton<FormPlanesCollection>().AddLogging(option =>
|
||||
{
|
||||
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||
string pathNeed = "";
|
||||
|
@ -8,4 +8,15 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -4,7 +4,7 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true" internalLogLevel="Info">
|
||||
<targets>
|
||||
<target xsi:type="File" name="tofile" fileName="cruiserlog-
|
||||
<target xsi:type="File" name="tofile" fileName="planelog-
|
||||
${shortdate}.log" />
|
||||
</targets>
|
||||
<rules>
|
||||
|
@ -14,7 +14,7 @@
|
||||
],
|
||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||
"Properties": {
|
||||
"Application": "cruiser"
|
||||
"Application": "plane"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user