Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
80df65a770 | |||
|
ee9c15b506 |
@ -1,140 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
internal abstract class AbstractMap
|
|
||||||
{
|
|
||||||
private IDrawningObject _drawningObject = null;
|
|
||||||
protected int[,] _map = null;
|
|
||||||
protected int _width;
|
|
||||||
protected int _height;
|
|
||||||
protected float _size_x;
|
|
||||||
protected float _size_y;
|
|
||||||
protected readonly Random _random = new Random();
|
|
||||||
protected readonly int _freeRoad = 0;
|
|
||||||
protected readonly int _barrier = 1;
|
|
||||||
|
|
||||||
public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject)
|
|
||||||
{
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
_drawningObject = drawningObject;
|
|
||||||
GenerateMap();
|
|
||||||
while (!SetObjectOnMap())
|
|
||||||
{
|
|
||||||
GenerateMap();
|
|
||||||
}
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
public Bitmap MoveObject(Direction direction)
|
|
||||||
{
|
|
||||||
(float leftX, float topY, float rightX, float bottomY) = _drawningObject.GetCurrentPosition();
|
|
||||||
|
|
||||||
for (int i = 0; i < _map.GetLength(0); i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _map.GetLength(1); j++)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case Direction.Up:
|
|
||||||
if (_size_y * (j + 1) >= topY - _drawningObject.Step && _size_y * (j + 1) < topY && _size_x * (i + 1) > leftX
|
|
||||||
&& _size_x * (i + 1) <= rightX)
|
|
||||||
{
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Direction.Down:
|
|
||||||
if (_size_y * j <= bottomY + _drawningObject.Step && _size_y * j > bottomY && _size_x * (i + 1) > leftX
|
|
||||||
&& _size_x * (i + 1) <= rightX)
|
|
||||||
{
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Direction.Left:
|
|
||||||
if (_size_x * (i + 1) >= leftX - _drawningObject.Step && _size_x * (i + 1) < leftX && _size_y * (j + 1) < bottomY
|
|
||||||
&& _size_y * (j + 1) >= topY)
|
|
||||||
{
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Direction.Right:
|
|
||||||
if (_size_x * i <= rightX + _drawningObject.Step && _size_x * i > leftX && _size_y * (j + 1) < bottomY
|
|
||||||
&& _size_y * (j + 1) >= topY)
|
|
||||||
{
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_drawningObject.MoveObject(direction);
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
private bool SetObjectOnMap()
|
|
||||||
{
|
|
||||||
(float leftX, float topY, float rightX, float bottomY) = _drawningObject.GetCurrentPosition();
|
|
||||||
if (_drawningObject == null || _map == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
float airplaneWidth = rightX - leftX;
|
|
||||||
float airplaneHeight = bottomY - topY;
|
|
||||||
|
|
||||||
int x = _random.Next(0, 10);
|
|
||||||
int y = _random.Next(0, 10);
|
|
||||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
if (x + airplaneWidth >= _size_x * i && x <= _size_x * i && y + airplaneHeight > _size_y * j && y <= _size_y * j)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_drawningObject.SetObject(x, y, _width, _height);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private Bitmap DrawMapWithObject()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(_width, _height);
|
|
||||||
if (_drawningObject == null || _map == null)
|
|
||||||
{
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _freeRoad)
|
|
||||||
{
|
|
||||||
DrawRoadPart(gr, i, j);
|
|
||||||
}
|
|
||||||
else if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
DrawBarrierPart(gr, i, j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_drawningObject.DrawningObject(gr);
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,30 +0,0 @@
|
|||||||
using System.Threading;
|
|
||||||
using Trolleybus;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
internal class AutoStopMap : SimpleMap
|
|
||||||
{
|
|
||||||
protected override void GenerateMap()
|
|
||||||
{
|
|
||||||
_map = new int[100, 100];
|
|
||||||
_size_x = (float)_width / _map.GetLength(0);
|
|
||||||
_size_y = (float)_height / _map.GetLength(1);
|
|
||||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
|
||||||
{
|
|
||||||
_map[i, j] = _freeRoad;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 50; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 50; j++)
|
|
||||||
{
|
|
||||||
_map[i, j] = _barrier;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -9,9 +9,8 @@ namespace Trolleybus
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Направление перемещения
|
/// Направление перемещения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum Direction
|
internal enum Direction
|
||||||
{
|
{
|
||||||
None = 0,
|
|
||||||
Up = 1,
|
Up = 1,
|
||||||
Down = 2,
|
Down = 2,
|
||||||
Left = 3,
|
Left = 3,
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
internal class DrawningSmallTrolleybus : DrawingTrolleybus
|
|
||||||
{
|
|
||||||
public DrawningSmallTrolleybus(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool horns, bool battary) :
|
|
||||||
base(speed, weight, bodyColor, 110, 60)
|
|
||||||
{
|
|
||||||
Trolleybus = new EntitySmallTrolleybus(speed, weight, bodyColor, dopColor,bodyKit, horns, battary);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (Trolleybus is not EntitySmallTrolleybus smallTrolleybus)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pen pen = new Pen(Color.Black);
|
|
||||||
Brush dopBrush = new SolidBrush(smallTrolleybus.DopColor);
|
|
||||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
|
||||||
Brush dBlue = new SolidBrush(Color.DarkBlue);
|
|
||||||
Brush bWhite = new SolidBrush(Color.White);
|
|
||||||
Pen WinBlue = new Pen(Color.Blue);
|
|
||||||
|
|
||||||
base.DrawTransport(g);
|
|
||||||
if (smallTrolleybus.BodyKit)
|
|
||||||
{
|
|
||||||
g.DrawRectangle(pen, _startPosX, _startPosY, 200, 50);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 100, _startPosY + 10, 20, 40);
|
|
||||||
g.FillEllipse(brBlue, _startPosX, _startPosY + 5, 20, 25);
|
|
||||||
g.DrawEllipse(WinBlue, _startPosX, _startPosY + 5, 20, 25);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 25, _startPosY + 5, 20, 25);
|
|
||||||
g.DrawEllipse(WinBlue, _startPosX + 25, _startPosY + 5, 20, 25);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 50, _startPosY + 5, 20, 25);
|
|
||||||
g.DrawEllipse(WinBlue, _startPosX + 50, _startPosY + 5, 20, 25);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 75, _startPosY + 5, 20, 25);
|
|
||||||
g.DrawEllipse(WinBlue, _startPosX + 75, _startPosY + 5, 20, 25);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 120, _startPosY + 5, 20, 25);
|
|
||||||
g.DrawEllipse(WinBlue, _startPosX + 120, _startPosY + 5, 20, 25);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 145, _startPosY + 5, 20, 25);
|
|
||||||
g.DrawEllipse(WinBlue, _startPosX + 145, _startPosY + 5, 20, 25);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 170, _startPosY + 5, 20, 25);
|
|
||||||
g.DrawEllipse(WinBlue, _startPosX + 170, _startPosY + 5, 20, 25);
|
|
||||||
g.FillEllipse(bWhite, _startPosX, _startPosY + 40, 30, 30);
|
|
||||||
g.DrawEllipse(pen, _startPosX, _startPosY + 40, 30, 30);
|
|
||||||
g.FillEllipse(bWhite, _startPosX + 170, _startPosY + 40, 30, 30);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 170, _startPosY + 40, 30, 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (smallTrolleybus.Horns)
|
|
||||||
{
|
|
||||||
g.DrawLine(pen, _startPosX + 100, _startPosY - 10, _startPosX + 150, _startPosY - 20);
|
|
||||||
g.DrawLine(pen, _startPosX + 150, _startPosY - 20, _startPosX, _startPosY - 30);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 50, _startPosY - 10, 100, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (smallTrolleybus.Battary)
|
|
||||||
{
|
|
||||||
g.DrawRectangle(pen, _startPosX + 100, _startPosY, 10, 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,25 +11,25 @@ namespace Trolleybus
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс прорисовки и перемещения объекта
|
/// Класс прорисовки и перемещения объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DrawingTrolleybus
|
internal class DrawingTrolleybus
|
||||||
{
|
{
|
||||||
public EntityTrolleybus Trolleybus { get; protected set; }
|
public EntityTrolleybus Trolleybus { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// левая координата отрисовки
|
/// левая координата отрисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float _startPosX;
|
private float _startPosX;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// верхняя координата отрисовки
|
/// верхняя координата отрисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float _startPosY;
|
private float _startPosY;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// левая координата начала отрисовки
|
/// левая координата начала отрисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float _startX;
|
//private float _startX;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Верхняя координата начала отрисовки
|
/// Верхняя координата начала отрисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float _startY;
|
//private float _startY;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна отрисовки
|
/// Ширина окна отрисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -52,15 +52,10 @@ namespace Trolleybus
|
|||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес автомобиля</param>
|
/// <param name="weight">Вес автомобиля</param>
|
||||||
/// <param name="bodyColor">Цвет кузова</param>
|
/// <param name="bodyColor">Цвет кузова</param>
|
||||||
public DrawingTrolleybus(int speed, float weight, Color bodyColor)
|
public void Init(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Trolleybus = new EntityTrolleybus(speed, weight, bodyColor);
|
Trolleybus = new EntityTrolleybus();
|
||||||
}
|
Trolleybus.Init(speed, weight, bodyColor);
|
||||||
protected DrawingTrolleybus(int speed, float weight, Color bodyColor, int trolleybusWidth, int trolleybusHeight)
|
|
||||||
{
|
|
||||||
Trolleybus = new EntityTrolleybus(speed, weight, bodyColor);
|
|
||||||
_trolleybusWidth = trolleybusWidth;
|
|
||||||
_trolleybusHeight = trolleybusHeight;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции
|
/// Установка позиции
|
||||||
@ -100,15 +95,13 @@ namespace Trolleybus
|
|||||||
break;
|
break;
|
||||||
//влево
|
//влево
|
||||||
case Direction.Left:
|
case Direction.Left:
|
||||||
// if (_startPosX > _startX)
|
|
||||||
if (_startPosX - Trolleybus.Step > 0)
|
if (_startPosX - Trolleybus.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosX -= Trolleybus.Step;
|
_startPosX -= Trolleybus.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//вверх
|
//вверх
|
||||||
case Direction.Up:
|
case Direction.Up:
|
||||||
// if (_startPosY > _startY)
|
|
||||||
if (_startPosY - Trolleybus.Step > 0)
|
if (_startPosY - Trolleybus.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosY -= Trolleybus.Step;
|
_startPosY -= Trolleybus.Step;
|
||||||
@ -127,7 +120,7 @@ namespace Trolleybus
|
|||||||
/// Отрисовка троллейбуса
|
/// Отрисовка троллейбуса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
public virtual void DrawTransport(Graphics g)
|
public void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (_startPosX < 0 || _startPosY < 0
|
if (_startPosX < 0 || _startPosY < 0
|
||||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||||
@ -184,10 +177,5 @@ namespace Trolleybus
|
|||||||
_startPosY = _pictureHeight.Value - _trolleybusHeight;
|
_startPosY = _pictureHeight.Value - _trolleybusHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
|
||||||
{
|
|
||||||
return (_startPosX, _startPosY, _startPosX + _trolleybusWidth, _startPosY + _trolleybusHeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using static System.Windows.Forms.AxHost;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
internal class DrawningObject : IDrawningObject
|
|
||||||
{
|
|
||||||
private DrawingTrolleybus _trolleybus = null;
|
|
||||||
|
|
||||||
public DrawningObject(DrawingTrolleybus car)
|
|
||||||
{
|
|
||||||
_trolleybus = car;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Step => _trolleybus?.Trolleybus?.Step ?? 0;
|
|
||||||
|
|
||||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
|
||||||
{
|
|
||||||
return _trolleybus?.GetCurrentPosition() ?? default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MoveObject(Direction direction)
|
|
||||||
{
|
|
||||||
_trolleybus?.MoveTransport(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void nothing()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetObject(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
_trolleybus.SetPosition(x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IDrawningObject.DrawningObject(Graphics g)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
internal class DrawningObjectTrolleybus : IDrawningObject
|
|
||||||
{
|
|
||||||
private DrawingTrolleybus _trolleybus = null;
|
|
||||||
|
|
||||||
public DrawningObjectTrolleybus(DrawingTrolleybus trolleybus)
|
|
||||||
{
|
|
||||||
_trolleybus = trolleybus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Step => _trolleybus?.Trolleybus?.Step ?? 0;
|
|
||||||
|
|
||||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
|
||||||
{
|
|
||||||
return _trolleybus?.GetCurrentPosition() ?? default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MoveObject(Direction direction)
|
|
||||||
{
|
|
||||||
_trolleybus?.MoveTransport(direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void nothing()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetObject(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
_trolleybus.SetPosition(x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IDrawningObject.DrawningObject(Graphics g)
|
|
||||||
{
|
|
||||||
_trolleybus.DrawTransport(g);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
class EntitySmallTrolleybus : EntityTrolleybus
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Дополнительный цвет
|
|
||||||
/// </summary>
|
|
||||||
public Color DopColor { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Признак наличия обвеса
|
|
||||||
/// </summary>
|
|
||||||
public bool BodyKit { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Признак наличия гоночной полосы
|
|
||||||
/// </summary>
|
|
||||||
public bool Horns { get; private set; }
|
|
||||||
public bool Battary { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Инициализация свойств
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес автомобиля</param>
|
|
||||||
/// <param name="bodyColor">Цвет кузова</param>
|
|
||||||
/// <param name="dopColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
|
||||||
/// <param name="horns">Признак наличия гоночной полосы</param>
|
|
||||||
/// /// <param name="battary">Признак наличия гоночной полосы</param>
|
|
||||||
public EntitySmallTrolleybus(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool horns, bool battary) :
|
|
||||||
base(speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
DopColor = dopColor;
|
|
||||||
BodyKit = bodyKit;
|
|
||||||
Horns = horns;
|
|
||||||
Battary = battary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,7 @@ namespace Trolleybus
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность "Троллейбус"
|
/// Класс-сущность "Троллейбус"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EntityTrolleybus
|
internal class EntityTrolleybus
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Скорость
|
/// Скорость
|
||||||
@ -35,12 +35,12 @@ namespace Trolleybus
|
|||||||
/// <param name="weight"></param>
|
/// <param name="weight"></param>
|
||||||
/// <param name="bodyColor"></param>
|
/// <param name="bodyColor"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public EntityTrolleybus(int speed, float weight, Color bodyColor)
|
public void Init(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
Speed = speed <= 0? rnd.Next(50, 150): speed;
|
Speed = speed <= 0? rnd.Next(50, 150): speed;
|
||||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||||
BodyColor = bodyColor;
|
bodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
30
Trolleybus/Trolleybus/Form1.Designer.cs
generated
30
Trolleybus/Trolleybus/Form1.Designer.cs
generated
@ -39,8 +39,6 @@ namespace Trolleybus
|
|||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
this.pictureBoxTrolleybus = new System.Windows.Forms.PictureBox();
|
this.pictureBoxTrolleybus = new System.Windows.Forms.PictureBox();
|
||||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSelectTrolleybus = new System.Windows.Forms.Button();
|
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTrolleybus)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTrolleybus)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -131,39 +129,17 @@ namespace Trolleybus
|
|||||||
//
|
//
|
||||||
// pictureBoxTrolleybus
|
// pictureBoxTrolleybus
|
||||||
//
|
//
|
||||||
this.pictureBoxTrolleybus.Location = new System.Drawing.Point(0, 0);
|
this.pictureBoxTrolleybus.Location = new System.Drawing.Point(0, -1);
|
||||||
this.pictureBoxTrolleybus.Name = "pictureBoxTrolleybus";
|
this.pictureBoxTrolleybus.Name = "pictureBoxTrolleybus";
|
||||||
this.pictureBoxTrolleybus.Size = new System.Drawing.Size(800, 450);
|
this.pictureBoxTrolleybus.Size = new System.Drawing.Size(800, 451);
|
||||||
this.pictureBoxTrolleybus.TabIndex = 0;
|
this.pictureBoxTrolleybus.TabIndex = 0;
|
||||||
this.pictureBoxTrolleybus.TabStop = false;
|
this.pictureBoxTrolleybus.TabStop = false;
|
||||||
//
|
//
|
||||||
// buttonCreateModif
|
|
||||||
//
|
|
||||||
this.buttonCreateModif.Location = new System.Drawing.Point(94, 389);
|
|
||||||
this.buttonCreateModif.Name = "buttonCreateModif";
|
|
||||||
this.buttonCreateModif.Size = new System.Drawing.Size(86, 23);
|
|
||||||
this.buttonCreateModif.TabIndex = 7;
|
|
||||||
this.buttonCreateModif.Text = "Модификация";
|
|
||||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
|
|
||||||
//
|
|
||||||
// buttonSelectTrolleybus
|
|
||||||
//
|
|
||||||
this.buttonSelectTrolleybus.Location = new System.Drawing.Point(578, 390);
|
|
||||||
this.buttonSelectTrolleybus.Name = "buttonSelectTrolleybus";
|
|
||||||
this.buttonSelectTrolleybus.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.buttonSelectTrolleybus.TabIndex = 8;
|
|
||||||
this.buttonSelectTrolleybus.Text = "Выбрать";
|
|
||||||
this.buttonSelectTrolleybus.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSelectTrolleybus.Click += new System.EventHandler(this.buttonSelectTrolleybus_Click);
|
|
||||||
//
|
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
this.Controls.Add(this.buttonSelectTrolleybus);
|
|
||||||
this.Controls.Add(this.buttonCreateModif);
|
|
||||||
this.Controls.Add(this.buttonUp);
|
this.Controls.Add(this.buttonUp);
|
||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
this.Controls.Add(this.buttonLeft);
|
this.Controls.Add(this.buttonLeft);
|
||||||
@ -193,8 +169,6 @@ namespace Trolleybus
|
|||||||
private System.Windows.Forms.Button buttonLeft;
|
private System.Windows.Forms.Button buttonLeft;
|
||||||
private System.Windows.Forms.Button buttonRight;
|
private System.Windows.Forms.Button buttonRight;
|
||||||
private System.Windows.Forms.Button buttonUp;
|
private System.Windows.Forms.Button buttonUp;
|
||||||
private System.Windows.Forms.Button buttonCreateModif;
|
|
||||||
private System.Windows.Forms.Button buttonSelectTrolleybus;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ namespace Trolleybus
|
|||||||
public partial class Form1 : Form
|
public partial class Form1 : Form
|
||||||
{
|
{
|
||||||
private DrawingTrolleybus _trolleybus;
|
private DrawingTrolleybus _trolleybus;
|
||||||
public DrawingTrolleybus SelectedTrolleybus { get; private set; }
|
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -30,15 +29,6 @@ namespace Trolleybus
|
|||||||
pictureBoxTrolleybus.Image = bmp;
|
pictureBoxTrolleybus.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetData()
|
|
||||||
{
|
|
||||||
Random rnd = new Random();
|
|
||||||
_trolleybus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_trolleybus.Trolleybus.Speed}";
|
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {_trolleybus.Trolleybus.Weight}";
|
|
||||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {_trolleybus.Trolleybus.BodyColor.Name}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обработка нажатия "Создать"
|
/// Обработка нажатия "Создать"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -47,14 +37,14 @@ namespace Trolleybus
|
|||||||
|
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new();
|
Random rnd = new Random();
|
||||||
Color myColor = new Color();
|
_trolleybus = new DrawingTrolleybus();
|
||||||
ColorDialog MyDialog = new ColorDialog();
|
_trolleybus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
if (MyDialog.ShowDialog() == DialogResult.OK)
|
//_trolleybus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), Location.X, Location.Y, pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||||
myColor = MyDialog.Color;
|
_trolleybus.SetPosition(rnd.Next(10, 100), rnd.Next(pictureBoxTrolleybus.Size.Height - 150, pictureBoxTrolleybus.Size.Height - 100), pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||||
_trolleybus = new DrawingTrolleybus(random.Next(30, 50), random.Next(1000, 2000),
|
toolStripStatusLabelSpeed.Text = $"Скорость: {_trolleybus.Trolleybus.Speed}";
|
||||||
myColor);
|
toolStripStatusLabelWeight.Text = $"Вес: {_trolleybus.Trolleybus.Weight}";
|
||||||
SetData();
|
toolStripStatusLabelBodyColor.Text = $"Цвет: {_trolleybus.Trolleybus.BodyColor.Name}";
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,31 +74,5 @@ namespace Trolleybus
|
|||||||
_trolleybus?.ChangeBorders(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
_trolleybus?.ChangeBorders(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCreateModif_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
Color firstColor = new Color();
|
|
||||||
Color secondColor = new Color();
|
|
||||||
ColorDialog MyDialog = new ColorDialog();
|
|
||||||
if (MyDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
firstColor = MyDialog.Color;
|
|
||||||
MyDialog = new ColorDialog();
|
|
||||||
if (MyDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
secondColor = MyDialog.Color;
|
|
||||||
_trolleybus = new DrawningSmallTrolleybus(random.Next(100, 300), random.Next(1000, 2000),
|
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
|
||||||
|
|
||||||
SetData();
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonSelectTrolleybus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
SelectedTrolleybus = _trolleybus;
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
199
Trolleybus/Trolleybus/FormMap.Designer.cs
generated
199
Trolleybus/Trolleybus/FormMap.Designer.cs
generated
@ -1,199 +0,0 @@
|
|||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
partial class FormMap
|
|
||||||
{
|
|
||||||
/// <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.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
|
||||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.buttonCreate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
|
||||||
this.pictureBoxTrolleybus = new System.Windows.Forms.PictureBox();
|
|
||||||
this.statusStrip1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTrolleybus)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// statusStrip1
|
|
||||||
//
|
|
||||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.toolStripStatusLabelSpeed,
|
|
||||||
this.toolStripStatusLabelWeight,
|
|
||||||
this.toolStripStatusLabelBodyColor});
|
|
||||||
this.statusStrip1.Location = new System.Drawing.Point(0, 428);
|
|
||||||
this.statusStrip1.Name = "statusStrip1";
|
|
||||||
this.statusStrip1.Size = new System.Drawing.Size(800, 22);
|
|
||||||
this.statusStrip1.TabIndex = 1;
|
|
||||||
this.statusStrip1.Text = "statusStrip1";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelSpeed
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
|
||||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(59, 17);
|
|
||||||
this.toolStripStatusLabelSpeed.Text = "Скорость";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelWeight
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
|
||||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(26, 17);
|
|
||||||
this.toolStripStatusLabelWeight.Text = "Вес";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelBodyColor
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
|
||||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(33, 17);
|
|
||||||
this.toolStripStatusLabelBodyColor.Text = "Цвет";
|
|
||||||
//
|
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
this.buttonCreate.Location = new System.Drawing.Point(12, 390);
|
|
||||||
this.buttonCreate.Name = "buttonCreate";
|
|
||||||
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.buttonCreate.TabIndex = 2;
|
|
||||||
this.buttonCreate.Text = "Создать";
|
|
||||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
|
||||||
//
|
|
||||||
// buttonCreateModif
|
|
||||||
//
|
|
||||||
this.buttonCreateModif.Location = new System.Drawing.Point(94, 389);
|
|
||||||
this.buttonCreateModif.Name = "buttonCreateModif";
|
|
||||||
this.buttonCreateModif.Size = new System.Drawing.Size(86, 23);
|
|
||||||
this.buttonCreateModif.TabIndex = 7;
|
|
||||||
this.buttonCreateModif.Text = "Модификация";
|
|
||||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
|
|
||||||
//
|
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
|
||||||
"Простая карта"});
|
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 21);
|
|
||||||
this.comboBoxSelectorMap.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
this.buttonUp.BackgroundImage = global::Trolleybus.Properties.Resources.up30;
|
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonUp.Location = new System.Drawing.Point(722, 353);
|
|
||||||
this.buttonUp.Name = "buttonUp";
|
|
||||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonUp.TabIndex = 6;
|
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
this.buttonRight.BackgroundImage = global::Trolleybus.Properties.Resources.right30;
|
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonRight.Location = new System.Drawing.Point(758, 389);
|
|
||||||
this.buttonRight.Name = "buttonRight";
|
|
||||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonRight.TabIndex = 5;
|
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
this.buttonLeft.BackgroundImage = global::Trolleybus.Properties.Resources.left30;
|
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(686, 389);
|
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonLeft.TabIndex = 4;
|
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
this.buttonDown.BackgroundImage = global::Trolleybus.Properties.Resources.down30;
|
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonDown.Location = new System.Drawing.Point(722, 389);
|
|
||||||
this.buttonDown.Name = "buttonDown";
|
|
||||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonDown.TabIndex = 3;
|
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// pictureBoxTrolleybus
|
|
||||||
//
|
|
||||||
this.pictureBoxTrolleybus.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.pictureBoxTrolleybus.Name = "pictureBoxTrolleybus";
|
|
||||||
this.pictureBoxTrolleybus.Size = new System.Drawing.Size(776, 413);
|
|
||||||
this.pictureBoxTrolleybus.TabIndex = 0;
|
|
||||||
this.pictureBoxTrolleybus.TabStop = false;
|
|
||||||
//
|
|
||||||
// FormMap
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.Controls.Add(this.comboBoxSelectorMap);
|
|
||||||
this.Controls.Add(this.buttonCreateModif);
|
|
||||||
this.Controls.Add(this.buttonUp);
|
|
||||||
this.Controls.Add(this.buttonRight);
|
|
||||||
this.Controls.Add(this.buttonLeft);
|
|
||||||
this.Controls.Add(this.buttonDown);
|
|
||||||
this.Controls.Add(this.buttonCreate);
|
|
||||||
this.Controls.Add(this.statusStrip1);
|
|
||||||
this.Controls.Add(this.pictureBoxTrolleybus);
|
|
||||||
this.Name = "FormMap";
|
|
||||||
this.Text = "Карта";
|
|
||||||
this.statusStrip1.ResumeLayout(false);
|
|
||||||
this.statusStrip1.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTrolleybus)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private System.Windows.Forms.PictureBox pictureBoxTrolleybus;
|
|
||||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
|
||||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpeed;
|
|
||||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelWeight;
|
|
||||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
|
||||||
private System.Windows.Forms.Button buttonCreate;
|
|
||||||
private System.Windows.Forms.Button buttonDown;
|
|
||||||
private System.Windows.Forms.Button buttonLeft;
|
|
||||||
private System.Windows.Forms.Button buttonRight;
|
|
||||||
private System.Windows.Forms.Button buttonUp;
|
|
||||||
private System.Windows.Forms.Button buttonCreateModif;
|
|
||||||
private System.Windows.Forms.ComboBox comboBoxSelectorMap;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,101 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Numerics;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
public partial class FormMap : Form
|
|
||||||
{
|
|
||||||
private AbstractMap _abstractMap;
|
|
||||||
public FormMap()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_abstractMap = new SimpleMap();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Заполнение информации по объекту
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="trolleybus"></param>
|
|
||||||
private void SetData(DrawingTrolleybus trolleybus)
|
|
||||||
{
|
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {trolleybus.Trolleybus.Speed}";
|
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {trolleybus.Trolleybus.Weight}";
|
|
||||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {trolleybus.Trolleybus.BodyColor.Name}";
|
|
||||||
pictureBoxTrolleybus.Image = _abstractMap.CreateMap(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height,
|
|
||||||
new DrawningObjectTrolleybus(trolleybus));
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Создать"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new Random();
|
|
||||||
var trolleybus = new DrawingTrolleybus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
||||||
SetData(trolleybus);
|
|
||||||
}
|
|
||||||
/// <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;
|
|
||||||
}
|
|
||||||
pictureBoxTrolleybus.Image = _abstractMap?.MoveObject(dir);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Модификация"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new Random();
|
|
||||||
var trolleybus = new DrawningSmallTrolleybus(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)), Convert.ToBoolean(rnd.Next(0, 2)));
|
|
||||||
SetData(trolleybus);
|
|
||||||
}
|
|
||||||
/// <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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,123 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,210 +0,0 @@
|
|||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
partial class FormMapWithSetTrolleybus
|
|
||||||
{
|
|
||||||
/// <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.groupBox1 = new System.Windows.Forms.GroupBox();
|
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
|
||||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
|
||||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
|
||||||
this.buttonRemoveTrolleybus = new System.Windows.Forms.Button();
|
|
||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
|
||||||
this.buttonAddTrolleybus = new System.Windows.Forms.Button();
|
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
|
||||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
|
||||||
this.groupBox1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBox1
|
|
||||||
//
|
|
||||||
this.groupBox1.Controls.Add(this.buttonLeft);
|
|
||||||
this.groupBox1.Controls.Add(this.buttonRight);
|
|
||||||
this.groupBox1.Controls.Add(this.buttonDown);
|
|
||||||
this.groupBox1.Controls.Add(this.buttonUp);
|
|
||||||
this.groupBox1.Controls.Add(this.buttonShowOnMap);
|
|
||||||
this.groupBox1.Controls.Add(this.buttonShowStorage);
|
|
||||||
this.groupBox1.Controls.Add(this.buttonRemoveTrolleybus);
|
|
||||||
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
|
||||||
this.groupBox1.Controls.Add(this.buttonAddTrolleybus);
|
|
||||||
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
|
||||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
|
||||||
this.groupBox1.Location = new System.Drawing.Point(600, 0);
|
|
||||||
this.groupBox1.Name = "groupBox1";
|
|
||||||
this.groupBox1.Size = new System.Drawing.Size(200, 450);
|
|
||||||
this.groupBox1.TabIndex = 0;
|
|
||||||
this.groupBox1.TabStop = false;
|
|
||||||
this.groupBox1.Text = "Инструменты";
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
this.buttonLeft.BackgroundImage = global::Trolleybus.Properties.Resources.left30;
|
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(59, 402);
|
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(32, 31);
|
|
||||||
this.buttonLeft.TabIndex = 9;
|
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
this.buttonRight.BackgroundImage = global::Trolleybus.Properties.Resources.right30;
|
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonRight.Location = new System.Drawing.Point(135, 402);
|
|
||||||
this.buttonRight.Name = "buttonRight";
|
|
||||||
this.buttonRight.Size = new System.Drawing.Size(32, 31);
|
|
||||||
this.buttonRight.TabIndex = 8;
|
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
this.buttonDown.BackgroundImage = global::Trolleybus.Properties.Resources.down30;
|
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonDown.Location = new System.Drawing.Point(97, 402);
|
|
||||||
this.buttonDown.Name = "buttonDown";
|
|
||||||
this.buttonDown.Size = new System.Drawing.Size(32, 31);
|
|
||||||
this.buttonDown.TabIndex = 7;
|
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
this.buttonUp.BackgroundImage = global::Trolleybus.Properties.Resources.up30;
|
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonUp.Location = new System.Drawing.Point(97, 365);
|
|
||||||
this.buttonUp.Name = "buttonUp";
|
|
||||||
this.buttonUp.Size = new System.Drawing.Size(32, 31);
|
|
||||||
this.buttonUp.TabIndex = 6;
|
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonShowOnMap
|
|
||||||
//
|
|
||||||
this.buttonShowOnMap.Location = new System.Drawing.Point(7, 256);
|
|
||||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
|
||||||
this.buttonShowOnMap.Size = new System.Drawing.Size(181, 23);
|
|
||||||
this.buttonShowOnMap.TabIndex = 5;
|
|
||||||
this.buttonShowOnMap.Text = "Посмотреть карту";
|
|
||||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
|
||||||
//
|
|
||||||
// buttonShowStorage
|
|
||||||
//
|
|
||||||
this.buttonShowStorage.Location = new System.Drawing.Point(7, 216);
|
|
||||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
|
||||||
this.buttonShowStorage.Size = new System.Drawing.Size(181, 23);
|
|
||||||
this.buttonShowStorage.TabIndex = 4;
|
|
||||||
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
|
||||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
|
||||||
//
|
|
||||||
// buttonRemoveTrolleybus
|
|
||||||
//
|
|
||||||
this.buttonRemoveTrolleybus.Location = new System.Drawing.Point(6, 170);
|
|
||||||
this.buttonRemoveTrolleybus.Name = "buttonRemoveTrolleybus";
|
|
||||||
this.buttonRemoveTrolleybus.Size = new System.Drawing.Size(182, 23);
|
|
||||||
this.buttonRemoveTrolleybus.TabIndex = 3;
|
|
||||||
this.buttonRemoveTrolleybus.Text = "Удалить троллейбус";
|
|
||||||
this.buttonRemoveTrolleybus.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRemoveTrolleybus.Click += new System.EventHandler(this.ButtonRemoveTrolleybus_Click);
|
|
||||||
//
|
|
||||||
// maskedTextBoxPosition
|
|
||||||
//
|
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(7, 128);
|
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(181, 20);
|
|
||||||
this.maskedTextBoxPosition.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// buttonAddTrolleybus
|
|
||||||
//
|
|
||||||
this.buttonAddTrolleybus.Location = new System.Drawing.Point(7, 85);
|
|
||||||
this.buttonAddTrolleybus.Name = "buttonAddTrolleybus";
|
|
||||||
this.buttonAddTrolleybus.Size = new System.Drawing.Size(181, 23);
|
|
||||||
this.buttonAddTrolleybus.TabIndex = 1;
|
|
||||||
this.buttonAddTrolleybus.Text = "Добавить троллейбус";
|
|
||||||
this.buttonAddTrolleybus.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAddTrolleybus.Click += new System.EventHandler(this.ButtonAddTrolleybus_Click);
|
|
||||||
//
|
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
|
||||||
"Простая карта",
|
|
||||||
"Сложная карта"});
|
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 42);
|
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(182, 21);
|
|
||||||
this.comboBoxSelectorMap.TabIndex = 0;
|
|
||||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// pictureBox
|
|
||||||
//
|
|
||||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.pictureBox.Name = "pictureBox";
|
|
||||||
this.pictureBox.Size = new System.Drawing.Size(600, 450);
|
|
||||||
this.pictureBox.TabIndex = 1;
|
|
||||||
this.pictureBox.TabStop = false;
|
|
||||||
//
|
|
||||||
// FormMapWithSetTrolleybus
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.Controls.Add(this.pictureBox);
|
|
||||||
this.Controls.Add(this.groupBox1);
|
|
||||||
this.Name = "FormMapWithSetTrolleybus";
|
|
||||||
this.Text = "FormMapWithSetTrolleybus";
|
|
||||||
this.groupBox1.ResumeLayout(false);
|
|
||||||
this.groupBox1.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private System.Windows.Forms.GroupBox groupBox1;
|
|
||||||
private System.Windows.Forms.Button buttonAddTrolleybus;
|
|
||||||
private System.Windows.Forms.ComboBox comboBoxSelectorMap;
|
|
||||||
private System.Windows.Forms.PictureBox pictureBox;
|
|
||||||
private System.Windows.Forms.Button buttonLeft;
|
|
||||||
private System.Windows.Forms.Button buttonRight;
|
|
||||||
private System.Windows.Forms.Button buttonDown;
|
|
||||||
private System.Windows.Forms.Button buttonUp;
|
|
||||||
private System.Windows.Forms.Button buttonShowOnMap;
|
|
||||||
private System.Windows.Forms.Button buttonShowStorage;
|
|
||||||
private System.Windows.Forms.Button buttonRemoveTrolleybus;
|
|
||||||
private System.Windows.Forms.MaskedTextBox maskedTextBoxPosition;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,147 +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 Trolleybus
|
|
||||||
{
|
|
||||||
public partial class FormMapWithSetTrolleybus : Form
|
|
||||||
{
|
|
||||||
public FormMapWithSetTrolleybus()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
private MapWithSetTrolleybusGeneric<DrawningObjectTrolleybus, AbstractMap> _mapTrolleybusCollectionGeneric;
|
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
AbstractMap map = null;
|
|
||||||
switch (comboBoxSelectorMap.Text)
|
|
||||||
{
|
|
||||||
case "Простая карта":
|
|
||||||
map = new SimpleMap();
|
|
||||||
break;
|
|
||||||
case "Сложная карта":
|
|
||||||
map = new AutoStopMap();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (map != null)
|
|
||||||
{
|
|
||||||
_mapTrolleybusCollectionGeneric = new MapWithSetTrolleybusGeneric<DrawningObjectTrolleybus, AbstractMap>(
|
|
||||||
pictureBox.Width, pictureBox.Height, map);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_mapTrolleybusCollectionGeneric = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAddTrolleybus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_mapTrolleybusCollectionGeneric == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Form1 form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
DrawningObjectTrolleybus trolleybus = new(form.SelectedTrolleybus);
|
|
||||||
if (_mapTrolleybusCollectionGeneric + trolleybus !=-1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBox.Image = _mapTrolleybusCollectionGeneric.ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonRemoveTrolleybus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
|
||||||
if (_mapTrolleybusCollectionGeneric - pos !=null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBox.Image = _mapTrolleybusCollectionGeneric.ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_mapTrolleybusCollectionGeneric == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _mapTrolleybusCollectionGeneric.ShowSet();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод карты
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_mapTrolleybusCollectionGeneric == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _mapTrolleybusCollectionGeneric.ShowOnMap();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_mapTrolleybusCollectionGeneric == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//получаем имя кнопки
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
Direction dir = Direction.None;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
dir = Direction.Up;
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
dir = Direction.Down;
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
dir = Direction.Left;
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
dir = Direction.Right;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _mapTrolleybusCollectionGeneric.MoveObject(dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
internal interface IDrawningObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения объекта
|
|
||||||
/// </summary>
|
|
||||||
public float Step { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Установка позиции объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
/// <param name="width">Ширина полотна</param>
|
|
||||||
/// <param name="height">Высота полотна</param>
|
|
||||||
void SetObject(int x, int y, int width, int height);
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления пермещения объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
void MoveObject(Direction direction);
|
|
||||||
/// <summary>
|
|
||||||
/// Отрисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
void DrawningObject(Graphics g);
|
|
||||||
/// <summary>
|
|
||||||
/// Получение текущей позиции объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
void nothing();
|
|
||||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,188 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
internal class MapWithSetTrolleybusGeneric<T, U>
|
|
||||||
where T : class, IDrawningObject
|
|
||||||
where U : AbstractMap
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна отрисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна отрисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Размер занимаемого объектом места (ширина)
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _placeSizeWidth = 210;
|
|
||||||
/// <summary>
|
|
||||||
/// Размер занимаемого объектом места (высота)
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _placeSizeHeight = 90;
|
|
||||||
/// <summary>
|
|
||||||
/// Набор объектов
|
|
||||||
/// </summary>
|
|
||||||
private readonly SetTrolleybusGeneric<T> _setTrolleybus;
|
|
||||||
/// <summary>
|
|
||||||
/// Карта
|
|
||||||
/// </summary>
|
|
||||||
private readonly U _map;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="picWidth"></param>
|
|
||||||
/// <param name="picHeight"></param>
|
|
||||||
/// <param name="map"></param>
|
|
||||||
public MapWithSetTrolleybusGeneric(int picWidth, int picHeight, U map)
|
|
||||||
{
|
|
||||||
int width = picWidth / _placeSizeWidth;
|
|
||||||
int height = picHeight / _placeSizeHeight;
|
|
||||||
_setTrolleybus = new SetTrolleybusGeneric<T>(width * height);
|
|
||||||
_pictureWidth = picWidth;
|
|
||||||
_pictureHeight = picHeight;
|
|
||||||
_map = map;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора сложения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="map"></param>
|
|
||||||
/// <param name="trolleybus"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static int operator +(MapWithSetTrolleybusGeneric<T, U> map, T trolleybus)
|
|
||||||
{
|
|
||||||
return map._setTrolleybus.Insert(trolleybus);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора вычитания
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="map"></param>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static T operator -(MapWithSetTrolleybusGeneric<T, U> map, int position)
|
|
||||||
{
|
|
||||||
return map._setTrolleybus.Remove(position);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод всего набора объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Bitmap ShowSet()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
DrawBackground(gr);
|
|
||||||
DrawTrolleybus(gr);
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Просмотр объекта на карте
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Bitmap ShowOnMap()
|
|
||||||
{
|
|
||||||
Shaking();
|
|
||||||
for (int i = 0; i < _setTrolleybus.Count; i++)
|
|
||||||
{
|
|
||||||
var car = _setTrolleybus.Get(i);
|
|
||||||
if (car != null)
|
|
||||||
{
|
|
||||||
return _map.CreateMap(_pictureWidth, _pictureHeight, car);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new(_pictureWidth, _pictureHeight);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение объекта по крате
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Bitmap MoveObject(Direction direction)
|
|
||||||
{
|
|
||||||
if (_map != null)
|
|
||||||
{
|
|
||||||
return _map.MoveObject(direction);
|
|
||||||
}
|
|
||||||
return new(_pictureWidth, _pictureHeight);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// "Взбалтываем" набор, чтобы все элементы оказались в начале
|
|
||||||
/// </summary>
|
|
||||||
private void Shaking()
|
|
||||||
{
|
|
||||||
int j = _setTrolleybus.Count - 1;
|
|
||||||
for (int i = 0; i < _setTrolleybus.Count; i++)
|
|
||||||
{
|
|
||||||
if (_setTrolleybus.Get(i) == null)
|
|
||||||
{
|
|
||||||
for (; j > i; j--)
|
|
||||||
{
|
|
||||||
var car = _setTrolleybus.Get(j);
|
|
||||||
if (car != null)
|
|
||||||
{
|
|
||||||
_setTrolleybus.Insert(car, i);
|
|
||||||
_setTrolleybus.Remove(j);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (j <= i)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Метод отрисовки фона
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
private void DrawBackground(Graphics g)
|
|
||||||
{
|
|
||||||
Pen pen = new(Color.Black, 3);
|
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
|
||||||
{//линия рамзетки места
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth, j * _placeSizeHeight);
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight + 10, i * _placeSizeWidth + _placeSizeWidth, j * _placeSizeHeight + 10);
|
|
||||||
}
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Метод прорисовки объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
private void DrawTrolleybus(Graphics g)
|
|
||||||
{
|
|
||||||
int xForLocomotive = _pictureWidth - 2 * _placeSizeWidth + 60;
|
|
||||||
int yForLocomotive = 10;
|
|
||||||
int countInRow = 0;
|
|
||||||
for (int i = 0; i < _setTrolleybus.Count; i++)
|
|
||||||
{
|
|
||||||
if (countInRow >= _pictureWidth / (_placeSizeWidth + 30))
|
|
||||||
{
|
|
||||||
xForLocomotive = _pictureWidth - _placeSizeWidth + 40;
|
|
||||||
yForLocomotive += _placeSizeHeight;
|
|
||||||
countInRow = 0;
|
|
||||||
}
|
|
||||||
if (_setTrolleybus.Get(i) != null)
|
|
||||||
{
|
|
||||||
T locomotive = _setTrolleybus.Get(i);
|
|
||||||
locomotive.SetObject(xForLocomotive, yForLocomotive, _pictureWidth, _pictureHeight);
|
|
||||||
locomotive.DrawningObject(g);
|
|
||||||
}
|
|
||||||
xForLocomotive -= _placeSizeWidth + 30;
|
|
||||||
countInRow++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,7 @@ namespace Trolleybus
|
|||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new FormMapWithSetTrolleybus());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
// Параметризованный набор объектов
|
|
||||||
internal class SetTrolleybusGeneric<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
// Массив объектов, которые храним
|
|
||||||
private readonly T[] _places;
|
|
||||||
// Количество объектов в массиве
|
|
||||||
public int Count => _places.Length;
|
|
||||||
// Конструктор
|
|
||||||
public SetTrolleybusGeneric(int count)
|
|
||||||
{
|
|
||||||
_places = new T[count];
|
|
||||||
}
|
|
||||||
// Добавление объекта в набор
|
|
||||||
public int Insert(T trolleybus)
|
|
||||||
{
|
|
||||||
// вставка в начало набора
|
|
||||||
return Insert(trolleybus, 0);
|
|
||||||
}
|
|
||||||
// Добавление объекта в набор на конкретную позицию
|
|
||||||
public int Insert(T trolleybus, int position)
|
|
||||||
{
|
|
||||||
// проверка позиции
|
|
||||||
if (position >= _places.Length || position < 0)
|
|
||||||
return -1;
|
|
||||||
//проверка, что элемент массива по этой позиции пустой, если нет, то
|
|
||||||
if (_places[position] == null)
|
|
||||||
{
|
|
||||||
_places[position] = trolleybus;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
//проверка, что после вставляемого элемента в массиве есть пустой элемент
|
|
||||||
int findEmptyPos = -1;
|
|
||||||
|
|
||||||
for (int i = position + 1; i < Count; i++)
|
|
||||||
{
|
|
||||||
if (_places[i] == null)
|
|
||||||
{
|
|
||||||
findEmptyPos = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (findEmptyPos < 0) return -1;
|
|
||||||
|
|
||||||
//сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
|
|
||||||
for (int i = findEmptyPos; i > position; i--)
|
|
||||||
{
|
|
||||||
_places[i] = _places[i - 1];
|
|
||||||
}
|
|
||||||
// вставка по позиции
|
|
||||||
_places[position] = trolleybus;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
// Удаление объекта из набора с конкретной позиции
|
|
||||||
public T Remove(int position)
|
|
||||||
{
|
|
||||||
// проверка позиции
|
|
||||||
if (position >= _places.Length || position < 0) return null;
|
|
||||||
// удаление объекта из массива, присовив элементу массива значение null
|
|
||||||
T temp = _places[position];
|
|
||||||
_places[position] = null;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
// Получение объекта из набора по позиции
|
|
||||||
public T Get(int position)
|
|
||||||
{
|
|
||||||
// проверка позиции
|
|
||||||
if (position >= _places.Length || position < 0)
|
|
||||||
return null;
|
|
||||||
return _places[position];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace Trolleybus
|
|
||||||
{
|
|
||||||
class SimpleMap : AbstractMap
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Цвет участка закрытого
|
|
||||||
/// </summary>
|
|
||||||
private readonly Brush barrierColor = new SolidBrush(Color.Black);
|
|
||||||
/// <summary>
|
|
||||||
/// Цвет участка открытого
|
|
||||||
/// </summary>
|
|
||||||
private readonly Brush roadColor = new SolidBrush(Color.Gray);
|
|
||||||
|
|
||||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
|
||||||
{
|
|
||||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), 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 < 50)
|
|
||||||
{
|
|
||||||
int x = _random.Next(0, 100);
|
|
||||||
int y = _random.Next(0, 100);
|
|
||||||
if (_map[x, y] == _freeRoad)
|
|
||||||
{
|
|
||||||
_map[x, y] = _barrier;
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,6 @@
|
|||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<LangVersion>9.0</LangVersion>
|
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
@ -47,13 +46,8 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AbstractMap.cs" />
|
|
||||||
<Compile Include="Direction.cs" />
|
<Compile Include="Direction.cs" />
|
||||||
<Compile Include="DrawingSmallTrolleybus.cs" />
|
|
||||||
<Compile Include="DrawingTrolleybus.cs" />
|
<Compile Include="DrawingTrolleybus.cs" />
|
||||||
<Compile Include="DrawningObject.cs" />
|
|
||||||
<Compile Include="DrawningObjectTrolleybus.cs" />
|
|
||||||
<Compile Include="EntitySmallTrolleybus.cs" />
|
|
||||||
<Compile Include="EntityTrolleybus.cs" />
|
<Compile Include="EntityTrolleybus.cs" />
|
||||||
<Compile Include="Form1.cs">
|
<Compile Include="Form1.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
@ -61,34 +55,11 @@
|
|||||||
<Compile Include="Form1.Designer.cs">
|
<Compile Include="Form1.Designer.cs">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="FormMap.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="FormMap.Designer.cs">
|
|
||||||
<DependentUpon>FormMap.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="FormMapWithSetTrolleybus.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="FormMapWithSetTrolleybus.Designer.cs">
|
|
||||||
<DependentUpon>FormMapWithSetTrolleybus.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="HardMap.cs" />
|
|
||||||
<Compile Include="IDrawingObject.cs" />
|
|
||||||
<Compile Include="MapWithSetTrolleybusGeneric.cs" />
|
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SetTrolleybusGeneric.cs" />
|
|
||||||
<Compile Include="SimpleMap.cs" />
|
|
||||||
<EmbeddedResource Include="Form1.resx">
|
<EmbeddedResource Include="Form1.resx">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="FormMap.resx">
|
|
||||||
<DependentUpon>FormMap.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="FormMapWithSetTrolleybus.resx">
|
|
||||||
<DependentUpon>FormMapWithSetTrolleybus.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
@ -1,114 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{07E18270-5508-4D1A-A699-8B170C1E8502}</ProjectGuid>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<RootNamespace>Trolleybus</RootNamespace>
|
|
||||||
<AssemblyName>Trolleybus</AssemblyName>
|
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
|
||||||
<Deterministic>true</Deterministic>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Deployment" />
|
|
||||||
<Reference Include="System.Drawing" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Windows.Forms" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="AbstractMap.cs" />
|
|
||||||
<Compile Include="Direction.cs" />
|
|
||||||
<Compile Include="DrawingSmallTrolleybus.cs" />
|
|
||||||
<Compile Include="DrawingTrolleybus.cs" />
|
|
||||||
<Compile Include="DrawningObject.cs" />
|
|
||||||
<Compile Include="EntitySmallTrolleybus.cs" />
|
|
||||||
<Compile Include="EntityTrolleybus.cs" />
|
|
||||||
<Compile Include="Form1.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Form1.Designer.cs">
|
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="FormMap.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="FormMap.Designer.cs">
|
|
||||||
<DependentUpon>FormMap.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="IDrawingObject.cs" />
|
|
||||||
<Compile Include="Program.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
<Compile Include="SimpleMap.cs" />
|
|
||||||
<EmbeddedResource Include="Form1.resx">
|
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="FormMap.resx">
|
|
||||||
<DependentUpon>FormMap.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
</Compile>
|
|
||||||
<None Include="Properties\Settings.settings">
|
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
<Compile Include="Properties\Settings.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Settings.settings</DependentUpon>
|
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="App.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Resources\up30.png" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Resources\left30.png" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Resources\down30.png" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Resources\right30.png" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
|
Loading…
x
Reference in New Issue
Block a user