Compare commits
No commits in common. "Lab4" and "main" have entirely different histories.
@ -1,72 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.MovementStrategy
|
|
||||||
{
|
|
||||||
public abstract class AbstractStrategy
|
|
||||||
{
|
|
||||||
private IMoveableObject? _moveableObject;
|
|
||||||
private Status _state = Status.NotInit;
|
|
||||||
protected int FieldWidth { get; private set; }
|
|
||||||
protected int FieldHeight { get; private set; }
|
|
||||||
public Status GetStatus() { return _state; }
|
|
||||||
public void SetData(IMoveableObject moveableObject, int width, int
|
|
||||||
height)
|
|
||||||
{
|
|
||||||
if (moveableObject == null)
|
|
||||||
{
|
|
||||||
_state = Status.NotInit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_state = Status.InProgress;
|
|
||||||
_moveableObject = moveableObject;
|
|
||||||
FieldWidth = width;
|
|
||||||
FieldHeight = height;
|
|
||||||
}
|
|
||||||
public void MakeStep()
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (IsTargetDestinaion())
|
|
||||||
{
|
|
||||||
_state = Status.Finish;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MoveToTarget();
|
|
||||||
}
|
|
||||||
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
|
||||||
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
|
||||||
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
|
||||||
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
|
||||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
|
||||||
protected int? GetStep()
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return _moveableObject?.GetStep;
|
|
||||||
}
|
|
||||||
protected abstract void MoveToTarget();
|
|
||||||
protected abstract bool IsTargetDestinaion();
|
|
||||||
private bool MoveTo(DirectionType directionType)
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
|
||||||
{
|
|
||||||
_moveableObject.MoveObject(directionType);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,134 +0,0 @@
|
|||||||
using ProjectTrolleybus.MovementStrategy;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ProjectTrolleybus.DrawingObjects;
|
|
||||||
using ProjectTrolleybus.Generics;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.Generics
|
|
||||||
{
|
|
||||||
internal class BusesGenericCollection<T, U>
|
|
||||||
where T : DrawingBus
|
|
||||||
where U : IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна прорисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна прорисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Размер занимаемого объектом места (ширина)
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _placeSizeWidth = 170;
|
|
||||||
/// <summary>
|
|
||||||
/// Размер занимаемого объектом места (высота)
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _placeSizeHeight = 124;
|
|
||||||
/// <summary>
|
|
||||||
/// Набор объектов
|
|
||||||
/// </summary>
|
|
||||||
private readonly SetGeneric<T> _collection;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="picWidth"></param>
|
|
||||||
/// <param name="picHeight"></param>
|
|
||||||
public BusesGenericCollection(int picWidth, int picHeight)
|
|
||||||
{
|
|
||||||
int width = picWidth / _placeSizeWidth;
|
|
||||||
int height = picHeight / _placeSizeHeight;
|
|
||||||
_pictureWidth = picWidth;
|
|
||||||
_pictureHeight = picHeight;
|
|
||||||
_collection = new SetGeneric<T>(width * height);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора сложения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collect"></param>
|
|
||||||
/// <param name="obj"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool operator +(BusesGenericCollection<T, U>? collect, T? obj)
|
|
||||||
{
|
|
||||||
if (obj == null || collect == null)
|
|
||||||
return false;
|
|
||||||
return collect?._collection.Insert(obj) ?? false;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора вычитания
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collect"></param>
|
|
||||||
/// <param name="pos"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static T? operator -(BusesGenericCollection<T, U> collect, int pos)
|
|
||||||
{
|
|
||||||
T? obj = collect._collection[pos];
|
|
||||||
if (obj != null)
|
|
||||||
collect._collection.Remove(pos);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта IMoveableObject
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pos"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public U? GetU(int pos)
|
|
||||||
{
|
|
||||||
return (U?)_collection[pos]?.GetMoveableObject;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод всего набора объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Bitmap ShowBuses()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
DrawBackground(gr);
|
|
||||||
DrawObjects(gr);
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Метод отрисовки фона
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
private void DrawBackground(Graphics g)
|
|
||||||
{
|
|
||||||
Pen pen = new(Color.Black, 3);
|
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
|
||||||
1; ++j)
|
|
||||||
{//линия разметки места
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
|
||||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
|
||||||
_placeSizeHeight);
|
|
||||||
}
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
|
||||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Метод прорисовки объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
private void DrawObjects(Graphics g)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
foreach (var bus in _collection.GetBuses())
|
|
||||||
{
|
|
||||||
if (bus != null)
|
|
||||||
{
|
|
||||||
int inRow = _pictureWidth / _placeSizeWidth;
|
|
||||||
bus.SetPosition(_placeSizeWidth * (inRow - 1) - (i % inRow * _placeSizeWidth), i / inRow * _placeSizeHeight);
|
|
||||||
bus.DrawTransport(g);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ProjectTrolleybus.DrawingObjects;
|
|
||||||
using ProjectTrolleybus.MovementStrategy;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.Generics
|
|
||||||
{
|
|
||||||
internal class BusesGenericStorage
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Словарь (хранилище)
|
|
||||||
/// </summary>
|
|
||||||
readonly Dictionary<string, BusesGenericCollection<DrawingBus,
|
|
||||||
DrawingObjectBus>> _busStorages;
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращение списка названий наборов
|
|
||||||
/// </summary>
|
|
||||||
public List<string> Keys => _busStorages.Keys.ToList();
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна отрисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна отрисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pictureWidth"></param>
|
|
||||||
/// <param name="pictureHeight"></param>
|
|
||||||
public BusesGenericStorage(int pictureWidth, int pictureHeight)
|
|
||||||
{
|
|
||||||
_busStorages = new Dictionary<string,
|
|
||||||
BusesGenericCollection<DrawingBus, DrawingObjectBus>>();
|
|
||||||
_pictureWidth = pictureWidth;
|
|
||||||
_pictureHeight = pictureHeight;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название набора</param>
|
|
||||||
public void AddSet(string name)
|
|
||||||
{
|
|
||||||
_busStorages.Add(name, new BusesGenericCollection<DrawingBus,
|
|
||||||
DrawingObjectBus>(_pictureWidth, _pictureHeight));
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название набора</param>
|
|
||||||
public void DelSet(string name)
|
|
||||||
{
|
|
||||||
if (!_busStorages.ContainsKey(name))
|
|
||||||
return;
|
|
||||||
_busStorages.Remove(name);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Доступ к набору
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ind"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public BusesGenericCollection<DrawingBus, DrawingObjectBus>?
|
|
||||||
this[string ind]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_busStorages.ContainsKey(ind))
|
|
||||||
return _busStorages[ind];
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus
|
|
||||||
{
|
|
||||||
public enum DirectionType
|
|
||||||
{
|
|
||||||
Up = 1,
|
|
||||||
Down = 2,
|
|
||||||
Left = 3,
|
|
||||||
Right = 4
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,157 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ProjectTrolleybus.Entities;
|
|
||||||
using ProjectTrolleybus.MovementStrategy;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.DrawingObjects
|
|
||||||
{
|
|
||||||
public class DrawingBus
|
|
||||||
{
|
|
||||||
public EntityBus? EntityBus { get; protected set; }
|
|
||||||
|
|
||||||
private int _pictureWidth;
|
|
||||||
|
|
||||||
private int _pictureHeight;
|
|
||||||
|
|
||||||
protected int _startPosX;
|
|
||||||
|
|
||||||
protected int _startPosY;
|
|
||||||
|
|
||||||
protected readonly int _busWidth = 170;
|
|
||||||
|
|
||||||
protected readonly int _busHeight = 124;
|
|
||||||
|
|
||||||
public DrawingBus(int speed, double weight, Color bodyColor, int
|
|
||||||
width, int height)
|
|
||||||
|
|
||||||
{
|
|
||||||
if (width < _busWidth || height < _busHeight)
|
|
||||||
return;
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
EntityBus = new EntityBus(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DrawingBus(int speed, double weight, Color bodyColor, int
|
|
||||||
width, int height, int busWidth, int busHeight)
|
|
||||||
{
|
|
||||||
if (width < _busWidth || height < _busHeight)
|
|
||||||
return;
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
_busWidth = busWidth;
|
|
||||||
_busHeight = busHeight;
|
|
||||||
EntityBus = new EntityBus(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetPosition(int x, int y)
|
|
||||||
{
|
|
||||||
if (x < 0 || y < 0 || x + _busWidth >= _pictureWidth || y + _busHeight >= _pictureHeight)
|
|
||||||
x = y = 10;
|
|
||||||
_startPosX = x;
|
|
||||||
_startPosY = y;
|
|
||||||
}
|
|
||||||
public int GetPosX => _startPosX;
|
|
||||||
|
|
||||||
public int GetPosY => _startPosY;
|
|
||||||
|
|
||||||
public int GetWidth => _busWidth;
|
|
||||||
|
|
||||||
public int GetHeight => _busHeight;
|
|
||||||
|
|
||||||
public bool CanMove(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (EntityBus == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return direction switch
|
|
||||||
{
|
|
||||||
//влево
|
|
||||||
DirectionType.Left => _startPosX - EntityBus.Step > 0,
|
|
||||||
//вверх
|
|
||||||
DirectionType.Up => _startPosY - EntityBus.Step > 0,
|
|
||||||
// вправо
|
|
||||||
DirectionType.Right => _startPosX + EntityBus.Step + _busWidth < _pictureWidth,
|
|
||||||
//вниз
|
|
||||||
DirectionType.Down => _startPosY + EntityBus.Step + _busHeight < _pictureHeight,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MoveTransport(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (!CanMove(direction) || EntityBus == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
//влево
|
|
||||||
case DirectionType.Left:
|
|
||||||
_startPosX -= (int)EntityBus.Step;
|
|
||||||
break;
|
|
||||||
//вверх
|
|
||||||
case DirectionType.Up:
|
|
||||||
_startPosY -= (int)EntityBus.Step;
|
|
||||||
break;
|
|
||||||
// вправо
|
|
||||||
case DirectionType.Right:
|
|
||||||
_startPosX += (int)EntityBus.Step;
|
|
||||||
break;
|
|
||||||
//вниз
|
|
||||||
case DirectionType.Down:
|
|
||||||
_startPosY += (int)EntityBus.Step;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityBus == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
//кузов
|
|
||||||
Brush br = new SolidBrush(EntityBus.BodyColor);
|
|
||||||
g.FillRectangle(br, _startPosX + 6, _startPosY + 31, 164, 79);
|
|
||||||
//задние фары
|
|
||||||
Brush brRed = new SolidBrush(Color.Red);
|
|
||||||
g.FillRectangle(brRed, _startPosX + 5, _startPosY + 85, 10, 20);
|
|
||||||
//передние фары
|
|
||||||
Brush brYellow = new SolidBrush(Color.Yellow);
|
|
||||||
g.FillRectangle(brYellow, _startPosX + 160, _startPosY + 85, 10, 20);
|
|
||||||
//стекла
|
|
||||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
|
||||||
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 40, 20, 40);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 10, _startPosY + 40, 20, 40);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 35, _startPosY + 40, 20, 40);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 95, _startPosY + 40, 20, 40);
|
|
||||||
g.FillEllipse(brBlue, _startPosX + 120, _startPosY + 40, 20, 40);
|
|
||||||
//дверь
|
|
||||||
Brush brDoor = new SolidBrush(EntityBus.BodyColor);
|
|
||||||
g.FillRectangle(brDoor, _startPosX + 60, _startPosY + 50, 30, 60);
|
|
||||||
//колеса
|
|
||||||
Brush brblack = new SolidBrush(Color.Black);
|
|
||||||
g.FillEllipse(brblack, _startPosX + 25, _startPosY + 95, 30, 30);
|
|
||||||
g.FillEllipse(brblack, _startPosX + 120, _startPosY + 95, 30, 30);
|
|
||||||
//границы троллейбуса
|
|
||||||
g.DrawRectangle(pen, _startPosX + 5, _startPosY + 30, 165, 80);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 25, _startPosY + 95, 30, 30);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 120, _startPosY + 95, 30, 30);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 5, _startPosY + 85, 10, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 160, _startPosY + 85, 10, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 60, _startPosY + 50, 30, 60);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 150, _startPosY + 40, 20, 40);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 40, 20, 40);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 35, _startPosY + 40, 20, 40);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 95, _startPosY + 40, 20, 40);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 120, _startPosY + 40, 20, 40);
|
|
||||||
}
|
|
||||||
public IMoveableObject GetMoveableObject => new DrawingObjectBus(this);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ProjectTrolleybus.DrawingObjects;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.MovementStrategy
|
|
||||||
{
|
|
||||||
public class DrawingObjectBus : IMoveableObject
|
|
||||||
{
|
|
||||||
private readonly DrawingBus? _drawningCar = null;
|
|
||||||
public DrawingObjectBus(DrawingBus drawningCar)
|
|
||||||
{
|
|
||||||
_drawningCar = drawningCar;
|
|
||||||
}
|
|
||||||
public ObjectParameters? GetObjectPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_drawningCar == null || _drawningCar.EntityBus ==
|
|
||||||
null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ObjectParameters(_drawningCar.GetPosX,
|
|
||||||
_drawningCar.GetPosY, _drawningCar.GetWidth, _drawningCar.GetHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int GetStep => (int)(_drawningCar?.EntityBus?.Step ?? 0);
|
|
||||||
public bool CheckCanMove(DirectionType direction) =>
|
|
||||||
_drawningCar?.CanMove(direction) ?? false;
|
|
||||||
public void MoveObject(DirectionType direction) =>
|
|
||||||
_drawningCar?.MoveTransport(direction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
using System.Numerics;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ProjectTrolleybus.DrawingObjects;
|
|
||||||
using ProjectTrolleybus.Entities;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus
|
|
||||||
{
|
|
||||||
public class DrawingTrolleybus : DrawingBus
|
|
||||||
{
|
|
||||||
public DrawingTrolleybus(int speed, double weight, Color bodyColor, Color additionalColor, bool roga, bool battery, int width, int height)
|
|
||||||
: base(speed, weight, bodyColor, width, height, 170, 124)
|
|
||||||
{
|
|
||||||
if (EntityBus != null)
|
|
||||||
{
|
|
||||||
EntityBus = new EntityTrolleybus(speed, weight, bodyColor, additionalColor, roga, battery);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityBus is not EntityTrolleybus trolleybus)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Brush additionalBrush = new
|
|
||||||
SolidBrush(trolleybus.AdditionalColor);
|
|
||||||
base.DrawTransport(g);
|
|
||||||
//"рога"
|
|
||||||
if (trolleybus.Roga)
|
|
||||||
{
|
|
||||||
g.DrawLine(new Pen(Color.Black, 3), _startPosX + 120, _startPosY + 30, _startPosX + 20, _startPosY + 3);
|
|
||||||
g.DrawLine(new Pen(Color.Black, 3), _startPosX + 140, _startPosY + 30, _startPosX + 40, _startPosY + 3);
|
|
||||||
g.DrawLine(new Pen(Color.Black, 1), _startPosX + 40, _startPosY + 30, _startPosX + 20, _startPosY + 3);
|
|
||||||
g.DrawLine(new Pen(Color.Black, 1), _startPosX + 60, _startPosY + 30, _startPosX + 40, _startPosY + 3);
|
|
||||||
}
|
|
||||||
//Батарея
|
|
||||||
if(trolleybus.Battery)
|
|
||||||
{
|
|
||||||
Brush brBattery = new SolidBrush(trolleybus.AdditionalColor);
|
|
||||||
g.FillRectangle(brBattery, _startPosX + 95, _startPosY + 85, 20, 25);
|
|
||||||
g.DrawLine(new Pen(Color.Yellow, 2), _startPosX + 112, _startPosY + 90, _startPosX + 97, _startPosY + 100);
|
|
||||||
g.DrawLine(new Pen(Color.Yellow, 2), _startPosX + 97, _startPosY + 100, _startPosX + 112, _startPosY + 100);
|
|
||||||
g.DrawLine(new Pen(Color.Yellow, 2), _startPosX + 112, _startPosY + 100, _startPosX + 97, _startPosY + 110);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 95, _startPosY + 85, 20, 25);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.Entities
|
|
||||||
{
|
|
||||||
public class EntityBus
|
|
||||||
{
|
|
||||||
public int Speed { get; private set; }
|
|
||||||
|
|
||||||
public double Weight { get; private set; }
|
|
||||||
|
|
||||||
public Color BodyColor { get; private set; }
|
|
||||||
|
|
||||||
public double Step => (double)Speed * 100 / Weight;
|
|
||||||
|
|
||||||
public EntityBus(int speed, double weight, Color bodyColor)
|
|
||||||
{
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.Entities
|
|
||||||
{
|
|
||||||
public class EntityTrolleybus : EntityBus
|
|
||||||
{
|
|
||||||
public Color AdditionalColor { get; private set; }
|
|
||||||
|
|
||||||
public bool Roga { get; private set; }
|
|
||||||
|
|
||||||
public bool Battery { get; private set; }
|
|
||||||
|
|
||||||
public EntityTrolleybus(int speed, double weight, Color bodyColor, Color
|
|
||||||
additionalColor, bool roga, bool battery)
|
|
||||||
: base (speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
AdditionalColor = additionalColor;
|
|
||||||
Roga = roga;
|
|
||||||
Battery = battery;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
39
Trolleybus/Trolleybus/Form1.Designer.cs
generated
Normal file
39
Trolleybus/Trolleybus/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace Trolleybus
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Text = "Form1";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
10
Trolleybus/Trolleybus/Form1.cs
Normal file
10
Trolleybus/Trolleybus/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Trolleybus
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
192
Trolleybus/Trolleybus/FormBusCollection.Designer.cs
generated
192
Trolleybus/Trolleybus/FormBusCollection.Designer.cs
generated
@ -1,192 +0,0 @@
|
|||||||
namespace ProjectTrolleybus
|
|
||||||
{
|
|
||||||
partial class FormBusCollection
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
groupBoxTrolleybus = new GroupBox();
|
|
||||||
groupBoxSets = new GroupBox();
|
|
||||||
textBoxStorageName = new TextBox();
|
|
||||||
buttonDelObject = new Button();
|
|
||||||
listBoxStorages = new ListBox();
|
|
||||||
buttonAddObject = new Button();
|
|
||||||
buttonUpdateCollection = new Button();
|
|
||||||
buttonDeleteBus = new Button();
|
|
||||||
maskedTextBoxNumber = new MaskedTextBox();
|
|
||||||
buttonAddBus = new Button();
|
|
||||||
pictureBoxCollection = new PictureBox();
|
|
||||||
groupBoxTrolleybus.SuspendLayout();
|
|
||||||
groupBoxSets.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBoxTrolleybus
|
|
||||||
//
|
|
||||||
groupBoxTrolleybus.Controls.Add(groupBoxSets);
|
|
||||||
groupBoxTrolleybus.Controls.Add(buttonUpdateCollection);
|
|
||||||
groupBoxTrolleybus.Controls.Add(buttonDeleteBus);
|
|
||||||
groupBoxTrolleybus.Controls.Add(maskedTextBoxNumber);
|
|
||||||
groupBoxTrolleybus.Controls.Add(buttonAddBus);
|
|
||||||
groupBoxTrolleybus.Location = new Point(538, 2);
|
|
||||||
groupBoxTrolleybus.Name = "groupBoxTrolleybus";
|
|
||||||
groupBoxTrolleybus.Size = new Size(262, 448);
|
|
||||||
groupBoxTrolleybus.TabIndex = 0;
|
|
||||||
groupBoxTrolleybus.TabStop = false;
|
|
||||||
groupBoxTrolleybus.Text = "Инструменты";
|
|
||||||
//
|
|
||||||
// groupBoxSets
|
|
||||||
//
|
|
||||||
groupBoxSets.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
|
||||||
groupBoxSets.Controls.Add(textBoxStorageName);
|
|
||||||
groupBoxSets.Controls.Add(buttonDelObject);
|
|
||||||
groupBoxSets.Controls.Add(listBoxStorages);
|
|
||||||
groupBoxSets.Controls.Add(buttonAddObject);
|
|
||||||
groupBoxSets.Location = new Point(6, 22);
|
|
||||||
groupBoxSets.Name = "groupBoxSets";
|
|
||||||
groupBoxSets.Size = new Size(245, 234);
|
|
||||||
groupBoxSets.TabIndex = 4;
|
|
||||||
groupBoxSets.TabStop = false;
|
|
||||||
groupBoxSets.Text = "Наборы";
|
|
||||||
//
|
|
||||||
// textBoxStorageName
|
|
||||||
//
|
|
||||||
textBoxStorageName.Location = new Point(6, 22);
|
|
||||||
textBoxStorageName.Name = "textBoxStorageName";
|
|
||||||
textBoxStorageName.Size = new Size(233, 23);
|
|
||||||
textBoxStorageName.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// buttonDelObject
|
|
||||||
//
|
|
||||||
buttonDelObject.Location = new Point(6, 194);
|
|
||||||
buttonDelObject.Name = "buttonDelObject";
|
|
||||||
buttonDelObject.Size = new Size(233, 30);
|
|
||||||
buttonDelObject.TabIndex = 3;
|
|
||||||
buttonDelObject.Text = "Удалить набор";
|
|
||||||
buttonDelObject.UseVisualStyleBackColor = true;
|
|
||||||
buttonDelObject.Click += ButtonDelObject_Click;
|
|
||||||
//
|
|
||||||
// listBoxStorages
|
|
||||||
//
|
|
||||||
listBoxStorages.FormattingEnabled = true;
|
|
||||||
listBoxStorages.ItemHeight = 15;
|
|
||||||
listBoxStorages.Location = new Point(6, 94);
|
|
||||||
listBoxStorages.Name = "listBoxStorages";
|
|
||||||
listBoxStorages.Size = new Size(233, 94);
|
|
||||||
listBoxStorages.TabIndex = 2;
|
|
||||||
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// buttonAddObject
|
|
||||||
//
|
|
||||||
buttonAddObject.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
|
||||||
buttonAddObject.Location = new Point(6, 62);
|
|
||||||
buttonAddObject.Name = "buttonAddObject";
|
|
||||||
buttonAddObject.Size = new Size(233, 26);
|
|
||||||
buttonAddObject.TabIndex = 1;
|
|
||||||
buttonAddObject.Text = "Добавить набор";
|
|
||||||
buttonAddObject.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddObject.Click += ButtonAddObject_Click;
|
|
||||||
//
|
|
||||||
// buttonUpdateCollection
|
|
||||||
//
|
|
||||||
buttonUpdateCollection.Location = new Point(10, 408);
|
|
||||||
buttonUpdateCollection.Name = "buttonUpdateCollection";
|
|
||||||
buttonUpdateCollection.Size = new Size(241, 28);
|
|
||||||
buttonUpdateCollection.TabIndex = 3;
|
|
||||||
buttonUpdateCollection.Text = "Обновить коллекцию";
|
|
||||||
buttonUpdateCollection.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdateCollection.Click += ButtonRefreshCollection_Click;
|
|
||||||
//
|
|
||||||
// buttonDeleteBus
|
|
||||||
//
|
|
||||||
buttonDeleteBus.Location = new Point(10, 343);
|
|
||||||
buttonDeleteBus.Name = "buttonDeleteBus";
|
|
||||||
buttonDeleteBus.Size = new Size(241, 29);
|
|
||||||
buttonDeleteBus.TabIndex = 2;
|
|
||||||
buttonDeleteBus.Text = "Удалить автобус";
|
|
||||||
buttonDeleteBus.UseVisualStyleBackColor = true;
|
|
||||||
buttonDeleteBus.Click += ButtonRemoveBus_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBoxNumber
|
|
||||||
//
|
|
||||||
maskedTextBoxNumber.Location = new Point(70, 305);
|
|
||||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
|
||||||
maskedTextBoxNumber.Size = new Size(115, 23);
|
|
||||||
maskedTextBoxNumber.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// buttonAddBus
|
|
||||||
//
|
|
||||||
buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
|
||||||
buttonAddBus.Location = new Point(10, 262);
|
|
||||||
buttonAddBus.Name = "buttonAddBus";
|
|
||||||
buttonAddBus.Size = new Size(241, 28);
|
|
||||||
buttonAddBus.TabIndex = 0;
|
|
||||||
buttonAddBus.Text = "Добавить автобус";
|
|
||||||
buttonAddBus.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddBus.Click += ButtonAddBus_Click;
|
|
||||||
//
|
|
||||||
// pictureBoxCollection
|
|
||||||
//
|
|
||||||
pictureBoxCollection.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
pictureBoxCollection.Location = new Point(0, 2);
|
|
||||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
|
||||||
pictureBoxCollection.Size = new Size(537, 448);
|
|
||||||
pictureBoxCollection.TabIndex = 1;
|
|
||||||
pictureBoxCollection.TabStop = false;
|
|
||||||
//
|
|
||||||
// FormBusCollection
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(805, 450);
|
|
||||||
Controls.Add(groupBoxTrolleybus);
|
|
||||||
Controls.Add(pictureBoxCollection);
|
|
||||||
Name = "FormBusCollection";
|
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
|
||||||
Text = "Набор автобусов";
|
|
||||||
groupBoxTrolleybus.ResumeLayout(false);
|
|
||||||
groupBoxTrolleybus.PerformLayout();
|
|
||||||
groupBoxSets.ResumeLayout(false);
|
|
||||||
groupBoxSets.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBoxTrolleybus;
|
|
||||||
private MaskedTextBox maskedTextBoxNumber;
|
|
||||||
private Button buttonAddBus;
|
|
||||||
private Button buttonUpdateCollection;
|
|
||||||
private Button buttonDeleteBus;
|
|
||||||
private PictureBox pictureBoxCollection;
|
|
||||||
private GroupBox groupBoxSets;
|
|
||||||
private Button buttonDelObject;
|
|
||||||
private ListBox listBoxStorages;
|
|
||||||
private Button buttonAddObject;
|
|
||||||
private TextBox textBoxStorageName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,141 +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;
|
|
||||||
using ProjectTrolleybus.DrawingObjects;
|
|
||||||
using ProjectTrolleybus.MovementStrategy;
|
|
||||||
using ProjectTrolleybus.Generics;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus
|
|
||||||
{
|
|
||||||
public partial class FormBusCollection : Form
|
|
||||||
{
|
|
||||||
private readonly BusesGenericStorage _storage;
|
|
||||||
public FormBusCollection()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_storage = new BusesGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
|
||||||
}
|
|
||||||
private void ReloadObjects()
|
|
||||||
{
|
|
||||||
int index = listBoxStorages.SelectedIndex;
|
|
||||||
listBoxStorages.Items.Clear();
|
|
||||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
|
||||||
{
|
|
||||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
|
||||||
}
|
|
||||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
|
||||||
>= listBoxStorages.Items.Count))
|
|
||||||
{
|
|
||||||
listBoxStorages.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
else if (listBoxStorages.Items.Count > 0 && index > -1 &&
|
|
||||||
index < listBoxStorages.Items.Count)
|
|
||||||
{
|
|
||||||
listBoxStorages.SelectedIndex = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_storage.AddSet(textBoxStorageName.Text);
|
|
||||||
ReloadObjects();
|
|
||||||
}
|
|
||||||
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBuses();
|
|
||||||
}
|
|
||||||
private void ButtonDelObject_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
_storage.DelSet(listBoxStorages.SelectedItem.ToString()
|
|
||||||
?? string.Empty);
|
|
||||||
ReloadObjects();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAddBus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
|
||||||
string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FormTrolleybus form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (obj + form.SelectedBus)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBoxCollection.Image = obj.ShowBuses();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonRemoveBus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
|
||||||
string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
|
||||||
if (obj - pos != null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBoxCollection.Image = obj.ShowBuses();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
|
||||||
string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBoxCollection.Image = obj.ShowBuses();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
190
Trolleybus/Trolleybus/FormTrolleybus.Designer.cs
generated
190
Trolleybus/Trolleybus/FormTrolleybus.Designer.cs
generated
@ -1,190 +0,0 @@
|
|||||||
namespace ProjectTrolleybus
|
|
||||||
{
|
|
||||||
partial class FormTrolleybus
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
ButtonCreateTrolleybus = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
buttonLeft = new Button();
|
|
||||||
buttonUp = new Button();
|
|
||||||
ButtonCreateBus = new Button();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
|
||||||
ButtonStep = new Button();
|
|
||||||
ButtonSelectBus = new Button();
|
|
||||||
pictureBoxTrolleybus = new PictureBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxTrolleybus).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// ButtonCreateTrolleybus
|
|
||||||
//
|
|
||||||
ButtonCreateTrolleybus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
ButtonCreateTrolleybus.Location = new Point(12, 411);
|
|
||||||
ButtonCreateTrolleybus.Name = "ButtonCreateTrolleybus";
|
|
||||||
ButtonCreateTrolleybus.Size = new Size(92, 38);
|
|
||||||
ButtonCreateTrolleybus.TabIndex = 1;
|
|
||||||
ButtonCreateTrolleybus.Text = "Создать троллейбус";
|
|
||||||
ButtonCreateTrolleybus.UseVisualStyleBackColor = true;
|
|
||||||
ButtonCreateTrolleybus.Click += ButtonCreateTrolleybus_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonRight.BackgroundImage = Trolleybus.Properties.Resources.Right;
|
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonRight.Location = new Point(842, 419);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(30, 30);
|
|
||||||
buttonRight.TabIndex = 2;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonDown.BackgroundImage = Trolleybus.Properties.Resources.Down;
|
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonDown.Location = new Point(806, 419);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(30, 30);
|
|
||||||
buttonDown.TabIndex = 3;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonLeft.BackgroundImage = Trolleybus.Properties.Resources.Left;
|
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonLeft.Location = new Point(770, 419);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(30, 30);
|
|
||||||
buttonLeft.TabIndex = 4;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonUp.BackgroundImage = Trolleybus.Properties.Resources.Up;
|
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonUp.Location = new Point(806, 383);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(30, 30);
|
|
||||||
buttonUp.TabIndex = 5;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// ButtonCreateBus
|
|
||||||
//
|
|
||||||
ButtonCreateBus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
ButtonCreateBus.Location = new Point(110, 411);
|
|
||||||
ButtonCreateBus.Name = "ButtonCreateBus";
|
|
||||||
ButtonCreateBus.Size = new Size(75, 38);
|
|
||||||
ButtonCreateBus.TabIndex = 6;
|
|
||||||
ButtonCreateBus.Text = "Создать автобус";
|
|
||||||
ButtonCreateBus.UseVisualStyleBackColor = true;
|
|
||||||
ButtonCreateBus.Click += ButtonCreateBus_Click;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
|
||||||
//
|
|
||||||
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "Движение в центр", "Движение в правый угол" });
|
|
||||||
comboBoxStrategy.Location = new Point(751, 12);
|
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
|
||||||
comboBoxStrategy.Size = new Size(121, 23);
|
|
||||||
comboBoxStrategy.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// ButtonStep
|
|
||||||
//
|
|
||||||
ButtonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
|
||||||
ButtonStep.Location = new Point(797, 41);
|
|
||||||
ButtonStep.Name = "ButtonStep";
|
|
||||||
ButtonStep.Size = new Size(75, 23);
|
|
||||||
ButtonStep.TabIndex = 8;
|
|
||||||
ButtonStep.Text = "Шаг";
|
|
||||||
ButtonStep.UseVisualStyleBackColor = true;
|
|
||||||
ButtonStep.Click += ButtonStep_Click;
|
|
||||||
//
|
|
||||||
// ButtonSelectBus
|
|
||||||
//
|
|
||||||
ButtonSelectBus.Location = new Point(797, 95);
|
|
||||||
ButtonSelectBus.Name = "ButtonSelectBus";
|
|
||||||
ButtonSelectBus.Size = new Size(75, 25);
|
|
||||||
ButtonSelectBus.TabIndex = 9;
|
|
||||||
ButtonSelectBus.Text = "Создание";
|
|
||||||
ButtonSelectBus.UseVisualStyleBackColor = true;
|
|
||||||
ButtonSelectBus.Click += ButtonSelectBus_Click;
|
|
||||||
//
|
|
||||||
// pictureBoxTrolleybus
|
|
||||||
//
|
|
||||||
pictureBoxTrolleybus.Dock = DockStyle.Fill;
|
|
||||||
pictureBoxTrolleybus.Location = new Point(0, 0);
|
|
||||||
pictureBoxTrolleybus.Name = "pictureBoxTrolleybus";
|
|
||||||
pictureBoxTrolleybus.Size = new Size(884, 461);
|
|
||||||
pictureBoxTrolleybus.SizeMode = PictureBoxSizeMode.AutoSize;
|
|
||||||
pictureBoxTrolleybus.TabIndex = 10;
|
|
||||||
pictureBoxTrolleybus.TabStop = false;
|
|
||||||
//
|
|
||||||
// FormTrolleybus
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(884, 461);
|
|
||||||
Controls.Add(ButtonSelectBus);
|
|
||||||
Controls.Add(ButtonStep);
|
|
||||||
Controls.Add(comboBoxStrategy);
|
|
||||||
Controls.Add(ButtonCreateBus);
|
|
||||||
Controls.Add(buttonUp);
|
|
||||||
Controls.Add(buttonLeft);
|
|
||||||
Controls.Add(buttonDown);
|
|
||||||
Controls.Add(buttonRight);
|
|
||||||
Controls.Add(ButtonCreateTrolleybus);
|
|
||||||
Controls.Add(pictureBoxTrolleybus);
|
|
||||||
Name = "FormTrolleybus";
|
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
|
||||||
Text = "Троллейбус";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxTrolleybus).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private Button ButtonCreateTrolleybus;
|
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button ButtonCreateBus;
|
|
||||||
private ComboBox comboBoxStrategy;
|
|
||||||
private Button ButtonStep;
|
|
||||||
private Button ButtonSelectBus;
|
|
||||||
private PictureBox pictureBoxTrolleybus;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
using ProjectTrolleybus.MovementStrategy;
|
|
||||||
using ProjectTrolleybus.DrawingObjects;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus
|
|
||||||
{
|
|
||||||
public partial class FormTrolleybus : Form
|
|
||||||
{
|
|
||||||
private DrawingBus? _drawingBus;
|
|
||||||
private AbstractStrategy? _strategy;
|
|
||||||
public DrawingBus? SelectedBus { get; private set; }
|
|
||||||
|
|
||||||
public FormTrolleybus()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_strategy = null;
|
|
||||||
SelectedBus = null;
|
|
||||||
}
|
|
||||||
private void Draw()
|
|
||||||
{
|
|
||||||
if (_drawingBus == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bitmap bmp = new Bitmap(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawingBus.DrawTransport(gr);
|
|
||||||
pictureBoxTrolleybus.Image = bmp;
|
|
||||||
}
|
|
||||||
private void ButtonCreateTrolleybus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
Color mainColor = Color.FromArgb(random.Next(0, 256),
|
|
||||||
random.Next(0, 256), random.Next(0, 256));
|
|
||||||
Color additColor = Color.FromArgb(random.Next(0, 256),
|
|
||||||
random.Next(0, 256), random.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
mainColor = dialog.Color;
|
|
||||||
}
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
additColor = dialog.Color;
|
|
||||||
}
|
|
||||||
_drawingBus = new DrawingTrolleybus(random.Next(100, 300),
|
|
||||||
random.Next(1000, 3000), mainColor, additColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
|
||||||
pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
|
||||||
_drawingBus.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void ButtonCreateBus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256),
|
|
||||||
random.Next(0, 256), random.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
_drawingBus = new DrawingBus(random.Next(100, 300),
|
|
||||||
random.Next(1000, 3000), color,
|
|
||||||
pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
|
||||||
_drawingBus.SetPosition(random.Next(10, 100), random.Next(10,
|
|
||||||
100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawingBus == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
_drawingBus.MoveTransport(DirectionType.Up);
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
_drawingBus.MoveTransport(DirectionType.Down);
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
_drawingBus.MoveTransport(DirectionType.Left);
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
_drawingBus.MoveTransport(DirectionType.Right);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void ButtonStep_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawingBus == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxStrategy.Enabled)
|
|
||||||
{
|
|
||||||
_strategy = comboBoxStrategy.SelectedIndex
|
|
||||||
switch
|
|
||||||
{
|
|
||||||
0 => new MoveToCenter(),
|
|
||||||
1 => new MoveToBorder(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_strategy.SetData(new
|
|
||||||
DrawingObjectBus(_drawingBus), pictureBoxTrolleybus.Width,
|
|
||||||
pictureBoxTrolleybus.Height);
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
}
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_strategy.MakeStep();
|
|
||||||
Draw();
|
|
||||||
if (_strategy.GetStatus() == Status.Finish)
|
|
||||||
{
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_strategy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonSelectBus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
SelectedBus = _drawingBus;
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.MovementStrategy
|
|
||||||
{
|
|
||||||
public interface IMoveableObject
|
|
||||||
{
|
|
||||||
ObjectParameters? GetObjectPosition { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
int GetStep { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка, можно ли переместиться по нужному направлению
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
bool CheckCanMove(DirectionType direction);
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления пермещения объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
void MoveObject(DirectionType direction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.MovementStrategy
|
|
||||||
{
|
|
||||||
public class MoveToBorder : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return objParams.RightBorder + GetStep() >= FieldWidth &&
|
|
||||||
objParams.DownBorder + GetStep() >= FieldHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var diffX = objParams.RightBorder - FieldWidth;
|
|
||||||
if (Math.Abs(diffX) > GetStep())
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
var diffY = objParams.DownBorder - FieldHeight;
|
|
||||||
if (Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.MovementStrategy
|
|
||||||
{
|
|
||||||
public class MoveToCenter : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
|
|
||||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
|
||||||
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
|
||||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
|
||||||
}
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
|
||||||
if (Math.Abs(diffX) > GetStep())
|
|
||||||
{
|
|
||||||
if (diffX > 0)
|
|
||||||
{
|
|
||||||
MoveLeft();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
|
||||||
if (Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
if (diffY > 0)
|
|
||||||
{
|
|
||||||
MoveUp();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.MovementStrategy
|
|
||||||
|
|
||||||
{
|
|
||||||
public class ObjectParameters
|
|
||||||
{
|
|
||||||
private readonly int _x;
|
|
||||||
private readonly int _y;
|
|
||||||
private readonly int _width;
|
|
||||||
private readonly int _height;
|
|
||||||
/// <summary>
|
|
||||||
/// Левая граница
|
|
||||||
/// </summary>
|
|
||||||
public int LeftBorder => _x;
|
|
||||||
/// <summary>
|
|
||||||
/// Верхняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int TopBorder => _y;
|
|
||||||
/// <summary>
|
|
||||||
/// Правая граница
|
|
||||||
/// </summary>
|
|
||||||
public int RightBorder => _x + _width;
|
|
||||||
/// <summary>
|
|
||||||
/// Нижняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int DownBorder => _y + _height;
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleVertical => _y + _height / 2;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
/// <param name="width">Ширина</param>
|
|
||||||
/// <param name="height">Высота</param>
|
|
||||||
public ObjectParameters(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
_x = x;
|
|
||||||
_y = y;
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
namespace ProjectTrolleybus
|
namespace Trolleybus
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
@ -11,7 +11,7 @@ namespace ProjectTrolleybus
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormBusCollection());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
103
Trolleybus/Trolleybus/Properties/Resources.Designer.cs
generated
103
Trolleybus/Trolleybus/Properties/Resources.Designer.cs
generated
@ -1,103 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Trolleybus.Properties {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
|
||||||
/// </summary>
|
|
||||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
|
||||||
// с помощью такого средства, как ResGen или Visual Studio.
|
|
||||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
|
||||||
// с параметром /str или перестройте свой проект VS.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Trolleybus.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Down {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Down", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Left {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Left", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Right {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Right", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Up {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Up", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,133 +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>
|
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="Down" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="Left" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="Right" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB |
@ -1,75 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.Generics
|
|
||||||
{
|
|
||||||
internal class SetGeneric<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
private readonly List<T?> _places;
|
|
||||||
|
|
||||||
private readonly int _maxCount;
|
|
||||||
|
|
||||||
public int Count => _places.Count;
|
|
||||||
|
|
||||||
public SetGeneric(int count)
|
|
||||||
{
|
|
||||||
_maxCount = count;
|
|
||||||
_places = new List<T?>(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Insert(T trolleybus)
|
|
||||||
{
|
|
||||||
if (_places.Count == _maxCount)
|
|
||||||
return false;
|
|
||||||
Insert(trolleybus, 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Insert(T trolleybus, int position)
|
|
||||||
{
|
|
||||||
if (!(position >= 0 && position <= Count && _places.Count < _maxCount))
|
|
||||||
return false;
|
|
||||||
_places.Insert(position, trolleybus);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(int position)
|
|
||||||
{
|
|
||||||
if (!(position >= 0 && position < Count))
|
|
||||||
return false;
|
|
||||||
_places.RemoveAt(position);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T? this[int position]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!(position >= 0 && position < Count))
|
|
||||||
return null;
|
|
||||||
return _places[position];
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (!(position >= 0 && position < Count && _places.Count < _maxCount))
|
|
||||||
return;
|
|
||||||
_places.Insert(position, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public IEnumerable<T?> GetBuses(int? maxBuses = null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _places.Count; ++i)
|
|
||||||
{
|
|
||||||
yield return _places[i];
|
|
||||||
if (maxBuses.HasValue && i == maxBuses.Value)
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectTrolleybus.MovementStrategy
|
|
||||||
{
|
|
||||||
public enum Status
|
|
||||||
{
|
|
||||||
NotInit,
|
|
||||||
InProgress,
|
|
||||||
Finish
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,19 +8,4 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user