Compare commits
No commits in common. "lab7" and "main" have entirely different histories.
@ -1,135 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
namespace SelfPropelledArtilleryUnit.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-стратегия перемещения объекта
|
|
||||||
/// </summary>
|
|
||||||
public abstract class AbstractStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещаемый объект
|
|
||||||
/// </summary>
|
|
||||||
private IMoveableObject? _moveableObject;
|
|
||||||
/// <summary>
|
|
||||||
/// Статус перемещения
|
|
||||||
/// </summary>
|
|
||||||
private Status _state = Status.NotInit;
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина поля
|
|
||||||
/// </summary>
|
|
||||||
protected int FieldWidth { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Высота поля
|
|
||||||
/// </summary>
|
|
||||||
protected int FieldHeight { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Статус перемещения
|
|
||||||
/// </summary>
|
|
||||||
public Status GetStatus() { return _state; }
|
|
||||||
/// <summary>
|
|
||||||
/// Установка данных
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="moveableObject">Перемещаемый объект</param>
|
|
||||||
/// <param name="width">Ширина поля</param>
|
|
||||||
/// <param name="height">Высота поля</param>
|
|
||||||
public void SetData(IMoveableObject moveableObject, int width, int
|
|
||||||
height)
|
|
||||||
{
|
|
||||||
if (moveableObject == null)
|
|
||||||
{
|
|
||||||
_state = Status.NotInit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_state = Status.InProgress;
|
|
||||||
_moveableObject = moveableObject;
|
|
||||||
FieldWidth = width;
|
|
||||||
FieldHeight = height;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения
|
|
||||||
/// </summary>
|
|
||||||
public void MakeStep()
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (IsTargetDestinaion())
|
|
||||||
{
|
|
||||||
_state = Status.Finish;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MoveToTarget();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение влево
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вправо
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вверх
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вниз
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
|
||||||
/// <summary>
|
|
||||||
/// Параметры объекта
|
|
||||||
/// </summary>
|
|
||||||
protected ObjectParameters? GetObjectParameters =>
|
|
||||||
_moveableObject?.GetObjectPosition;
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected int? GetStep()
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return _moveableObject?.GetStep;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение к цели
|
|
||||||
/// </summary>
|
|
||||||
protected abstract void MoveToTarget();
|
|
||||||
/// <summary>
|
|
||||||
/// Достигнута ли цель
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected abstract bool IsTargetDestinaion();
|
|
||||||
/// <summary>
|
|
||||||
/// Попытка перемещения в требуемом направлении
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="directionType">Направление</param>
|
|
||||||
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
private bool MoveTo(DirectionType directionType)
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
|
||||||
{
|
|
||||||
_moveableObject.MoveObject(directionType);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.Drawnings
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Направление перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum DirectionType
|
|
||||||
{
|
|
||||||
|
|
||||||
Up = 1,
|
|
||||||
|
|
||||||
Down = 2,
|
|
||||||
|
|
||||||
Left = 3,
|
|
||||||
|
|
||||||
Right = 4
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,260 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using SelfPropelledArtilleryUnit.Entities;
|
|
||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using SelfPropelledArtilleryUnit.MovementStrategy;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.DrawningObjects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
|
||||||
/// </summary>
|
|
||||||
public class DrawningUsta
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность
|
|
||||||
/// </summary>
|
|
||||||
public EntityUsta? EntityUsta { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна
|
|
||||||
/// </summary>
|
|
||||||
private int _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна
|
|
||||||
/// </summary>
|
|
||||||
private int _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Левая координата прорисовки установки
|
|
||||||
/// </summary>
|
|
||||||
protected int _startPosX;
|
|
||||||
/// <summary>
|
|
||||||
/// Верхняя кооридната прорисовки установки
|
|
||||||
/// </summary>
|
|
||||||
protected int _startPosY;
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина прорисовки установки
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _ustaWidth = 140;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота прорисовки установки
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _ustaHeight = 90;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="width">Ширина картинки</param>
|
|
||||||
/// <param name="height">Высота картинки</param>
|
|
||||||
public DrawningUsta(int speed, double weight, Color bodyColor, int
|
|
||||||
width, int height)
|
|
||||||
{
|
|
||||||
// TODO: Продумать проверки
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
EntityUsta = new EntityUsta(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="width">Ширина картинки</param>
|
|
||||||
/// <param name="height">Высота картинки</param>
|
|
||||||
/// <param name="carWidth">Ширина прорисовки установки</param>
|
|
||||||
/// <param name="carHeight">Высота прорисовки установки</param>
|
|
||||||
protected DrawningUsta(int speed, double weight, Color bodyColor, int
|
|
||||||
width, int height, int ustaWidth, int ustaHeight)
|
|
||||||
{
|
|
||||||
// TODO: Продумать проверки
|
|
||||||
if (width <= _pictureWidth || height <= _pictureHeight)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
_ustaWidth = ustaWidth;
|
|
||||||
_ustaHeight = ustaHeight;
|
|
||||||
EntityUsta = new EntityUsta(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
public void SetPosition(int x, int y)
|
|
||||||
{
|
|
||||||
// TODO: Изменение x, y, если при установке объект выходит за границы
|
|
||||||
if (x < 0 || y < 0 || x + _ustaWidth > _pictureWidth || y + _ustaHeight > _pictureHeight)
|
|
||||||
{
|
|
||||||
x = 10;
|
|
||||||
y = 10;
|
|
||||||
}
|
|
||||||
_startPosX = x;
|
|
||||||
_startPosY = y;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта IMoveableObject из объекта DrawningUsta
|
|
||||||
/// </summary>
|
|
||||||
public IMoveableObject GetMoveableObject => new DrawningObjectUsta(this);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления перемещения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Прорисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
/// <summary>
|
|
||||||
/// Координата X объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetPosX => _startPosX;
|
|
||||||
/// <summary>
|
|
||||||
/// Координата Y объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetPosY => _startPosY;
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetWidth => _ustaWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetHeight => _ustaHeight;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка, что объект может переместится по указанному направлению
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <returns>true - можно переместится по указанному направлению</returns>
|
|
||||||
public virtual bool CanMove(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (EntityUsta == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return direction switch
|
|
||||||
{
|
|
||||||
//влево
|
|
||||||
DirectionType.Left => _startPosX - EntityUsta.Step > 0,
|
|
||||||
//вверх
|
|
||||||
DirectionType.Up => _startPosY - EntityUsta.Step > 7,
|
|
||||||
// вправо
|
|
||||||
DirectionType.Right => _startPosX + EntityUsta.Step + _ustaWidth < _pictureWidth,// TODO: Продумать логику
|
|
||||||
//вниз
|
|
||||||
DirectionType.Down => _startPosY + EntityUsta.Step + _ustaHeight < _pictureHeight,// TODO: Продумать логику
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления перемещения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
public virtual void MoveTransport(DirectionType direction)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!CanMove(direction) || EntityUsta == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case DirectionType.Left:
|
|
||||||
_startPosX -= (int)EntityUsta.Step;
|
|
||||||
break;
|
|
||||||
case DirectionType.Up:
|
|
||||||
_startPosY -= (int)EntityUsta.Step;
|
|
||||||
break;
|
|
||||||
case DirectionType.Right:
|
|
||||||
_startPosX += (int)EntityUsta.Step;
|
|
||||||
break;
|
|
||||||
case DirectionType.Down:
|
|
||||||
_startPosY += (int)EntityUsta.Step;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityUsta == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
|
|
||||||
|
|
||||||
Brush BodyColor = new SolidBrush(EntityUsta.BodyColor);
|
|
||||||
|
|
||||||
//зеленый темнее
|
|
||||||
int lineWidth = 10;
|
|
||||||
Color color1 = Color.FromArgb(65, 72, 51);
|
|
||||||
Brush pen1 = new SolidBrush(color1);
|
|
||||||
|
|
||||||
//black
|
|
||||||
|
|
||||||
Color color3 = Color.FromArgb(0, 0, 0);
|
|
||||||
Brush pen3 = new SolidBrush(color3);
|
|
||||||
|
|
||||||
|
|
||||||
//зеленый мох
|
|
||||||
Color color2 = Color.FromArgb(47, 69, 56);
|
|
||||||
Brush pen2 = new SolidBrush(color1);
|
|
||||||
|
|
||||||
|
|
||||||
//прорисовка арт. установки
|
|
||||||
|
|
||||||
int cornerRadius = 16; // Радиус скругления углов
|
|
||||||
int cornerRadius1 = 12;
|
|
||||||
|
|
||||||
GraphicsPath path = new GraphicsPath();
|
|
||||||
path.AddArc(_startPosX + 5, _startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 180, 90); // Верхний левый угол
|
|
||||||
path.AddArc(_startPosX + 110, _startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 270, 90); // Верхний правый угол
|
|
||||||
path.AddArc(_startPosX + 110, _startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius, 0, 90); // Нижний правый угол
|
|
||||||
path.AddArc(_startPosX + 5, _startPosY + 50, 2 * cornerRadius, 2 * cornerRadius, 90, 90); // Нижний левый угол
|
|
||||||
path.CloseFigure(); // Замкнуть путь
|
|
||||||
|
|
||||||
// отрисовка прямоугольника с кругленными краями
|
|
||||||
g.FillPath(BodyColor, path);
|
|
||||||
g.DrawPath(pen, path);
|
|
||||||
|
|
||||||
|
|
||||||
g.FillEllipse(pen3, _startPosX + 47, _startPosY + 44, 13, 13);
|
|
||||||
g.FillEllipse(pen3, _startPosX + 62, _startPosY + 44, 13, 13);
|
|
||||||
g.FillEllipse(pen3, _startPosX + 77, _startPosY + 44, 13, 13);
|
|
||||||
|
|
||||||
|
|
||||||
g.FillRectangle(BodyColor, _startPosX + 45, _startPosY + 20, 40, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 45, _startPosY + 20, 40, 20);
|
|
||||||
|
|
||||||
g.DrawEllipse(pen, _startPosX + 40, _startPosY + 65, 13, 13);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 55, _startPosY + 65, 13, 13);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 70, _startPosY + 65, 13, 13);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 85, _startPosY + 65, 13, 13);
|
|
||||||
|
|
||||||
g.FillRectangle(BodyColor, _startPosX + 10, _startPosY + 40, 120, 10);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 40, 120, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(pen3, _startPosX + 10, _startPosY + 52, 26, 26);
|
|
||||||
g.FillEllipse(pen3, _startPosX + 105, _startPosY + 52, 26, 26);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,176 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
using SelfPropelledArtilleryUnit.Entities;
|
|
||||||
namespace SelfPropelledArtilleryUnit.DrawningObjects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
|
||||||
/// </summary>
|
|
||||||
public class DrawningUstaBat : DrawningUsta
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="bodyKit">Признак наличия батареи</param>
|
|
||||||
/// <param name="pushka">Признак наличия пушки</param>
|
|
||||||
/// <param name="width">Ширина картинки</param>
|
|
||||||
/// <param name="height">Высота картинки</param>
|
|
||||||
public DrawningUstaBat(int speed, double weight, Color bodyColor, Color
|
|
||||||
additionalColor, bool bodyKit, bool pushka, int width, int height) :
|
|
||||||
base(speed, weight, bodyColor, width, height, 140, 90)
|
|
||||||
{
|
|
||||||
if (EntityUsta != null)
|
|
||||||
{
|
|
||||||
EntityUsta = new EntityUstaBat(speed, weight, bodyColor,
|
|
||||||
additionalColor, bodyKit, pushka);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityUsta is not EntityUstaBat ustaBat)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
|
|
||||||
Brush additionalBrush = new SolidBrush(ustaBat.AdditionalColor);
|
|
||||||
Brush BodyColor = new SolidBrush(EntityUsta.BodyColor);
|
|
||||||
|
|
||||||
//зеленый темнее
|
|
||||||
Color color1 = Color.FromArgb(65, 72, 51);
|
|
||||||
Brush pen1 = new SolidBrush(color1);
|
|
||||||
|
|
||||||
//black
|
|
||||||
|
|
||||||
Color color3 = Color.FromArgb(0, 0, 0);
|
|
||||||
Brush pen3 = new SolidBrush(color3);
|
|
||||||
|
|
||||||
|
|
||||||
//зеленый мох
|
|
||||||
Color color2 = Color.FromArgb(47, 69, 56);
|
|
||||||
Brush pen2 = new SolidBrush(color1);
|
|
||||||
// батарея
|
|
||||||
if (ustaBat.BodyKit)
|
|
||||||
{
|
|
||||||
GraphicsPath path1 = new GraphicsPath();
|
|
||||||
path1.AddLine(_startPosX + 15, _startPosY + 40, _startPosX + 15, _startPosY + 30);
|
|
||||||
path1.AddLine(_startPosX + 15, _startPosY + 30, _startPosX + 15, _startPosY + 35);
|
|
||||||
path1.AddLine(_startPosX + 15, _startPosY + 35, _startPosX + 25, _startPosY + 35);
|
|
||||||
path1.AddLine(_startPosX + 25, _startPosY + 35, _startPosX + 30, _startPosY + 30);
|
|
||||||
path1.AddLine(_startPosX + 30, _startPosY + 30, _startPosX + 35, _startPosY + 40);
|
|
||||||
path1.CloseFigure();
|
|
||||||
|
|
||||||
g.DrawPath(pen, path1);
|
|
||||||
|
|
||||||
g.FillPath(BodyColor, path1);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GraphicsPath path2 = new GraphicsPath();
|
|
||||||
path2.AddLine(_startPosX + 15, _startPosY + 30, _startPosX + 40, _startPosY + 20);
|
|
||||||
path2.AddLine(_startPosX + 40, _startPosY + 20, _startPosX + 40, _startPosY + 25);
|
|
||||||
path2.AddLine(_startPosX + 40, _startPosY + 25, _startPosX + 25, _startPosY + 35);
|
|
||||||
path2.AddLine(_startPosX + 25, _startPosY + 35, _startPosX + 15, _startPosY + 35);
|
|
||||||
|
|
||||||
path2.CloseFigure();
|
|
||||||
|
|
||||||
g.DrawPath(pen, path2);
|
|
||||||
|
|
||||||
g.FillPath(additionalBrush, path2);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GraphicsPath path3 = new GraphicsPath();
|
|
||||||
path3.AddLine(_startPosX + 10, _startPosY + 32, _startPosX, _startPosY + 10);
|
|
||||||
path3.AddLine(_startPosX, _startPosY + 10, _startPosX + 40, _startPosY - 7);
|
|
||||||
path3.AddLine(_startPosX + 40, _startPosY - 7, _startPosX + 50, _startPosY + 16);
|
|
||||||
|
|
||||||
path3.CloseFigure();
|
|
||||||
|
|
||||||
g.DrawPath(pen, path3);
|
|
||||||
|
|
||||||
g.FillPath(pen3, path3);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GraphicsPath path4 = new GraphicsPath();
|
|
||||||
path4.AddLine(_startPosX, _startPosY + 10, _startPosX + 40, _startPosY - 7);
|
|
||||||
path4.AddLine(_startPosX + 40, _startPosY - 7, _startPosX + 43, _startPosY - 5);
|
|
||||||
path4.AddLine(_startPosX + 43, _startPosY - 5, _startPosX + 41, _startPosY - 3);
|
|
||||||
path4.AddLine(_startPosX + 41, _startPosY - 3, _startPosX + 2, _startPosY + 13);
|
|
||||||
|
|
||||||
path4.CloseFigure();
|
|
||||||
|
|
||||||
g.DrawPath(pen, path4);
|
|
||||||
|
|
||||||
g.FillPath(additionalBrush, path4);
|
|
||||||
|
|
||||||
|
|
||||||
GraphicsPath path5 = new GraphicsPath();
|
|
||||||
path5.AddLine(_startPosX + 3, _startPosY + 15, _startPosX + 45, _startPosY - 2);
|
|
||||||
path5.AddLine(_startPosX + 46, _startPosY - 2, _startPosX + 49, _startPosY - 1);
|
|
||||||
path5.AddLine(_startPosX + 49, _startPosY - 1, _startPosX + 46, _startPosY + 3);
|
|
||||||
path5.AddLine(_startPosX + 46, _startPosY + 3, _startPosX + 6, _startPosY + 20);
|
|
||||||
|
|
||||||
path5.CloseFigure();
|
|
||||||
|
|
||||||
g.DrawPath(pen, path5);
|
|
||||||
|
|
||||||
g.FillPath(BodyColor, path5);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GraphicsPath path6 = new GraphicsPath();
|
|
||||||
path6.AddLine(_startPosX + 5, _startPosY + 22, _startPosX + 47, _startPosY + 5);
|
|
||||||
path6.AddLine(_startPosX + 47, _startPosY + 5, _startPosX + 51, _startPosY + 5);
|
|
||||||
path6.AddLine(_startPosX + 51, _startPosY + 5, _startPosX + 53, _startPosY + 7);
|
|
||||||
path6.AddLine(_startPosX + 53, _startPosY + 7, _startPosX + 8, _startPosY + 25);
|
|
||||||
|
|
||||||
path6.CloseFigure();
|
|
||||||
|
|
||||||
g.DrawPath(pen, path6);
|
|
||||||
|
|
||||||
g.FillPath(additionalBrush, path6);
|
|
||||||
|
|
||||||
|
|
||||||
GraphicsPath path7 = new GraphicsPath();
|
|
||||||
path7.AddLine(_startPosX + 7, _startPosY + 27, _startPosX + 46, _startPosY + 11);
|
|
||||||
path7.AddLine(_startPosX + 46, _startPosY + 11, _startPosX + 51, _startPosY + 9);
|
|
||||||
path7.AddLine(_startPosX + 51, _startPosY + 9, _startPosX + 56, _startPosY + 11);
|
|
||||||
path7.AddLine(_startPosX + 56, _startPosY + 11, _startPosX + 10, _startPosY + 31);
|
|
||||||
|
|
||||||
path7.CloseFigure();
|
|
||||||
|
|
||||||
g.DrawPath(pen, path7);
|
|
||||||
|
|
||||||
g.FillPath(BodyColor, path7);
|
|
||||||
}
|
|
||||||
base.DrawTransport(g);
|
|
||||||
// пушка
|
|
||||||
if (ustaBat.Pushka)
|
|
||||||
{
|
|
||||||
g.FillRectangle(pen2, _startPosX + 80, _startPosY + 25, 10, 10);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 80, _startPosY + 25, 10, 10);
|
|
||||||
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 90, _startPosY + 28, 40, 5);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 28, 40, 5);
|
|
||||||
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 130, _startPosY + 27, 5, 7);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 130, _startPosY + 27, 5, 7);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.Entities
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность "Установка"
|
|
||||||
/// </summary>
|
|
||||||
public class EntityUsta
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Скорость
|
|
||||||
/// </summary>
|
|
||||||
public int Speed { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Вес
|
|
||||||
/// </summary>
|
|
||||||
public double Weight { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Основной цвет
|
|
||||||
/// </summary>
|
|
||||||
public Color BodyColor { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения установки
|
|
||||||
/// </summary>
|
|
||||||
public double Step => (double)Speed * 100 / Weight;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор с параметрами
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес установки</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
public EntityUsta(int speed, double weight, Color bodyColor)
|
|
||||||
{
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.Entities
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность "Установка с вооружением"
|
|
||||||
/// </summary>
|
|
||||||
public class EntityUstaBat : EntityUsta
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Дополнительный цвет (для опциональных элементов)
|
|
||||||
/// </summary>
|
|
||||||
public Color AdditionalColor { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Признак (опция) наличия батареи
|
|
||||||
/// </summary>
|
|
||||||
public bool BodyKit { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Признак (опция) наличия пушки
|
|
||||||
/// </summary>
|
|
||||||
public bool Pushka { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Инициализация полей объекта-класса установки с вооружением
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес автомобиля</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="pushka">Признак наличия пушки</param>
|
|
||||||
/// <param name="bodyKit">Признак наличия батареи</param>
|
|
||||||
public EntityUstaBat(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool pushka)
|
|
||||||
: base(speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
AdditionalColor = additionalColor;
|
|
||||||
BodyKit = bodyKit;
|
|
||||||
Pushka = pushka;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
using SelfPropelledArtilleryUnit.Entities;
|
|
||||||
namespace SelfPropelledArtilleryUnit.DrawningObjects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Расширение для класса EntityUsta
|
|
||||||
/// </summary>
|
|
||||||
public static class ExtentionDrawningUsta
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из строки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info">Строка с данными для создания объекта</param>
|
|
||||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
|
||||||
/// <param name="width">Ширина</param>
|
|
||||||
/// <param name="height">Высота</param>
|
|
||||||
/// <returns>Объект</returns>
|
|
||||||
public static DrawningUsta? CreateDrawningUsta(this string info, char
|
|
||||||
separatorForObject, int width, int height)
|
|
||||||
{
|
|
||||||
string[] strs = info.Split(separatorForObject);
|
|
||||||
if (strs.Length == 3)
|
|
||||||
{
|
|
||||||
return new DrawningUsta(Convert.ToInt32(strs[0]),
|
|
||||||
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
|
||||||
}
|
|
||||||
else if (strs.Length == 6)
|
|
||||||
{
|
|
||||||
return new DrawningUstaBat(Convert.ToInt32(strs[0]),
|
|
||||||
Convert.ToInt32(strs[1]),
|
|
||||||
Color.FromName(strs[2]),
|
|
||||||
Color.FromName(strs[3]),
|
|
||||||
Convert.ToBoolean(strs[4]),
|
|
||||||
Convert.ToBoolean(strs[5]), width, height);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Получение данных для сохранения в файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="drawningUsta">Сохраняемый объект</param>
|
|
||||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
|
||||||
/// <returns>Строка с данными по объекту</returns>
|
|
||||||
public static string GetDataForSave(this DrawningUsta drawningUsta,
|
|
||||||
char separatorForUsta)
|
|
||||||
{
|
|
||||||
var usta = drawningUsta.EntityUsta;
|
|
||||||
if (usta == null)
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
var str =
|
|
||||||
$"{usta.Speed}{separatorForUsta}{usta.Weight}{separatorForUsta}{usta.BodyColor.Name}";
|
|
||||||
if (usta is not EntityUstaBat sportUsta)
|
|
||||||
{
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
return $"{str}{separatorForUsta}{sportUsta.AdditionalColor.Name}{separatorForUsta}{sportUsta.BodyKit}{separatorForUsta}{sportUsta.Pushka}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -28,156 +28,18 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormSelfPropelledArtilleryUnit));
|
|
||||||
comboBoxStrategy = new ComboBox();
|
|
||||||
ButtonCreateUstaBat = new Button();
|
|
||||||
ButtonCreateUsta = new Button();
|
|
||||||
ButtonStep = new Button();
|
|
||||||
buttonUp = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
buttonLeft = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
pictureBoxUsta = new PictureBox();
|
|
||||||
ButtonSelectUsta = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxUsta).BeginInit();
|
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// comboBoxStrategy
|
|
||||||
//
|
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "MoveToCenter", "MoveToBorder", "-" });
|
|
||||||
comboBoxStrategy.Location = new Point(667, 12);
|
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
|
||||||
comboBoxStrategy.Size = new Size(121, 23);
|
|
||||||
comboBoxStrategy.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ButtonCreateUstaBat
|
|
||||||
//
|
|
||||||
ButtonCreateUstaBat.Location = new Point(19, 393);
|
|
||||||
ButtonCreateUstaBat.Name = "ButtonCreateUstaBat";
|
|
||||||
ButtonCreateUstaBat.Size = new Size(160, 42);
|
|
||||||
ButtonCreateUstaBat.TabIndex = 1;
|
|
||||||
ButtonCreateUstaBat.Text = "Создать арт. установку с вооружением";
|
|
||||||
ButtonCreateUstaBat.UseVisualStyleBackColor = true;
|
|
||||||
ButtonCreateUstaBat.Click += ButtonCreateUstaBat_Click;
|
|
||||||
//
|
|
||||||
// ButtonCreateUsta
|
|
||||||
//
|
|
||||||
ButtonCreateUsta.Location = new Point(185, 393);
|
|
||||||
ButtonCreateUsta.Name = "ButtonCreateUsta";
|
|
||||||
ButtonCreateUsta.Size = new Size(157, 42);
|
|
||||||
ButtonCreateUsta.TabIndex = 2;
|
|
||||||
ButtonCreateUsta.Text = "Создать арт. установку";
|
|
||||||
ButtonCreateUsta.UseVisualStyleBackColor = true;
|
|
||||||
ButtonCreateUsta.Click += ButtonCreateUsta_Click;
|
|
||||||
//
|
|
||||||
// ButtonStep
|
|
||||||
//
|
|
||||||
ButtonStep.Location = new Point(713, 50);
|
|
||||||
ButtonStep.Name = "ButtonStep";
|
|
||||||
ButtonStep.Size = new Size(75, 23);
|
|
||||||
ButtonStep.TabIndex = 3;
|
|
||||||
ButtonStep.Text = "Шаг";
|
|
||||||
ButtonStep.UseVisualStyleBackColor = true;
|
|
||||||
ButtonStep.Click += ButtonStep_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
|
|
||||||
buttonUp.Location = new Point(622, 326);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(50, 50);
|
|
||||||
buttonUp.TabIndex = 4;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
|
|
||||||
buttonDown.Location = new Point(622, 382);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(50, 50);
|
|
||||||
buttonDown.TabIndex = 5;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
|
|
||||||
buttonLeft.Location = new Point(566, 382);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(50, 50);
|
|
||||||
buttonLeft.TabIndex = 6;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
|
|
||||||
buttonRight.Location = new Point(678, 382);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(50, 50);
|
|
||||||
buttonRight.TabIndex = 7;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// pictureBoxUsta
|
|
||||||
//
|
|
||||||
pictureBoxUsta.Dock = DockStyle.Fill;
|
|
||||||
pictureBoxUsta.Location = new Point(0, 0);
|
|
||||||
pictureBoxUsta.Name = "pictureBoxUsta";
|
|
||||||
pictureBoxUsta.Size = new Size(800, 450);
|
|
||||||
pictureBoxUsta.SizeMode = PictureBoxSizeMode.AutoSize;
|
|
||||||
pictureBoxUsta.TabIndex = 8;
|
|
||||||
pictureBoxUsta.TabStop = false;
|
|
||||||
//
|
|
||||||
// ButtonSelectUsta
|
|
||||||
//
|
|
||||||
ButtonSelectUsta.Location = new Point(348, 393);
|
|
||||||
ButtonSelectUsta.Name = "ButtonSelectUsta";
|
|
||||||
ButtonSelectUsta.Size = new Size(157, 42);
|
|
||||||
ButtonSelectUsta.TabIndex = 9;
|
|
||||||
ButtonSelectUsta.Text = "Выбор";
|
|
||||||
ButtonSelectUsta.UseVisualStyleBackColor = true;
|
|
||||||
ButtonSelectUsta.Click += ButtonSelectUsta_Click;
|
|
||||||
//
|
|
||||||
// FormSelfPropelledArtilleryUnit
|
// FormSelfPropelledArtilleryUnit
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(ButtonSelectUsta);
|
|
||||||
Controls.Add(buttonRight);
|
|
||||||
Controls.Add(buttonLeft);
|
|
||||||
Controls.Add(buttonDown);
|
|
||||||
Controls.Add(buttonUp);
|
|
||||||
Controls.Add(ButtonStep);
|
|
||||||
Controls.Add(ButtonCreateUsta);
|
|
||||||
Controls.Add(ButtonCreateUstaBat);
|
|
||||||
Controls.Add(comboBoxStrategy);
|
|
||||||
Controls.Add(pictureBoxUsta);
|
|
||||||
Name = "FormSelfPropelledArtilleryUnit";
|
Name = "FormSelfPropelledArtilleryUnit";
|
||||||
Text = "Создание арт. установки";
|
Text = "Form1";
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxUsta).EndInit();
|
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private ComboBox comboBoxStrategy;
|
|
||||||
private Button ButtonCreateUstaBat;
|
|
||||||
private Button ButtonCreateUsta;
|
|
||||||
private Button ButtonStep;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonRight;
|
|
||||||
private PictureBox pictureBoxUsta;
|
|
||||||
private Button ButtonSelectUsta;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,187 +1,10 @@
|
|||||||
using SelfPropelledArtilleryUnit.DrawningObjects;
|
|
||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
using SelfPropelledArtilleryUnit.MovementStrategy;
|
|
||||||
namespace SelfPropelledArtilleryUnit
|
namespace SelfPropelledArtilleryUnit
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Ôîðìà ðàáîòû ñ îáúåêòîì "Óñòàíîâêà ñ âîîðóæåíèåì"
|
|
||||||
/// </summary>
|
|
||||||
public partial class FormSelfPropelledArtilleryUnit : Form
|
public partial class FormSelfPropelledArtilleryUnit : Form
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
|
|
||||||
/// </summary>
|
|
||||||
private DrawningUsta? _drawningUsta;
|
|
||||||
/// <summary>
|
|
||||||
/// Ñòðàòåãèÿ ïåðåìåùåíèÿ
|
|
||||||
/// </summary>
|
|
||||||
private AbstractStrategy? _abstractStrategy;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Âûáðàííàÿ óñòàíîâêà
|
|
||||||
/// </summary>
|
|
||||||
public DrawningUsta? SelectedUsta { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Èíèöèàëèçàöèÿ ôîðìû
|
|
||||||
/// </summary>
|
|
||||||
public FormSelfPropelledArtilleryUnit()
|
public FormSelfPropelledArtilleryUnit()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_abstractStrategy = null;
|
|
||||||
SelectedUsta = null;
|
|
||||||
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Ìåòîä ïðîðèñîâêè óñòàíîâêè
|
|
||||||
/// </summary>
|
|
||||||
private void Draw()
|
|
||||||
{
|
|
||||||
if (_drawningUsta == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bitmap bmp = new(pictureBoxUsta.Width,
|
|
||||||
pictureBoxUsta.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawningUsta.DrawTransport(gr);
|
|
||||||
pictureBoxUsta.Image = bmp;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü àðò. óñòàíîâêó ñ âîîðóæåíèåì"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreateUstaBat_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
|
||||||
//TODO âûáîð îñíîâíîãî öâåòà
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
|
||||||
//TODO âûáîð äîïîëíèòåëüíîãî öâåòà
|
|
||||||
ColorDialog dialog_dop = new();
|
|
||||||
if (dialog_dop.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
dopColor = dialog_dop.Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
_drawningUsta = new DrawningUstaBat(random.Next(100, 300),
|
|
||||||
random.Next(1000, 3000),
|
|
||||||
color,
|
|
||||||
dopColor,
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
|
||||||
pictureBoxUsta.Width, pictureBoxUsta.Height);
|
|
||||||
_drawningUsta.SetPosition(random.Next(10, 100), random.Next(10,
|
|
||||||
100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü àðò. óñòàíîâêó"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreateUsta_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
_drawningUsta = new DrawningUsta(random.Next(100, 300),
|
|
||||||
random.Next(1000, 3000),
|
|
||||||
color,
|
|
||||||
pictureBoxUsta.Width, pictureBoxUsta.Height);
|
|
||||||
_drawningUsta.SetPosition(random.Next(10, 100), random.Next(10,
|
|
||||||
100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Èçìåíåíèå ïîëîæåíèÿ óñòàíîâêè
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningUsta == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
_drawningUsta.MoveTransport(DirectionType.Up);
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
_drawningUsta.MoveTransport(DirectionType.Down);
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
_drawningUsta.MoveTransport(DirectionType.Left);
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
_drawningUsta.MoveTransport(DirectionType.Right);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Øàã"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonStep_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningUsta == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxStrategy.Enabled)
|
|
||||||
{
|
|
||||||
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
|
||||||
switch
|
|
||||||
{
|
|
||||||
0 => new MoveToCenter(),
|
|
||||||
1 => new MoveToBorder(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
if (_abstractStrategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_abstractStrategy.SetData(new
|
|
||||||
DrawningObjectUsta(_drawningUsta), pictureBoxUsta.Width,
|
|
||||||
pictureBoxUsta.Height);
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
}
|
|
||||||
if (_abstractStrategy != null)
|
|
||||||
{
|
|
||||||
_abstractStrategy.MakeStep();
|
|
||||||
Draw();
|
|
||||||
|
|
||||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
|
||||||
{
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_abstractStrategy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSelectUsta_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
SelectedUsta = _drawningUsta;
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -117,63 +117,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
|
||||||
<data name="buttonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>
|
|
||||||
iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
|
||||||
DAAACwwBP0AiyAAAAcJJREFUaEPtmcFKAkEYx+0m9Sz1BguKh6wFL0FdRPRaFEUPUYfoBfTcKxT4BC7a
|
|
||||||
oc4dos5dXSGa/t8yH0TO1jjr7Iw1P/iBrM433++oVgL/iBg+w3cpvd6FK8Up/IDim/SM3lsJjmEWUa/X
|
|
||||||
RZIkYjQaZa/pmfQMes0hzCKazaaYTqeCmc1motVqfY05h16SG8GsQsyvEYzPMdoRjI8xC0cwPsUcQaMI
|
|
||||||
xoeYwhGMy5ilRTAuYpYewZQZYy2CKSPGegRjM6a0CMZGzA7MhsVxLNI0lVfZh+6iO/l+uA2NeYSi0WiU
|
|
||||||
GsHQnXQ37QAfaCFTXqHo9XpiPB7nOplMjELpDJ1VzWS73S6HvNBCpiSQB/1op9OR6+nTbreVs3KkXYy5
|
|
||||||
gaqhc9ZqNbmePnRGNStH2sWYA6gaOmcJIfuwECfwCb7lmMKiITRDNZuku+nrs3WuYdEQmuGcEBJCLBFC
|
|
||||||
QoglQkgIsUQICSGWCCEhxBJ/JuQKiiiK5Hr60Bk6K2c4h/5uFtVqVQwGAzEcDrXs9/vZGTorZzhnD/JC
|
|
||||||
ptIM52xB1XKLuAmdswbvoGpBHW8hzfCCDXgJ7yH9fKMjffYCrsNAwE8qlU+yNBGf6frdkAAAAABJRU5E
|
|
||||||
rkJggg==
|
|
||||||
</value>
|
|
||||||
</data>
|
|
||||||
<data name="buttonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>
|
|
||||||
iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
|
||||||
DAAACwwBP0AiyAAAAchJREFUaEPtmLFKM0EURqN1Kn0SMSJxSUjeQQsRUZsEku7HF9BafAF9AZukzANo
|
|
||||||
GUXtQwStVRLC32S9fneZATET3Z3NzOzKHDggiXPvPaUWPH+UVXgJn+BrTPl3L+AKzATL8AaSpteQZzhn
|
|
||||||
HaoOTOIadM4OVB2XxG3onGNIxWKRut0u9fv9WHY6negNv4X/eJBrziBVq1VKCr/ht2KGc84h1Wo1cV58
|
|
||||||
+A2/FTOc40N8iCF8iA8xhA/xIYbwIT7EED7EhxgiFyH8341T+A7lUqUpQ37yDZ7AJajNIVQNn9FgiPQA
|
|
||||||
anMFVUNntBDCt2hzC1VDZ2w2m+K8+DQaDeWsOfIt2rxAarfbNBgM5jocDikMQ3FefKbTafRWNVPaarVk
|
|
||||||
yDMfpMs9pHK5TOPxWKy3B+/k3XwDvOODdAngB6RKpWI1hnfxTt4tbtiCqdiFUUwQBDQajcQqc0wmE6rX
|
|
||||||
618jjuBCsBZjMkJiPMZGhMRYjM0IycJjXERIFhbjMkKSOiYLERLtmCxFSBLHZDFCEjsmyxGSX2PyECGZ
|
|
||||||
G5OnCMkejGJKpRL1er1I/pk/E9+l+mvPJvswivlmCPm7XLEJH+F/4QPcgB5PfigUPgEBKRF/8g21wAAA
|
|
||||||
AABJRU5ErkJggg==
|
|
||||||
</value>
|
|
||||||
</data>
|
|
||||||
<data name="buttonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>
|
|
||||||
iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
|
||||||
DAAACwwBP0AiyAAAAgdJREFUaEPtmD1uGkEYholTgEPhiIqGQ7gNPxJOAaJDKIULtw5OGqpEkWxfwE0O
|
|
||||||
QOEbcACM5DIFosgVcgAkfgRGib+872pBm8myzCJwZpx5pKdAYmAfZpmd3YTD4XD8txzBU/gOnsAstI6P
|
|
||||||
8CeUgL/gDbSGFvQOPpPJBEOWvoXGs4qo1Woyn8+lUqmoIV+g0fB0eoRSrVZlNpsJaTQaasg1NJbQCGJT
|
|
||||||
yNoIYktIZASxIeQDjIwgpodoRRCTQ/5aYqMICeGFcbED53AIv8OvkDsJbWJFkFarpYbsy2/wJdxI7Aiy
|
|
||||||
WCxkMBhIv9/fqZ1OR9LptBpThpFsFbFvCoWCGvIerkX7j/3UlEolNeQChsJC700mzcQS3ZDX0NuKmxhB
|
|
||||||
dEMuoeRyOZlMJv5Qs9ANuYVSr9f9YeahG/IJSjableFw6A81C92QV5BXUCkWizIej/3h5qAbQvjgwFt6
|
|
||||||
TYyJE0L4JMSLyefzMhqN/I/598QNIWfQuJnhD8tjCngON7JVzHQ6lV6vJ91ud6e2221JpVJqSAFqETum
|
|
||||||
2WyqX7Yv7+ALqE2smJD7Ea6E0x04gj/gPbyChzA22guADffsWjE2hJCNMbaEkMgYm0LI2hjbQkhojI0h
|
|
||||||
5I+lmTHlclkN+QytYBWTTCbVCJqH1sDT7AEGA/jamtkIcgC593kDjyHvbxwOh8PxnEkkfgN6PQ5e0uzk
|
|
||||||
oAAAAABJRU5ErkJggg==
|
|
||||||
</value>
|
|
||||||
</data>
|
|
||||||
<data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>
|
|
||||||
iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
|
||||||
DAAACwwBP0AiyAAAAhhJREFUaEPtmb2KWkEYhmUJaIKEgIUEvInU/qBhQVAQRFKk2GKbXWSbSIqQJneQ
|
|
||||||
IhdgrsFehLQBscgt5AIEf0DXZGffF84ZJus5o+se43wwDzyFxRm+h/PjGU15PB6Px8Jr+Ba+g+/hSyiO
|
|
||||||
r/AvVIZ/4A0Uwzk0A1QulzM/f4Ai+Az14PV6Xa1WK9VsNsXFfIF66E6no8h6vVatVsuM+QidJjKESIuJ
|
|
||||||
DSGSYqwhRErMzhAiIWavEJJUzCv4Df6CU7iCtwn4zxehLYTw0dxoNMyYRz2an8Gf0FzgKPZ6vWDkeJ4S
|
|
||||||
w3cgfWA2m1WDwUCNx+NEnUwmarPZBOPaOTTmGuqDSqVSsNxpOSSmC/UBlUolWOr0PPYB4GwIiTgzvIIi
|
|
||||||
cTqEPIjZwMj9jPMhZLFYqEKhEM7Jt+otRISQdrsdzvkdbiEiZDqdqnw+H84ZedM7HzKfz1W5XA5nXMMM
|
|
||||||
3MLpkAcRd5A/YETibAhv8Gq1akZcwliuoA4pFovBMqcl4kxcQCsVqEMymYzq9/tqOBwm6mg0UsvlMhjT
|
|
||||||
ziER5AyOoI45lt1uNxg1nkMjQp5DboJ+wN9wBpcJyD2JDtm1H3lqxDHZe4fIy65Wq5kR1hv7f7NXiOsR
|
|
||||||
ZGeIhAhiDZESQWJDJEWQyBBpEeQT1CEcfjabOfuItVGGOoSm02lxESHczfHV2wziZ/4FJ44X8A0sBvK1
|
|
||||||
yOPxeDxSSaXuAf56EEyW1ZwcAAAAAElFTkSuQmCC
|
|
||||||
</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
</root>
|
@ -1,249 +0,0 @@
|
|||||||
namespace SelfPropelledArtilleryUnit
|
|
||||||
{
|
|
||||||
partial class FormSelfPropelledArtilleryUnitCollection
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
ButtonAddUsta = new Button();
|
|
||||||
ButtonRemoveUsta = new Button();
|
|
||||||
ButtonRefreshCollection = new Button();
|
|
||||||
pictureBoxCollection = new PictureBox();
|
|
||||||
maskedTextBoxNumber = new MaskedTextBox();
|
|
||||||
groupBox1 = new GroupBox();
|
|
||||||
groupBox2 = new GroupBox();
|
|
||||||
listBoxStorage = new ListBox();
|
|
||||||
ButtonDelObject = new Button();
|
|
||||||
ButtonAddObject = new Button();
|
|
||||||
textBoxStorageName = new TextBox();
|
|
||||||
menuStrip = new MenuStrip();
|
|
||||||
fileToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
SaveToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
LoadToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
openFileDialog = new OpenFileDialog();
|
|
||||||
saveFileDialog = new SaveFileDialog();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
|
||||||
groupBox1.SuspendLayout();
|
|
||||||
groupBox2.SuspendLayout();
|
|
||||||
menuStrip.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// ButtonAddUsta
|
|
||||||
//
|
|
||||||
ButtonAddUsta.Location = new Point(26, 366);
|
|
||||||
ButtonAddUsta.Name = "ButtonAddUsta";
|
|
||||||
ButtonAddUsta.Size = new Size(166, 40);
|
|
||||||
ButtonAddUsta.TabIndex = 0;
|
|
||||||
ButtonAddUsta.Text = "Добавить арт. установку";
|
|
||||||
ButtonAddUsta.UseVisualStyleBackColor = true;
|
|
||||||
ButtonAddUsta.Click += ButtonAddUsta_Click;
|
|
||||||
//
|
|
||||||
// ButtonRemoveUsta
|
|
||||||
//
|
|
||||||
ButtonRemoveUsta.Location = new Point(26, 457);
|
|
||||||
ButtonRemoveUsta.Name = "ButtonRemoveUsta";
|
|
||||||
ButtonRemoveUsta.Size = new Size(166, 39);
|
|
||||||
ButtonRemoveUsta.TabIndex = 1;
|
|
||||||
ButtonRemoveUsta.Text = "Удалить арт. установку";
|
|
||||||
ButtonRemoveUsta.UseVisualStyleBackColor = true;
|
|
||||||
ButtonRemoveUsta.Click += ButtonRemoveUsta_Click;
|
|
||||||
//
|
|
||||||
// ButtonRefreshCollection
|
|
||||||
//
|
|
||||||
ButtonRefreshCollection.Location = new Point(26, 502);
|
|
||||||
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
|
||||||
ButtonRefreshCollection.Size = new Size(166, 40);
|
|
||||||
ButtonRefreshCollection.TabIndex = 2;
|
|
||||||
ButtonRefreshCollection.Text = "Обновить коллекцию";
|
|
||||||
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
|
||||||
ButtonRefreshCollection.Click += ButtonRefreshCollection_Click;
|
|
||||||
//
|
|
||||||
// pictureBoxCollection
|
|
||||||
//
|
|
||||||
pictureBoxCollection.Location = new Point(0, 0);
|
|
||||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
|
||||||
pictureBoxCollection.Size = new Size(637, 583);
|
|
||||||
pictureBoxCollection.SizeMode = PictureBoxSizeMode.Zoom;
|
|
||||||
pictureBoxCollection.TabIndex = 3;
|
|
||||||
pictureBoxCollection.TabStop = false;
|
|
||||||
//
|
|
||||||
// maskedTextBoxNumber
|
|
||||||
//
|
|
||||||
maskedTextBoxNumber.Font = new Font("Showcard Gothic", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
|
||||||
maskedTextBoxNumber.Location = new Point(58, 429);
|
|
||||||
maskedTextBoxNumber.Mask = "00";
|
|
||||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
|
||||||
maskedTextBoxNumber.Size = new Size(100, 22);
|
|
||||||
maskedTextBoxNumber.TabIndex = 4;
|
|
||||||
maskedTextBoxNumber.ValidatingType = typeof(int);
|
|
||||||
//
|
|
||||||
// groupBox1
|
|
||||||
//
|
|
||||||
groupBox1.Controls.Add(groupBox2);
|
|
||||||
groupBox1.Controls.Add(ButtonAddUsta);
|
|
||||||
groupBox1.Controls.Add(ButtonRefreshCollection);
|
|
||||||
groupBox1.Controls.Add(maskedTextBoxNumber);
|
|
||||||
groupBox1.Controls.Add(ButtonRemoveUsta);
|
|
||||||
groupBox1.Controls.Add(menuStrip);
|
|
||||||
groupBox1.Location = new Point(643, 12);
|
|
||||||
groupBox1.Name = "groupBox1";
|
|
||||||
groupBox1.Size = new Size(209, 560);
|
|
||||||
groupBox1.TabIndex = 5;
|
|
||||||
groupBox1.TabStop = false;
|
|
||||||
groupBox1.Text = "Инструменты";
|
|
||||||
//
|
|
||||||
// groupBox2
|
|
||||||
//
|
|
||||||
groupBox2.Controls.Add(listBoxStorage);
|
|
||||||
groupBox2.Controls.Add(ButtonDelObject);
|
|
||||||
groupBox2.Controls.Add(ButtonAddObject);
|
|
||||||
groupBox2.Controls.Add(textBoxStorageName);
|
|
||||||
groupBox2.Location = new Point(6, 64);
|
|
||||||
groupBox2.Name = "groupBox2";
|
|
||||||
groupBox2.Size = new Size(197, 274);
|
|
||||||
groupBox2.TabIndex = 6;
|
|
||||||
groupBox2.TabStop = false;
|
|
||||||
groupBox2.Text = "Наборы";
|
|
||||||
//
|
|
||||||
// listBoxStorage
|
|
||||||
//
|
|
||||||
listBoxStorage.FormattingEnabled = true;
|
|
||||||
listBoxStorage.ItemHeight = 15;
|
|
||||||
listBoxStorage.Location = new Point(20, 106);
|
|
||||||
listBoxStorage.Name = "listBoxStorage";
|
|
||||||
listBoxStorage.Size = new Size(158, 109);
|
|
||||||
listBoxStorage.TabIndex = 9;
|
|
||||||
listBoxStorage.SelectedIndexChanged += listBoxStorage_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// ButtonDelObject
|
|
||||||
//
|
|
||||||
ButtonDelObject.Location = new Point(33, 235);
|
|
||||||
ButtonDelObject.Name = "ButtonDelObject";
|
|
||||||
ButtonDelObject.Size = new Size(136, 33);
|
|
||||||
ButtonDelObject.TabIndex = 8;
|
|
||||||
ButtonDelObject.Text = "Удалить набор";
|
|
||||||
ButtonDelObject.UseVisualStyleBackColor = true;
|
|
||||||
ButtonDelObject.Click += ButtonDelObject_Click;
|
|
||||||
//
|
|
||||||
// ButtonAddObject
|
|
||||||
//
|
|
||||||
ButtonAddObject.Location = new Point(33, 54);
|
|
||||||
ButtonAddObject.Name = "ButtonAddObject";
|
|
||||||
ButtonAddObject.Size = new Size(136, 33);
|
|
||||||
ButtonAddObject.TabIndex = 7;
|
|
||||||
ButtonAddObject.Text = "Добавить набор";
|
|
||||||
ButtonAddObject.UseVisualStyleBackColor = true;
|
|
||||||
ButtonAddObject.Click += ButtonAddObject_Click;
|
|
||||||
//
|
|
||||||
// textBoxStorageName
|
|
||||||
//
|
|
||||||
textBoxStorageName.Location = new Point(20, 22);
|
|
||||||
textBoxStorageName.Name = "textBoxStorageName";
|
|
||||||
textBoxStorageName.Size = new Size(158, 23);
|
|
||||||
textBoxStorageName.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// menuStrip
|
|
||||||
//
|
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
|
|
||||||
menuStrip.Location = new Point(3, 19);
|
|
||||||
menuStrip.Name = "menuStrip";
|
|
||||||
menuStrip.Size = new Size(203, 24);
|
|
||||||
menuStrip.TabIndex = 7;
|
|
||||||
menuStrip.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// fileToolStripMenuItem
|
|
||||||
//
|
|
||||||
fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
|
||||||
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
|
||||||
fileToolStripMenuItem.Size = new Size(48, 20);
|
|
||||||
fileToolStripMenuItem.Text = "Файл";
|
|
||||||
//
|
|
||||||
// SaveToolStripMenuItem
|
|
||||||
//
|
|
||||||
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
|
||||||
SaveToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
SaveToolStripMenuItem.Text = "Сохранение";
|
|
||||||
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// LoadToolStripMenuItem
|
|
||||||
//
|
|
||||||
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
|
||||||
LoadToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
LoadToolStripMenuItem.Text = "Загрузка";
|
|
||||||
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// openFileDialog
|
|
||||||
//
|
|
||||||
openFileDialog.FileName = "openFileDialog1";
|
|
||||||
openFileDialog.Filter = "txt file | *.txt";
|
|
||||||
openFileDialog.Title = "Сохранить текстовый файл";
|
|
||||||
//
|
|
||||||
// saveFileDialog
|
|
||||||
//
|
|
||||||
saveFileDialog.Filter = "txt file | *.txt";
|
|
||||||
saveFileDialog.Title = "Выберите текстовый файл";
|
|
||||||
//
|
|
||||||
// FormSelfPropelledArtilleryUnitCollection
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(867, 584);
|
|
||||||
Controls.Add(groupBox1);
|
|
||||||
Controls.Add(pictureBoxCollection);
|
|
||||||
MainMenuStrip = menuStrip;
|
|
||||||
Name = "FormSelfPropelledArtilleryUnitCollection";
|
|
||||||
Text = "Набор арт. установок";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
|
||||||
groupBox1.ResumeLayout(false);
|
|
||||||
groupBox1.PerformLayout();
|
|
||||||
groupBox2.ResumeLayout(false);
|
|
||||||
groupBox2.PerformLayout();
|
|
||||||
menuStrip.ResumeLayout(false);
|
|
||||||
menuStrip.PerformLayout();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button ButtonAddUsta;
|
|
||||||
private Button ButtonRemoveUsta;
|
|
||||||
private Button ButtonRefreshCollection;
|
|
||||||
private PictureBox pictureBoxCollection;
|
|
||||||
private MaskedTextBox maskedTextBoxNumber;
|
|
||||||
private GroupBox groupBox1;
|
|
||||||
private GroupBox groupBox2;
|
|
||||||
private TextBox textBoxStorageName;
|
|
||||||
private ListBox listBoxStorage;
|
|
||||||
private Button ButtonDelObject;
|
|
||||||
private Button ButtonAddObject;
|
|
||||||
private MenuStrip menuStrip;
|
|
||||||
private ToolStripMenuItem fileToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
|
||||||
private OpenFileDialog openFileDialog;
|
|
||||||
private SaveFileDialog saveFileDialog;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,265 +0,0 @@
|
|||||||
|
|
||||||
using SelfPropelledArtilleryUnit.DrawningObjects;
|
|
||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
using SelfPropelledArtilleryUnit.Generics;
|
|
||||||
using SelfPropelledArtilleryUnit.MovementStrategy;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Форма для работы с набором объектов класса DrawningUsta
|
|
||||||
/// </summary>
|
|
||||||
public partial class FormSelfPropelledArtilleryUnitCollection : Form
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Набор объектов
|
|
||||||
/// </summary>
|
|
||||||
private readonly UstaGenericStorage _storage;
|
|
||||||
/// <summary>
|
|
||||||
/// Логер
|
|
||||||
/// </summary>
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public FormSelfPropelledArtilleryUnitCollection(ILogger<FormSelfPropelledArtilleryUnitCollection> logger)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_storage = new UstaGenericStorage(pictureBoxCollection.Width,
|
|
||||||
pictureBoxCollection.Height);
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Заполнение listBoxObjects
|
|
||||||
/// </summary>
|
|
||||||
private void ReloadObjects()
|
|
||||||
{
|
|
||||||
int index = listBoxStorage.SelectedIndex;
|
|
||||||
listBoxStorage.Items.Clear();
|
|
||||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
|
||||||
{
|
|
||||||
listBoxStorage.Items.Add(_storage.Keys[i]);
|
|
||||||
}
|
|
||||||
if (listBoxStorage.Items.Count > 0 && (index == -1 || index
|
|
||||||
>= listBoxStorage.Items.Count))
|
|
||||||
{
|
|
||||||
listBoxStorage.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
else if (listBoxStorage.Items.Count > 0 && index > -1 &&
|
|
||||||
index < listBoxStorage.Items.Count)
|
|
||||||
{
|
|
||||||
listBoxStorage.SelectedIndex = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление набора в коллекцию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
_logger.LogWarning("Пустое название набора");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_storage.AddSet(textBoxStorageName.Text);
|
|
||||||
ReloadObjects();
|
|
||||||
_logger.LogInformation($"Добавлен набор:{ textBoxStorageName.Text}");
|
|
||||||
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Выбор набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void listBoxStorage_SelectedIndexChanged(object sender,
|
|
||||||
EventArgs e)
|
|
||||||
{
|
|
||||||
pictureBoxCollection.Image =
|
|
||||||
_storage[listBoxStorage.SelectedItem?.ToString() ?? string.Empty]?.ShowUsta();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonDelObject_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorage.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Удаление невыбранного набора");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string name = listBoxStorage.SelectedItem.ToString() ?? string.Empty;
|
|
||||||
if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
|
|
||||||
{
|
|
||||||
_storage.DelSet(listBoxStorage.SelectedItem.ToString()
|
|
||||||
?? string.Empty);
|
|
||||||
ReloadObjects();
|
|
||||||
_logger.LogInformation($"Удален набор: {name}");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в набор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonAddUsta_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorage.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var formSelfPropelledArtilleryUnitConfig = new FormSelfPropelledArtilleryUnitConfig();
|
|
||||||
|
|
||||||
formSelfPropelledArtilleryUnitConfig.AddEvent(usta =>
|
|
||||||
{
|
|
||||||
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Добавление пустого объекта");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_ = obj + usta;
|
|
||||||
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBoxCollection.Image = obj.ShowUsta();
|
|
||||||
_logger.LogInformation($"Добавлен объект в набор {listBoxStorage.SelectedItem.ToString()}");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
_logger.LogWarning($"{ex.Message} в наборе {listBoxStorage.SelectedItem.ToString()}");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
formSelfPropelledArtilleryUnitConfig.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление объекта из набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonRemoveUsta_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorage.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Удаление объекта из несуществующего набора");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var obj = _storage[listBoxStorage.SelectedItem.ToString() ??
|
|
||||||
string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (obj - pos != null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBoxCollection.Image = obj.ShowUsta();
|
|
||||||
_logger.LogInformation($"Удален объект из набора {listBoxStorage.SelectedItem.ToString()}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
_logger.LogWarning($"Не удалось удалить объект из набора {listBoxStorage.SelectedItem.ToString()}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (UstaNotFoundException ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message);
|
|
||||||
_logger.LogWarning($"{ex.Message} из набора {listBoxStorage.SelectedItem.ToString()}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Обновление рисунка по набору
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonRefreshCollection_Click(object sender, EventArgs
|
|
||||||
e)
|
|
||||||
{
|
|
||||||
if (listBoxStorage.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var obj = _storage[listBoxStorage.SelectedItem.ToString() ??
|
|
||||||
string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBoxCollection.Image = obj.ShowUsta();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия "Сохранение"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_storage.SaveData(saveFileDialog.FileName);
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
_logger.LogInformation($"Сохранение наборов в файл {saveFileDialog.FileName}");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
_logger.LogWarning($"Не удалось сохранить наборы с ошибкой: {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
|
|
||||||
{
|
|
||||||
_storage.LoadData(openFileDialog.FileName);
|
|
||||||
ReloadObjects();
|
|
||||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
_logger.LogInformation($"Загрузились наборы из файла {openFileDialog.FileName}");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
_logger.LogWarning($"Не удалось сохранить наборы с ошибкой: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
|||||||
<?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>
|
|
||||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>126, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>259, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,362 +0,0 @@
|
|||||||
namespace SelfPropelledArtilleryUnit
|
|
||||||
{
|
|
||||||
partial class FormSelfPropelledArtilleryUnitConfig
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
groupBox1 = new GroupBox();
|
|
||||||
labelModifiedObject = new Label();
|
|
||||||
labelSimpleObject = new Label();
|
|
||||||
groupBox2 = new GroupBox();
|
|
||||||
panelPurple = new Panel();
|
|
||||||
panelYellow = new Panel();
|
|
||||||
panelBlack = new Panel();
|
|
||||||
panelBlue = new Panel();
|
|
||||||
panelGray = new Panel();
|
|
||||||
panelGreen = new Panel();
|
|
||||||
panelWhite = new Panel();
|
|
||||||
panelRed = new Panel();
|
|
||||||
checkBoxBodyKit = new CheckBox();
|
|
||||||
checkBoxPushka = new CheckBox();
|
|
||||||
numericUpDownWeight = new NumericUpDown();
|
|
||||||
numericUpDownSpeed = new NumericUpDown();
|
|
||||||
label2 = new Label();
|
|
||||||
label1 = new Label();
|
|
||||||
panelColor = new Panel();
|
|
||||||
labelDopColor = new Label();
|
|
||||||
labelBaseColor = new Label();
|
|
||||||
pictureBoxObject = new PictureBox();
|
|
||||||
ButtonOk = new Button();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
groupBox1.SuspendLayout();
|
|
||||||
groupBox2.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
|
||||||
panelColor.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBox1
|
|
||||||
//
|
|
||||||
groupBox1.Controls.Add(labelModifiedObject);
|
|
||||||
groupBox1.Controls.Add(labelSimpleObject);
|
|
||||||
groupBox1.Controls.Add(groupBox2);
|
|
||||||
groupBox1.Controls.Add(checkBoxBodyKit);
|
|
||||||
groupBox1.Controls.Add(checkBoxPushka);
|
|
||||||
groupBox1.Controls.Add(numericUpDownWeight);
|
|
||||||
groupBox1.Controls.Add(numericUpDownSpeed);
|
|
||||||
groupBox1.Controls.Add(label2);
|
|
||||||
groupBox1.Controls.Add(label1);
|
|
||||||
groupBox1.Location = new Point(12, 12);
|
|
||||||
groupBox1.Name = "groupBox1";
|
|
||||||
groupBox1.Size = new Size(454, 228);
|
|
||||||
groupBox1.TabIndex = 0;
|
|
||||||
groupBox1.TabStop = false;
|
|
||||||
groupBox1.Text = "Параметры";
|
|
||||||
//
|
|
||||||
// labelModifiedObject
|
|
||||||
//
|
|
||||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelModifiedObject.Location = new Point(313, 146);
|
|
||||||
labelModifiedObject.Name = "labelModifiedObject";
|
|
||||||
labelModifiedObject.Size = new Size(87, 27);
|
|
||||||
labelModifiedObject.TabIndex = 8;
|
|
||||||
labelModifiedObject.Text = "Продвинутый";
|
|
||||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// labelSimpleObject
|
|
||||||
//
|
|
||||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelSimpleObject.Location = new Point(215, 146);
|
|
||||||
labelSimpleObject.Name = "labelSimpleObject";
|
|
||||||
labelSimpleObject.Size = new Size(87, 27);
|
|
||||||
labelSimpleObject.TabIndex = 7;
|
|
||||||
labelSimpleObject.Text = "Простой";
|
|
||||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// groupBox2
|
|
||||||
//
|
|
||||||
groupBox2.Controls.Add(panelPurple);
|
|
||||||
groupBox2.Controls.Add(panelYellow);
|
|
||||||
groupBox2.Controls.Add(panelBlack);
|
|
||||||
groupBox2.Controls.Add(panelBlue);
|
|
||||||
groupBox2.Controls.Add(panelGray);
|
|
||||||
groupBox2.Controls.Add(panelGreen);
|
|
||||||
groupBox2.Controls.Add(panelWhite);
|
|
||||||
groupBox2.Controls.Add(panelRed);
|
|
||||||
groupBox2.Location = new Point(215, 32);
|
|
||||||
groupBox2.Name = "groupBox2";
|
|
||||||
groupBox2.Size = new Size(185, 106);
|
|
||||||
groupBox2.TabIndex = 6;
|
|
||||||
groupBox2.TabStop = false;
|
|
||||||
groupBox2.Text = "Цвета";
|
|
||||||
//
|
|
||||||
// panelPurple
|
|
||||||
//
|
|
||||||
panelPurple.BackColor = Color.Purple;
|
|
||||||
panelPurple.Location = new Point(139, 63);
|
|
||||||
panelPurple.Name = "panelPurple";
|
|
||||||
panelPurple.Size = new Size(35, 30);
|
|
||||||
panelPurple.TabIndex = 7;
|
|
||||||
panelPurple.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelYellow
|
|
||||||
//
|
|
||||||
panelYellow.BackColor = Color.Yellow;
|
|
||||||
panelYellow.Location = new Point(139, 22);
|
|
||||||
panelYellow.Name = "panelYellow";
|
|
||||||
panelYellow.Size = new Size(35, 30);
|
|
||||||
panelYellow.TabIndex = 3;
|
|
||||||
panelYellow.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelBlack
|
|
||||||
//
|
|
||||||
panelBlack.BackColor = Color.Black;
|
|
||||||
panelBlack.Location = new Point(98, 63);
|
|
||||||
panelBlack.Name = "panelBlack";
|
|
||||||
panelBlack.Size = new Size(35, 30);
|
|
||||||
panelBlack.TabIndex = 6;
|
|
||||||
panelBlack.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelBlue
|
|
||||||
//
|
|
||||||
panelBlue.BackColor = Color.Blue;
|
|
||||||
panelBlue.Location = new Point(98, 22);
|
|
||||||
panelBlue.Name = "panelBlue";
|
|
||||||
panelBlue.Size = new Size(35, 30);
|
|
||||||
panelBlue.TabIndex = 2;
|
|
||||||
panelBlue.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelGray
|
|
||||||
//
|
|
||||||
panelGray.BackColor = Color.Gray;
|
|
||||||
panelGray.Location = new Point(57, 63);
|
|
||||||
panelGray.Name = "panelGray";
|
|
||||||
panelGray.Size = new Size(35, 30);
|
|
||||||
panelGray.TabIndex = 5;
|
|
||||||
panelGray.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelGreen
|
|
||||||
//
|
|
||||||
panelGreen.BackColor = Color.Green;
|
|
||||||
panelGreen.Location = new Point(57, 22);
|
|
||||||
panelGreen.Name = "panelGreen";
|
|
||||||
panelGreen.Size = new Size(35, 30);
|
|
||||||
panelGreen.TabIndex = 1;
|
|
||||||
panelGreen.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelWhite
|
|
||||||
//
|
|
||||||
panelWhite.BackColor = Color.White;
|
|
||||||
panelWhite.Location = new Point(16, 63);
|
|
||||||
panelWhite.Name = "panelWhite";
|
|
||||||
panelWhite.Size = new Size(35, 30);
|
|
||||||
panelWhite.TabIndex = 4;
|
|
||||||
panelWhite.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelRed
|
|
||||||
//
|
|
||||||
panelRed.BackColor = Color.Red;
|
|
||||||
panelRed.Location = new Point(16, 22);
|
|
||||||
panelRed.Name = "panelRed";
|
|
||||||
panelRed.Size = new Size(35, 30);
|
|
||||||
panelRed.TabIndex = 0;
|
|
||||||
panelRed.MouseDown += panelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// checkBoxBodyKit
|
|
||||||
//
|
|
||||||
checkBoxBodyKit.AutoSize = true;
|
|
||||||
checkBoxBodyKit.Location = new Point(10, 154);
|
|
||||||
checkBoxBodyKit.Name = "checkBoxBodyKit";
|
|
||||||
checkBoxBodyKit.Size = new Size(170, 19);
|
|
||||||
checkBoxBodyKit.TabIndex = 5;
|
|
||||||
checkBoxBodyKit.Text = "Признак наличия батареи";
|
|
||||||
checkBoxBodyKit.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxPushka
|
|
||||||
//
|
|
||||||
checkBoxPushka.AutoSize = true;
|
|
||||||
checkBoxPushka.Location = new Point(10, 119);
|
|
||||||
checkBoxPushka.Name = "checkBoxPushka";
|
|
||||||
checkBoxPushka.Size = new Size(163, 19);
|
|
||||||
checkBoxPushka.TabIndex = 4;
|
|
||||||
checkBoxPushka.Text = "Признак наличия пушки";
|
|
||||||
checkBoxPushka.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// numericUpDownWeight
|
|
||||||
//
|
|
||||||
numericUpDownWeight.Location = new Point(76, 60);
|
|
||||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
|
||||||
numericUpDownWeight.Size = new Size(73, 23);
|
|
||||||
numericUpDownWeight.TabIndex = 3;
|
|
||||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// numericUpDownSpeed
|
|
||||||
//
|
|
||||||
numericUpDownSpeed.Location = new Point(76, 31);
|
|
||||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
|
||||||
numericUpDownSpeed.Size = new Size(73, 23);
|
|
||||||
numericUpDownSpeed.TabIndex = 2;
|
|
||||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(10, 62);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(29, 15);
|
|
||||||
label2.TabIndex = 1;
|
|
||||||
label2.Text = "Вес:";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(10, 33);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(62, 15);
|
|
||||||
label1.TabIndex = 0;
|
|
||||||
label1.Text = "Скорость:";
|
|
||||||
//
|
|
||||||
// panelColor
|
|
||||||
//
|
|
||||||
panelColor.AllowDrop = true;
|
|
||||||
panelColor.Controls.Add(labelDopColor);
|
|
||||||
panelColor.Controls.Add(labelBaseColor);
|
|
||||||
panelColor.Controls.Add(pictureBoxObject);
|
|
||||||
panelColor.Location = new Point(472, 12);
|
|
||||||
panelColor.Name = "panelColor";
|
|
||||||
panelColor.Size = new Size(276, 184);
|
|
||||||
panelColor.TabIndex = 1;
|
|
||||||
panelColor.DragDrop += PanelObject_DragDrop;
|
|
||||||
panelColor.DragEnter += PanelObject_DragEnter;
|
|
||||||
//
|
|
||||||
// labelDopColor
|
|
||||||
//
|
|
||||||
labelDopColor.AllowDrop = true;
|
|
||||||
labelDopColor.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelDopColor.Location = new Point(164, 10);
|
|
||||||
labelDopColor.Name = "labelDopColor";
|
|
||||||
labelDopColor.Size = new Size(100, 29);
|
|
||||||
labelDopColor.TabIndex = 2;
|
|
||||||
labelDopColor.Text = "Доп. цвет";
|
|
||||||
labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelDopColor.DragDrop += LabelDopColor_DragDrop;
|
|
||||||
labelDopColor.DragEnter += LabelColor_DragEnter;
|
|
||||||
labelDopColor.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// labelBaseColor
|
|
||||||
//
|
|
||||||
labelBaseColor.AllowDrop = true;
|
|
||||||
labelBaseColor.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelBaseColor.Location = new Point(12, 10);
|
|
||||||
labelBaseColor.Name = "labelBaseColor";
|
|
||||||
labelBaseColor.Size = new Size(100, 29);
|
|
||||||
labelBaseColor.TabIndex = 2;
|
|
||||||
labelBaseColor.Text = "Цвет";
|
|
||||||
labelBaseColor.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelBaseColor.DragDrop += LabelBaseColor_DragDrop;
|
|
||||||
labelBaseColor.DragEnter += LabelColor_DragEnter;
|
|
||||||
labelBaseColor.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// pictureBoxObject
|
|
||||||
//
|
|
||||||
pictureBoxObject.Location = new Point(12, 46);
|
|
||||||
pictureBoxObject.Name = "pictureBoxObject";
|
|
||||||
pictureBoxObject.Size = new Size(252, 127);
|
|
||||||
pictureBoxObject.TabIndex = 0;
|
|
||||||
pictureBoxObject.TabStop = false;
|
|
||||||
//
|
|
||||||
// ButtonOk
|
|
||||||
//
|
|
||||||
ButtonOk.Location = new Point(484, 208);
|
|
||||||
ButtonOk.Name = "ButtonOk";
|
|
||||||
ButtonOk.Size = new Size(100, 32);
|
|
||||||
ButtonOk.TabIndex = 2;
|
|
||||||
ButtonOk.Text = "Добавить";
|
|
||||||
ButtonOk.UseVisualStyleBackColor = true;
|
|
||||||
ButtonOk.Click += ButtonOk_Click;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Location = new Point(636, 208);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(100, 32);
|
|
||||||
buttonCancel.TabIndex = 3;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// FormSelfPropelledArtilleryUnitConfig
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 252);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(ButtonOk);
|
|
||||||
Controls.Add(panelColor);
|
|
||||||
Controls.Add(groupBox1);
|
|
||||||
Name = "FormSelfPropelledArtilleryUnitConfig";
|
|
||||||
Text = "FormSelfPropelledArtilleryUnitConfig";
|
|
||||||
groupBox1.ResumeLayout(false);
|
|
||||||
groupBox1.PerformLayout();
|
|
||||||
groupBox2.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
|
||||||
panelColor.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBox1;
|
|
||||||
private NumericUpDown numericUpDownWeight;
|
|
||||||
private NumericUpDown numericUpDownSpeed;
|
|
||||||
private Label label2;
|
|
||||||
private Label label1;
|
|
||||||
private GroupBox groupBox2;
|
|
||||||
private CheckBox checkBoxBodyKit;
|
|
||||||
private CheckBox checkBoxPushka;
|
|
||||||
private Panel panelPurple;
|
|
||||||
private Panel panelYellow;
|
|
||||||
private Panel panelBlack;
|
|
||||||
private Panel panelBlue;
|
|
||||||
private Panel panelGray;
|
|
||||||
private Panel panelGreen;
|
|
||||||
private Panel panelWhite;
|
|
||||||
private Panel panelRed;
|
|
||||||
private Label labelSimpleObject;
|
|
||||||
private Label labelModifiedObject;
|
|
||||||
private Panel panelColor;
|
|
||||||
private PictureBox pictureBoxObject;
|
|
||||||
private Label labelDopColor;
|
|
||||||
private Label labelBaseColor;
|
|
||||||
private Button ButtonOk;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,180 +0,0 @@
|
|||||||
|
|
||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
using SelfPropelledArtilleryUnit.Entities;
|
|
||||||
using SelfPropelledArtilleryUnit;
|
|
||||||
using SelfPropelledArtilleryUnit.DrawningObjects;
|
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Форма создания объекта
|
|
||||||
/// </summary>
|
|
||||||
public partial class FormSelfPropelledArtilleryUnitConfig : Form
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Переменная-выбранная установка
|
|
||||||
/// </summary>
|
|
||||||
DrawningUsta? _usta = null;
|
|
||||||
/// <summary>
|
|
||||||
/// Событие
|
|
||||||
/// </summary>
|
|
||||||
private event Action<DrawningUsta> EventAddUsta;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public FormSelfPropelledArtilleryUnitConfig()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
panelBlack.MouseDown += panelColor_MouseDown;
|
|
||||||
panelPurple.MouseDown += panelColor_MouseDown;
|
|
||||||
panelGray.MouseDown += panelColor_MouseDown;
|
|
||||||
panelGreen.MouseDown += panelColor_MouseDown;
|
|
||||||
panelRed.MouseDown += panelColor_MouseDown;
|
|
||||||
panelWhite.MouseDown += panelColor_MouseDown;
|
|
||||||
panelYellow.MouseDown += panelColor_MouseDown;
|
|
||||||
panelBlue.MouseDown += panelColor_MouseDown;
|
|
||||||
// TODO buttonCancel.Click with lambda
|
|
||||||
buttonCancel.Click += (sender, e) => Close();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Отрисовать установку
|
|
||||||
/// </summary>
|
|
||||||
private void DrawUsta()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_usta?.SetPosition(5, 5);
|
|
||||||
_usta?.DrawTransport(gr);
|
|
||||||
pictureBoxObject.Image = bmp;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление события
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ev">Привязанный метод</param>
|
|
||||||
public void AddEvent(Action<DrawningUsta> ev)
|
|
||||||
{
|
|
||||||
if (EventAddUsta == null)
|
|
||||||
{
|
|
||||||
EventAddUsta = new Action<DrawningUsta>(ev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EventAddUsta += ev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <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, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = 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":
|
|
||||||
_usta = new DrawningUsta((int)numericUpDownSpeed.Value,
|
|
||||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
|
||||||
pictureBoxObject.Height);
|
|
||||||
break;
|
|
||||||
case "labelModifiedObject":
|
|
||||||
_usta = new DrawningUstaBat((int)numericUpDownSpeed.Value,
|
|
||||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBodyKit.Checked,
|
|
||||||
checkBoxPushka.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DrawUsta();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Отправляем цвет с панели
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void panelColor_MouseDown(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
|
||||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (_usta != null)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
_usta.EntityUsta.BodyColor = (Color)e.Data.GetData(typeof(Color));
|
|
||||||
|
|
||||||
}
|
|
||||||
DrawUsta();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (_usta != null && _usta.EntityUsta is EntityUstaBat entityustabat)
|
|
||||||
{
|
|
||||||
labelDopColor.AllowDrop = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
labelDopColor.AllowDrop = false;
|
|
||||||
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (_usta != null && _usta.EntityUsta is EntityUstaBat entityustabat)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
entityustabat.AdditionalColor = (Color)e.Data.GetData(typeof(Color));
|
|
||||||
|
|
||||||
}
|
|
||||||
DrawUsta();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление установки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonOk_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
EventAddUsta?.Invoke(_usta);
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,41 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
namespace SelfPropelledArtilleryUnit.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс для работы с перемещаемым объектом
|
|
||||||
/// </summary>
|
|
||||||
public interface IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получение координаты X объекта
|
|
||||||
/// </summary>
|
|
||||||
ObjectParameters? GetObjectPosition { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
int GetStep { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка, можно ли переместиться по нужному направлению
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
bool CheckCanMove(DirectionType direction);
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления пермещения объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
void MoveObject(DirectionType direction);
|
|
||||||
|
|
||||||
void SetPosition(int x, int y);
|
|
||||||
|
|
||||||
void Draw(Graphics g);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using SelfPropelledArtilleryUnit.DrawningObjects;
|
|
||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Реализация интерфейса IDrawningObject для работы с объектом DrawningUsta (паттерн Adapter)
|
|
||||||
/// </summary>
|
|
||||||
public class DrawningObjectUsta : IMoveableObject
|
|
||||||
{
|
|
||||||
private readonly DrawningUsta? _drawningUsta = null;
|
|
||||||
public DrawningObjectUsta(DrawningUsta drawningUsta)
|
|
||||||
{
|
|
||||||
_drawningUsta = drawningUsta;
|
|
||||||
}
|
|
||||||
public ObjectParameters? GetObjectPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_drawningUsta == null || _drawningUsta.EntityUsta ==
|
|
||||||
null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ObjectParameters(_drawningUsta.GetPosX,
|
|
||||||
_drawningUsta.GetPosY, _drawningUsta.GetWidth, _drawningUsta.GetHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int GetStep => (int)(_drawningUsta?.EntityUsta?.Step ?? 0);
|
|
||||||
public bool CheckCanMove(DirectionType direction) =>
|
|
||||||
_drawningUsta?.CanMove(direction) ?? false;
|
|
||||||
public void MoveObject(DirectionType direction) =>
|
|
||||||
_drawningUsta?.MoveTransport(direction);
|
|
||||||
public void SetPosition(int x, int y)
|
|
||||||
{
|
|
||||||
if (_drawningUsta != null)
|
|
||||||
{
|
|
||||||
_drawningUsta.SetPosition(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Draw(Graphics g)
|
|
||||||
{
|
|
||||||
if (_drawningUsta != null)
|
|
||||||
{
|
|
||||||
_drawningUsta.DrawTransport(g);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Стратегия перемещения объекта к границе экрана
|
|
||||||
/// </summary>
|
|
||||||
public class MoveToBorder : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return objParams.RightBorder <= FieldWidth &&
|
|
||||||
objParams.RightBorder + GetStep() >= FieldWidth &&
|
|
||||||
objParams.DownBorder <= FieldHeight &&
|
|
||||||
objParams.DownBorder + GetStep() >= FieldHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var diffX = objParams.RightBorder - FieldWidth;
|
|
||||||
if (Math.Abs(diffX) > GetStep())
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
var diffY = objParams.DownBorder - FieldHeight;
|
|
||||||
if (Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Стратегия перемещения объекта в центр экрана
|
|
||||||
/// </summary>
|
|
||||||
public class MoveToCenter : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
|
|
||||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
|
||||||
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
|
||||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
|
||||||
}
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
|
||||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
|
||||||
|
|
||||||
// Проверка, чтобы объект не двигался слишком далеко
|
|
||||||
if (Math.Abs(diffX) > GetStep() || Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
if (Math.Abs(diffX) > GetStep())
|
|
||||||
{
|
|
||||||
if (diffX > 0)
|
|
||||||
{
|
|
||||||
MoveLeft();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
if (diffY > 0)
|
|
||||||
{
|
|
||||||
MoveUp();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Параметры-координаты объекта
|
|
||||||
/// </summary>
|
|
||||||
public class ObjectParameters
|
|
||||||
{
|
|
||||||
private readonly int _x;
|
|
||||||
private readonly int _y;
|
|
||||||
private readonly int _width;
|
|
||||||
private readonly int _height;
|
|
||||||
/// <summary>
|
|
||||||
/// Левая граница
|
|
||||||
/// </summary>
|
|
||||||
public int LeftBorder => _x;
|
|
||||||
/// <summary>
|
|
||||||
/// Верхняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int TopBorder => _y;
|
|
||||||
/// <summary>
|
|
||||||
/// Правая граница
|
|
||||||
/// </summary>
|
|
||||||
public int RightBorder => _x + _width;
|
|
||||||
/// <summary>
|
|
||||||
/// Нижняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int DownBorder => _y + _height;
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleVertical => _y + _height / 2;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
/// <param name="width">Ширина</param>
|
|
||||||
/// <param name="height">Высота</param>
|
|
||||||
public ObjectParameters(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
_x = x;
|
|
||||||
_y = y;
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +1,17 @@
|
|||||||
using SelfPropelledArtilleryUnit;
|
namespace SelfPropelledArtilleryUnit
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NLog.Extensions.Logging;
|
|
||||||
using Serilog;
|
|
||||||
|
|
||||||
namespace ProjectUsta
|
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
var services = new ServiceCollection();
|
Application.Run(new FormSelfPropelledArtilleryUnit());
|
||||||
ConfigureServices(services);
|
|
||||||
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
|
||||||
{
|
|
||||||
Application.Run(serviceProvider.GetRequiredService<FormSelfPropelledArtilleryUnitCollection>());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddSingleton<FormSelfPropelledArtilleryUnitCollection>().AddLogging(option =>
|
|
||||||
{
|
|
||||||
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
|
||||||
string pathNeed = "";
|
|
||||||
for (int i = 0; i < path.Length - 3; i++)
|
|
||||||
{
|
|
||||||
pathNeed += path[i] + "\\";
|
|
||||||
}
|
|
||||||
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(path: $"{pathNeed}appsettings.json", optional: false, reloadOnChange: true).Build();
|
|
||||||
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
|
||||||
|
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
|
||||||
option.AddSerilog(logger);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,63 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.Properties {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
|
||||||
/// </summary>
|
|
||||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
|
||||||
// с помощью такого средства, как ResGen или Visual Studio.
|
|
||||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
|
||||||
// с параметром /str или перестройте свой проект VS.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SelfPropelledArtilleryUnit.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?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,14 +8,4 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
|
||||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -1,115 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.Generics
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Параметризованный набор объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
internal class SetGeneric<T>
|
|
||||||
where T : class
|
|
||||||
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Массив объектов, которые храним
|
|
||||||
/// </summary>
|
|
||||||
private readonly List<T?> _places;
|
|
||||||
/// <summary>
|
|
||||||
/// Количество объектов в массиве
|
|
||||||
/// </summary>
|
|
||||||
public int Count => _places.Count;
|
|
||||||
/// <summary>
|
|
||||||
/// Максимальное количество объектов в списке
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _maxCount;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="count"></param>
|
|
||||||
public SetGeneric(int count)
|
|
||||||
{
|
|
||||||
_maxCount = count;
|
|
||||||
_places = new List<T?>(count);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в набор
|
|
||||||
public int Insert(T usta)
|
|
||||||
{
|
|
||||||
|
|
||||||
return Insert(usta, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <returns></returns>
|
|
||||||
public int Insert(T usta, int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= _maxCount)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (Count >= _maxCount)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_places.Insert(position, usta);
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление объекта из набора с конкретной позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool Remove(int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position > _maxCount || position >= Count)
|
|
||||||
throw new UstaNotFoundException();
|
|
||||||
if (_places[position] == null)
|
|
||||||
{
|
|
||||||
throw new UstaNotFoundException();
|
|
||||||
}
|
|
||||||
_places[position] = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта из набора по позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public T? this[int position]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (position < 0 || position > _maxCount)
|
|
||||||
return null;
|
|
||||||
return _places[position];
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (position < 0 || position > _maxCount)
|
|
||||||
return;
|
|
||||||
_places[position] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Проход по списку
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public IEnumerable<T?> GetUsta(int? maxUsta = null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _places.Count; ++i)
|
|
||||||
{
|
|
||||||
yield return _places[i];
|
|
||||||
if (maxUsta.HasValue && i == maxUsta.Value)
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Статус выполнения операции перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum Status
|
|
||||||
{
|
|
||||||
NotInit,
|
|
||||||
InProgress,
|
|
||||||
Finish
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.Exceptions
|
|
||||||
{
|
|
||||||
[Serializable] internal class StorageOverflowException : ApplicationException
|
|
||||||
{
|
|
||||||
public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { }
|
|
||||||
public StorageOverflowException() : base() { }
|
|
||||||
public StorageOverflowException(string message) : base(message) { }
|
|
||||||
public StorageOverflowException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected StorageOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
using SelfPropelledArtilleryUnit.MovementStrategy;
|
|
||||||
using SelfPropelledArtilleryUnit.DrawningObjects;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.Generics
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Параметризованный класс для набора объектов DrawningUsta
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <typeparam name="U"></typeparam>
|
|
||||||
internal class UstaGenericCollection<T, U>
|
|
||||||
where T : DrawningUsta
|
|
||||||
where U : IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объектов коллекции
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<T?> GetUsta => _collection.GetUsta();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна прорисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна прорисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Размер занимаемого объектом места (ширина)
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _placeSizeWidth = 210;
|
|
||||||
/// <summary>
|
|
||||||
/// Размер занимаемого объектом места (высота)
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _placeSizeHeight = 110;
|
|
||||||
/// <summary>
|
|
||||||
/// Набор объектов
|
|
||||||
/// </summary>
|
|
||||||
private readonly SetGeneric<T> _collection;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="picWidth"></param>
|
|
||||||
/// <param name="picHeight"></param>
|
|
||||||
public UstaGenericCollection(int picWidth, int picHeight)
|
|
||||||
{
|
|
||||||
int width = picWidth / _placeSizeWidth;
|
|
||||||
int height = picHeight / _placeSizeHeight;
|
|
||||||
_pictureWidth = picWidth;
|
|
||||||
_pictureHeight = picHeight;
|
|
||||||
_collection = new SetGeneric<T>(width * height);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора сложения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collect"></param>
|
|
||||||
/// <param name="obj"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static int operator +(UstaGenericCollection<T, U> collect, T?
|
|
||||||
obj)
|
|
||||||
{
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return collect?._collection.Insert(obj) ?? -1;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора вычитания
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collect"></param>
|
|
||||||
/// <param name="pos"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static T operator -(UstaGenericCollection<T, U> collect, int
|
|
||||||
pos)
|
|
||||||
{
|
|
||||||
T obj = collect._collection[pos];
|
|
||||||
if (obj != null)
|
|
||||||
{
|
|
||||||
collect?._collection.Remove(pos);
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта IMoveableObject
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pos"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public U? GetU(int pos)
|
|
||||||
{
|
|
||||||
return (U?)_collection[pos]?.GetMoveableObject;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод всего набора объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Bitmap ShowUsta()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
DrawBackground(gr);
|
|
||||||
DrawObjects(gr);
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Метод отрисовки фона
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
private void DrawBackground(Graphics g)
|
|
||||||
{
|
|
||||||
Pen pen = new(Color.Black, 3);
|
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
|
||||||
1; ++j)
|
|
||||||
{//линия разметки места
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
|
||||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2 + 2 , j *
|
|
||||||
_placeSizeHeight);
|
|
||||||
}
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
|
||||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Метод прорисовки объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
private void DrawObjects(Graphics g)
|
|
||||||
{
|
|
||||||
int c = 14;
|
|
||||||
foreach (var usta in _collection.GetUsta())
|
|
||||||
{
|
|
||||||
if (usta != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
int index = _collection.GetUsta().ToList().IndexOf(usta);
|
|
||||||
if (index % 3 == 0 && index != 0)
|
|
||||||
{
|
|
||||||
c = c - 3;
|
|
||||||
|
|
||||||
}
|
|
||||||
// TODO получение объекта
|
|
||||||
// TODO установка позиции
|
|
||||||
// TODO прорисовка объекта
|
|
||||||
// Установка позиции объекта
|
|
||||||
|
|
||||||
int posX = index % (_pictureWidth / _placeSizeWidth) * _placeSizeWidth + 3;
|
|
||||||
int posY = c / (_pictureWidth / _placeSizeWidth) * _placeSizeHeight + 15;
|
|
||||||
|
|
||||||
// Прорисовка объекта
|
|
||||||
usta.SetPosition(posX, posY);
|
|
||||||
usta.DrawTransport(g);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,194 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using SelfPropelledArtilleryUnit.Drawnings;
|
|
||||||
using SelfPropelledArtilleryUnit.MovementStrategy;
|
|
||||||
using SelfPropelledArtilleryUnit.DrawningObjects;
|
|
||||||
using SelfPropelledArtilleryUnit.Exceptions;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit.Generics
|
|
||||||
|
|
||||||
{
|
|
||||||
internal class UstaGenericStorage
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Словарь (хранилище)
|
|
||||||
/// </summary>
|
|
||||||
readonly Dictionary<string, UstaGenericCollection<DrawningUsta,
|
|
||||||
DrawningObjectUsta>> _ustaStorages;
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращение списка названий наборов
|
|
||||||
/// </summary>
|
|
||||||
public List<string> Keys => _ustaStorages.Keys.ToList();
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна отрисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна отрисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записи ключа и значения элемента словаря
|
|
||||||
/// </summary>
|
|
||||||
private static readonly char _separatorForKeyValue = '|';
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записей коллекции данных в файл
|
|
||||||
/// </summary>
|
|
||||||
private readonly char _separatorRecords = ';';
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записи информации по объекту в файл
|
|
||||||
/// </summary>
|
|
||||||
private static readonly char _separatorForObject = ':';
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pictureWidth"></param>
|
|
||||||
/// <param name="pictureHeight"></param>
|
|
||||||
public UstaGenericStorage(int pictureWidth, int pictureHeight)
|
|
||||||
{
|
|
||||||
_ustaStorages = new Dictionary<string,
|
|
||||||
UstaGenericCollection<DrawningUsta, DrawningObjectUsta>>();
|
|
||||||
_pictureWidth = pictureWidth;
|
|
||||||
_pictureHeight = pictureHeight;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название набора</param>
|
|
||||||
public void AddSet(string name)
|
|
||||||
{
|
|
||||||
// TODO Прописать логику для добавления
|
|
||||||
if (!_ustaStorages.ContainsKey(name))
|
|
||||||
{
|
|
||||||
var ustaCollection = new UstaGenericCollection<DrawningUsta, DrawningObjectUsta>(_pictureWidth, _pictureHeight);
|
|
||||||
_ustaStorages.Add(name, ustaCollection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название набора</param>
|
|
||||||
public void DelSet(string name)
|
|
||||||
{
|
|
||||||
// TODO Прописать логику для удаления
|
|
||||||
if (_ustaStorages.ContainsKey(name))
|
|
||||||
{
|
|
||||||
_ustaStorages.Remove(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Доступ к набору
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ind"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public UstaGenericCollection<DrawningUsta, DrawningObjectUsta>? this[string ind]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// TODO Продумать логику получения набора
|
|
||||||
if (_ustaStorages.ContainsKey(ind))
|
|
||||||
{
|
|
||||||
return _ustaStorages[ind];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение информации по установкам в хранилище в файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
|
||||||
public void SaveData(string filename)
|
|
||||||
{
|
|
||||||
if (File.Exists(filename))
|
|
||||||
{
|
|
||||||
File.Delete(filename);
|
|
||||||
}
|
|
||||||
StringBuilder data = new();
|
|
||||||
foreach (KeyValuePair<string, UstaGenericCollection<DrawningUsta, DrawningObjectUsta>> record in _ustaStorages)
|
|
||||||
{
|
|
||||||
StringBuilder records = new();
|
|
||||||
foreach (DrawningUsta? elem in record.Value.GetUsta)
|
|
||||||
{
|
|
||||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
|
||||||
}
|
|
||||||
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
|
||||||
}
|
|
||||||
if (data.Length == 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Невалидная операция, нет данных для сохранения");
|
|
||||||
}
|
|
||||||
|
|
||||||
using (StreamWriter writer = new StreamWriter(filename))
|
|
||||||
{
|
|
||||||
writer.Write($"UstaStorage{Environment.NewLine}{data}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Загрузка информации по установкам в хранилище из файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
|
||||||
public void LoadData(string filename)
|
|
||||||
{
|
|
||||||
if (!File.Exists(filename))
|
|
||||||
{
|
|
||||||
throw new Exception("Файл не найден");
|
|
||||||
}
|
|
||||||
|
|
||||||
using (StreamReader reader = new StreamReader(filename))
|
|
||||||
{
|
|
||||||
string cheker = reader.ReadLine();
|
|
||||||
if (cheker == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Нет данных для загрузки");
|
|
||||||
}
|
|
||||||
if (!cheker.StartsWith("UstaStorage"))
|
|
||||||
{
|
|
||||||
throw new Exception("Неверный формат ввода");
|
|
||||||
}
|
|
||||||
_ustaStorages.Clear();
|
|
||||||
string strs;
|
|
||||||
bool firstinit = true;
|
|
||||||
while ((strs = reader.ReadLine()) != null)
|
|
||||||
{
|
|
||||||
if (strs == null && firstinit)
|
|
||||||
{
|
|
||||||
throw new Exception("Нет данных для загрузки");
|
|
||||||
}
|
|
||||||
if (strs == null)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
firstinit = false;
|
|
||||||
string name = strs.Split(_separatorForKeyValue)[0];
|
|
||||||
UstaGenericCollection<DrawningUsta, DrawningObjectUsta> collection = new(_pictureWidth, _pictureHeight);
|
|
||||||
foreach (string data in strs.Split(_separatorForKeyValue)[1].Split(_separatorRecords))
|
|
||||||
{
|
|
||||||
DrawningUsta? usta =
|
|
||||||
data?.CreateDrawningUsta(_separatorForObject, _pictureWidth, _pictureHeight);
|
|
||||||
if (usta != null)
|
|
||||||
{
|
|
||||||
try { _ = collection + usta; }
|
|
||||||
catch (UstaNotFoundException e)
|
|
||||||
{
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
catch (StorageOverflowException e)
|
|
||||||
{
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ustaStorages.Add(name, collection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SelfPropelledArtilleryUnit
|
|
||||||
{
|
|
||||||
[Serializable] internal class UstaNotFoundException : ApplicationException
|
|
||||||
{
|
|
||||||
public UstaNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
|
||||||
public UstaNotFoundException() : base() { }
|
|
||||||
public UstaNotFoundException(string message) : base(message) { }
|
|
||||||
public UstaNotFoundException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected UstaNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"Serilog": {
|
|
||||||
"Using": [ "Serilog.Sinks.File" ],
|
|
||||||
"MinimumLevel": "Information",
|
|
||||||
"WriteTo": [
|
|
||||||
{
|
|
||||||
"Name": "File",
|
|
||||||
"Args": {
|
|
||||||
"path": "Logs/log_.log",
|
|
||||||
"rollingInterval": "Day",
|
|
||||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
|
||||||
"Properties": {
|
|
||||||
"Application": "GasolineTanker"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user