Compare commits
No commits in common. "lab5" and "master" have entirely different histories.
@ -1,165 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal abstract class AbstractMap
|
|
||||||
{
|
|
||||||
private IDrawingObject _drawingObject = null;
|
|
||||||
protected int[,] _map = null;
|
|
||||||
protected int _width;
|
|
||||||
protected int _height;
|
|
||||||
protected float _size_x;
|
|
||||||
protected float _size_y;
|
|
||||||
protected readonly Random _random = new();
|
|
||||||
protected readonly int _freeRoad = 0;
|
|
||||||
protected readonly int _barrier = 1;
|
|
||||||
|
|
||||||
|
|
||||||
public Bitmap CreateMap(int width, int height, IDrawingObject drawingObject)
|
|
||||||
{
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
_drawingObject = drawingObject;
|
|
||||||
GenerateMap();
|
|
||||||
while (!SetObjectOnMap())
|
|
||||||
{
|
|
||||||
GenerateMap();
|
|
||||||
}
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
public Bitmap MoveObject(Direction direction)
|
|
||||||
{
|
|
||||||
bool isFree = true;
|
|
||||||
int startPosX = (int)(_drawingObject.GetCurrentPosition().Left / _size_x);
|
|
||||||
int startPosY = (int)(_drawingObject.GetCurrentPosition().Right / _size_y);
|
|
||||||
int locomotiveWidth = (int)(_drawingObject.GetCurrentPosition().Top / _size_x);
|
|
||||||
int locomotiveHeight = (int)(_drawingObject.GetCurrentPosition().Bottom / _size_y);
|
|
||||||
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
// вправо
|
|
||||||
case Direction.Right:
|
|
||||||
for (int i = locomotiveWidth; i <= locomotiveWidth + (int)(_drawingObject.Step / _size_x); i++)
|
|
||||||
{
|
|
||||||
for (int j = startPosY; j <= locomotiveHeight; j++)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
isFree = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
//влево
|
|
||||||
case Direction.Left:
|
|
||||||
for (int i = startPosX; i >= (int)(_drawingObject.Step / _size_x); i--)
|
|
||||||
{
|
|
||||||
for (int j = startPosY; j <= locomotiveHeight; j++)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
isFree = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
//вверх
|
|
||||||
case Direction.Up:
|
|
||||||
for (int i = startPosX; i <= locomotiveWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = startPosY; j >= (int)(_drawingObject.Step / _size_y); j--)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
isFree = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
//вниз
|
|
||||||
case Direction.Down:
|
|
||||||
for (int i = startPosX; i <= locomotiveWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = locomotiveHeight; j <= locomotiveHeight + (int)(_drawingObject.Step / _size_y); j++)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
isFree = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFree)
|
|
||||||
{
|
|
||||||
_drawingObject.MoveObject(direction);
|
|
||||||
}
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
private bool SetObjectOnMap()
|
|
||||||
{
|
|
||||||
if (_drawingObject == null || _map == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int x = _random.Next(0, 10);
|
|
||||||
int y = _random.Next(0, 10);
|
|
||||||
_drawingObject.SetObject(x, y, _width, _height);
|
|
||||||
// TODO првоерка, что объект не "накладывается" на закрытые участки
|
|
||||||
_drawingObject.SetObject(x, y, _width, _height);
|
|
||||||
int startPosX = (int)(_drawingObject.GetCurrentPosition().Left / _size_x);
|
|
||||||
int startPosY = (int)(_drawingObject.GetCurrentPosition().Right / _size_y);
|
|
||||||
int locomotiveWidth = (int)(_drawingObject.GetCurrentPosition().Top / _size_x);
|
|
||||||
int locomotiveHeight = (int)(_drawingObject.GetCurrentPosition().Bottom / _size_y);
|
|
||||||
for (int i = startPosX; i <= locomotiveWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = startPosY; j <= locomotiveHeight; j++)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private Bitmap DrawMapWithObject()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new Bitmap(_width, _height);
|
|
||||||
if (_drawingObject == 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_drawingObject.DrawingObject(gr);
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void GenerateMap();
|
|
||||||
protected abstract void DrawRoadPart(Graphics g, int i, int j);
|
|
||||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal class BushesMap : AbstractMap
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly Pen barrierColor = new Pen(Color.DarkGreen, 3);
|
|
||||||
private readonly Brush roadColor = new SolidBrush(Color.Brown);
|
|
||||||
|
|
||||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
|
||||||
{
|
|
||||||
g.DrawLine(barrierColor, new Point(Convert.ToInt32(i * (_size_x - 1)), Convert.ToInt32(j * (_size_y - 1))), new Point(Convert.ToInt32(i * (_size_x - 1) + 7), Convert.ToInt32(j * (_size_y - 1)) + 7));
|
|
||||||
g.DrawLine(barrierColor, new Point(Convert.ToInt32(i * (_size_x - 1) + 7), Convert.ToInt32(j * (_size_y - 1))), new Point(Convert.ToInt32(i * (_size_x - 1) + 7), Convert.ToInt32(j * (_size_y - 1)) + 7));
|
|
||||||
g.DrawLine(barrierColor, new Point(Convert.ToInt32(i * (_size_x - 1) + 7), Convert.ToInt32(j * (_size_y - 1)) + 7), new Point(Convert.ToInt32(i * (_size_x - 1) + 14), Convert.ToInt32(j * (_size_y - 1))));
|
|
||||||
}
|
|
||||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
|
||||||
{
|
|
||||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
|
||||||
}
|
|
||||||
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 < 20)
|
|
||||||
{
|
|
||||||
int x = _random.Next(0, 100);
|
|
||||||
int y = _random.Next(0, 100);
|
|
||||||
if (_map[x, y] == _freeRoad)
|
|
||||||
{
|
|
||||||
_map[x, y] = _barrier;
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
public enum Direction
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Up = 1,
|
|
||||||
Down = 2,
|
|
||||||
Left = 3,
|
|
||||||
Right = 4
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,197 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
public class DrawingLocomotive
|
|
||||||
{
|
|
||||||
public EntityLocomotive Locomotive { get; protected set; }
|
|
||||||
protected float _startPosX;
|
|
||||||
protected float _startPosY;
|
|
||||||
private int? _pictureWidth = null;
|
|
||||||
private int? _pictureHeight = null;
|
|
||||||
private readonly int _locomotiveWidth = 80;
|
|
||||||
private readonly int _locomotiveHeight = 50;
|
|
||||||
|
|
||||||
public void SetPosition(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
//Сделать проверки (все параметры больше 0 и координаты не выходят за границы полей)
|
|
||||||
//x
|
|
||||||
if ((x < 0 || (x + _locomotiveWidth > width)) || (y < 0 || (y + _locomotiveHeight > height)))
|
|
||||||
{
|
|
||||||
_startPosX = 0;
|
|
||||||
_startPosY = 0;
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_startPosX = x;
|
|
||||||
_startPosY = y;
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
public void checkMove()
|
|
||||||
{
|
|
||||||
if (_startPosX < 0)
|
|
||||||
{
|
|
||||||
_startPosX = 0;
|
|
||||||
}
|
|
||||||
if (_startPosY < 0)
|
|
||||||
{
|
|
||||||
_startPosY = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MoveTransport(Direction direction)
|
|
||||||
{
|
|
||||||
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 - _locomotiveWidth - Locomotive.Step < _pictureWidth)
|
|
||||||
{
|
|
||||||
_startPosX -= Locomotive.Step;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Direction.Up:
|
|
||||||
if (_startPosY - _locomotiveHeight - Locomotive.Step < _pictureHeight)
|
|
||||||
{
|
|
||||||
_startPosY -= Locomotive.Step;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Direction.Down:
|
|
||||||
if (_startPosY + _locomotiveHeight + Locomotive.Step < _pictureHeight)
|
|
||||||
{
|
|
||||||
_startPosY += Locomotive.Step;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
checkMove();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawingLocomotive(int speed, float weight, Color bodyColor)
|
|
||||||
{
|
|
||||||
Locomotive = new EntityLocomotive(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawingLocomotive(int speed, float weight, Color bodyColor, int locomotiveWidth, int locomotiveHeight) :
|
|
||||||
this(speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
_locomotiveWidth = locomotiveWidth;
|
|
||||||
_locomotiveHeight = locomotiveHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (_startPosX < 0 || _startPosY < 0
|
|
||||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
|
|
||||||
|
|
||||||
PointF point1 = new PointF(_startPosX + 20, _startPosY);
|
|
||||||
PointF point2 = new PointF(_startPosX + 140, _startPosY);
|
|
||||||
PointF point3 = new PointF(_startPosX + 150, _startPosY + 20);
|
|
||||||
PointF point4 = new PointF(_startPosX + 150, _startPosY + 40);
|
|
||||||
PointF point5 = new PointF(_startPosX + 160, _startPosY + 50);
|
|
||||||
PointF point6 = new PointF(_startPosX + 140, _startPosY + 40);
|
|
||||||
PointF point7 = new PointF(_startPosX + 20, _startPosY + 40);
|
|
||||||
PointF point8 = new PointF(_startPosX + 10, _startPosY + 50);
|
|
||||||
PointF point9 = new PointF(_startPosX + 10, _startPosY + 20);
|
|
||||||
PointF[] curvePoints =
|
|
||||||
{
|
|
||||||
point1,
|
|
||||||
point2,
|
|
||||||
point3,
|
|
||||||
point4,
|
|
||||||
point5,
|
|
||||||
point6,
|
|
||||||
point7,
|
|
||||||
point8,
|
|
||||||
point9
|
|
||||||
};
|
|
||||||
|
|
||||||
//кузов покрас
|
|
||||||
Brush br = new SolidBrush(Locomotive?.BodyColor ?? Color.Orange);
|
|
||||||
|
|
||||||
g.FillPolygon(br, curvePoints);
|
|
||||||
|
|
||||||
//кузов контур
|
|
||||||
g.DrawPolygon(pen, curvePoints);
|
|
||||||
|
|
||||||
//колёса
|
|
||||||
Brush brBlack = new SolidBrush(Color.Black);
|
|
||||||
g.FillEllipse(brBlack, _startPosX + 10, _startPosY + 40, 20, 20);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 40, 20, 20);
|
|
||||||
g.FillEllipse(brBlack, _startPosX + 40, _startPosY + 40, 20, 20);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 40, _startPosY + 40, 20, 20);
|
|
||||||
g.FillEllipse(brBlack, _startPosX + 90, _startPosY + 40, 20, 20);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, 20);
|
|
||||||
g.FillEllipse(brBlack, _startPosX + 120, _startPosY + 40, 20, 20);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 120, _startPosY + 40, 20, 20);
|
|
||||||
|
|
||||||
Brush brBlue = new SolidBrush(Color.Blue);
|
|
||||||
//window
|
|
||||||
g.FillRectangle(brBlue, _startPosX + 110, _startPosY + 5, 20, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 110, _startPosY + 5, 20, 20);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void SetBodyColor(Color color)
|
|
||||||
{
|
|
||||||
(Locomotive as EntityLocomotive).setColor(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
|
||||||
{
|
|
||||||
return (_startPosX, _startPosY, _startPosX + _locomotiveWidth, _startPosY + _locomotiveHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal class DrawingMonorailLocomotive : DrawingLocomotive
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Инициализация свойств
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес автомобиля</param>
|
|
||||||
/// <param name="bodyColor">Цвет кузова</param>
|
|
||||||
/// <param name="dopColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="monorail">Признак наличия магнитного рельса</param>
|
|
||||||
/// <param name="dopCabin">Признак наличия второй кабины сзади</param>
|
|
||||||
|
|
||||||
public DrawingMonorailLocomotive(int speed, float weight, Color bodyColor,
|
|
||||||
Color dopColor, bool monorail, bool dopCabin) :
|
|
||||||
base(speed, weight, bodyColor, 110,60)
|
|
||||||
{
|
|
||||||
Locomotive = new EntityMonorailLocomotive(speed, weight, bodyColor, dopColor, monorail, dopCabin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (Locomotive is not EntityMonorailLocomotive monorailLocomotive)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
|
|
||||||
base.DrawTransport(g);
|
|
||||||
|
|
||||||
if (monorailLocomotive.DopCabin)
|
|
||||||
{
|
|
||||||
|
|
||||||
Brush brBlue = new SolidBrush(Color.Blue);
|
|
||||||
// задняя кабина
|
|
||||||
g.FillRectangle(brBlue, _startPosX + 25, _startPosY + 5, 20, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 25, _startPosY + 5, 20, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monorailLocomotive.Monorail)
|
|
||||||
{
|
|
||||||
|
|
||||||
Brush dopBrush = new SolidBrush(monorailLocomotive.DopColor);
|
|
||||||
//монорельса
|
|
||||||
g.FillRectangle(dopBrush, _startPosX + 10, _startPosY + 45, 130, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 45, 130, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetExtraColor(Color color)
|
|
||||||
{
|
|
||||||
(Locomotive as EntityMonorailLocomotive).DopColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal class DrawingObjectLocomotive : IDrawingObject
|
|
||||||
{
|
|
||||||
private DrawingLocomotive _locomotive = null;
|
|
||||||
|
|
||||||
public DrawingObjectLocomotive(DrawingLocomotive locomotive)
|
|
||||||
{
|
|
||||||
_locomotive = locomotive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Step => _locomotive?.Locomotive?.Step ?? 0;
|
|
||||||
|
|
||||||
public (float Left, float Right, float Top, float Bottom)
|
|
||||||
GetCurrentPosition()
|
|
||||||
{
|
|
||||||
return _locomotive?.GetCurrentPosition() ?? default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MoveObject(Direction direction)
|
|
||||||
{
|
|
||||||
_locomotive?.MoveTransport(direction);
|
|
||||||
}
|
|
||||||
public void SetObject(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
_locomotive.SetPosition(x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IDrawingObject.DrawingObject(Graphics g)
|
|
||||||
{
|
|
||||||
_locomotive.DrawTransport(g);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
public class EntityLocomotive
|
|
||||||
{
|
|
||||||
public int Speed { get; private set; }
|
|
||||||
public float Weight { get; private set; }
|
|
||||||
public Color BodyColor { get; set; }
|
|
||||||
public float Step => Speed * 100 / Weight;
|
|
||||||
public EntityLocomotive(int speed, float weight, Color bodyColor)
|
|
||||||
{
|
|
||||||
Random rnd = new Random();
|
|
||||||
Speed = speed <= 0 ? rnd.Next(40, 120) : speed;
|
|
||||||
Weight = weight <= 0 ? rnd.Next(150, 200) : weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColor(Color color)
|
|
||||||
{
|
|
||||||
BodyColor = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal class EntityMonorailLocomotive : EntityLocomotive
|
|
||||||
{
|
|
||||||
public Color DopColor { get; set; }
|
|
||||||
public bool Monorail { get; private set; }
|
|
||||||
public bool DopCabin { get; private set; }
|
|
||||||
|
|
||||||
public EntityMonorailLocomotive(int speed, float weight, Color bodyColor,
|
|
||||||
Color dopColor, bool monorail, bool dopCabin) :
|
|
||||||
base(speed,weight,bodyColor)
|
|
||||||
{
|
|
||||||
DopColor = dopColor;
|
|
||||||
Monorail = monorail;
|
|
||||||
DopCabin = dopCabin;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal class FieldMap : AbstractMap
|
|
||||||
{
|
|
||||||
private readonly Brush barrierColor = new SolidBrush(Color.Brown);
|
|
||||||
private readonly Brush roadColor = new SolidBrush(Color.Green);
|
|
||||||
|
|
||||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
|
||||||
{
|
|
||||||
g.FillEllipse(barrierColor, i * (_size_x - 1), j * (_size_y - 1), 30, 15);
|
|
||||||
}
|
|
||||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
|
||||||
{
|
|
||||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x), j * (_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 < 20)
|
|
||||||
{
|
|
||||||
int x = _random.Next(0, 100);
|
|
||||||
int y = _random.Next(0, 100);
|
|
||||||
if (_map[x, y] == _freeRoad)
|
|
||||||
{
|
|
||||||
_map[x, y] = _barrier;
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
39
Monorail/Monorail/Form1.Designer.cs
generated
Normal file
39
Monorail/Monorail/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace Monorail
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
10
Monorail/Monorail/Form1.cs
Normal file
10
Monorail/Monorail/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Monorail
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -117,17 +117,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.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.jpg;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.jpg;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.jpg;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.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
</root>
|
202
Monorail/Monorail/FormLocomotive.Designer.cs
generated
202
Monorail/Monorail/FormLocomotive.Designer.cs
generated
@ -1,202 +0,0 @@
|
|||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
pictureBoxLocomotive = new PictureBox();
|
|
||||||
statusStrip = new StatusStrip();
|
|
||||||
toolStripStatusLabelSpeed = new ToolStripStatusLabel();
|
|
||||||
toolStripStatusLabelWeight = new ToolStripStatusLabel();
|
|
||||||
toolStripStatusLabelBodyColor = new ToolStripStatusLabel();
|
|
||||||
buttonCreate = new Button();
|
|
||||||
buttonUp = new Button();
|
|
||||||
buttonLeft = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
buttonCreateModify = new Button();
|
|
||||||
ButtonSelectLocomotive = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).BeginInit();
|
|
||||||
statusStrip.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// pictureBoxLocomotive
|
|
||||||
//
|
|
||||||
pictureBoxLocomotive.Dock = DockStyle.Fill;
|
|
||||||
pictureBoxLocomotive.Location = new Point(0, 0);
|
|
||||||
pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
|
||||||
pictureBoxLocomotive.Size = new Size(800, 428);
|
|
||||||
pictureBoxLocomotive.SizeMode = PictureBoxSizeMode.AutoSize;
|
|
||||||
pictureBoxLocomotive.TabIndex = 0;
|
|
||||||
pictureBoxLocomotive.TabStop = false;
|
|
||||||
pictureBoxLocomotive.Resize += PictureBoxLocomotive_Resize;
|
|
||||||
//
|
|
||||||
// statusStrip
|
|
||||||
//
|
|
||||||
statusStrip.Items.AddRange(new ToolStripItem[] { toolStripStatusLabelSpeed, toolStripStatusLabelWeight, toolStripStatusLabelBodyColor });
|
|
||||||
statusStrip.Location = new Point(0, 428);
|
|
||||||
statusStrip.Name = "statusStrip";
|
|
||||||
statusStrip.Size = new Size(800, 22);
|
|
||||||
statusStrip.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelSpeed
|
|
||||||
//
|
|
||||||
toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
|
||||||
toolStripStatusLabelSpeed.Size = new Size(62, 17);
|
|
||||||
toolStripStatusLabelSpeed.Text = "Скорость:";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelWeight
|
|
||||||
//
|
|
||||||
toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
|
||||||
toolStripStatusLabelWeight.Size = new Size(29, 17);
|
|
||||||
toolStripStatusLabelWeight.Text = "Вес:";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelBodyColor
|
|
||||||
//
|
|
||||||
toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
|
||||||
toolStripStatusLabelBodyColor.Size = new Size(36, 17);
|
|
||||||
toolStripStatusLabelBodyColor.Text = "Цвет:";
|
|
||||||
//
|
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreate.Location = new Point(12, 390);
|
|
||||||
buttonCreate.Name = "buttonCreate";
|
|
||||||
buttonCreate.Size = new Size(75, 23);
|
|
||||||
buttonCreate.TabIndex = 2;
|
|
||||||
buttonCreate.Text = "Создать";
|
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreate.Click += ButtonCreate_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
|
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUp.Location = new Point(722, 350);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(30, 30);
|
|
||||||
buttonUp.TabIndex = 3;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonLeft.Location = new Point(686, 386);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(30, 30);
|
|
||||||
buttonLeft.TabIndex = 4;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
|
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonRight.Location = new Point(758, 386);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(30, 30);
|
|
||||||
buttonRight.TabIndex = 5;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
|
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDown.Location = new Point(722, 386);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(30, 30);
|
|
||||||
buttonDown.TabIndex = 6;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonCreateModify
|
|
||||||
//
|
|
||||||
buttonCreateModify.Location = new Point(93, 390);
|
|
||||||
buttonCreateModify.Name = "buttonCreateModify";
|
|
||||||
buttonCreateModify.Size = new Size(152, 23);
|
|
||||||
buttonCreateModify.TabIndex = 7;
|
|
||||||
buttonCreateModify.Text = "Модифицировать";
|
|
||||||
buttonCreateModify.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateModify.Click += ButtonCreateModify_Click;
|
|
||||||
//
|
|
||||||
// ButtonSelectLocomotive
|
|
||||||
//
|
|
||||||
ButtonSelectLocomotive.Location = new Point(635, 12);
|
|
||||||
ButtonSelectLocomotive.Name = "ButtonSelectLocomotive";
|
|
||||||
ButtonSelectLocomotive.Size = new Size(153, 33);
|
|
||||||
ButtonSelectLocomotive.TabIndex = 8;
|
|
||||||
ButtonSelectLocomotive.Text = "Выбрать";
|
|
||||||
ButtonSelectLocomotive.UseVisualStyleBackColor = true;
|
|
||||||
ButtonSelectLocomotive.Click += ButtonSelectLocomotive_Click;
|
|
||||||
//
|
|
||||||
// FormLocomotive
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(ButtonSelectLocomotive);
|
|
||||||
Controls.Add(buttonCreateModify);
|
|
||||||
Controls.Add(buttonDown);
|
|
||||||
Controls.Add(buttonRight);
|
|
||||||
Controls.Add(buttonLeft);
|
|
||||||
Controls.Add(buttonUp);
|
|
||||||
Controls.Add(buttonCreate);
|
|
||||||
Controls.Add(pictureBoxLocomotive);
|
|
||||||
Controls.Add(statusStrip);
|
|
||||||
Name = "FormLocomotive";
|
|
||||||
Text = "Локомотив";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).EndInit();
|
|
||||||
statusStrip.ResumeLayout(false);
|
|
||||||
statusStrip.PerformLayout();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private PictureBox pictureBoxLocomotive;
|
|
||||||
private StatusStrip statusStrip;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
|
||||||
private Button buttonCreate;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonCreateModify;
|
|
||||||
private Button ButtonSelectLocomotive;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
public partial class FormLocomotive : Form
|
|
||||||
{
|
|
||||||
private DrawingLocomotive _locomotive;
|
|
||||||
public DrawingLocomotive SelectedLocomotive { get; private set; }
|
|
||||||
public FormLocomotive()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
private void Draw()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_locomotive?.DrawTransport(gr);
|
|
||||||
pictureBoxLocomotive.Image = bmp;
|
|
||||||
}
|
|
||||||
private void SetData()
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
|
||||||
pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
|
||||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_locomotive.Locomotive.Speed}";
|
|
||||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_locomotive.Locomotive.Weight}";
|
|
||||||
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_locomotive.Locomotive.BodyColor.Name} ";
|
|
||||||
}
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),
|
|
||||||
rnd.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
_locomotive = new DrawingLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
|
||||||
color);
|
|
||||||
SetData();
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
//ïîëó÷àåì èìÿ êíîïêè
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
_locomotive?.MoveTransport(Direction.Up);
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
_locomotive?.MoveTransport(Direction.Down);
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
_locomotive?.MoveTransport(Direction.Left);
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
_locomotive?.MoveTransport(Direction.Right);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PictureBoxLocomotive_Resize(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
_locomotive?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCreateModify_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),
|
|
||||||
rnd.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),
|
|
||||||
rnd.Next(0, 256));
|
|
||||||
ColorDialog dialogDop = new();
|
|
||||||
if (dialogDop.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
dopColor = dialogDop.Color;
|
|
||||||
}
|
|
||||||
_locomotive = new DrawingMonorailLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
|
||||||
color, dopColor, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
|
||||||
SetData();
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSelectLocomotive_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
SelectedLocomotive = _locomotive;
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
<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>
|
|
365
Monorail/Monorail/FormLocomotiveConfig.Designer.cs
generated
365
Monorail/Monorail/FormLocomotiveConfig.Designer.cs
generated
@ -1,365 +0,0 @@
|
|||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
partial class FormLocomotiveConfig
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
groupBoxConfig = new GroupBox();
|
|
||||||
labelModifiedObject = new Label();
|
|
||||||
labelSimpleObject = new Label();
|
|
||||||
groupBoxColors = new GroupBox();
|
|
||||||
panelPurple = new Panel();
|
|
||||||
panelBlack = new Panel();
|
|
||||||
panelGray = new Panel();
|
|
||||||
panelWhite = new Panel();
|
|
||||||
panelYellow = new Panel();
|
|
||||||
panelBlue = new Panel();
|
|
||||||
panelGreen = new Panel();
|
|
||||||
panelRed = new Panel();
|
|
||||||
checkBoxMonorail = new CheckBox();
|
|
||||||
checkBoxDopCabin = new CheckBox();
|
|
||||||
numericUpDownWeight = new NumericUpDown();
|
|
||||||
numericUpDownSpeed = new NumericUpDown();
|
|
||||||
labelWeight = new Label();
|
|
||||||
labelSpeed = new Label();
|
|
||||||
pictureBoxObject = new PictureBox();
|
|
||||||
panelObject = new Panel();
|
|
||||||
labelDopColor = new Label();
|
|
||||||
labelBaseColor = new Label();
|
|
||||||
buttonOk = new Button();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
groupBoxConfig.SuspendLayout();
|
|
||||||
groupBoxColors.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
|
||||||
panelObject.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBoxConfig
|
|
||||||
//
|
|
||||||
groupBoxConfig.Controls.Add(labelModifiedObject);
|
|
||||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
|
||||||
groupBoxConfig.Controls.Add(groupBoxColors);
|
|
||||||
groupBoxConfig.Controls.Add(checkBoxMonorail);
|
|
||||||
groupBoxConfig.Controls.Add(checkBoxDopCabin);
|
|
||||||
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
|
||||||
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
|
||||||
groupBoxConfig.Controls.Add(labelWeight);
|
|
||||||
groupBoxConfig.Controls.Add(labelSpeed);
|
|
||||||
groupBoxConfig.Location = new Point(12, 29);
|
|
||||||
groupBoxConfig.Name = "groupBoxConfig";
|
|
||||||
groupBoxConfig.Size = new Size(479, 218);
|
|
||||||
groupBoxConfig.TabIndex = 0;
|
|
||||||
groupBoxConfig.TabStop = false;
|
|
||||||
groupBoxConfig.Text = "Параметры:";
|
|
||||||
//
|
|
||||||
// labelModifiedObject
|
|
||||||
//
|
|
||||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelModifiedObject.Location = new Point(365, 152);
|
|
||||||
labelModifiedObject.Name = "labelModifiedObject";
|
|
||||||
labelModifiedObject.Size = new Size(90, 45);
|
|
||||||
labelModifiedObject.TabIndex = 8;
|
|
||||||
labelModifiedObject.Text = "Продвинутый";
|
|
||||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// labelSimpleObject
|
|
||||||
//
|
|
||||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelSimpleObject.Location = new Point(245, 152);
|
|
||||||
labelSimpleObject.Name = "labelSimpleObject";
|
|
||||||
labelSimpleObject.Size = new Size(90, 45);
|
|
||||||
labelSimpleObject.TabIndex = 7;
|
|
||||||
labelSimpleObject.Text = "Простой";
|
|
||||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// groupBoxColors
|
|
||||||
//
|
|
||||||
groupBoxColors.Controls.Add(panelPurple);
|
|
||||||
groupBoxColors.Controls.Add(panelBlack);
|
|
||||||
groupBoxColors.Controls.Add(panelGray);
|
|
||||||
groupBoxColors.Controls.Add(panelWhite);
|
|
||||||
groupBoxColors.Controls.Add(panelYellow);
|
|
||||||
groupBoxColors.Controls.Add(panelBlue);
|
|
||||||
groupBoxColors.Controls.Add(panelGreen);
|
|
||||||
groupBoxColors.Controls.Add(panelRed);
|
|
||||||
groupBoxColors.Location = new Point(245, 22);
|
|
||||||
groupBoxColors.Name = "groupBoxColors";
|
|
||||||
groupBoxColors.Size = new Size(210, 116);
|
|
||||||
groupBoxColors.TabIndex = 6;
|
|
||||||
groupBoxColors.TabStop = false;
|
|
||||||
groupBoxColors.Text = "Цвета:";
|
|
||||||
//
|
|
||||||
// panelPurple
|
|
||||||
//
|
|
||||||
panelPurple.BackColor = Color.Purple;
|
|
||||||
panelPurple.Location = new Point(153, 63);
|
|
||||||
panelPurple.Name = "panelPurple";
|
|
||||||
panelPurple.Size = new Size(40, 35);
|
|
||||||
panelPurple.TabIndex = 7;
|
|
||||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelBlack
|
|
||||||
//
|
|
||||||
panelBlack.BackColor = Color.Black;
|
|
||||||
panelBlack.Location = new Point(107, 63);
|
|
||||||
panelBlack.Name = "panelBlack";
|
|
||||||
panelBlack.Size = new Size(40, 35);
|
|
||||||
panelBlack.TabIndex = 6;
|
|
||||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelGray
|
|
||||||
//
|
|
||||||
panelGray.BackColor = Color.Gray;
|
|
||||||
panelGray.Location = new Point(61, 63);
|
|
||||||
panelGray.Name = "panelGray";
|
|
||||||
panelGray.Size = new Size(40, 35);
|
|
||||||
panelGray.TabIndex = 5;
|
|
||||||
panelGray.MouseDown += PanelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelWhite
|
|
||||||
//
|
|
||||||
panelWhite.BackColor = Color.White;
|
|
||||||
panelWhite.Location = new Point(15, 63);
|
|
||||||
panelWhite.Name = "panelWhite";
|
|
||||||
panelWhite.Size = new Size(40, 35);
|
|
||||||
panelWhite.TabIndex = 4;
|
|
||||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelYellow
|
|
||||||
//
|
|
||||||
panelYellow.BackColor = Color.Yellow;
|
|
||||||
panelYellow.Location = new Point(153, 22);
|
|
||||||
panelYellow.Name = "panelYellow";
|
|
||||||
panelYellow.Size = new Size(40, 35);
|
|
||||||
panelYellow.TabIndex = 3;
|
|
||||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelBlue
|
|
||||||
//
|
|
||||||
panelBlue.BackColor = Color.Blue;
|
|
||||||
panelBlue.Location = new Point(107, 22);
|
|
||||||
panelBlue.Name = "panelBlue";
|
|
||||||
panelBlue.Size = new Size(40, 35);
|
|
||||||
panelBlue.TabIndex = 2;
|
|
||||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelGreen
|
|
||||||
//
|
|
||||||
panelGreen.BackColor = Color.Green;
|
|
||||||
panelGreen.Location = new Point(61, 22);
|
|
||||||
panelGreen.Name = "panelGreen";
|
|
||||||
panelGreen.Size = new Size(40, 35);
|
|
||||||
panelGreen.TabIndex = 1;
|
|
||||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// panelRed
|
|
||||||
//
|
|
||||||
panelRed.BackColor = Color.Red;
|
|
||||||
panelRed.Location = new Point(15, 22);
|
|
||||||
panelRed.Name = "panelRed";
|
|
||||||
panelRed.Size = new Size(40, 35);
|
|
||||||
panelRed.TabIndex = 0;
|
|
||||||
panelRed.MouseDown += PanelColor_MouseDown;
|
|
||||||
//
|
|
||||||
// checkBoxMonorail
|
|
||||||
//
|
|
||||||
checkBoxMonorail.AutoSize = true;
|
|
||||||
checkBoxMonorail.Location = new Point(18, 144);
|
|
||||||
checkBoxMonorail.Name = "checkBoxMonorail";
|
|
||||||
checkBoxMonorail.Size = new Size(194, 19);
|
|
||||||
checkBoxMonorail.TabIndex = 5;
|
|
||||||
checkBoxMonorail.Text = "Признак наличия монорельса";
|
|
||||||
checkBoxMonorail.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxDopCabin
|
|
||||||
//
|
|
||||||
checkBoxDopCabin.AutoSize = true;
|
|
||||||
checkBoxDopCabin.Location = new Point(18, 119);
|
|
||||||
checkBoxDopCabin.Name = "checkBoxDopCabin";
|
|
||||||
checkBoxDopCabin.Size = new Size(208, 19);
|
|
||||||
checkBoxDopCabin.TabIndex = 4;
|
|
||||||
checkBoxDopCabin.Text = "Признак наличия задней кабины";
|
|
||||||
checkBoxDopCabin.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// numericUpDownWeight
|
|
||||||
//
|
|
||||||
numericUpDownWeight.Location = new Point(83, 70);
|
|
||||||
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
|
||||||
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
|
||||||
numericUpDownWeight.Size = new Size(120, 23);
|
|
||||||
numericUpDownWeight.TabIndex = 3;
|
|
||||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// numericUpDownSpeed
|
|
||||||
//
|
|
||||||
numericUpDownSpeed.Location = new Point(83, 34);
|
|
||||||
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
|
||||||
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
|
||||||
numericUpDownSpeed.Size = new Size(120, 23);
|
|
||||||
numericUpDownSpeed.TabIndex = 2;
|
|
||||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// labelWeight
|
|
||||||
//
|
|
||||||
labelWeight.AutoSize = true;
|
|
||||||
labelWeight.Location = new Point(18, 72);
|
|
||||||
labelWeight.Name = "labelWeight";
|
|
||||||
labelWeight.Size = new Size(26, 15);
|
|
||||||
labelWeight.TabIndex = 1;
|
|
||||||
labelWeight.Text = "Вес";
|
|
||||||
//
|
|
||||||
// labelSpeed
|
|
||||||
//
|
|
||||||
labelSpeed.AutoSize = true;
|
|
||||||
labelSpeed.Location = new Point(18, 36);
|
|
||||||
labelSpeed.Name = "labelSpeed";
|
|
||||||
labelSpeed.Size = new Size(59, 15);
|
|
||||||
labelSpeed.TabIndex = 0;
|
|
||||||
labelSpeed.Text = "Скорость";
|
|
||||||
//
|
|
||||||
// pictureBoxObject
|
|
||||||
//
|
|
||||||
pictureBoxObject.Location = new Point(14, 65);
|
|
||||||
pictureBoxObject.Name = "pictureBoxObject";
|
|
||||||
pictureBoxObject.Size = new Size(186, 125);
|
|
||||||
pictureBoxObject.TabIndex = 1;
|
|
||||||
pictureBoxObject.TabStop = false;
|
|
||||||
//
|
|
||||||
// panelObject
|
|
||||||
//
|
|
||||||
panelObject.AllowDrop = true;
|
|
||||||
panelObject.Controls.Add(labelDopColor);
|
|
||||||
panelObject.Controls.Add(labelBaseColor);
|
|
||||||
panelObject.Controls.Add(pictureBoxObject);
|
|
||||||
panelObject.Location = new Point(520, 15);
|
|
||||||
panelObject.Name = "panelObject";
|
|
||||||
panelObject.Size = new Size(215, 211);
|
|
||||||
panelObject.TabIndex = 2;
|
|
||||||
panelObject.DragDrop += panelObject_DragDrop;
|
|
||||||
panelObject.DragEnter += panelObject_DragEnter;
|
|
||||||
//
|
|
||||||
// labelDopColor
|
|
||||||
//
|
|
||||||
labelDopColor.AllowDrop = true;
|
|
||||||
labelDopColor.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelDopColor.Location = new Point(110, 14);
|
|
||||||
labelDopColor.Name = "labelDopColor";
|
|
||||||
labelDopColor.Size = new Size(90, 45);
|
|
||||||
labelDopColor.TabIndex = 3;
|
|
||||||
labelDopColor.Text = "Доп. Цвет";
|
|
||||||
labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelDopColor.DragDrop += LabelDopColor_DragDrop;
|
|
||||||
labelDopColor.DragEnter += LabelDopColor_DragEnter;
|
|
||||||
//
|
|
||||||
// labelBaseColor
|
|
||||||
//
|
|
||||||
labelBaseColor.AllowDrop = true;
|
|
||||||
labelBaseColor.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelBaseColor.Location = new Point(14, 14);
|
|
||||||
labelBaseColor.Name = "labelBaseColor";
|
|
||||||
labelBaseColor.Size = new Size(90, 45);
|
|
||||||
labelBaseColor.TabIndex = 2;
|
|
||||||
labelBaseColor.Text = "Цвет";
|
|
||||||
labelBaseColor.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelBaseColor.DragDrop += LabelBaseColor_DragDrop;
|
|
||||||
labelBaseColor.DragEnter += LabelBaseColor_DragEnter;
|
|
||||||
//
|
|
||||||
// buttonOk
|
|
||||||
//
|
|
||||||
buttonOk.Location = new Point(520, 242);
|
|
||||||
buttonOk.Name = "buttonOk";
|
|
||||||
buttonOk.Size = new Size(90, 30);
|
|
||||||
buttonOk.TabIndex = 3;
|
|
||||||
buttonOk.Text = "Добавить";
|
|
||||||
buttonOk.UseVisualStyleBackColor = true;
|
|
||||||
buttonOk.Click += buttonOk_Click;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Location = new Point(645, 242);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(90, 30);
|
|
||||||
buttonCancel.TabIndex = 4;
|
|
||||||
buttonCancel.Text = "Отменить";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += buttonCancel_Click;
|
|
||||||
//
|
|
||||||
// FormLocomotiveConfig
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 299);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonOk);
|
|
||||||
Controls.Add(panelObject);
|
|
||||||
Controls.Add(groupBoxConfig);
|
|
||||||
Name = "FormLocomotiveConfig";
|
|
||||||
Text = "Создание объекта";
|
|
||||||
groupBoxConfig.ResumeLayout(false);
|
|
||||||
groupBoxConfig.PerformLayout();
|
|
||||||
groupBoxColors.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
|
||||||
panelObject.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBoxConfig;
|
|
||||||
private CheckBox checkBoxMonorail;
|
|
||||||
private CheckBox checkBoxDopCabin;
|
|
||||||
private NumericUpDown numericUpDownWeight;
|
|
||||||
private NumericUpDown numericUpDownSpeed;
|
|
||||||
private Label labelWeight;
|
|
||||||
private Label labelSpeed;
|
|
||||||
private GroupBox groupBoxColors;
|
|
||||||
private Panel panelPurple;
|
|
||||||
private Panel panelBlack;
|
|
||||||
private Panel panelGray;
|
|
||||||
private Panel panelWhite;
|
|
||||||
private Panel panelYellow;
|
|
||||||
private Panel panelBlue;
|
|
||||||
private Panel panelGreen;
|
|
||||||
private Panel panelRed;
|
|
||||||
private Label labelModifiedObject;
|
|
||||||
private Label labelSimpleObject;
|
|
||||||
private PictureBox pictureBoxObject;
|
|
||||||
private Panel panelObject;
|
|
||||||
private Label labelDopColor;
|
|
||||||
private Label labelBaseColor;
|
|
||||||
private Button buttonOk;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,145 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
public partial class FormLocomotiveConfig : Form
|
|
||||||
{
|
|
||||||
private event Action<DrawingLocomotive> EventAddLocomotive;
|
|
||||||
DrawingLocomotive _locomotive = null;
|
|
||||||
public FormLocomotiveConfig()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelGray.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelRed.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddEvent(Action<DrawingLocomotive> ev)
|
|
||||||
{
|
|
||||||
if (EventAddLocomotive == null)
|
|
||||||
{
|
|
||||||
EventAddLocomotive = new Action<DrawingLocomotive>(ev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EventAddLocomotive += ev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawLocomotive()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_locomotive?.SetPosition(5, 5, pictureBoxObject.Width,
|
|
||||||
pictureBoxObject.Height);
|
|
||||||
_locomotive?.DrawTransport(gr);
|
|
||||||
pictureBoxObject.Image = bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void panelObject_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void panelObject_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
|
||||||
{
|
|
||||||
case "labelSimpleObject":
|
|
||||||
{
|
|
||||||
_locomotive = new DrawingLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "labelModifiedObject":
|
|
||||||
{
|
|
||||||
_locomotive = new DrawingMonorailLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxMonorail.Checked, checkBoxDopCabin.Checked);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DrawLocomotive();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonOk_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
EventAddLocomotive?.Invoke(_locomotive);
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
_locomotive.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
|
||||||
DrawLocomotive();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (_locomotive is not DrawingMonorailLocomotive HardLocomotive)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HardLocomotive.SetExtraColor((Color)e.Data.GetData(typeof(Color)));
|
|
||||||
DrawLocomotive();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelBaseColor_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelDopColor_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
203
Monorail/Monorail/FormMap.Designer.cs
generated
203
Monorail/Monorail/FormMap.Designer.cs
generated
@ -1,203 +0,0 @@
|
|||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
partial class FormMap : 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()
|
|
||||||
{
|
|
||||||
statusStrip1 = new StatusStrip();
|
|
||||||
toolStripStatusLabelSpeed = new ToolStripStatusLabel();
|
|
||||||
toolStripStatusLabelWeight = new ToolStripStatusLabel();
|
|
||||||
toolStripStatusLabelBodyColor = new ToolStripStatusLabel();
|
|
||||||
pictureBoxLocomotive = new PictureBox();
|
|
||||||
buttonCreate = new Button();
|
|
||||||
buttonCreateModify = new Button();
|
|
||||||
buttonUp = new Button();
|
|
||||||
buttonLeft = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
comboBoxSelectorMap = new ComboBox();
|
|
||||||
statusStrip1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// statusStrip1
|
|
||||||
//
|
|
||||||
statusStrip1.Items.AddRange(new ToolStripItem[] { toolStripStatusLabelSpeed, toolStripStatusLabelWeight, toolStripStatusLabelBodyColor });
|
|
||||||
statusStrip1.Location = new Point(0, 428);
|
|
||||||
statusStrip1.Name = "statusStrip1";
|
|
||||||
statusStrip1.Size = new Size(800, 22);
|
|
||||||
statusStrip1.TabIndex = 0;
|
|
||||||
statusStrip1.Text = "statusStrip1";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelSpeed
|
|
||||||
//
|
|
||||||
toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
|
||||||
toolStripStatusLabelSpeed.Size = new Size(62, 17);
|
|
||||||
toolStripStatusLabelSpeed.Text = "Скорость:";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelWeight
|
|
||||||
//
|
|
||||||
toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
|
||||||
toolStripStatusLabelWeight.Size = new Size(29, 17);
|
|
||||||
toolStripStatusLabelWeight.Text = "Вес:";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelBodyColor
|
|
||||||
//
|
|
||||||
toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
|
||||||
toolStripStatusLabelBodyColor.Size = new Size(36, 17);
|
|
||||||
toolStripStatusLabelBodyColor.Text = "Цвет:";
|
|
||||||
//
|
|
||||||
// pictureBoxLocomotive
|
|
||||||
//
|
|
||||||
pictureBoxLocomotive.Dock = DockStyle.Fill;
|
|
||||||
pictureBoxLocomotive.Location = new Point(0, 0);
|
|
||||||
pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
|
||||||
pictureBoxLocomotive.Size = new Size(800, 428);
|
|
||||||
pictureBoxLocomotive.TabIndex = 1;
|
|
||||||
pictureBoxLocomotive.TabStop = false;
|
|
||||||
//
|
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreate.Location = new Point(12, 386);
|
|
||||||
buttonCreate.Name = "buttonCreate";
|
|
||||||
buttonCreate.Size = new Size(101, 25);
|
|
||||||
buttonCreate.TabIndex = 2;
|
|
||||||
buttonCreate.Text = "Создать";
|
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreate.Click += ButtonCreate_Click;
|
|
||||||
//
|
|
||||||
// buttonCreateModify
|
|
||||||
//
|
|
||||||
buttonCreateModify.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreateModify.Location = new Point(138, 386);
|
|
||||||
buttonCreateModify.Name = "buttonCreateModify";
|
|
||||||
buttonCreateModify.Size = new Size(139, 25);
|
|
||||||
buttonCreateModify.TabIndex = 3;
|
|
||||||
buttonCreateModify.Text = "Модифицировать";
|
|
||||||
buttonCreateModify.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateModify.Click += ButtonCreateModify_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
|
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonUp.Location = new Point(722, 350);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(30, 30);
|
|
||||||
buttonUp.TabIndex = 4;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonLeft.Location = new Point(686, 386);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(30, 30);
|
|
||||||
buttonLeft.TabIndex = 5;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
|
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonRight.Location = new Point(758, 386);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(30, 30);
|
|
||||||
buttonRight.TabIndex = 6;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
|
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonDown.Location = new Point(722, 386);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(30, 30);
|
|
||||||
buttonDown.TabIndex = 7;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
comboBoxSelectorMap.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
comboBoxSelectorMap.Items.AddRange(new object[] { "Простая карта", "Поле с грязью", "Кусты на карте" });
|
|
||||||
comboBoxSelectorMap.Location = new Point(12, 12);
|
|
||||||
comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
comboBoxSelectorMap.Size = new Size(121, 23);
|
|
||||||
comboBoxSelectorMap.TabIndex = 8;
|
|
||||||
comboBoxSelectorMap.SelectedIndexChanged += ComboBoxSelectorMap_SelectedIndexChanged;
|
|
||||||
comboBoxSelectorMap.Click += ComboBoxSelectorMap_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// FormMap
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(comboBoxSelectorMap);
|
|
||||||
Controls.Add(buttonDown);
|
|
||||||
Controls.Add(buttonRight);
|
|
||||||
Controls.Add(buttonLeft);
|
|
||||||
Controls.Add(buttonUp);
|
|
||||||
Controls.Add(buttonCreateModify);
|
|
||||||
Controls.Add(buttonCreate);
|
|
||||||
Controls.Add(pictureBoxLocomotive);
|
|
||||||
Controls.Add(statusStrip1);
|
|
||||||
Name = "FormMap";
|
|
||||||
Text = "Карта";
|
|
||||||
statusStrip1.ResumeLayout(false);
|
|
||||||
statusStrip1.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private StatusStrip statusStrip1;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
|
||||||
private PictureBox pictureBoxLocomotive;
|
|
||||||
private Button buttonCreate;
|
|
||||||
private Button buttonCreateModify;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonDown;
|
|
||||||
private ComboBox comboBoxSelectorMap;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
public partial class FormMap : Form
|
|
||||||
{
|
|
||||||
private AbstractMap _abstractMap;
|
|
||||||
public FormMap()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_abstractMap = new SimpleMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetData(DrawingLocomotive locomotive)
|
|
||||||
{
|
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {locomotive.Locomotive.Speed}";
|
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {locomotive.Locomotive.Weight}";
|
|
||||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {locomotive.Locomotive.BodyColor.Name}";
|
|
||||||
pictureBoxLocomotive.Image = _abstractMap.CreateMap(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height,
|
|
||||||
new DrawingObjectLocomotive(locomotive));
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Создать"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var car = new DrawingLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
||||||
SetData(car);
|
|
||||||
}
|
|
||||||
/// <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;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
pictureBoxLocomotive.Image = _abstractMap?.MoveObject(dir);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Модификация"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreateModify_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var locomotive = new DrawingMonorailLocomotive(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)));
|
|
||||||
SetData(locomotive);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Смена карты
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
switch (comboBoxSelectorMap.Text)
|
|
||||||
{
|
|
||||||
case "Простая карта":
|
|
||||||
_abstractMap = new SimpleMap();
|
|
||||||
break;
|
|
||||||
case "Поле с грязью":
|
|
||||||
_abstractMap = new FieldMap();
|
|
||||||
break;
|
|
||||||
case "Кусты на карте":
|
|
||||||
_abstractMap = new BushesMap();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
<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="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
271
Monorail/Monorail/FormMapWithSetLocomotive.Designer.cs
generated
271
Monorail/Monorail/FormMapWithSetLocomotive.Designer.cs
generated
@ -1,271 +0,0 @@
|
|||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
partial class FormMapWithSetLocomotive
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
pictureBoxLocomotive = new PictureBox();
|
|
||||||
comboBoxSelectorMap = new ComboBox();
|
|
||||||
buttonAddCar = new Button();
|
|
||||||
buttonRemoveCar = new Button();
|
|
||||||
buttonShowStorage = new Button();
|
|
||||||
buttonShowOnMap = new Button();
|
|
||||||
maskedTextBoxPosition = new MaskedTextBox();
|
|
||||||
buttonUp = new Button();
|
|
||||||
buttonLeft = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
groupBoxTools = new GroupBox();
|
|
||||||
groupBoxMaps = new GroupBox();
|
|
||||||
textBoxNewMapName = new TextBox();
|
|
||||||
buttonDeleteMap = new Button();
|
|
||||||
buttonAddMap = new Button();
|
|
||||||
listBoxMaps = new ListBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).BeginInit();
|
|
||||||
groupBoxTools.SuspendLayout();
|
|
||||||
groupBoxMaps.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// pictureBoxLocomotive
|
|
||||||
//
|
|
||||||
pictureBoxLocomotive.Dock = DockStyle.Left;
|
|
||||||
pictureBoxLocomotive.Location = new Point(0, 0);
|
|
||||||
pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
|
||||||
pictureBoxLocomotive.Size = new Size(579, 561);
|
|
||||||
pictureBoxLocomotive.TabIndex = 0;
|
|
||||||
pictureBoxLocomotive.TabStop = false;
|
|
||||||
//
|
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
comboBoxSelectorMap.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
comboBoxSelectorMap.Items.AddRange(new object[] { "Простая карта", "Карта с грязью", "Карта с кустами" });
|
|
||||||
comboBoxSelectorMap.Location = new Point(15, 53);
|
|
||||||
comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
comboBoxSelectorMap.Size = new Size(168, 23);
|
|
||||||
comboBoxSelectorMap.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// buttonAddCar
|
|
||||||
//
|
|
||||||
buttonAddCar.Location = new Point(23, 288);
|
|
||||||
buttonAddCar.Name = "buttonAddCar";
|
|
||||||
buttonAddCar.Size = new Size(169, 30);
|
|
||||||
buttonAddCar.TabIndex = 3;
|
|
||||||
buttonAddCar.Text = "Добавить локомотив";
|
|
||||||
buttonAddCar.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddCar.Click += ButtonAddLocomotive_Click;
|
|
||||||
//
|
|
||||||
// buttonRemoveCar
|
|
||||||
//
|
|
||||||
buttonRemoveCar.Location = new Point(23, 353);
|
|
||||||
buttonRemoveCar.Name = "buttonRemoveCar";
|
|
||||||
buttonRemoveCar.Size = new Size(169, 30);
|
|
||||||
buttonRemoveCar.TabIndex = 4;
|
|
||||||
buttonRemoveCar.Text = "Удалить локомотив";
|
|
||||||
buttonRemoveCar.UseVisualStyleBackColor = true;
|
|
||||||
buttonRemoveCar.Click += ButtonRemoveLocomotive_Click;
|
|
||||||
//
|
|
||||||
// buttonShowStorage
|
|
||||||
//
|
|
||||||
buttonShowStorage.Location = new Point(25, 406);
|
|
||||||
buttonShowStorage.Name = "buttonShowStorage";
|
|
||||||
buttonShowStorage.Size = new Size(169, 30);
|
|
||||||
buttonShowStorage.TabIndex = 5;
|
|
||||||
buttonShowStorage.Text = "Посмотреть хранилище";
|
|
||||||
buttonShowStorage.UseVisualStyleBackColor = true;
|
|
||||||
buttonShowStorage.Click += ButtonShowStorage_Click;
|
|
||||||
//
|
|
||||||
// buttonShowOnMap
|
|
||||||
//
|
|
||||||
buttonShowOnMap.Location = new Point(25, 443);
|
|
||||||
buttonShowOnMap.Name = "buttonShowOnMap";
|
|
||||||
buttonShowOnMap.Size = new Size(169, 30);
|
|
||||||
buttonShowOnMap.TabIndex = 6;
|
|
||||||
buttonShowOnMap.Text = "Посмотреть карту";
|
|
||||||
buttonShowOnMap.UseVisualStyleBackColor = true;
|
|
||||||
buttonShowOnMap.Click += ButtonShowOnMap_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBoxPosition
|
|
||||||
//
|
|
||||||
maskedTextBoxPosition.Location = new Point(24, 324);
|
|
||||||
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
|
||||||
maskedTextBoxPosition.Size = new Size(169, 23);
|
|
||||||
maskedTextBoxPosition.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
|
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonUp.Location = new Point(96, 483);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(30, 30);
|
|
||||||
buttonUp.TabIndex = 8;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonLeft.Location = new Point(60, 519);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(30, 30);
|
|
||||||
buttonLeft.TabIndex = 9;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
|
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonDown.Location = new Point(96, 519);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(30, 30);
|
|
||||||
buttonDown.TabIndex = 10;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
|
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonRight.Location = new Point(132, 519);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(30, 30);
|
|
||||||
buttonRight.TabIndex = 11;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// groupBoxTools
|
|
||||||
//
|
|
||||||
groupBoxTools.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
groupBoxTools.Controls.Add(groupBoxMaps);
|
|
||||||
groupBoxTools.Controls.Add(buttonRight);
|
|
||||||
groupBoxTools.Controls.Add(buttonDown);
|
|
||||||
groupBoxTools.Controls.Add(buttonLeft);
|
|
||||||
groupBoxTools.Controls.Add(buttonUp);
|
|
||||||
groupBoxTools.Controls.Add(maskedTextBoxPosition);
|
|
||||||
groupBoxTools.Controls.Add(buttonShowOnMap);
|
|
||||||
groupBoxTools.Controls.Add(buttonShowStorage);
|
|
||||||
groupBoxTools.Controls.Add(buttonRemoveCar);
|
|
||||||
groupBoxTools.Controls.Add(buttonAddCar);
|
|
||||||
groupBoxTools.Location = new Point(585, 0);
|
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
|
||||||
groupBoxTools.Size = new Size(212, 560);
|
|
||||||
groupBoxTools.TabIndex = 12;
|
|
||||||
groupBoxTools.TabStop = false;
|
|
||||||
groupBoxTools.Text = "Инструменты";
|
|
||||||
//
|
|
||||||
// groupBoxMaps
|
|
||||||
//
|
|
||||||
groupBoxMaps.Controls.Add(textBoxNewMapName);
|
|
||||||
groupBoxMaps.Controls.Add(buttonDeleteMap);
|
|
||||||
groupBoxMaps.Controls.Add(buttonAddMap);
|
|
||||||
groupBoxMaps.Controls.Add(listBoxMaps);
|
|
||||||
groupBoxMaps.Controls.Add(comboBoxSelectorMap);
|
|
||||||
groupBoxMaps.Location = new Point(8, 21);
|
|
||||||
groupBoxMaps.Name = "groupBoxMaps";
|
|
||||||
groupBoxMaps.Size = new Size(197, 249);
|
|
||||||
groupBoxMaps.TabIndex = 16;
|
|
||||||
groupBoxMaps.TabStop = false;
|
|
||||||
groupBoxMaps.Text = "Карты";
|
|
||||||
//
|
|
||||||
// textBoxNewMapName
|
|
||||||
//
|
|
||||||
textBoxNewMapName.Location = new Point(14, 24);
|
|
||||||
textBoxNewMapName.Name = "textBoxNewMapName";
|
|
||||||
textBoxNewMapName.Size = new Size(169, 23);
|
|
||||||
textBoxNewMapName.TabIndex = 15;
|
|
||||||
//
|
|
||||||
// buttonDeleteMap
|
|
||||||
//
|
|
||||||
buttonDeleteMap.Location = new Point(15, 208);
|
|
||||||
buttonDeleteMap.Name = "buttonDeleteMap";
|
|
||||||
buttonDeleteMap.Size = new Size(169, 30);
|
|
||||||
buttonDeleteMap.TabIndex = 14;
|
|
||||||
buttonDeleteMap.Text = "Удалить карту";
|
|
||||||
buttonDeleteMap.UseVisualStyleBackColor = true;
|
|
||||||
buttonDeleteMap.Click += ButtonDeleteMap_Click;
|
|
||||||
//
|
|
||||||
// buttonAddMap
|
|
||||||
//
|
|
||||||
buttonAddMap.Location = new Point(15, 82);
|
|
||||||
buttonAddMap.Name = "buttonAddMap";
|
|
||||||
buttonAddMap.Size = new Size(169, 30);
|
|
||||||
buttonAddMap.TabIndex = 13;
|
|
||||||
buttonAddMap.Text = "Добавить карту";
|
|
||||||
buttonAddMap.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddMap.Click += ButtonAddMap_Click;
|
|
||||||
//
|
|
||||||
// listBoxMaps
|
|
||||||
//
|
|
||||||
listBoxMaps.FormattingEnabled = true;
|
|
||||||
listBoxMaps.ItemHeight = 15;
|
|
||||||
listBoxMaps.Location = new Point(15, 123);
|
|
||||||
listBoxMaps.Name = "listBoxMaps";
|
|
||||||
listBoxMaps.Size = new Size(169, 79);
|
|
||||||
listBoxMaps.TabIndex = 12;
|
|
||||||
listBoxMaps.SelectedIndexChanged += listBoxMaps_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// FormMapWithSetLocomotive
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 561);
|
|
||||||
Controls.Add(groupBoxTools);
|
|
||||||
Controls.Add(pictureBoxLocomotive);
|
|
||||||
Name = "FormMapWithSetLocomotive";
|
|
||||||
Text = "Карта с набором объектов";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).EndInit();
|
|
||||||
groupBoxTools.ResumeLayout(false);
|
|
||||||
groupBoxTools.PerformLayout();
|
|
||||||
groupBoxMaps.ResumeLayout(false);
|
|
||||||
groupBoxMaps.PerformLayout();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private PictureBox pictureBoxLocomotive;
|
|
||||||
private ComboBox comboBoxSelectorMap;
|
|
||||||
private Button buttonAddCar;
|
|
||||||
private Button buttonRemoveCar;
|
|
||||||
private Button buttonShowStorage;
|
|
||||||
private Button buttonShowOnMap;
|
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonRight;
|
|
||||||
private GroupBox groupBoxTools;
|
|
||||||
private Button buttonDeleteMap;
|
|
||||||
private Button buttonAddMap;
|
|
||||||
private ListBox listBoxMaps;
|
|
||||||
private GroupBox groupBoxMaps;
|
|
||||||
private TextBox textBoxNewMapName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,185 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
public partial class FormMapWithSetLocomotive : Form
|
|
||||||
{
|
|
||||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
|
||||||
{
|
|
||||||
{ "Простая карта", new SimpleMap() },
|
|
||||||
{ "Карта с грязью", new FieldMap() },
|
|
||||||
{ "Карта с кустами", new BushesMap() }
|
|
||||||
};
|
|
||||||
private readonly MapsCollection _mapsCollection;
|
|
||||||
|
|
||||||
public FormMapWithSetLocomotive()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_mapsCollection = new MapsCollection(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
|
||||||
comboBoxSelectorMap.Items.Clear();
|
|
||||||
foreach (var elem in _mapsDict)
|
|
||||||
{
|
|
||||||
comboBoxSelectorMap.Items.Add(elem.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReloadMaps()
|
|
||||||
{
|
|
||||||
int index = listBoxMaps.SelectedIndex;
|
|
||||||
|
|
||||||
listBoxMaps.Items.Clear();
|
|
||||||
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
|
||||||
{
|
|
||||||
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
|
||||||
{
|
|
||||||
listBoxMaps.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
|
||||||
{
|
|
||||||
listBoxMaps.SelectedIndex = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
|
||||||
ReloadMaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void listBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
pictureBoxLocomotive.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDeleteMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
|
||||||
ReloadMaps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var FormLocmotiveConfig = new FormLocomotiveConfig();
|
|
||||||
FormLocmotiveConfig.AddEvent(new(AddLocomotive));
|
|
||||||
FormLocmotiveConfig.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddLocomotive(DrawingLocomotive locomotive)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObjectLocomotive(locomotive) != -1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Object is added");
|
|
||||||
pictureBoxLocomotive.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Unable to add object");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRemoveLocomotive_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBoxLocomotive.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBoxLocomotive.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBoxLocomotive.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
pictureBoxLocomotive.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
@ -1,41 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal interface IDrawingObject
|
|
||||||
{
|
|
||||||
/// <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>
|
|
||||||
/// <returns></returns>
|
|
||||||
void MoveObject(Direction direction);
|
|
||||||
/// <summary>
|
|
||||||
/// Отрисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
void DrawingObject(Graphics g);
|
|
||||||
/// <summary>
|
|
||||||
/// Получение текущей позиции объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal class MapWithSetLocomotiveGeneric<T, U>
|
|
||||||
where T : class, IDrawingObject
|
|
||||||
where U : AbstractMap
|
|
||||||
{
|
|
||||||
// Ширина окна отрисовки
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
// Высота окна отрисовки
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
// Размер занимаемого объектом места (ширина)
|
|
||||||
private readonly int _placeSizeWidth = 180;
|
|
||||||
// Размер занимаемого объектом места (высота)
|
|
||||||
private readonly int _placeSizeHeight = 150;
|
|
||||||
// Набор объектов
|
|
||||||
private readonly SetLocomotiveGeneric<T> _setLocomotive;
|
|
||||||
// Карта
|
|
||||||
private readonly U _map;
|
|
||||||
|
|
||||||
private readonly T[] _places;
|
|
||||||
// Конструктор
|
|
||||||
public MapWithSetLocomotiveGeneric(int picWidth, int picHeight, U map)
|
|
||||||
{
|
|
||||||
int width = picWidth / _placeSizeWidth;
|
|
||||||
int height = picHeight / _placeSizeHeight;
|
|
||||||
_setLocomotive = new SetLocomotiveGeneric<T>(width * height);
|
|
||||||
_pictureWidth = picWidth;
|
|
||||||
_pictureHeight = picHeight;
|
|
||||||
_map = map;
|
|
||||||
}
|
|
||||||
// Перегрузка оператора сложения
|
|
||||||
public static int operator +(MapWithSetLocomotiveGeneric<T, U> map, T locomotive)
|
|
||||||
{
|
|
||||||
return map._setLocomotive.Insert(locomotive);
|
|
||||||
}
|
|
||||||
public static T operator -(MapWithSetLocomotiveGeneric<T, U> map, int position)
|
|
||||||
{
|
|
||||||
return map._setLocomotive.Remove(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bitmap ShowSet()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
DrawBackground(gr);
|
|
||||||
DrawLocomotive(gr);
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
public Bitmap ShowOnMap()
|
|
||||||
{
|
|
||||||
Shaking();
|
|
||||||
foreach (var locomotive in _setLocomotive.GetLocomotives())
|
|
||||||
{
|
|
||||||
return _map.CreateMap(_pictureWidth, _pictureHeight, locomotive);
|
|
||||||
}
|
|
||||||
return new(_pictureWidth, _pictureHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bitmap MoveObject(Direction direction)
|
|
||||||
{
|
|
||||||
if (_map != null)
|
|
||||||
{
|
|
||||||
return _map.MoveObject(direction);
|
|
||||||
}
|
|
||||||
return new(_pictureWidth, _pictureHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Shaking()
|
|
||||||
{
|
|
||||||
int j = _setLocomotive.Count - 1;
|
|
||||||
for (int i = 0; i < _setLocomotive.Count; i++)
|
|
||||||
{
|
|
||||||
if (_setLocomotive[i] == null)
|
|
||||||
{
|
|
||||||
for (; j > i; j--)
|
|
||||||
{
|
|
||||||
var Locomotive = _setLocomotive[j];
|
|
||||||
if (Locomotive != null)
|
|
||||||
{
|
|
||||||
_setLocomotive.Insert(Locomotive, i);
|
|
||||||
_setLocomotive.Remove(j);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (j <= i)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Метод отрисовки фона
|
|
||||||
private void DrawBackground(Graphics g)
|
|
||||||
{
|
|
||||||
Pen pen = new(Color.Sienna, 3);
|
|
||||||
Brush brush = new SolidBrush(Color.DodgerBlue);
|
|
||||||
g.FillRectangle(brush, 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 + 2, i * _placeSizeWidth + _placeSizeWidth / 2 + 40, j * _placeSizeHeight + 2);
|
|
||||||
}
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth + 7, 2, i * _placeSizeWidth + 7, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth + 3, 2, i * _placeSizeWidth + 3, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Метод прорисовки объектов
|
|
||||||
private void DrawLocomotive(Graphics g)
|
|
||||||
{
|
|
||||||
int xPosition = _pictureWidth - _placeSizeWidth;
|
|
||||||
int yPosition = 12;
|
|
||||||
|
|
||||||
foreach (var locomotive in _setLocomotive.GetLocomotives())
|
|
||||||
{
|
|
||||||
locomotive.SetObject(xPosition, yPosition, _pictureWidth, _pictureHeight);
|
|
||||||
locomotive.DrawingObject(g);
|
|
||||||
|
|
||||||
xPosition -= _placeSizeWidth;
|
|
||||||
if (xPosition < 0)
|
|
||||||
{
|
|
||||||
yPosition += _placeSizeHeight;
|
|
||||||
xPosition = _pictureWidth - _placeSizeWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal class MapsCollection
|
|
||||||
{
|
|
||||||
readonly Dictionary<string, MapWithSetLocomotiveGeneric<DrawingObjectLocomotive, AbstractMap>> _mapStorages;
|
|
||||||
public List<string> Keys => _mapStorages.Keys.ToList();
|
|
||||||
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
|
|
||||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
|
||||||
{
|
|
||||||
_mapStorages = new Dictionary<string, MapWithSetLocomotiveGeneric<DrawingObjectLocomotive, AbstractMap>>();
|
|
||||||
_pictureWidth = pictureWidth;
|
|
||||||
_pictureHeight = pictureHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddMap(string name, AbstractMap map)
|
|
||||||
{
|
|
||||||
if (!_mapStorages.ContainsKey(name))
|
|
||||||
{
|
|
||||||
_mapStorages.Add(name, new MapWithSetLocomotiveGeneric<DrawingObjectLocomotive, AbstractMap>
|
|
||||||
(_pictureWidth, _pictureHeight, map));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void DelMap(string name)
|
|
||||||
{
|
|
||||||
if (_mapStorages.ContainsKey(name))
|
|
||||||
_mapStorages.Remove(name);
|
|
||||||
}
|
|
||||||
public MapWithSetLocomotiveGeneric<DrawingObjectLocomotive, AbstractMap> this[string ind]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_mapStorages.ContainsKey(ind))
|
|
||||||
return _mapStorages[ind];
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -8,19 +8,4 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<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>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -11,7 +11,7 @@ namespace Monorail
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormMapWithSetLocomotive());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
103
Monorail/Monorail/Properties/Resources.Designer.cs
generated
103
Monorail/Monorail/Properties/Resources.Designer.cs
generated
@ -1,103 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Monorail.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("Monorail.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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 61 KiB |
Binary file not shown.
Before Width: | Height: | Size: 60 KiB |
Binary file not shown.
Before Width: | Height: | Size: 60 KiB |
Binary file not shown.
Before Width: | Height: | Size: 61 KiB |
@ -1,77 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal class SetLocomotiveGeneric<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
private readonly List<T> _places;
|
|
||||||
public int Count => _places.Count;
|
|
||||||
private readonly int _maxCount;
|
|
||||||
|
|
||||||
public SetLocomotiveGeneric(int count)
|
|
||||||
{
|
|
||||||
_maxCount = count;
|
|
||||||
_places = new List<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T locomotive)
|
|
||||||
{
|
|
||||||
return Insert(locomotive, 0);
|
|
||||||
}
|
|
||||||
public int Insert(T locomotive, int position)
|
|
||||||
{
|
|
||||||
if (position <= _places.Count && _places.Count < _maxCount && position >= 0)
|
|
||||||
{
|
|
||||||
_places.Insert(position, locomotive);
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
public T Remove(int position)
|
|
||||||
{
|
|
||||||
if (position < _places.Count && position >= 0)
|
|
||||||
{
|
|
||||||
var locomotive = _places[position];
|
|
||||||
_places.RemoveAt(position);
|
|
||||||
return locomotive;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T this[int position]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (position < _places.Count && position >= 0)
|
|
||||||
return _places[position];
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Insert(value, position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public IEnumerable<T> GetLocomotives()
|
|
||||||
{
|
|
||||||
foreach (var locomotive in _places)
|
|
||||||
{
|
|
||||||
if (locomotive != null)
|
|
||||||
{
|
|
||||||
yield return locomotive;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Monorail
|
|
||||||
{
|
|
||||||
internal class SimpleMap : AbstractMap
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly Brush barrierColor = new SolidBrush(Color.Black);
|
|
||||||
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, i * (_size_x), j * (_size_y));
|
|
||||||
}
|
|
||||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
|
||||||
{
|
|
||||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x), j * (_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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user