Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
19a298716d | |||
e198915d98 | |||
c11451d5f2 | |||
18eebd2f00 | |||
3d772e6615 | |||
bc9ad54897 | |||
515079e770 | |||
f6c10b9cf0 | |||
70a3795822 | |||
15eb081a88 | |||
d93265500a |
243
LocomotivesAdvanced/LocomotivesAdvanced/AbstractMap.cs
Normal file
243
LocomotivesAdvanced/LocomotivesAdvanced/AbstractMap.cs
Normal file
@ -0,0 +1,243 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
internal abstract class AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле от интерфейса прорисовки
|
||||
/// </summary>
|
||||
private IDrawningObject _drawningObject = null;
|
||||
/// <summary>
|
||||
/// Массив карты
|
||||
/// </summary>
|
||||
protected int[,] _map = null;
|
||||
/// <summary>
|
||||
/// Ширина карты (графической панели)
|
||||
/// </summary>
|
||||
protected int _width;
|
||||
/// <summary>
|
||||
/// Высота карты (графической панели)
|
||||
/// </summary>
|
||||
protected int _height;
|
||||
/// <summary>
|
||||
/// Ширина ячейки
|
||||
/// </summary>
|
||||
protected float _size_x;
|
||||
/// <summary>
|
||||
/// Высота ячейки
|
||||
/// </summary>
|
||||
protected float _size_y;
|
||||
protected readonly Random _random = new();
|
||||
/// <summary>
|
||||
/// Доступная для движения ячейка
|
||||
/// </summary>
|
||||
protected readonly int _freeRoad = 0;
|
||||
/// <summary>
|
||||
/// Недоступная для движения ячейка
|
||||
/// </summary>
|
||||
protected readonly int _barrier = 1;
|
||||
/// <summary>
|
||||
/// Наполнение графической панели
|
||||
/// </summary>
|
||||
/// <param name="width">Ширина</param>
|
||||
/// <param name="height">Высота</param>
|
||||
/// <param name="drawningObject"></param>
|
||||
/// <returns></returns>
|
||||
public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject)
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
_drawningObject = drawningObject;
|
||||
GenerateMap();
|
||||
while (!SetObjectOnMap())
|
||||
{
|
||||
GenerateMap();
|
||||
}
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение координат отрисовываемого объекта в массиве
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (int Top, int Bottom, int Left, int Right) GetObjectCoordinates()
|
||||
{
|
||||
return
|
||||
(
|
||||
(int)(_drawningObject.GetCurrentPosition().Top / _size_y),
|
||||
(int)(_drawningObject.GetCurrentPosition().Bottom / _size_y),
|
||||
(int)(_drawningObject.GetCurrentPosition().Left / _size_x),
|
||||
(int)(_drawningObject.GetCurrentPosition().Right / _size_x)
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка возможности движения в данном направлении
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns></returns>
|
||||
private bool AbleToMove(Direction direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Up:
|
||||
if (GetObjectCoordinates().Top - 1 < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
if (GetObjectCoordinates().Bottom + 1 > _map.GetLength(0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Direction.Left:
|
||||
if (GetObjectCoordinates().Left - 1 < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Direction.Right:
|
||||
if (GetObjectCoordinates().Right + 1 > _map.GetLength(1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
for (int i = GetObjectCoordinates().Left; i <= GetObjectCoordinates().Right; i++)
|
||||
{
|
||||
for (int j = GetObjectCoordinates().Top; j <= GetObjectCoordinates().Bottom; j++)
|
||||
{
|
||||
if (i - 1 < 0 || j - 1 < 0 || i + 1 > _map.GetLength(0) || j + 1 > _map.GetLength(1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Up:
|
||||
if (_map[i, j - 1] == _barrier)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
if (_map[i, j + 1] == _barrier)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Direction.Left:
|
||||
if (_map[i - 1, j] == _barrier)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Direction.Right:
|
||||
if (_map[i + 1, j] == _barrier)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка возможности установить объект на карте
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool AbleToSetObject()
|
||||
{
|
||||
for (int i = GetObjectCoordinates().Left; i <= GetObjectCoordinates().Right; i++)
|
||||
{
|
||||
for (int j = GetObjectCoordinates().Top; j <= GetObjectCoordinates().Bottom; j++)
|
||||
{
|
||||
if (_map[i, j] == _barrier || i < 0 || j < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Передвижение объекта по карте
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns></returns>
|
||||
public Bitmap MoveObject(Direction direction)
|
||||
{
|
||||
if (!AbleToMove(direction))
|
||||
{
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
_drawningObject.MoveObject(direction);
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание объекта на карте
|
||||
/// </summary>
|
||||
/// <returns>Возможность создать объект</returns>
|
||||
private bool SetObjectOnMap()
|
||||
{
|
||||
if (_drawningObject == null || _map == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int x = _random.Next(10, 100);
|
||||
int y = _random.Next(10, 100);
|
||||
_drawningObject.SetObject(x, y, _width, _height);
|
||||
if (!AbleToSetObject())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовка карты
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Bitmap DrawMapWithObject()
|
||||
{
|
||||
Bitmap bmp = new(_width, _height);
|
||||
if (_drawningObject == null || _map == null)
|
||||
{
|
||||
return bmp;
|
||||
}
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||
{
|
||||
if (_map[i, j] == _freeRoad)
|
||||
{
|
||||
DrawRoadPart(gr, i, j);
|
||||
}
|
||||
else if (_map[i, j] == _barrier)
|
||||
{
|
||||
DrawBarrierPart(gr, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
_drawningObject.DrawningObject(gr);
|
||||
return bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Генерация массива карты
|
||||
/// </summary>
|
||||
protected abstract void GenerateMap();
|
||||
/// <summary>
|
||||
/// Отрисовка ячейки со свободным пространством (дорогой)
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="i"></param>
|
||||
/// <param name="j"></param>
|
||||
protected abstract void DrawRoadPart(Graphics g, int i, int j);
|
||||
/// <summary>
|
||||
/// Отрисовка ячейки с барьером
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="i"></param>
|
||||
/// <param name="j"></param>
|
||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный класс с параметрами типа сущности и интерфейса отрисовки дополнительных частей
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
internal class AdvancedObjectGeneric<T, U>
|
||||
where T : EntityLocomotive
|
||||
where U : class, IDrawningAdditionalElements
|
||||
{
|
||||
/// <summary>
|
||||
/// Массив сущностей
|
||||
/// </summary>
|
||||
private T[] Entities = new T[10];
|
||||
/// <summary>
|
||||
/// Текущая выбранная сущность(индекс для заполнения)
|
||||
/// </summary>
|
||||
private int CurrentEntityIndex = 0;
|
||||
/// <summary>
|
||||
/// Массив конфигураций(набора параметров для доп. отрисовки)
|
||||
/// </summary>
|
||||
private U[] AdditionalElementsSetups = new U[10];
|
||||
/// <summary>
|
||||
/// Текущая выбранная конфигурация
|
||||
/// </summary>
|
||||
int CurrentAdditionalElementSetupIndex = 0;
|
||||
/// <summary>
|
||||
/// Добавление новой сущности в массив сущностей
|
||||
/// </summary>
|
||||
/// <param name="NewEntity">Добавляемая сущность</param>
|
||||
public void AddEntity(T NewEntity)
|
||||
{
|
||||
if (CurrentEntityIndex >= 9)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Entities[CurrentEntityIndex] = NewEntity;
|
||||
CurrentEntityIndex++;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление новой конфигурации в массив конфигураций
|
||||
/// </summary>
|
||||
/// <param name="NewAdditionalElementSetup">Добавляемая конфигурация</param>
|
||||
public void AddAdditionalElementSetup(U NewAdditionalElementSetup)
|
||||
{
|
||||
if (CurrentAdditionalElementSetupIndex >= 9)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AdditionalElementsSetups[CurrentAdditionalElementSetupIndex] = NewAdditionalElementSetup;
|
||||
CurrentAdditionalElementSetupIndex++;
|
||||
}
|
||||
/// <summary>
|
||||
/// Генерация нового объекта от класса отрисовки на основе случайно выбранной сущности и набора конфигураций
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DrawningLocomotive GeneratedObject()
|
||||
{
|
||||
Random rnd = new();
|
||||
int SelectedEntityIndex = rnd.Next(0, 9);
|
||||
int SelectedAdditionalElementSetupIndex = rnd.Next(0, 9);
|
||||
DrawningLocomotive Object = null;
|
||||
if (Entities[SelectedEntityIndex] is EntityWarmlyLocomotive entitywarmlylocomotive)
|
||||
{
|
||||
Object = new DrawningWarmlyLocomotive(entitywarmlylocomotive.Speed, entitywarmlylocomotive.Weight, entitywarmlylocomotive.BodyColor, 160, 115, entitywarmlylocomotive.AdditionalColor, entitywarmlylocomotive.HasPipe, entitywarmlylocomotive.HasFuelTank);
|
||||
Object.AdditionalElements = AdditionalElementsSetups[SelectedAdditionalElementSetupIndex];
|
||||
}
|
||||
else if (Entities[SelectedEntityIndex] is EntityLocomotive entitylocomotive)
|
||||
{
|
||||
Object = new DrawningLocomotive(entitylocomotive.Speed, entitylocomotive.Weight, entitylocomotive.BodyColor);
|
||||
Object.Locomotive = Entities[SelectedEntityIndex];
|
||||
Object.AdditionalElements = AdditionalElementsSetups[SelectedAdditionalElementSetupIndex];
|
||||
}
|
||||
return Object;
|
||||
}
|
||||
}
|
||||
}
|
52
LocomotivesAdvanced/LocomotivesAdvanced/CrossMap.cs
Normal file
52
LocomotivesAdvanced/LocomotivesAdvanced/CrossMap.cs
Normal file
@ -0,0 +1,52 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Карта в виде креста
|
||||
/// </summary>
|
||||
internal class CrossMap : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Цвет участка закрытого
|
||||
/// </summary>
|
||||
private readonly Brush barrierColor = new SolidBrush(Color.Red);
|
||||
/// <summary>
|
||||
/// Цвет участка открытого
|
||||
/// </summary>
|
||||
private readonly Brush roadColor = new SolidBrush(Color.Transparent);
|
||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, _size_x, _size_y);
|
||||
}
|
||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * _size_x, _size_y);
|
||||
}
|
||||
protected override void GenerateMap()
|
||||
{
|
||||
_map = new int[100, 100];
|
||||
_size_x = (float)_width / _map.GetLength(0);
|
||||
_size_y = (float)_height / _map.GetLength(1);
|
||||
for (int i = 0; i < _map.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); j++)
|
||||
{
|
||||
_map[i, j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
for (int i = 45; i < 55; i++)
|
||||
{
|
||||
for (int j = 15; j < 85; j++)
|
||||
{
|
||||
_map[i, j] = _barrier;
|
||||
}
|
||||
}
|
||||
for (int i = 45; i < 55; i++)
|
||||
{
|
||||
for (int j = 30; j < 80; j++)
|
||||
{
|
||||
_map[j, i] = _barrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
LocomotivesAdvanced/LocomotivesAdvanced/Direction.cs
Normal file
29
LocomotivesAdvanced/LocomotivesAdvanced/Direction.cs
Normal file
@ -0,0 +1,29 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Перечисление направлений перемещения
|
||||
/// </summary>
|
||||
public enum Direction
|
||||
{
|
||||
/// <summary>
|
||||
/// никуда
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
internal class DrawningEllipseOrnament : IDrawningAdditionalElements
|
||||
{
|
||||
private WheelsNumber wheelsNumber;
|
||||
|
||||
public int WheelsNum
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value < 2 || value > 4)
|
||||
{
|
||||
wheelsNumber = (WheelsNumber)2;
|
||||
}
|
||||
else
|
||||
{
|
||||
wheelsNumber = (WheelsNumber)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void DrawWheels(Graphics g, float startPosX, float startPosY, Color wheelsColor)
|
||||
{
|
||||
Pen pen = new(wheelsColor);
|
||||
switch (wheelsNumber)
|
||||
{
|
||||
case WheelsNumber.Two:
|
||||
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
|
||||
break;
|
||||
case WheelsNumber.Three:
|
||||
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
|
||||
break;
|
||||
case WheelsNumber.Four:
|
||||
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 50, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawOrnament(Graphics g, float startPosX, float startPosY)
|
||||
{
|
||||
//рисуем круглый орнамент
|
||||
Pen pen = new(Color.Red);
|
||||
switch (wheelsNumber)
|
||||
{
|
||||
case WheelsNumber.Two:
|
||||
g.DrawEllipse(pen, startPosX + 25, startPosY + 45, 10, 7);
|
||||
g.DrawEllipse(pen, startPosX + 125, startPosY + 45, 10, 7);
|
||||
break;
|
||||
case WheelsNumber.Three:
|
||||
g.DrawEllipse(pen, startPosX + 25, startPosY + 45, 10, 7);
|
||||
g.DrawEllipse(pen, startPosX + 95, startPosY + 45, 10, 7);
|
||||
g.DrawEllipse(pen, startPosX + 125, startPosY + 45, 10, 7);
|
||||
break;
|
||||
case WheelsNumber.Four:
|
||||
g.DrawEllipse(pen, startPosX + 25, startPosY + 45, 10, 7);
|
||||
g.DrawEllipse(pen, startPosX + 55, startPosY + 45, 10, 7);
|
||||
g.DrawEllipse(pen, startPosX + 95, startPosY + 45, 10, 7);
|
||||
g.DrawEllipse(pen, startPosX + 125, startPosY + 45, 10, 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
214
LocomotivesAdvanced/LocomotivesAdvanced/DrawningLocomotive.cs
Normal file
214
LocomotivesAdvanced/LocomotivesAdvanced/DrawningLocomotive.cs
Normal file
@ -0,0 +1,214 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за отрисовку объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityLocomotive Locomotive { get; set; }
|
||||
/// <summary>
|
||||
/// Класс отрисовки колёс
|
||||
/// </summary>
|
||||
public IDrawningAdditionalElements AdditionalElements;
|
||||
/// <summary>
|
||||
/// Левая координата отрисовки локомотива
|
||||
/// </summary>
|
||||
protected float _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя координата отрисовки локомотива
|
||||
/// </summary>
|
||||
protected float _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private int? _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private int? _pictureHeight;
|
||||
/// <summary>
|
||||
/// Ширина локомотива
|
||||
/// </summary>
|
||||
protected readonly int _locomotiveWidth = 160;
|
||||
/// <summary>
|
||||
/// Высота локомотива
|
||||
/// </summary>
|
||||
protected readonly int _locomotiveHeight = 80;
|
||||
/// <summary>
|
||||
/// Инициализация свойств объекта-сущности
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
public DrawningLocomotive(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Locomotive = new EntityLocomotive(speed, weight, bodyColor);
|
||||
AdditionalElements = new DrawningWheels();
|
||||
}
|
||||
/// <summary>
|
||||
/// Конструктор для изменения размеров локомотива
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="locomotiveWidth">Ширина локомотива</param>
|
||||
/// <param name="locomotiveHeight">Высота локомотива</param>
|
||||
protected DrawningLocomotive(int speed, float weight, Color bodyColor, int locomotiveWidth, int locomotiveHeight)
|
||||
: this(speed, weight, bodyColor)
|
||||
{
|
||||
_locomotiveWidth = locomotiveWidth;
|
||||
_locomotiveHeight = locomotiveHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка начальной позиции локомотива
|
||||
/// </summary>
|
||||
/// <param name="x">Левая координата</param>
|
||||
/// <param name="y">Правая координата</param>
|
||||
/// <param name="width">Ширина</param>
|
||||
/// <param name="height">Высота</param>
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
if (x < 0 || y < 0 || x + _locomotiveWidth > width || y + _locomotiveHeight > height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение локомотива в зависимости от направления
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
public void MoveLocomotive(Direction direction)
|
||||
{
|
||||
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//вправо
|
||||
case Direction.Right:
|
||||
if (_startPosX + _locomotiveWidth + Locomotive.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += Locomotive.Step;
|
||||
}
|
||||
break;
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if (_startPosX >= Locomotive.Step)
|
||||
{
|
||||
_startPosX -= Locomotive.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
if (_startPosY >= Locomotive.Step)
|
||||
{
|
||||
_startPosY -= Locomotive.Step;
|
||||
}
|
||||
break;
|
||||
//вниз
|
||||
case Direction.Down:
|
||||
if (_startPosY + _locomotiveHeight + Locomotive.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += Locomotive.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод отрисовки локомотива
|
||||
/// </summary>
|
||||
/// <param name="g">Графика</param>
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//кузов
|
||||
Pen penBodyColor = new Pen(Locomotive?.BodyColor ?? Color.Black);
|
||||
for (int i = (int)_startPosX + 10; i <= _startPosX + 20; i++)
|
||||
{
|
||||
g.DrawLine(penBodyColor, _startPosX + 20, _startPosY, i, _startPosY + 20);
|
||||
}
|
||||
Brush brBodyColor = new SolidBrush(Locomotive?.BodyColor ?? Color.Black);
|
||||
g.FillRectangle(brBodyColor, _startPosX + 20, _startPosY, 130, 20);//верхняя часть
|
||||
g.FillRectangle(brBodyColor, _startPosX + 10, _startPosY + 20, 140, 20);//нижняя часть
|
||||
//переход
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
g.FillRectangle(brBlack, _startPosX + 150, _startPosY + 5, 10, 30);
|
||||
Pen pen = new(Color.Black);
|
||||
//границы локомотива
|
||||
g.DrawLine(pen, _startPosX + 20, _startPosY, _startPosX + 10, _startPosY + 20);
|
||||
g.DrawLine(pen, _startPosX, _startPosY + 50, _startPosX + 10, _startPosY + 50);
|
||||
for (int i = (int)_startPosX + 10; i <= (int)_startPosX + 20; i++)
|
||||
{
|
||||
g.DrawLine(pen, i, _startPosY + 40, i - 10, _startPosY + 50);
|
||||
}
|
||||
for (int i = (int)_startPosX + 140; i <= (int)_startPosX + 150; i++)
|
||||
{
|
||||
g.DrawLine(pen, i, _startPosY + 40, i + 10, _startPosY + 50);
|
||||
}
|
||||
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 20, 140, 20);
|
||||
g.DrawLine(pen, _startPosX + 20, _startPosY, _startPosX + 150, _startPosY);
|
||||
g.DrawLine(pen, _startPosX + 150, _startPosY, _startPosX + 150, _startPosY + 20);
|
||||
//окна
|
||||
Brush brWhite = new SolidBrush(Color.White);
|
||||
g.FillRectangle(brWhite, _startPosX + 25, _startPosY + 5, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 25, _startPosY + 5, 10, 10);
|
||||
g.FillRectangle(brWhite, _startPosX + 40, _startPosY + 5, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 40, _startPosY + 5, 10, 10);
|
||||
g.FillRectangle(brWhite, _startPosX + 130, _startPosY + 5, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 130, _startPosY + 5, 10, 10);
|
||||
//дверь
|
||||
g.FillRectangle(brBodyColor, _startPosX + 60, _startPosY + 10, 15, 25);
|
||||
g.DrawRectangle(pen, _startPosX + 60, _startPosY + 10, 15, 25);
|
||||
//колёса
|
||||
AdditionalElements.DrawWheels(g, _startPosX, _startPosY, Color.Black);
|
||||
AdditionalElements.DrawOrnament(g, _startPosX, _startPosY);
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод перерисовки при изменении границ рисунка
|
||||
/// </summary>
|
||||
/// <param name="width">Новая ширина</param>
|
||||
/// <param name="height">Новая высота</param>
|
||||
public void ChangeBorders(int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_pictureWidth <= _locomotiveWidth || _pictureHeight <= _locomotiveHeight)
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
return;
|
||||
}
|
||||
if (_startPosX + _locomotiveWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _pictureWidth.Value - _locomotiveWidth;
|
||||
}
|
||||
if (_startPosY + _locomotiveHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = _pictureHeight.Value - _locomotiveHeight;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (float Top, float Bottom, float Left, float Right) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosY, _startPosY + _locomotiveHeight, _startPosX, _startPosX + _locomotiveWidth);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-наследник от интерфейса (реализация)
|
||||
/// </summary>
|
||||
internal class DrawningObjectLocomotive : IDrawningObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Объект от класса отрисовки локомотива
|
||||
/// </summary>
|
||||
private DrawningLocomotive _locomotive = null;
|
||||
public DrawningObjectLocomotive(DrawningLocomotive locomotive)
|
||||
{
|
||||
_locomotive = locomotive;
|
||||
}
|
||||
public float Step => _locomotive?.Locomotive?.Step ?? 0;
|
||||
public (float Top, float Bottom, float Left, float Right) GetCurrentPosition()
|
||||
{
|
||||
return _locomotive?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_locomotive?.MoveLocomotive(direction);
|
||||
}
|
||||
public void SetObject(int x, int y, int width, int height)
|
||||
{
|
||||
_locomotive.SetPosition(x, y, width, height);
|
||||
}
|
||||
public void DrawningObject(Graphics g)
|
||||
{
|
||||
_locomotive.DrawTransport(g);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
internal class DrawningRectOrnament : IDrawningAdditionalElements
|
||||
{
|
||||
private WheelsNumber wheelsNumber;
|
||||
|
||||
public int WheelsNum
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value < 2 || value > 4)
|
||||
{
|
||||
wheelsNumber = (WheelsNumber)2;
|
||||
}
|
||||
else
|
||||
{
|
||||
wheelsNumber = (WheelsNumber)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void DrawWheels(Graphics g, float startPosX, float startPosY, Color wheelsColor)
|
||||
{
|
||||
Pen pen = new(wheelsColor);
|
||||
switch (wheelsNumber)
|
||||
{
|
||||
case WheelsNumber.Two:
|
||||
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
|
||||
break;
|
||||
case WheelsNumber.Three:
|
||||
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
|
||||
break;
|
||||
case WheelsNumber.Four:
|
||||
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 50, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawOrnament(Graphics g, float startPosX, float startPosY)
|
||||
{
|
||||
//рисуем прямоугольный орнамент
|
||||
Brush brush = new SolidBrush(Color.Blue);
|
||||
switch (wheelsNumber)
|
||||
{
|
||||
case WheelsNumber.Two:
|
||||
g.FillRectangle(brush, startPosX + 25, startPosY + 45, 10, 7);
|
||||
g.FillRectangle(brush, startPosX + 125, startPosY + 45, 10, 7);
|
||||
break;
|
||||
case WheelsNumber.Three:
|
||||
g.FillRectangle(brush, startPosX + 25, startPosY + 45, 10, 7);
|
||||
g.FillRectangle(brush, startPosX + 95, startPosY + 45, 10, 7);
|
||||
g.FillRectangle(brush, startPosX + 125, startPosY + 45, 10, 7);
|
||||
break;
|
||||
case WheelsNumber.Four:
|
||||
g.FillRectangle(brush, startPosX + 25, startPosY + 45, 10, 7);
|
||||
g.FillRectangle(brush, startPosX + 55, startPosY + 45, 10, 7);
|
||||
g.FillRectangle(brush, startPosX + 95, startPosY + 45, 10, 7);
|
||||
g.FillRectangle(brush, startPosX + 125, startPosY + 45, 10, 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-наследник от класса отрисовки локомотива
|
||||
/// </summary>
|
||||
internal class DrawningWarmlyLocomotive : DrawningLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Конструктор, передаём в protected конструктор базового класса обычные параметры и вводим новые
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="locomotiveWidth">Ширина локомотива</param>
|
||||
/// <param name="locomotiveHeight">Высота локомотива</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="hasPipe">Признак наличия трубы</param>
|
||||
/// <param name="hasFuelTank">Признак наличия топливного бака</param>
|
||||
public DrawningWarmlyLocomotive(int speed, float weight, Color bodyColor, int locomotiveWidth, int locomotiveHeight, Color additionalColor, bool hasPipe, bool hasFuelTank) : base(speed, weight, bodyColor, locomotiveWidth, locomotiveHeight)
|
||||
{
|
||||
Locomotive = new EntityWarmlyLocomotive(speed, weight, bodyColor, additionalColor, hasPipe, hasFuelTank);
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовываем базовую часть локомотива и добавляем дополнительные элементы, если они есть
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (Locomotive is not EntityWarmlyLocomotive warmlyLocomotive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//Прорисовка трубы
|
||||
if (warmlyLocomotive.HasPipe)
|
||||
{
|
||||
Pen pen = new Pen(Color.Black);
|
||||
Brush brAdditionalColor = new SolidBrush(warmlyLocomotive.AdditionalColor);
|
||||
g.FillRectangle(brAdditionalColor, _startPosX + 20, _startPosY, 25, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 20, _startPosY, 25, 10);
|
||||
g.FillRectangle(brAdditionalColor, _startPosX + 25, _startPosY + 10, 15, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 25, _startPosY + 10, 15, 20);
|
||||
}
|
||||
_startPosY += 30;
|
||||
base.DrawTransport(g);
|
||||
_startPosY -= 30;
|
||||
//Прорисовка топливного бака
|
||||
if (warmlyLocomotive.HasFuelTank)
|
||||
{
|
||||
Pen pen = new Pen(Color.Black);
|
||||
Brush brAdditionalColor = new SolidBrush(warmlyLocomotive.AdditionalColor);
|
||||
Pen penYellow = new Pen(Color.Yellow);
|
||||
g.FillRectangle(brAdditionalColor, _startPosX + 80, _startPosY + 40, 45, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 80, _startPosY + 40, 45, 20);
|
||||
for (int i = (int)_startPosX + 100; i < (int)_startPosX + 110; i++)
|
||||
{
|
||||
g.DrawLine(penYellow, _startPosX + 105, _startPosY + 45, i, _startPosY + 55);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
48
LocomotivesAdvanced/LocomotivesAdvanced/DrawningWheels.cs
Normal file
48
LocomotivesAdvanced/LocomotivesAdvanced/DrawningWheels.cs
Normal file
@ -0,0 +1,48 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
internal class DrawningWheels : IDrawningAdditionalElements
|
||||
{
|
||||
private WheelsNumber wheelsNumber;
|
||||
|
||||
public int WheelsNum
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value < 2 || value > 4)
|
||||
{
|
||||
wheelsNumber = (WheelsNumber)2;
|
||||
}
|
||||
else
|
||||
{
|
||||
wheelsNumber = (WheelsNumber)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void DrawWheels(Graphics g, float startPosX, float startPosY, Color wheelsColor)
|
||||
{
|
||||
Pen pen = new(wheelsColor);
|
||||
switch (wheelsNumber)
|
||||
{
|
||||
case WheelsNumber.Two:
|
||||
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
|
||||
break;
|
||||
case WheelsNumber.Three:
|
||||
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
|
||||
break;
|
||||
case WheelsNumber.Four:
|
||||
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 50, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15);
|
||||
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawOrnament(Graphics g, float startPosX, float startPosY)
|
||||
{
|
||||
//ничего не рисуем, т.к. орнамента нет
|
||||
}
|
||||
}
|
||||
}
|
38
LocomotivesAdvanced/LocomotivesAdvanced/EntityLocomotive.cs
Normal file
38
LocomotivesAdvanced/LocomotivesAdvanced/EntityLocomotive.cs
Normal file
@ -0,0 +1,38 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность локомотив
|
||||
/// </summary>
|
||||
public class EntityLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public float Weight { get; private set; }
|
||||
/// <summary>
|
||||
/// Цвет кузова
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения
|
||||
/// </summary>
|
||||
public float Step => Speed * 100 / Weight;
|
||||
/// <summary>
|
||||
/// Конструктор (инициализация полей объекта-класса локомотива)
|
||||
/// </summary>
|
||||
/// <param name="speed">скорость</param>
|
||||
/// <param name="weight">вес</param>
|
||||
/// <param name="bodyColor">цвет кузова</param>
|
||||
public EntityLocomotive(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-наследник от класса-сущности локомотива (усложнённый локомотив/тепловоз)
|
||||
/// </summary>
|
||||
internal class EntityWarmlyLocomotive : EntityLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия трубы
|
||||
/// </summary>
|
||||
public bool HasPipe { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия топливного бака
|
||||
/// </summary>
|
||||
public bool HasFuelTank { get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация свойств усложнённого локомотива (тепловоза)
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="hasPipe">Признак наличия трубы</param>
|
||||
/// <param name="hasFuelTank">Признак наличия топливного бака</param>
|
||||
public EntityWarmlyLocomotive(int speed, float weight, Color bodyColor, Color additionalColor, bool hasPipe, bool hasFuelTank) : base (speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
HasPipe = hasPipe;
|
||||
HasFuelTank = hasFuelTank;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
namespace WarmlyLocomotive
|
||||
{
|
||||
partial class Form1 : Form
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace WarmlyLocomotive
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
278
LocomotivesAdvanced/LocomotivesAdvanced/FormLocomotive.Designer.cs
generated
Normal file
278
LocomotivesAdvanced/LocomotivesAdvanced/FormLocomotive.Designer.cs
generated
Normal file
@ -0,0 +1,278 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
partial class FormLocomotive
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.pictureBoxLocomotive = new System.Windows.Forms.PictureBox();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.numericUpDownWheelsNumber = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWheelsNumber = new System.Windows.Forms.Label();
|
||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
||||
this.buttonSelectLocomotive = new System.Windows.Forms.Button();
|
||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelAdditionalColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelHasPipe = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelHasFuelTank = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxLocomotive
|
||||
//
|
||||
this.pictureBoxLocomotive.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxLocomotive.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxLocomotive.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
||||
this.pictureBoxLocomotive.Size = new System.Drawing.Size(800, 450);
|
||||
this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxLocomotive.TabIndex = 0;
|
||||
this.pictureBoxLocomotive.TabStop = false;
|
||||
this.pictureBoxLocomotive.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreate.Location = new System.Drawing.Point(12, 395);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(90, 30);
|
||||
this.buttonCreate.TabIndex = 2;
|
||||
this.buttonCreate.Text = "Создать";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(758, 395);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 3;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(686, 395);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 4;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(722, 395);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 5;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(722, 359);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 6;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// numericUpDownWheelsNumber
|
||||
//
|
||||
this.numericUpDownWheelsNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.numericUpDownWheelsNumber.Location = new System.Drawing.Point(651, 402);
|
||||
this.numericUpDownWheelsNumber.Maximum = new decimal(new int[] {
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWheelsNumber.Minimum = new decimal(new int[] {
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWheelsNumber.Name = "numericUpDownWheelsNumber";
|
||||
this.numericUpDownWheelsNumber.ReadOnly = true;
|
||||
this.numericUpDownWheelsNumber.Size = new System.Drawing.Size(29, 23);
|
||||
this.numericUpDownWheelsNumber.TabIndex = 7;
|
||||
this.numericUpDownWheelsNumber.Value = new decimal(new int[] {
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelWheelsNumber
|
||||
//
|
||||
this.labelWheelsNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelWheelsNumber.AutoSize = true;
|
||||
this.labelWheelsNumber.Location = new System.Drawing.Point(565, 404);
|
||||
this.labelWheelsNumber.Name = "labelWheelsNumber";
|
||||
this.labelWheelsNumber.Size = new System.Drawing.Size(80, 15);
|
||||
this.labelWheelsNumber.TabIndex = 8;
|
||||
this.labelWheelsNumber.Text = "Число колёс:";
|
||||
//
|
||||
// buttonCreateModif
|
||||
//
|
||||
this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreateModif.Location = new System.Drawing.Point(108, 395);
|
||||
this.buttonCreateModif.Name = "buttonCreateModif";
|
||||
this.buttonCreateModif.Size = new System.Drawing.Size(98, 30);
|
||||
this.buttonCreateModif.TabIndex = 9;
|
||||
this.buttonCreateModif.Text = "Модификация";
|
||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
|
||||
//
|
||||
// buttonSelectLocomotive
|
||||
//
|
||||
this.buttonSelectLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonSelectLocomotive.Location = new System.Drawing.Point(461, 396);
|
||||
this.buttonSelectLocomotive.Name = "buttonSelectLocomotive";
|
||||
this.buttonSelectLocomotive.Size = new System.Drawing.Size(98, 30);
|
||||
this.buttonSelectLocomotive.TabIndex = 10;
|
||||
this.buttonSelectLocomotive.Text = "Выбрать";
|
||||
this.buttonSelectLocomotive.UseVisualStyleBackColor = true;
|
||||
this.buttonSelectLocomotive.Click += new System.EventHandler(this.ButtonSelectLocomotive_Click);
|
||||
//
|
||||
// toolStripStatusLabelSpeed
|
||||
//
|
||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(65, 17);
|
||||
this.toolStripStatusLabelSpeed.Text = "Скорость: ";
|
||||
//
|
||||
// toolStripStatusLabelWeight
|
||||
//
|
||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(32, 17);
|
||||
this.toolStripStatusLabelWeight.Text = "Вес: ";
|
||||
//
|
||||
// toolStripStatusLabelBodyColor
|
||||
//
|
||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(39, 17);
|
||||
this.toolStripStatusLabelBodyColor.Text = "Цвет: ";
|
||||
//
|
||||
// toolStripStatusLabelAdditionalColor
|
||||
//
|
||||
this.toolStripStatusLabelAdditionalColor.Name = "toolStripStatusLabelAdditionalColor";
|
||||
this.toolStripStatusLabelAdditionalColor.Size = new System.Drawing.Size(137, 17);
|
||||
this.toolStripStatusLabelAdditionalColor.Text = "Дополнительный цвет: ";
|
||||
//
|
||||
// toolStripStatusLabelHasPipe
|
||||
//
|
||||
this.toolStripStatusLabelHasPipe.Name = "toolStripStatusLabelHasPipe";
|
||||
this.toolStripStatusLabelHasPipe.Size = new System.Drawing.Size(99, 17);
|
||||
this.toolStripStatusLabelHasPipe.Text = "Наличие трубы: ";
|
||||
//
|
||||
// toolStripStatusLabelHasFuelTank
|
||||
//
|
||||
this.toolStripStatusLabelHasFuelTank.Name = "toolStripStatusLabelHasFuelTank";
|
||||
this.toolStripStatusLabelHasFuelTank.Size = new System.Drawing.Size(158, 17);
|
||||
this.toolStripStatusLabelHasFuelTank.Text = "Наличие топливного бака: ";
|
||||
//
|
||||
// statusStrip
|
||||
//
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
this.toolStripStatusLabelBodyColor,
|
||||
this.toolStripStatusLabelAdditionalColor,
|
||||
this.toolStripStatusLabelHasPipe,
|
||||
this.toolStripStatusLabelHasFuelTank});
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 428);
|
||||
this.statusStrip.Name = "statusStrip";
|
||||
this.statusStrip.Size = new System.Drawing.Size(800, 22);
|
||||
this.statusStrip.TabIndex = 1;
|
||||
this.statusStrip.Text = "statusStrip1";
|
||||
//
|
||||
// FormLocomotive
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonSelectLocomotive);
|
||||
this.Controls.Add(this.buttonCreateModif);
|
||||
this.Controls.Add(this.labelWheelsNumber);
|
||||
this.Controls.Add(this.numericUpDownWheelsNumber);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.statusStrip);
|
||||
this.Controls.Add(this.pictureBoxLocomotive);
|
||||
this.Name = "FormLocomotive";
|
||||
this.Text = "Локомотив";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).EndInit();
|
||||
this.statusStrip.ResumeLayout(false);
|
||||
this.statusStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxLocomotive;
|
||||
private Button buttonCreate;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonUp;
|
||||
private NumericUpDown numericUpDownWheelsNumber;
|
||||
private Label labelWheelsNumber;
|
||||
private Button buttonCreateModif;
|
||||
private Button buttonSelectLocomotive;
|
||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||
private ToolStripStatusLabel toolStripStatusLabelAdditionalColor;
|
||||
private ToolStripStatusLabel toolStripStatusLabelHasPipe;
|
||||
private ToolStripStatusLabel toolStripStatusLabelHasFuelTank;
|
||||
private StatusStrip statusStrip;
|
||||
}
|
||||
}
|
141
LocomotivesAdvanced/LocomotivesAdvanced/FormLocomotive.cs
Normal file
141
LocomotivesAdvanced/LocomotivesAdvanced/FormLocomotive.cs
Normal file
@ -0,0 +1,141 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
public partial class FormLocomotive : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Объект от класса отрисовки локомотива
|
||||
/// </summary>
|
||||
private DrawningLocomotive _locomotive;
|
||||
/// <summary>
|
||||
/// Выбранный объект
|
||||
/// </summary>
|
||||
public DrawningLocomotive SelectedLocomotive { get; private set; }
|
||||
|
||||
public FormLocomotive()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод отрисовки локомотива
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_locomotive?.DrawTransport(gr);
|
||||
pictureBoxLocomotive.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Заполнение информации по объекту
|
||||
/// </summary>
|
||||
/// <param name="locomotive">Объект от класса отрисовки или его наследника</param>
|
||||
private void SetData(DrawningLocomotive locomotive)
|
||||
{
|
||||
Random rnd = new();
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {locomotive.Locomotive.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {locomotive.Locomotive.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {locomotive.Locomotive.BodyColor.Name}";
|
||||
toolStripStatusLabelAdditionalColor.Text = $"Дополнительный цвет: н/д";
|
||||
toolStripStatusLabelHasPipe.Text = $"Наличие трубы: н/д";
|
||||
toolStripStatusLabelHasFuelTank.Text = $"Наличие топливного бака: н/д";
|
||||
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||
}
|
||||
/// <summary>
|
||||
/// Заполнение дополнительной информации по объекту (только для усложнённого объекта)
|
||||
/// </summary>
|
||||
/// <param name="warmlylocomotive">Объект от наследника класса отрисовки</param>
|
||||
private void SetAdditionalData(DrawningWarmlyLocomotive warmlylocomotive)
|
||||
{
|
||||
if (warmlylocomotive.Locomotive is EntityWarmlyLocomotive entityWarmlyLocomotive)
|
||||
{
|
||||
toolStripStatusLabelAdditionalColor.Text = $"Дополнительный цвет: {entityWarmlyLocomotive.AdditionalColor.Name}";
|
||||
toolStripStatusLabelHasPipe.Text = $"Наличие трубы: {entityWarmlyLocomotive.HasPipe}";
|
||||
toolStripStatusLabelHasFuelTank.Text = $"Наличие топливного бака: {entityWarmlyLocomotive.HasFuelTank}";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод обработки нажатия на кнопку "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||
SetData(_locomotive);
|
||||
_locomotive.AdditionalElements.WheelsNum = (int)numericUpDownWheelsNumber.Value;
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод обработки нажатия на кнопки перемещения
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//получаем имя кнопки
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_locomotive?.MoveLocomotive(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_locomotive?.MoveLocomotive(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_locomotive?.MoveLocomotive(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_locomotive?.MoveLocomotive(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение размеров формы
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PictureBoxLocomotive_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_locomotive?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод обработки нажатия на кнопку "Модификация"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_locomotive = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
160, 115,
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData(_locomotive);
|
||||
SetAdditionalData((DrawningWarmlyLocomotive)_locomotive);
|
||||
_locomotive.AdditionalElements.WheelsNum = (int)numericUpDownWheelsNumber.Value;
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод обработки нажатия на кнопку "Выбрать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSelectLocomotive_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedLocomotive = _locomotive;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void buttonGenerateEntities_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
63
LocomotivesAdvanced/LocomotivesAdvanced/FormLocomotive.resx
Normal file
63
LocomotivesAdvanced/LocomotivesAdvanced/FormLocomotive.resx
Normal file
@ -0,0 +1,63 @@
|
||||
<root>
|
||||
<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="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
206
LocomotivesAdvanced/LocomotivesAdvanced/FormLocomotiveAdditional.Designer.cs
generated
Normal file
206
LocomotivesAdvanced/LocomotivesAdvanced/FormLocomotiveAdditional.Designer.cs
generated
Normal file
@ -0,0 +1,206 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
partial class FormLocomotiveAdditional
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.pictureBoxLocomotive = new System.Windows.Forms.PictureBox();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.numericUpDownWheelsNumber = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWheelsNumber = new System.Windows.Forms.Label();
|
||||
this.buttonGenerateEntities = new System.Windows.Forms.Button();
|
||||
this.buttonGenerateAdditionalElementsSetup = new System.Windows.Forms.Button();
|
||||
this.buttonShowGeneratedObject = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxLocomotive
|
||||
//
|
||||
this.pictureBoxLocomotive.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxLocomotive.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxLocomotive.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
||||
this.pictureBoxLocomotive.Size = new System.Drawing.Size(800, 450);
|
||||
this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxLocomotive.TabIndex = 0;
|
||||
this.pictureBoxLocomotive.TabStop = false;
|
||||
this.pictureBoxLocomotive.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(761, 406);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 3;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(689, 406);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 4;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(725, 406);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 5;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(725, 370);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 6;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// numericUpDownWheelsNumber
|
||||
//
|
||||
this.numericUpDownWheelsNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.numericUpDownWheelsNumber.Location = new System.Drawing.Point(651, 413);
|
||||
this.numericUpDownWheelsNumber.Maximum = new decimal(new int[] {
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWheelsNumber.Minimum = new decimal(new int[] {
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWheelsNumber.Name = "numericUpDownWheelsNumber";
|
||||
this.numericUpDownWheelsNumber.ReadOnly = true;
|
||||
this.numericUpDownWheelsNumber.Size = new System.Drawing.Size(29, 23);
|
||||
this.numericUpDownWheelsNumber.TabIndex = 7;
|
||||
this.numericUpDownWheelsNumber.Value = new decimal(new int[] {
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelWheelsNumber
|
||||
//
|
||||
this.labelWheelsNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelWheelsNumber.AutoSize = true;
|
||||
this.labelWheelsNumber.Location = new System.Drawing.Point(565, 415);
|
||||
this.labelWheelsNumber.Name = "labelWheelsNumber";
|
||||
this.labelWheelsNumber.Size = new System.Drawing.Size(80, 15);
|
||||
this.labelWheelsNumber.TabIndex = 8;
|
||||
this.labelWheelsNumber.Text = "Число колёс:";
|
||||
//
|
||||
// buttonGenerateEntities
|
||||
//
|
||||
this.buttonGenerateEntities.Location = new System.Drawing.Point(12, 406);
|
||||
this.buttonGenerateEntities.Name = "buttonGenerateEntities";
|
||||
this.buttonGenerateEntities.Size = new System.Drawing.Size(156, 32);
|
||||
this.buttonGenerateEntities.TabIndex = 11;
|
||||
this.buttonGenerateEntities.Text = "Сгенерировать сущности";
|
||||
this.buttonGenerateEntities.UseVisualStyleBackColor = true;
|
||||
this.buttonGenerateEntities.Click += new System.EventHandler(this.ButtonGenerateEntities_Click);
|
||||
//
|
||||
// buttonGenerateAdditionalElementsSetup
|
||||
//
|
||||
this.buttonGenerateAdditionalElementsSetup.Location = new System.Drawing.Point(375, 406);
|
||||
this.buttonGenerateAdditionalElementsSetup.Name = "buttonGenerateAdditionalElementsSetup";
|
||||
this.buttonGenerateAdditionalElementsSetup.Size = new System.Drawing.Size(184, 32);
|
||||
this.buttonGenerateAdditionalElementsSetup.TabIndex = 12;
|
||||
this.buttonGenerateAdditionalElementsSetup.Text = "Сгенерировать доп. отрисовку";
|
||||
this.buttonGenerateAdditionalElementsSetup.UseVisualStyleBackColor = true;
|
||||
this.buttonGenerateAdditionalElementsSetup.Click += new System.EventHandler(this.ButtonGenerateAdditionalElementsSetup_Click);
|
||||
//
|
||||
// buttonShowGeneratedObject
|
||||
//
|
||||
this.buttonShowGeneratedObject.Location = new System.Drawing.Point(204, 406);
|
||||
this.buttonShowGeneratedObject.Name = "buttonShowGeneratedObject";
|
||||
this.buttonShowGeneratedObject.Size = new System.Drawing.Size(139, 32);
|
||||
this.buttonShowGeneratedObject.TabIndex = 13;
|
||||
this.buttonShowGeneratedObject.Text = "Сгенерировать объект";
|
||||
this.buttonShowGeneratedObject.UseVisualStyleBackColor = true;
|
||||
this.buttonShowGeneratedObject.Click += new System.EventHandler(this.ButtonShowGeneratedObject_Click);
|
||||
//
|
||||
// FormLocomotiveAdditional
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonShowGeneratedObject);
|
||||
this.Controls.Add(this.buttonGenerateAdditionalElementsSetup);
|
||||
this.Controls.Add(this.buttonGenerateEntities);
|
||||
this.Controls.Add(this.labelWheelsNumber);
|
||||
this.Controls.Add(this.numericUpDownWheelsNumber);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.pictureBoxLocomotive);
|
||||
this.Name = "FormLocomotiveAdditional";
|
||||
this.Text = "Локомотив";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWheelsNumber)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxLocomotive;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonUp;
|
||||
private NumericUpDown numericUpDownWheelsNumber;
|
||||
private Label labelWheelsNumber;
|
||||
private Button buttonGenerateEntities;
|
||||
private Button buttonGenerateAdditionalElementsSetup;
|
||||
private Button buttonShowGeneratedObject;
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
public partial class FormLocomotiveAdditional : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Объект от класса отрисовки локомотива
|
||||
/// </summary>
|
||||
private DrawningLocomotive _locomotive;
|
||||
/// <summary>
|
||||
/// Объект от параметризованного класса с параметрами типа сущности и интерфейса отрисовки дополнительных частей
|
||||
/// </summary>
|
||||
private AdvancedObjectGeneric<EntityLocomotive,IDrawningAdditionalElements> AdvancedObject = new AdvancedObjectGeneric<EntityLocomotive, IDrawningAdditionalElements>();
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormLocomotiveAdditional()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод отрисовки локомотива
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_locomotive?.DrawTransport(gr);
|
||||
pictureBoxLocomotive.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод обработки нажатия на кнопки перемещения
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//получаем имя кнопки
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_locomotive?.MoveLocomotive(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_locomotive?.MoveLocomotive(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_locomotive?.MoveLocomotive(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_locomotive?.MoveLocomotive(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение размеров формы
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PictureBoxLocomotive_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_locomotive?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод обработки нажатия на кнопку "Сгенерировать сущности"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonGenerateEntities_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
bool IsAdvancedEntity = Convert.ToBoolean(rnd.Next(0, 2));
|
||||
EntityLocomotive Entity;
|
||||
if (!IsAdvancedEntity)
|
||||
{
|
||||
Entity = new EntityLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
}
|
||||
else
|
||||
{
|
||||
Entity = new EntityWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
}
|
||||
AdvancedObject.AddEntity(Entity);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод обработки нажатия на кнопку "Сгенерировать доп. элементы"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonGenerateAdditionalElementsSetup_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int AdditionalElementSetupType = rnd.Next(0, 3);
|
||||
switch (AdditionalElementSetupType)
|
||||
{
|
||||
case 0:
|
||||
AdvancedObject.AddAdditionalElementSetup(new DrawningWheels());
|
||||
break;
|
||||
case 1:
|
||||
AdvancedObject.AddAdditionalElementSetup(new DrawningRectOrnament());
|
||||
break;
|
||||
case 2:
|
||||
AdvancedObject.AddAdditionalElementSetup(new DrawningEllipseOrnament());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод обработки нажатия на кнопку "Сгенерировать объект"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowGeneratedObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_locomotive = AdvancedObject.GeneratedObject();
|
||||
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||
_locomotive.AdditionalElements.WheelsNum = 2;
|
||||
_locomotive.AdditionalElements.WheelsNum = (int)numericUpDownWheelsNumber.Value;
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
217
LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.Designer.cs
generated
Normal file
217
LocomotivesAdvanced/LocomotivesAdvanced/FormMapWithSetLocomotives.Designer.cs
generated
Normal file
@ -0,0 +1,217 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
partial class FormMapWithSetLocomotives
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||
this.buttonRemoveLocomotive = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonAddCar = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.pictureBoxLocomotives = new System.Windows.Forms.PictureBox();
|
||||
this.groupBoxTools.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotives)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxTools
|
||||
//
|
||||
this.groupBoxTools.Controls.Add(this.buttonUp);
|
||||
this.groupBoxTools.Controls.Add(this.buttonDown);
|
||||
this.groupBoxTools.Controls.Add(this.buttonLeft);
|
||||
this.groupBoxTools.Controls.Add(this.buttonRight);
|
||||
this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
|
||||
this.groupBoxTools.Controls.Add(this.buttonShowStorage);
|
||||
this.groupBoxTools.Controls.Add(this.buttonRemoveLocomotive);
|
||||
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBoxTools.Controls.Add(this.buttonAddCar);
|
||||
this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBoxTools.Location = new System.Drawing.Point(577, 0);
|
||||
this.groupBoxTools.Name = "groupBoxTools";
|
||||
this.groupBoxTools.Size = new System.Drawing.Size(223, 450);
|
||||
this.groupBoxTools.TabIndex = 0;
|
||||
this.groupBoxTools.TabStop = false;
|
||||
this.groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(107, 378);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 10;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(107, 414);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 9;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(71, 414);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 8;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.ArrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(143, 414);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 7;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(31, 314);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(164, 26);
|
||||
this.buttonShowOnMap.TabIndex = 5;
|
||||
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(31, 217);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(164, 26);
|
||||
this.buttonShowStorage.TabIndex = 4;
|
||||
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||
//
|
||||
// buttonRemoveLocomotive
|
||||
//
|
||||
this.buttonRemoveLocomotive.Location = new System.Drawing.Point(31, 156);
|
||||
this.buttonRemoveLocomotive.Name = "buttonRemoveLocomotive";
|
||||
this.buttonRemoveLocomotive.Size = new System.Drawing.Size(164, 26);
|
||||
this.buttonRemoveLocomotive.TabIndex = 3;
|
||||
this.buttonRemoveLocomotive.Text = "Удалить локомотив";
|
||||
this.buttonRemoveLocomotive.UseVisualStyleBackColor = true;
|
||||
this.buttonRemoveLocomotive.Click += new System.EventHandler(this.ButtonRemoveLocomotive_Click);
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(31, 127);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(164, 23);
|
||||
this.maskedTextBoxPosition.TabIndex = 2;
|
||||
//
|
||||
// buttonAddCar
|
||||
//
|
||||
this.buttonAddCar.Location = new System.Drawing.Point(31, 72);
|
||||
this.buttonAddCar.Name = "buttonAddCar";
|
||||
this.buttonAddCar.Size = new System.Drawing.Size(164, 26);
|
||||
this.buttonAddCar.TabIndex = 1;
|
||||
this.buttonAddCar.Text = "Добавить локомотив";
|
||||
this.buttonAddCar.UseVisualStyleBackColor = true;
|
||||
this.buttonAddCar.Click += new System.EventHandler(this.ButtonAddLocomotive_Click);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Карта с крестом",
|
||||
"Карта с дорожками"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(31, 22);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(164, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 0;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||
//
|
||||
// pictureBoxLocomotives
|
||||
//
|
||||
this.pictureBoxLocomotives.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxLocomotives.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxLocomotives.Name = "pictureBoxLocomotives";
|
||||
this.pictureBoxLocomotives.Size = new System.Drawing.Size(577, 450);
|
||||
this.pictureBoxLocomotives.TabIndex = 1;
|
||||
this.pictureBoxLocomotives.TabStop = false;
|
||||
//
|
||||
// FormMapWithSetLocomotives
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.pictureBoxLocomotives);
|
||||
this.Controls.Add(this.groupBoxTools);
|
||||
this.Name = "FormMapWithSetLocomotives";
|
||||
this.Text = "Карта с набором объектов";
|
||||
this.groupBoxTools.ResumeLayout(false);
|
||||
this.groupBoxTools.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotives)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxTools;
|
||||
private PictureBox pictureBoxLocomotives;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
private Button buttonAddCar;
|
||||
private MaskedTextBox maskedTextBoxPosition;
|
||||
private Button buttonRemoveLocomotive;
|
||||
private Button buttonShowStorage;
|
||||
private Button buttonShowOnMap;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private Button buttonLeft;
|
||||
private Button buttonRight;
|
||||
}
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма для работы с набором объектов
|
||||
/// </summary>
|
||||
public partial class FormMapWithSetLocomotives : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Объект от класса карты с набором объектов
|
||||
/// </summary>
|
||||
private MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap> _mapCarsCollectionGeneric;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormMapWithSetLocomotives()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Выбор карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
AbstractMap map = null;
|
||||
switch (comboBoxSelectorMap.Text)
|
||||
{
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Карта с крестом":
|
||||
map = new CrossMap();
|
||||
break;
|
||||
case "Карта с дорожками":
|
||||
map = new RoadsMap();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (map != null)
|
||||
{
|
||||
_mapCarsCollectionGeneric = new
|
||||
MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap>(pictureBoxLocomotives.Width, pictureBoxLocomotives.Height, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapCarsCollectionGeneric = null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormLocomotive form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawningObjectLocomotive locomotive = new(form.SelectedLocomotive);
|
||||
if ((_mapCarsCollectionGeneric + locomotive) > -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxLocomotives.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveLocomotive_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if ((_mapCarsCollectionGeneric - pos) != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxLocomotives.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxLocomotives.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxLocomotives.Image = _mapCarsCollectionGeneric.ShowOnMap();
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//получаем имя кнопки
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
Direction dir = Direction.None;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
dir = Direction.Up;
|
||||
break;
|
||||
case "buttonDown":
|
||||
dir = Direction.Down;
|
||||
break;
|
||||
case "buttonLeft":
|
||||
dir = Direction.Left;
|
||||
break;
|
||||
case "buttonRight":
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
}
|
||||
pictureBoxLocomotives.Image = _mapCarsCollectionGeneric.MoveObject(dir);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
@ -0,0 +1,28 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Интерфейс для прорисовки элементов усложнения
|
||||
/// </summary>
|
||||
public interface IDrawningAdditionalElements
|
||||
{
|
||||
/// <summary>
|
||||
/// Свойство получения количества колёс
|
||||
/// </summary>
|
||||
public int WheelsNum { set; }
|
||||
/// <summary>
|
||||
/// Отрисовка колёс
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="startPosX"></param>
|
||||
/// <param name="startPosY"></param>
|
||||
/// <param name="wheelsColor"></param>
|
||||
public void DrawWheels(Graphics g, float startPosX, float startPosY, Color wheelsColor);
|
||||
/// <summary>
|
||||
/// Отрисовка орнамента (если есть)
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="startPosX"></param>
|
||||
/// <param name="startPosY"></param>
|
||||
public void DrawOrnament(Graphics g, float startPosX, float startPosY);
|
||||
}
|
||||
}
|
36
LocomotivesAdvanced/LocomotivesAdvanced/IDrawningObject.cs
Normal file
36
LocomotivesAdvanced/LocomotivesAdvanced/IDrawningObject.cs
Normal file
@ -0,0 +1,36 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Интерфейс для отрисовки
|
||||
/// </summary>
|
||||
internal interface IDrawningObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Шаг перемещения объекта
|
||||
/// </summary>
|
||||
public float Step { get; }
|
||||
/// <summary>
|
||||
/// Установка позиции объекта
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
/// <param name="width">Ширина полотна</param>
|
||||
/// <param name="height">Высота полотна</param>
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения объекта
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
void MoveObject(Direction direction);
|
||||
/// <summary>
|
||||
/// Отрисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
void DrawningObject(Graphics g);
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
(float Top, float Bottom, float Left, float Right) GetCurrentPosition();
|
||||
}
|
||||
}
|
@ -0,0 +1,180 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
internal class MapWithSetLocomotivesGeneric<T, U>
|
||||
where T : class, IDrawningObject
|
||||
where U : AbstractMap
|
||||
{
|
||||
/// <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 SetLocomotivesGeneric<T> _setLocomotives;
|
||||
/// <summary>
|
||||
/// Карта
|
||||
/// </summary>
|
||||
private readonly U _map;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="picWidth"></param>
|
||||
/// <param name="picHeight"></param>
|
||||
/// <param name="map"></param>
|
||||
public MapWithSetLocomotivesGeneric(int picWidth, int picHeight, U map)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_setLocomotives = new SetLocomotivesGeneric<T>(width * height);
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_map = map;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="locomotive"></param>
|
||||
/// <returns></returns>
|
||||
public static int operator +(MapWithSetLocomotivesGeneric<T, U> map, T locomotive)
|
||||
{
|
||||
return map._setLocomotives.Insert(locomotive, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public static T operator -(MapWithSetLocomotivesGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setLocomotives.Remove(position);
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод всего набора объектов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowSet()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawLocomotives(gr);
|
||||
return bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Просмотр объекта на карте
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowOnMap()
|
||||
{
|
||||
Shaking();
|
||||
for (int i = 0; i < _setLocomotives.Count; i++)
|
||||
{
|
||||
var locomotive = _setLocomotives.Get(i);
|
||||
if (locomotive != null)
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, locomotive);
|
||||
}
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение объекта по крате
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
public Bitmap MoveObject(Direction direction)
|
||||
{
|
||||
if (_map != null)
|
||||
{
|
||||
return _map.MoveObject(direction);
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// "Взбалтываем" набор, чтобы все элементы оказались в начале
|
||||
/// </summary>
|
||||
private void Shaking()
|
||||
{
|
||||
int j = _setLocomotives.Count - 1;
|
||||
for (int i = 0; i < _setLocomotives.Count; i++)
|
||||
{
|
||||
if (_setLocomotives.Get(i) == null)
|
||||
{
|
||||
for (; j > i; j--)
|
||||
{
|
||||
var locomotive = _setLocomotives.Get(j);
|
||||
if (locomotive != null)
|
||||
{
|
||||
_setLocomotives.Insert(locomotive, i);
|
||||
_setLocomotives.Remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j <= i)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод отрисовки фона
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Brown, 3);
|
||||
Brush brBackground = new SolidBrush(Color.Yellow);
|
||||
g.FillRectangle(brBackground, 0, 0, _pictureWidth, _pictureHeight);
|
||||
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, j * _placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth,
|
||||
(_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод прорисовки объектов
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawLocomotives(Graphics g)
|
||||
{
|
||||
int LocomotivesInLine = _pictureWidth / _placeSizeWidth;
|
||||
int CurrentVertPos = 20;
|
||||
int CurrentHorPos = 0;
|
||||
for (int i = 0; i < _setLocomotives.Count; i++)
|
||||
{
|
||||
_setLocomotives.Get(i)?.SetObject(CurrentHorPos, CurrentVertPos, _pictureWidth, _pictureHeight);
|
||||
_setLocomotives.Get(i)?.DrawningObject(g);
|
||||
if (CurrentHorPos < LocomotivesInLine)
|
||||
{
|
||||
CurrentHorPos += _placeSizeWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentHorPos = 0;
|
||||
CurrentVertPos += _placeSizeHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,14 @@
|
||||
namespace WarmlyLocomotive
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormLocomotiveAdditional());
|
||||
}
|
||||
}
|
||||
}
|
103
LocomotivesAdvanced/LocomotivesAdvanced/Properties/Resources.Designer.cs
generated
Normal file
103
LocomotivesAdvanced/LocomotivesAdvanced/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WarmlyLocomotive.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("WarmlyLocomotive.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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ArrowDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ArrowDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ArrowLeft {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ArrowLeft", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ArrowRight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ArrowRight", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ArrowUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ArrowUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -117,4 +117,17 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ArrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ArrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ArrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ArrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ArrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ArrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ArrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ArrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
LocomotivesAdvanced/LocomotivesAdvanced/Resources/ArrowDown.png
Normal file
BIN
LocomotivesAdvanced/LocomotivesAdvanced/Resources/ArrowDown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 483 B |
BIN
LocomotivesAdvanced/LocomotivesAdvanced/Resources/ArrowLeft.png
Normal file
BIN
LocomotivesAdvanced/LocomotivesAdvanced/Resources/ArrowLeft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 444 B |
BIN
LocomotivesAdvanced/LocomotivesAdvanced/Resources/ArrowRight.png
Normal file
BIN
LocomotivesAdvanced/LocomotivesAdvanced/Resources/ArrowRight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 464 B |
BIN
LocomotivesAdvanced/LocomotivesAdvanced/Resources/ArrowUp.png
Normal file
BIN
LocomotivesAdvanced/LocomotivesAdvanced/Resources/ArrowUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 459 B |
45
LocomotivesAdvanced/LocomotivesAdvanced/RoadsMap.cs
Normal file
45
LocomotivesAdvanced/LocomotivesAdvanced/RoadsMap.cs
Normal file
@ -0,0 +1,45 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Карта в виде дорожек
|
||||
/// </summary>
|
||||
internal class RoadsMap : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Цвет участка закрытого
|
||||
/// </summary>
|
||||
private readonly Brush barrierColor = new SolidBrush(Color.Blue);
|
||||
/// <summary>
|
||||
/// Цвет участка открытого
|
||||
/// </summary>
|
||||
private readonly Brush roadColor = new SolidBrush(Color.Green);
|
||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, _size_x, _size_y);
|
||||
}
|
||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * _size_x, _size_y);
|
||||
}
|
||||
protected override void GenerateMap()
|
||||
{
|
||||
_map = new int[100, 100];
|
||||
_size_x = (float)_width / _map.GetLength(0);
|
||||
_size_y = (float)_height / _map.GetLength(1);
|
||||
for (int i = 0; i < _map.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); j++)
|
||||
{
|
||||
_map[i, j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
for (int i = 25; i < _map.GetLength(1) - 20; i++)
|
||||
{
|
||||
for (int j = 30; j < _map.GetLength(0); j += 20)
|
||||
{
|
||||
_map[i, j] = _barrier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
internal class SetLocomotivesGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Массив объектов, которые храним
|
||||
/// </summary>
|
||||
private readonly T[] _places;
|
||||
/// <summary>
|
||||
/// Количество объектов в массиве
|
||||
/// </summary>
|
||||
public int Count => _places.Length;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public SetLocomotivesGeneric(int count)
|
||||
{
|
||||
_places = new T[count];
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="locomotive">Добавляемый локомотив</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T locomotive, int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int ClosestNullElementIndex = position;
|
||||
while (_places[ClosestNullElementIndex] != null)
|
||||
{
|
||||
if (ClosestNullElementIndex == Count)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
ClosestNullElementIndex++;
|
||||
}
|
||||
while (ClosestNullElementIndex != position)
|
||||
{
|
||||
_places[ClosestNullElementIndex] = _places[ClosestNullElementIndex - 1];
|
||||
ClosestNullElementIndex--;
|
||||
}
|
||||
_places[position] = locomotive;
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (_places[position] == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = _places[position];
|
||||
_places[position] = null;
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T Get(int position)
|
||||
{
|
||||
if (_places[position] != null)
|
||||
{
|
||||
return _places[position];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
49
LocomotivesAdvanced/LocomotivesAdvanced/SimpleMap.cs
Normal file
49
LocomotivesAdvanced/LocomotivesAdvanced/SimpleMap.cs
Normal file
@ -0,0 +1,49 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Карта с 50-ю барьерами в случайных местах
|
||||
/// </summary>
|
||||
internal class SimpleMap : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Цвет участка закрытого
|
||||
/// </summary>
|
||||
private readonly Brush barrierColor = new SolidBrush(Color.Black);
|
||||
/// <summary>
|
||||
/// Цвет участка открытого
|
||||
/// </summary>
|
||||
private readonly Brush roadColor = new SolidBrush(Color.Gray);
|
||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, _size_x, _size_y);
|
||||
}
|
||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y);
|
||||
}
|
||||
protected override void GenerateMap()
|
||||
{
|
||||
_map = new int[100, 100];
|
||||
_size_x = (float)_width / _map.GetLength(0);
|
||||
_size_y = (float)_height / _map.GetLength(1);
|
||||
int counter = 0;
|
||||
for (int i = 0; i < _map.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); j++)
|
||||
{
|
||||
_map[i, j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
while (counter < 50)
|
||||
{
|
||||
int x = _random.Next(0, 100);
|
||||
int y = _random.Next(0, 100);
|
||||
if (_map[x, y] == _freeRoad)
|
||||
{
|
||||
_map[x, y] = _barrier;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,4 +8,26 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="FormLocomotiveAdditional.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
12
LocomotivesAdvanced/LocomotivesAdvanced/WheelsNumber.cs
Normal file
12
LocomotivesAdvanced/LocomotivesAdvanced/WheelsNumber.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace WarmlyLocomotove
|
||||
{
|
||||
/// <summary>
|
||||
/// Число колёс
|
||||
/// </summary>
|
||||
internal enum WheelsNumber
|
||||
{
|
||||
Two = 2,
|
||||
Three = 3,
|
||||
Four = 4
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user