diff --git a/lab_0/CollectionGenericObject/AbstractCompany.cs b/lab_0/CollectionGenericObject/AbstractCompany.cs
new file mode 100644
index 0000000..025fa32
--- /dev/null
+++ b/lab_0/CollectionGenericObject/AbstractCompany.cs
@@ -0,0 +1,116 @@
+using ProjectBus.Drawnings;
+
+namespace ProjectBus.CollectionGenericObject;
+///
+/// Абстракция компании, хранящий коллекцию автомобилей
+///
+public abstract class AbstractCompany
+{
+ ///
+ /// Размер места (ширина)
+ ///
+ protected readonly int _placeSizeWidth = 400;
+
+ ///
+ /// Размер места (высота)
+ ///
+ protected readonly int _placeSizeHeight = 80;
+
+ ///
+ /// Ширина окна
+ ///
+ protected readonly int _pictureWidth;
+
+ ///
+ /// Высота окна
+ ///
+ protected readonly int _pictureHeight;
+
+ ///
+ /// Коллекция автобусов
+ ///
+ protected ICollectionGenericObjects? _collection = null;
+
+ ///
+ /// Вычисление максимального количества элементов, который можно разместить в окне
+ ///
+ private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
+
+ ///
+ /// Конструктор
+ ///
+ /// Ширина окна
+ /// Высота окна
+ /// Коллекция поездов
+ public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection)
+ {
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _collection = collection;
+ _collection.SetMaxCount = GetMaxCount;
+ }
+
+ ///
+ /// Перегрузка оператора сложения для класса
+ ///
+ /// Компания
+ /// Добавляемый объект
+ ///
+ public static int operator +(AbstractCompany company, DrawningSimpleBus simplebus)
+ {
+ return company._collection.Insert(simplebus);
+ }
+
+ ///
+ /// Перегрузка оператора удаления для класса
+ ///
+ /// Компания
+ /// Номер удаляемого объекта
+ ///
+ public static DrawningSimpleBus? operator -(AbstractCompany company, int position)
+ {
+ return company._collection?.Remove(position);
+ }
+
+ ///
+ /// Получение случайного объекта из коллекции
+ ///
+ ///
+ public DrawningSimpleBus? GetRandomObject()
+ {
+ Random rnd = new();
+ return _collection?.Get(rnd.Next(GetMaxCount));
+ }
+
+ ///
+ /// Вывод всей коллекции
+ ///
+ ///
+ public Bitmap? Show()
+ {
+ Bitmap bitmap = new(_pictureWidth, _pictureHeight);
+ Graphics graphics = Graphics.FromImage(bitmap);
+ DrawBackgound(graphics);
+
+ SetObjectsPosition();
+ for (int i = 0; i < (_collection?.Count ?? 0); ++i)
+ {
+ DrawningSimpleBus? obj = _collection?.Get(i);
+ obj?.DrawTransport(graphics);
+ }
+
+ return bitmap;
+ }
+
+ ///
+ /// Вывод заднего фона
+ ///
+ ///
+ protected abstract void DrawBackgound(Graphics g);
+
+ ///
+ /// Расстановка объектов
+ ///
+ protected abstract void SetObjectsPosition();
+}
+
diff --git a/lab_0/CollectionGenericObject/BusStation.cs b/lab_0/CollectionGenericObject/BusStation.cs
new file mode 100644
index 0000000..ddc7084
--- /dev/null
+++ b/lab_0/CollectionGenericObject/BusStation.cs
@@ -0,0 +1,56 @@
+using ProjectBus.Drawnings;
+using ProjectBus.Entities;
+using System;
+
+namespace ProjectBus.CollectionGenericObject;
+///
+/// Реализация абстрактной компании - аренда поезда
+///
+public class BusStation : AbstractCompany
+{
+ ///
+ /// Конструктор
+ ///
+ ///
+ ///
+ ///
+ public BusStation(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection)
+ {
+ }
+
+ protected override void DrawBackgound(Graphics g)
+ {
+ Pen pen = new(Color.Black);
+ for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
+ {
+ for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
+ {
+ g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * j));
+ g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new(_placeSizeWidth * i, _placeSizeHeight * (j + 1)));
+ }
+ g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * (_pictureHeight / _placeSizeHeight)), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * (_pictureHeight / _placeSizeHeight)));
+ }
+
+
+ }
+
+ protected override void SetObjectsPosition()
+ {
+ int n = 0;
+ for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
+ {
+ for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
+ {
+ DrawningSimpleBus? drawningSimpleBus = _collection?.Get(n);
+ n++;
+ if (drawningSimpleBus != null)
+ {
+ drawningSimpleBus.SetPictureSize(_pictureWidth, _pictureHeight);
+ drawningSimpleBus.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
+ }
+ }
+ }
+ }
+}
+
+
diff --git a/lab_0/CollectionGenericObject/CollectionType.cs b/lab_0/CollectionGenericObject/CollectionType.cs
new file mode 100644
index 0000000..a47150a
--- /dev/null
+++ b/lab_0/CollectionGenericObject/CollectionType.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBus.CollectionGenericObject;
+
+public enum CollectionType
+{
+ ///
+ /// Неопределено
+ ///
+ None = 0,
+
+ ///
+ /// Массив
+ ///
+ Massive = 1,
+
+ ///
+ /// Список
+ ///
+ List = 2
+}
diff --git a/lab_0/CollectionGenericObject/ICollectionGenericObjects.cs b/lab_0/CollectionGenericObject/ICollectionGenericObjects.cs
new file mode 100644
index 0000000..1c57f2c
--- /dev/null
+++ b/lab_0/CollectionGenericObject/ICollectionGenericObjects.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBus.CollectionGenericObject;
+
+ ///
+ /// Интерфейс описания действий для набора хранимых объектов
+ ///
+ /// Параметр: ограничение - ссылочный тип
+ public interface ICollectionGenericObjects
+ where T : class
+ {
+ ///
+ /// Количество объектов в коллекции
+ ///
+ int Count { get; }
+
+ ///
+ /// Установка максимального количества элементов
+ ///
+ int SetMaxCount { set; }
+
+ ///
+ /// Добавление объекта в коллекцию
+ ///
+ /// Добавляемый объект
+ /// true - вставка прошла удачно, false - вставка не удалась
+ int Insert(T obj);
+
+ ///
+ /// Добавление объекта в коллекцию на конкретную позицию
+ ///
+ /// Добавляемый объект
+ /// Позиция
+ /// true - вставка прошла удачно, false - вставка не удалась
+ int Insert(T obj, int position);
+
+ ///
+ /// Удаление объекта из коллекции с конкретной позиции
+ ///
+ /// Позиция
+ /// true - удаление прошло удачно, false - удаление не удалось
+ T? Remove(int position);
+
+ ///
+ /// Получение объекта по позиции
+ ///
+ /// Позиция
+ /// Объект
+ T? Get(int position);
+ }
+
+
+
diff --git a/lab_0/CollectionGenericObject/ListGenericObjects.cs b/lab_0/CollectionGenericObject/ListGenericObjects.cs
new file mode 100644
index 0000000..2fbfbdb
--- /dev/null
+++ b/lab_0/CollectionGenericObject/ListGenericObjects.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBus.CollectionGenericObject;
+
+public class ListGenericObjects : ICollectionGenericObjects
+ where T : class
+{
+ ///
+ /// Список объектов, которые храним
+ ///
+ private readonly List _collection;
+
+ ///
+ /// Максимально допустимое число объектов в списке
+ ///
+ private int _maxCount;
+
+ public int Count => _collection.Count;
+
+ public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
+
+ ///
+ /// Конструктор
+ ///
+ public ListGenericObjects()
+ {
+ _collection = new();
+ }
+
+ public T? Get(int position)
+ {
+
+ if (position < 0 || position > _collection.Count - 1)
+ {
+ return null;
+ }
+ return _collection[position];
+ }
+
+ public int Insert(T obj)
+ {
+ if (_collection.Count + 1 > _maxCount) { return 0; }
+ _collection.Add(obj);
+
+ return 1;
+ }
+
+ public int Insert(T obj, int position)
+ {
+ if (_collection.Count + 1 < _maxCount) { return 0; }
+ if (position > _collection.Count || position < 0)
+ {
+ return 0;
+ }
+ _collection.Insert(position, obj);
+ return 1;
+ }
+
+ public T Remove(int position)
+ {
+ if (position > _collection.Count || position < 0)
+ {
+ return null;
+ }
+ T temp = _collection[position];
+ _collection.RemoveAt(position);
+ return temp;
+ }
+}
+
diff --git a/lab_0/CollectionGenericObject/MassiveGenericObjects.cs b/lab_0/CollectionGenericObject/MassiveGenericObjects.cs
new file mode 100644
index 0000000..9b4ee88
--- /dev/null
+++ b/lab_0/CollectionGenericObject/MassiveGenericObjects.cs
@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBus.CollectionGenericObject;
+
+///
+/// Параметризованный набор объектов
+///
+/// Параметр: ограничение - ссылочный тип
+ public class MassiveGenericObjects : ICollectionGenericObjects
+ where T : class
+
+ {
+ ///
+ /// Массив объектов, которые храним
+ ///
+ private T?[] _collection;
+
+ public int Count => _collection.Length;
+
+ public int SetMaxCount
+ {
+ set
+ {
+ if (value > 0)
+ {
+ if (_collection.Length > 0)
+ {
+ Array.Resize(ref _collection, value);
+ }
+ else
+ {
+ _collection = new T?[value];
+ }
+ }
+ }
+ }
+
+ ///
+ /// Конструктор
+ ///
+ public MassiveGenericObjects()
+ {
+ _collection = Array.Empty();
+ }
+
+ public T? Get(int position)
+ {
+ if (position >= 0 && position < Count)
+ {
+ return _collection[position];
+ }
+
+ return null;
+ }
+
+ public int Insert(T obj)
+ {
+ // вставка в свободное место набора
+ for (int i = 0; i < Count; i++)
+ {
+ if (_collection[i] == null)
+ {
+ _collection[i] = obj;
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ public int Insert(T obj, int position)
+ {
+ // проверка позиции
+ if (position < 0 || position >= Count)
+ {
+ return -1;
+ }
+
+ // проверка, что элемент массива по этой позиции пустой, если нет, то ищется свободное место после этой позиции и идет вставка туда если нет после, ищем до
+ if (_collection[position] != null)
+ {
+ bool pushed = false;
+ for (int index = position + 1; index < Count; index++)
+ {
+ if (_collection[index] == null)
+ {
+ position = index;
+ pushed = true;
+ break;
+ }
+ }
+
+ if (!pushed)
+ {
+ for (int index = position - 1; index >= 0; index--)
+ {
+ if (_collection[index] == null)
+ {
+ position = index;
+ pushed = true;
+ break;
+ }
+ }
+ }
+
+ if (!pushed)
+ {
+ return position;
+ }
+ }
+
+ // вставка
+ _collection[position] = obj;
+ return position;
+ }
+
+ public T? Remove(int position)
+ {
+ // проверка позиции
+ if (position < 0 || position >= Count)
+ {
+ return null;
+ }
+
+ if (_collection[position] == null) return null;
+
+ T? temp = _collection[position];
+ _collection[position] = null;
+ return temp;
+ }
+ }
+
diff --git a/lab_0/CollectionGenericObject/StorageCollection.cs b/lab_0/CollectionGenericObject/StorageCollection.cs
new file mode 100644
index 0000000..bec1f83
--- /dev/null
+++ b/lab_0/CollectionGenericObject/StorageCollection.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBus.CollectionGenericObject;
+
+///
+/// Класс-хранилище коллекций
+///
+///
+
+public class StorageCollection
+ where T : class
+{///
+ /// Словарь (хранилище) с коллекциями
+ ///
+ readonly Dictionary> _storages;
+
+ ///
+ /// Возвращение списка названий коллекций
+ ///
+ public List Keys => _storages.Keys.ToList();
+
+ ///
+ /// Конструктор
+ ///
+ public StorageCollection()
+ {
+ _storages = new Dictionary>();
+ }
+
+ ///
+ /// Добавление коллекции в хранилище
+ ///
+ /// Название коллекции
+ /// тип коллекции
+ public void AddCollection(string name, CollectionType collectionType)
+ {
+ if (name == null || _storages.ContainsKey(name)) { return; }
+ switch (collectionType)
+
+ {
+ case CollectionType.None:
+ return;
+ case CollectionType.Massive:
+ _storages.Add(name, new MassiveGenericObjects { });
+ return;
+ case CollectionType.List:
+ _storages.Add(name, new ListGenericObjects { });
+ return;
+ }
+
+ }
+
+ ///
+ /// Удаление коллекции
+ ///
+ /// Название коллекции
+ public void DelCollection(string name)
+ {
+ if (name == null || !_storages.ContainsKey(name)) { return; }
+ _storages.Remove(name);
+ }
+
+ ///
+ /// Доступ к коллекции
+ ///
+ /// Название коллекции
+ ///
+ public ICollectionGenericObjects? this[string name]
+ {
+ get
+ {
+ if (name == null || !_storages.ContainsKey(name)) { return null; }
+ return _storages[name];
+ }
+ }
+}
diff --git a/lab_0/Drawnings/DirectionType.cs b/lab_0/Drawnings/DirectionType.cs
new file mode 100644
index 0000000..8214c58
--- /dev/null
+++ b/lab_0/Drawnings/DirectionType.cs
@@ -0,0 +1,30 @@
+namespace ProjectBus. Drawnings;
+
+///
+/// Направление перемещения
+///
+
+public enum DirectionType
+{
+ ///
+ /// Вверх
+ ///
+ Unknow = -1,
+
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+ ///
+ /// Влево
+ ///
+ Left = 3,
+ ///
+ /// Вправо
+ ///
+ Right = 4
+}
diff --git a/lab_0/Drawnings/DrawningBus.cs b/lab_0/Drawnings/DrawningBus.cs
new file mode 100644
index 0000000..e391f59
--- /dev/null
+++ b/lab_0/Drawnings/DrawningBus.cs
@@ -0,0 +1,89 @@
+using ProjectBus.Entities;
+using System.Drawing;
+
+namespace ProjectBus.Drawnings;
+
+///
+/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
+///
+public class DrawningBus : DrawningSimpleBus
+{
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия дополнительного отсека
+ /// Признак наличия гармошки
+ public DrawningBus(int speed, double weight, Color bodyColor, Color additionalColor, bool additionalCompartment, bool accordion) : base(310,52)
+ {
+ EntitySimpleBus = new EntityBus(speed, weight, bodyColor, additionalColor, additionalCompartment, accordion);
+ }
+
+ public override void DrawTransport(Graphics g)
+ {
+ if (EntitySimpleBus == null || EntitySimpleBus is not EntityBus bus || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+ Brush additionalBrush= new SolidBrush(bus.AdditionalColor);
+
+ //доп отсек
+ if (bus.AdditionalCompartment)
+ {
+ //корпус
+ g.DrawRectangle(pen, _startPosX.Value + 204, _startPosY.Value - 1, 105, 50);
+ g.DrawRectangle(pen, _startPosX.Value + 205, _startPosY.Value, 105, 50);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 205, _startPosY.Value, 105, 50);
+
+
+ //окна
+ g.FillEllipse(additionalBrush, _startPosX.Value + 247, _startPosY.Value + 6, 16, 25);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 275, _startPosY.Value + 6, 16, 25);
+ g.DrawEllipse(pen, _startPosX.Value + 247, _startPosY.Value + 6, 16, 25);
+ g.DrawEllipse(pen, _startPosX.Value + 275, _startPosY.Value + 6, 16, 25);
+
+
+ //дверь
+ g.FillRectangle(additionalBrush, _startPosX.Value + 215, _startPosY.Value + 10, 20, 40);
+ g.DrawRectangle(pen, _startPosX.Value + 215, _startPosY.Value + 10, 20, 40);
+
+ //колеса
+ g.FillEllipse(additionalBrush, _startPosX.Value + 250, _startPosY.Value + 40, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 250, _startPosY.Value + 40, 20, 20);
+ }
+
+ base.DrawTransport(g);
+
+
+ //гармошка
+ if (bus.Accordion)
+ {
+ Brush brGray = new SolidBrush(Color.LightGray);
+
+ g.FillRectangle(brGray, _startPosX.Value + 175, _startPosY.Value + 4, 30, 42);
+ g.FillRectangle(brGray, _startPosX.Value + 180, _startPosY.Value + 4, 5, 42);
+ g.FillRectangle(brGray, _startPosX.Value + 185, _startPosY.Value + 4, 5, 42);
+ g.FillRectangle(brGray, _startPosX.Value + 190, _startPosY.Value + 4, 5, 42);
+ g.FillRectangle(brGray, _startPosX.Value + 195, _startPosY.Value + 4, 5, 42);
+
+ g.DrawRectangle(pen, _startPosX.Value + 175, _startPosY.Value + 4, 30, 42);
+ g.DrawRectangle(pen, _startPosX.Value + 180, _startPosY.Value + 4, 5, 42);
+ g.DrawRectangle(pen, _startPosX.Value + 185, _startPosY.Value + 4, 5, 42);
+ g.DrawRectangle(pen, _startPosX.Value + 190, _startPosY.Value + 4, 5, 42);
+ g.DrawRectangle(pen, _startPosX.Value + 195, _startPosY.Value + 4, 5, 42);
+ }
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/lab_0/Drawnings/DrawningSimpleBus.cs b/lab_0/Drawnings/DrawningSimpleBus.cs
new file mode 100644
index 0000000..873435a
--- /dev/null
+++ b/lab_0/Drawnings/DrawningSimpleBus.cs
@@ -0,0 +1,274 @@
+using ProjectBus.Drawnings;
+using ProjectBus.Entities;
+
+namespace ProjectBus.Drawnings;
+
+public class DrawningSimpleBus
+{
+ ///
+ /// Класс-сущность
+ ///
+ public EntitySimpleBus? EntitySimpleBus { get; protected set; }
+
+ ///
+ /// Ширина окна
+ ///
+ private int? _pictureWidth;
+
+ ///
+ /// Высота окна
+ ///
+ private int? _pictureHeight;
+
+ ///
+ /// Левая координата прорисовки автобуса
+ ///
+ protected int? _startPosX;
+
+ ///
+ /// Верхняя кооридната прорисовки автобуса
+ ///
+ protected int? _startPosY;
+
+ ///
+ /// Ширина прорисовки автобуса
+ /// ///
+ private readonly int _drawningBusWidth = 310;
+
+ ///
+ /// Высота прорисовки автобуса
+ ///
+ private readonly int _drawningBusHeight = 52;
+
+ ///
+ /// Координата X объекта
+ ///
+ public int? GetPosX => _startPosX;
+ ///
+ /// Координата Y объекта
+ ///
+ public int? GetPosY => _startPosY;
+ ///
+ /// Ширина объекта
+ ///
+ public int GetWidth => _drawningBusWidth;
+ ///
+ /// Высота объекта
+ ///
+ public int GetHeight => _drawningBusHeight;
+
+ ///
+ /// Пустой конструктор
+ ///
+ private DrawningSimpleBus()
+ {
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+
+ }
+
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ public DrawningSimpleBus(int speed, double weight, Color bodyColor) : this()
+ {
+ EntitySimpleBus = new EntitySimpleBus(speed, weight, bodyColor);
+ }
+
+ ///
+ /// Конструктор для наследников
+ ///
+ /// Ширина прорисовки автобуса
+ /// Высота прорисовки автобуса
+ protected DrawningSimpleBus(int drawningBusWidth, int drawningBusHeight) : this()
+ {
+ _drawningBusWidth = drawningBusWidth;
+ _drawningBusHeight= drawningBusHeight;
+ }
+
+ ///
+ /// Установка границ поля
+ ///
+ /// Ширина поля
+ /// Высота поля
+ /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
+ public bool SetPictureSize(int width, int height)
+ {
+ if (width >= _drawningBusWidth && height >= _drawningBusWidth)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+ if (_startPosX.HasValue && _startPosY.HasValue)
+ {
+ SetPosition(_startPosX.Value, _startPosY.Value);
+ }
+ return true;
+ }
+
+
+ return false;
+ }
+
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ //public void SetPosition(int x, int y)
+ //{
+ // if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ // {
+ // return;
+ // }
+
+
+
+ // _startPosX = x;
+ // _startPosY = y;
+ //}
+
+ public void SetPosition(int x, int y)
+ {
+ if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+ return;
+ }
+
+ if (x < 0)
+ {
+ x = 0;
+ }
+ else if (x > _pictureWidth.Value - _drawningBusWidth)
+ {
+ x = _pictureWidth.Value - _drawningBusWidth;
+ }
+
+ if (y < 0)
+ {
+ y = 0;
+ }
+ else if (y > _pictureHeight.Value - _drawningBusHeight)
+ {
+ y = _pictureHeight.Value - _drawningBusHeight;
+ }
+
+ _startPosX = x;
+ _startPosY = y;
+ }
+
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ /// true - перемещене выполнено, false - перемещение невозможно
+ public bool MoveTransport(DirectionType direction)
+ {
+ if (EntitySimpleBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return false;
+ }
+
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX.Value - EntitySimpleBus.Step > 0)
+ {
+ _startPosX -= (int)EntitySimpleBus.Step;
+ }
+ return true;
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY.Value - EntitySimpleBus.Step > 0)
+ {
+ _startPosY -= (int)EntitySimpleBus.Step;
+ }
+ return true;
+ // вправо
+ case DirectionType.Right:
+ if (_startPosX.Value + EntitySimpleBus.Step <_pictureWidth - _drawningBusWidth)
+ {
+ _startPosX += (int)EntitySimpleBus.Step;
+ }
+ return true;
+ //вниз
+ case DirectionType.Down:
+ if (_startPosY.Value + EntitySimpleBus.Step < _pictureHeight - _drawningBusHeight)
+ {
+ _startPosY += (int)EntitySimpleBus.Step;
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public virtual void DrawTransport(Graphics g)
+ {
+ if (EntitySimpleBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+
+
+ Pen pen = new(Color.Black);
+
+ //корпус автобуса
+
+
+
+ g.DrawRectangle(pen, _startPosX.Value + 0, _startPosY.Value, 175, 50);
+ g.DrawRectangle(pen, _startPosX.Value + 0, _startPosY.Value - 1, 175, 50);
+
+ Brush br1 = new SolidBrush(EntitySimpleBus.BodyColor);
+ g.FillRectangle(br1, _startPosX.Value + 0, _startPosY.Value, 175, 50);
+
+ //окна
+
+ Brush brBlue = new SolidBrush(Color.LightBlue);
+ g.FillEllipse(brBlue, _startPosX.Value + 80, _startPosY.Value + 6, 16, 25);
+ g.FillEllipse(brBlue, _startPosX.Value + 105, _startPosY.Value + 6, 16, 25);
+ g.FillEllipse(brBlue, _startPosX.Value + 130, _startPosY.Value + 6, 16, 25);
+ g.FillEllipse(brBlue, _startPosX.Value + 155, _startPosY.Value + 6, 16, 25);
+ g.FillEllipse(brBlue, _startPosX.Value + 25, _startPosY.Value + 6, 16, 25);
+ g.FillEllipse(brBlue, _startPosX.Value + 5, _startPosY.Value + 6, 16, 25);
+
+ g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 6, 16, 25);
+ g.DrawEllipse(pen, _startPosX.Value + 105, _startPosY.Value + 6, 16, 25);
+ g.DrawEllipse(pen, _startPosX.Value + 130, _startPosY.Value + 6, 16, 25);
+ g.DrawEllipse(pen, _startPosX.Value + 155, _startPosY.Value + 6, 16, 25);
+ g.DrawEllipse(pen, _startPosX.Value + 25, _startPosY.Value + 6, 16, 25);
+ g.DrawEllipse(pen, _startPosX.Value + 5, _startPosY.Value + 6, 16, 25);
+
+
+ //дверь
+
+ Brush br2 = new SolidBrush(EntitySimpleBus.BodyColor);
+ g.DrawRectangle(pen, _startPosX.Value + 49, _startPosY.Value + 9, 20, 40);
+ g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value + 10, 20, 40);
+ g.FillRectangle(br2, _startPosX.Value + 50, _startPosY.Value + 10, 20, 40);
+
+
+
+ //колеса
+
+ Brush brGrey = new SolidBrush(Color.Gray);
+ g.FillEllipse(brGrey, _startPosX.Value + 15, _startPosY.Value + 40, 20, 20);
+ g.FillEllipse(brGrey, _startPosX.Value + 115, _startPosY.Value + 40, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 15, _startPosY.Value + 40, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 115, _startPosY.Value + 40, 20, 20);
+
+
+ }
+ }
+
+
diff --git a/lab_0/Entities/EntityBus.cs b/lab_0/Entities/EntityBus.cs
new file mode 100644
index 0000000..9e89c00
--- /dev/null
+++ b/lab_0/Entities/EntityBus.cs
@@ -0,0 +1,41 @@
+namespace ProjectBus.Entities;
+
+///
+/// Класс-сущность "Автобус"
+///
+public class EntityBus : EntitySimpleBus
+{
+ ///
+ /// Дополнительный цвет (для опциональных элементов)
+ ///
+ ///
+ public Color AdditionalColor { get; private set; }
+ public Color BodyColor { get; private set; }
+
+ ///
+ /// Признак (опция) наличия дополнительного отсека
+ ///
+ public bool AdditionalCompartment { get; private set; }
+
+ ///
+ /// Признак (опция) наличия гармошки
+ ///
+ public bool Accordion { get; private set; }
+
+ ///
+ /// Инициализация полей объекта-класса спортивного автомобиля
+ ///
+ /// Скорость
+ /// Вес автобуса
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия дополнительного отсека
+ /// Признак наличия гармошки
+ public EntityBus(int speed, double weight, Color bodyColor, Color additionalColor, bool additionalCompartment, bool accordion) : base(speed, weight, bodyColor)
+ {
+ AdditionalColor = additionalColor;
+ BodyColor = bodyColor;
+ AdditionalCompartment = additionalCompartment;
+ Accordion = accordion;
+ }
+}
\ No newline at end of file
diff --git a/lab_0/Entities/EntitySimpleBus.cs b/lab_0/Entities/EntitySimpleBus.cs
new file mode 100644
index 0000000..9e68233
--- /dev/null
+++ b/lab_0/Entities/EntitySimpleBus.cs
@@ -0,0 +1,42 @@
+namespace ProjectBus.Entities;
+
+///
+/// Класс-сущность "Автобус"
+///
+
+public class EntitySimpleBus
+{
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; set; }
+
+ ///
+ /// Вес
+ ///
+ public double Weight { get; set; }
+
+ ///
+ /// Основной цвет
+ ///
+ public Color BodyColor { get; private set; }
+
+
+ ///
+ /// Шаг перемещения автомобиля
+ ///
+ public double Step => Speed * 100 / Weight;
+
+ ///
+ /// Конструктор сущности
+ ///
+ /// Скорость
+ /// Вес автобуса
+ /// Основной цвет
+ public EntitySimpleBus(int speed, double weight, Color bodyColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ }
+}
diff --git a/lab_0/Form1.Designer.cs b/lab_0/Form1.Designer.cs
deleted file mode 100644
index 91e436d..0000000
--- a/lab_0/Form1.Designer.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-namespace lab_0
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- SuspendLayout();
- //
- // Form1
- //
- AutoScaleDimensions = new SizeF(13F, 32F);
- AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(800, 450);
- Name = "Form1";
- Text = "Form1";
- Load += Form1_Load;
- ResumeLayout(false);
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/lab_0/Form1.cs b/lab_0/Form1.cs
deleted file mode 100644
index 6bc877c..0000000
--- a/lab_0/Form1.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace lab_0
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
-
- private void Form1_Load(object sender, EventArgs e)
- {
-
- }
- }
-}
\ No newline at end of file
diff --git a/lab_0/FormBus.Designer.cs b/lab_0/FormBus.Designer.cs
new file mode 100644
index 0000000..d4e6261
--- /dev/null
+++ b/lab_0/FormBus.Designer.cs
@@ -0,0 +1,145 @@
+namespace ProjectBus
+{
+ partial class FormBus
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ pictureBoxBus = new PictureBox();
+ buttonLeft = new Button();
+ buttonRight = new Button();
+ buttonUp = new Button();
+ buttonDown = new Button();
+ comboBoxStrategy = new ComboBox();
+ buttonStrategyStep = new Button();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxBus).BeginInit();
+ SuspendLayout();
+ //
+ // pictureBoxBus
+ //
+ pictureBoxBus.Dock = DockStyle.Fill;
+ pictureBoxBus.Location = new Point(0, 0);
+ pictureBoxBus.Name = "pictureBoxBus";
+ pictureBoxBus.Size = new Size(1155, 557);
+ pictureBoxBus.TabIndex = 7;
+ pictureBoxBus.TabStop = false;
+ //
+ // buttonLeft
+ //
+ buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
+ buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonLeft.Location = new Point(981, 495);
+ buttonLeft.Name = "buttonLeft";
+ buttonLeft.Size = new Size(50, 50);
+ buttonLeft.TabIndex = 3;
+ buttonLeft.UseVisualStyleBackColor = true;
+ buttonLeft.Click += ButtonMove_Click;
+ //
+ // buttonRight
+ //
+ buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonRight.BackgroundImage = Properties.Resources.arrowRight;
+ buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonRight.Location = new Point(1093, 497);
+ buttonRight.Name = "buttonRight";
+ buttonRight.Size = new Size(50, 50);
+ buttonRight.TabIndex = 4;
+ buttonRight.UseVisualStyleBackColor = true;
+ buttonRight.Click += ButtonMove_Click;
+ //
+ // buttonUp
+ //
+ buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonUp.BackgroundImage = Properties.Resources.arrowUp;
+ buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUp.Location = new Point(1037, 439);
+ buttonUp.Name = "buttonUp";
+ buttonUp.Size = new Size(50, 50);
+ buttonUp.TabIndex = 5;
+ buttonUp.UseVisualStyleBackColor = true;
+ buttonUp.Click += ButtonMove_Click;
+ //
+ // buttonDown
+ //
+ buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonDown.BackgroundImage = Properties.Resources.arrowDown;
+ buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDown.Location = new Point(1037, 495);
+ buttonDown.Name = "buttonDown";
+ buttonDown.Size = new Size(50, 50);
+ buttonDown.TabIndex = 6;
+ buttonDown.UseVisualStyleBackColor = true;
+ buttonDown.Click += ButtonMove_Click;
+ //
+ // comboBoxStrategy
+ //
+ comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxStrategy.FormattingEnabled = true;
+ comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
+ comboBoxStrategy.Location = new Point(901, 12);
+ comboBoxStrategy.Name = "comboBoxStrategy";
+ comboBoxStrategy.Size = new Size(242, 40);
+ comboBoxStrategy.TabIndex = 9;
+ //
+ // buttonStrategyStep
+ //
+ buttonStrategyStep.Location = new Point(993, 58);
+ buttonStrategyStep.Name = "buttonStrategyStep";
+ buttonStrategyStep.Size = new Size(150, 46);
+ buttonStrategyStep.TabIndex = 10;
+ buttonStrategyStep.Text = "Шаг";
+ buttonStrategyStep.UseVisualStyleBackColor = true;
+ buttonStrategyStep.Click += buttonStrategyStep_Click;
+ //
+ // FormBus
+ //
+ AutoScaleDimensions = new SizeF(13F, 32F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1155, 557);
+ Controls.Add(buttonStrategyStep);
+ Controls.Add(comboBoxStrategy);
+ Controls.Add(buttonDown);
+ Controls.Add(buttonUp);
+ Controls.Add(buttonRight);
+ Controls.Add(buttonLeft);
+ Controls.Add(pictureBoxBus);
+ Name = "FormBus";
+ Text = "Автобус";
+ ((System.ComponentModel.ISupportInitialize)pictureBoxBus).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+ private PictureBox pictureBoxBus;
+ private Button buttonLeft;
+ private Button buttonRight;
+ private Button buttonUp;
+ private Button buttonDown;
+ private ComboBox comboBoxStrategy;
+ private Button buttonStrategyStep;
+ }
+}
\ No newline at end of file
diff --git a/lab_0/FormBus.cs b/lab_0/FormBus.cs
new file mode 100644
index 0000000..d2c49c5
--- /dev/null
+++ b/lab_0/FormBus.cs
@@ -0,0 +1,153 @@
+using ProjectBus.Drawnings;
+using ProjectBus.MovementStrategy;
+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 ProjectBus;
+///
+/// форма работы с объектом "Автобус"
+///
+public partial class FormBus : Form
+{
+ ///
+ /// поле-объект для прорисовки объекта
+ ///
+ private DrawningSimpleBus? _drawningSimpleBus;
+
+ ///
+ /// Стратегия перемещения
+ ///
+ private AbstractStrategy? _strategy;
+
+ ///
+ /// Получение объекта
+ ///
+ public DrawningSimpleBus SetSimpleBus
+ {
+ set
+ {
+ _drawningSimpleBus = value;
+ _drawningSimpleBus.SetPictureSize(pictureBoxBus.Width, pictureBoxBus.Height);
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ Draw();
+ }
+ }
+
+
+
+ ///
+ /// конструктор формы
+ ///
+ public FormBus()
+ {
+ InitializeComponent();
+ _strategy = null;
+ }
+
+ ///
+ /// метод прорисовки машины
+ ///
+ private void Draw()
+ {
+ if (_drawningSimpleBus == null)
+ {
+ return;
+ }
+
+ Bitmap bmp = new(pictureBoxBus.Width, pictureBoxBus.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _drawningSimpleBus.DrawTransport(gr);
+ pictureBoxBus.Image = bmp;
+ }
+
+
+
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_drawningSimpleBus == null)
+ {
+ return;
+ }
+
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ bool result = false;
+ switch (name)
+ {
+ case "buttonUp":
+ result =
+ _drawningSimpleBus.MoveTransport(DirectionType.Up);
+ break;
+ case "buttonDown":
+ result =
+ _drawningSimpleBus.MoveTransport(DirectionType.Down);
+ break;
+ case "buttonLeft":
+ result =
+ _drawningSimpleBus.MoveTransport(DirectionType.Left);
+ break;
+ case "buttonRight":
+ result =
+ _drawningSimpleBus.MoveTransport(DirectionType.Right);
+ break;
+ }
+
+ if (result)
+ {
+ Draw();
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void buttonStrategyStep_Click(object sender, EventArgs e)
+ {
+ if (_drawningSimpleBus == null)
+ {
+ return;
+ }
+
+ if (comboBoxStrategy.Enabled)
+ {
+ _strategy = comboBoxStrategy.SelectedIndex switch
+ {
+ 0 => new MoveToCenter(),
+ 1 => new MoveToBorder(),
+ _ => null,
+ };
+ if (_strategy == null)
+ {
+ return;
+ }
+ _strategy.SetData(new MoveableSimpleBus(_drawningSimpleBus), pictureBoxBus.Width, pictureBoxBus.Height);
+ }
+
+ if (_strategy == null)
+ {
+ return;
+ }
+
+ comboBoxStrategy.Enabled = false;
+ _strategy.MakeStep();
+ Draw();
+
+ if (_strategy.GetStatus() == StrategyStatus.Finish)
+ {
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ }
+ }
+}
+
+
+
diff --git a/lab_0/Form1.resx b/lab_0/FormBus.resx
similarity index 100%
rename from lab_0/Form1.resx
rename to lab_0/FormBus.resx
diff --git a/lab_0/FormSimpleBusCollection.Designer.cs b/lab_0/FormSimpleBusCollection.Designer.cs
new file mode 100644
index 0000000..bb33b9e
--- /dev/null
+++ b/lab_0/FormSimpleBusCollection.Designer.cs
@@ -0,0 +1,302 @@
+namespace ProjectBus
+{
+ partial class FormSimpleBusCollection
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ groupBoxTools = new GroupBox();
+ panelCompanyTools = new Panel();
+ buttonAddBus = new Button();
+ buttonAddSimpleBus = new Button();
+ maskedTextBox = new MaskedTextBox();
+ buttonRefresh = new Button();
+ buttonDelBus = new Button();
+ buttonGoToCheck = new Button();
+ panelStorage = new Panel();
+ buttonCollectionDel = new Button();
+ buttonCreateCompany = new Button();
+ listBoxCollection = new ListBox();
+ buttonCollectionAdd = new Button();
+ comboBoxSelectorCompany = new ComboBox();
+ radioButtonList = new RadioButton();
+ radioButtonMassive = new RadioButton();
+ textBoxCollectionName = new TextBox();
+ labelCollectionName = new Label();
+ pictureBox = new PictureBox();
+ groupBoxTools.SuspendLayout();
+ panelCompanyTools.SuspendLayout();
+ panelStorage.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
+ SuspendLayout();
+ //
+ // groupBoxTools
+ //
+ groupBoxTools.Controls.Add(panelCompanyTools);
+ groupBoxTools.Controls.Add(panelStorage);
+ groupBoxTools.Dock = DockStyle.Right;
+ groupBoxTools.Location = new Point(1018, 0);
+ groupBoxTools.Name = "groupBoxTools";
+ groupBoxTools.Size = new Size(356, 1058);
+ groupBoxTools.TabIndex = 0;
+ groupBoxTools.TabStop = false;
+ groupBoxTools.Text = "Инструменты";
+ //
+ // panelCompanyTools
+ //
+ panelCompanyTools.Controls.Add(buttonAddBus);
+ panelCompanyTools.Controls.Add(buttonAddSimpleBus);
+ panelCompanyTools.Controls.Add(maskedTextBox);
+ panelCompanyTools.Controls.Add(buttonRefresh);
+ panelCompanyTools.Controls.Add(buttonDelBus);
+ panelCompanyTools.Controls.Add(buttonGoToCheck);
+ panelCompanyTools.Dock = DockStyle.Bottom;
+ panelCompanyTools.Enabled = false;
+ panelCompanyTools.Location = new Point(3, 543);
+ panelCompanyTools.Name = "panelCompanyTools";
+ panelCompanyTools.Size = new Size(350, 512);
+ panelCompanyTools.TabIndex = 8;
+ //
+ // buttonAddBus
+ //
+ buttonAddBus.Location = new Point(6, 77);
+ buttonAddBus.Name = "buttonAddBus";
+ buttonAddBus.Size = new Size(321, 76);
+ buttonAddBus.TabIndex = 2;
+ buttonAddBus.Text = "Добавление автобуса с доп. отсеком";
+ buttonAddBus.UseVisualStyleBackColor = true;
+ buttonAddBus.Click += ButtonAddBus_Click;
+ //
+ // buttonAddSimpleBus
+ //
+ buttonAddSimpleBus.Location = new Point(9, 3);
+ buttonAddSimpleBus.Name = "buttonAddSimpleBus";
+ buttonAddSimpleBus.Size = new Size(318, 59);
+ buttonAddSimpleBus.TabIndex = 1;
+ buttonAddSimpleBus.Text = "Добавление автобуса";
+ buttonAddSimpleBus.UseVisualStyleBackColor = true;
+ buttonAddSimpleBus.Click += ButtonAddSimpleBus_Click;
+ //
+ // maskedTextBox
+ //
+ maskedTextBox.Location = new Point(15, 173);
+ maskedTextBox.Mask = "00";
+ maskedTextBox.Name = "maskedTextBox";
+ maskedTextBox.Size = new Size(306, 39);
+ maskedTextBox.TabIndex = 0;
+ maskedTextBox.ValidatingType = typeof(int);
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(6, 366);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(328, 49);
+ buttonRefresh.TabIndex = 7;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
+ //
+ // buttonDelBus
+ //
+ buttonDelBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonDelBus.Location = new Point(6, 231);
+ buttonDelBus.Name = "buttonDelBus";
+ buttonDelBus.Size = new Size(321, 46);
+ buttonDelBus.TabIndex = 5;
+ buttonDelBus.Text = "Удалить автобус";
+ buttonDelBus.UseVisualStyleBackColor = true;
+ buttonDelBus.Click += buttonDelBus_Click;
+ //
+ // buttonGoToCheck
+ //
+ buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonGoToCheck.Location = new Point(6, 293);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(328, 58);
+ buttonGoToCheck.TabIndex = 6;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += ButtonGoToCheck_Click;
+ //
+ // panelStorage
+ //
+ panelStorage.Controls.Add(buttonCollectionDel);
+ panelStorage.Controls.Add(buttonCreateCompany);
+ panelStorage.Controls.Add(listBoxCollection);
+ panelStorage.Controls.Add(buttonCollectionAdd);
+ panelStorage.Controls.Add(comboBoxSelectorCompany);
+ panelStorage.Controls.Add(radioButtonList);
+ panelStorage.Controls.Add(radioButtonMassive);
+ panelStorage.Controls.Add(textBoxCollectionName);
+ panelStorage.Controls.Add(labelCollectionName);
+ panelStorage.Dock = DockStyle.Top;
+ panelStorage.Location = new Point(3, 35);
+ panelStorage.Name = "panelStorage";
+ panelStorage.Size = new Size(350, 518);
+ panelStorage.TabIndex = 8;
+ //
+ // buttonCollectionDel
+ //
+ buttonCollectionDel.Location = new Point(3, 348);
+ buttonCollectionDel.Name = "buttonCollectionDel";
+ buttonCollectionDel.Size = new Size(324, 46);
+ buttonCollectionDel.TabIndex = 6;
+ buttonCollectionDel.Text = "Удалить коллекцию";
+ buttonCollectionDel.UseVisualStyleBackColor = true;
+ buttonCollectionDel.Click += ButtonCollectionDel_Click;
+ //
+ // buttonCreateCompany
+ //
+ buttonCreateCompany.Location = new Point(6, 456);
+ buttonCreateCompany.Name = "buttonCreateCompany";
+ buttonCreateCompany.Size = new Size(324, 46);
+ buttonCreateCompany.TabIndex = 9;
+ buttonCreateCompany.Text = "Создать компанию";
+ buttonCreateCompany.UseVisualStyleBackColor = true;
+ buttonCreateCompany.Click += ButtonCreateCompany_Click;
+ //
+ // listBoxCollection
+ //
+ listBoxCollection.ItemHeight = 32;
+ listBoxCollection.Location = new Point(0, 231);
+ listBoxCollection.Name = "listBoxCollection";
+ listBoxCollection.Size = new Size(324, 100);
+ listBoxCollection.TabIndex = 7;
+ //
+ // buttonCollectionAdd
+ //
+ buttonCollectionAdd.Location = new Point(0, 166);
+ buttonCollectionAdd.Name = "buttonCollectionAdd";
+ buttonCollectionAdd.Size = new Size(324, 46);
+ buttonCollectionAdd.TabIndex = 4;
+ buttonCollectionAdd.Text = "Добавить коллекцию";
+ buttonCollectionAdd.UseVisualStyleBackColor = true;
+ buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
+ //
+ // comboBoxSelectorCompany
+ //
+ comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxSelectorCompany.FormattingEnabled = true;
+ comboBoxSelectorCompany.Items.AddRange(new object[] { "хранилище" });
+ comboBoxSelectorCompany.Location = new Point(0, 400);
+ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
+ comboBoxSelectorCompany.Size = new Size(344, 40);
+ comboBoxSelectorCompany.TabIndex = 0;
+ comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
+ //
+ // radioButtonList
+ //
+ radioButtonList.AutoSize = true;
+ radioButtonList.Location = new Point(181, 114);
+ radioButtonList.Name = "radioButtonList";
+ radioButtonList.Size = new Size(125, 36);
+ radioButtonList.TabIndex = 3;
+ radioButtonList.TabStop = true;
+ radioButtonList.Text = "Список";
+ radioButtonList.UseVisualStyleBackColor = true;
+ //
+ // radioButtonMassive
+ //
+ radioButtonMassive.AutoSize = true;
+ radioButtonMassive.Location = new Point(13, 114);
+ radioButtonMassive.Name = "radioButtonMassive";
+ radioButtonMassive.Size = new Size(128, 36);
+ radioButtonMassive.TabIndex = 2;
+ radioButtonMassive.TabStop = true;
+ radioButtonMassive.Text = "Массив";
+ radioButtonMassive.UseVisualStyleBackColor = true;
+ //
+ // textBoxCollectionName
+ //
+ textBoxCollectionName.Location = new Point(3, 60);
+ textBoxCollectionName.Name = "textBoxCollectionName";
+ textBoxCollectionName.Size = new Size(318, 39);
+ textBoxCollectionName.TabIndex = 1;
+ //
+ // labelCollectionName
+ //
+ labelCollectionName.AutoSize = true;
+ labelCollectionName.Location = new Point(34, 25);
+ labelCollectionName.Name = "labelCollectionName";
+ labelCollectionName.Size = new Size(251, 32);
+ labelCollectionName.TabIndex = 0;
+ labelCollectionName.Text = "Название коллекции:";
+ //
+ // pictureBox
+ //
+ pictureBox.Dock = DockStyle.Fill;
+ pictureBox.Location = new Point(0, 0);
+ pictureBox.Name = "pictureBox";
+ pictureBox.Size = new Size(1018, 1058);
+ pictureBox.TabIndex = 0;
+ pictureBox.TabStop = false;
+ //
+ // FormSimpleBusCollection
+ //
+ AutoScaleDimensions = new SizeF(13F, 32F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1374, 1058);
+ Controls.Add(pictureBox);
+ Controls.Add(groupBoxTools);
+ Name = "FormSimpleBusCollection";
+ Text = "Коллекция автобусов";
+ groupBoxTools.ResumeLayout(false);
+ panelCompanyTools.ResumeLayout(false);
+ panelCompanyTools.PerformLayout();
+ panelStorage.ResumeLayout(false);
+ panelStorage.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ ResumeLayout(false);
+ }
+
+
+
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private ComboBox comboBoxSelectorCompany;
+ private Button buttonAddBus;
+ private Button buttonAddSimpleBus;
+ private Button buttonDelBus;
+ private MaskedTextBox maskedTextBox;
+ private PictureBox pictureBox;
+ private Button buttonRefresh;
+ private Button buttonGoToCheck;
+ private Panel panelStorage;
+ private Label labelCollectionName;
+ private TextBox textBoxCollectionName;
+ private RadioButton radioButtonList;
+ private RadioButton radioButtonMassive;
+ private Button buttonCollectionDel;
+ private ListBox listBoxCollection;
+ private Button buttonCollectionAdd;
+ private Button buttonCreateCompany;
+ private Panel panelCompanyTools;
+ }
+}
\ No newline at end of file
diff --git a/lab_0/FormSimpleBusCollection.cs b/lab_0/FormSimpleBusCollection.cs
new file mode 100644
index 0000000..58e7f6a
--- /dev/null
+++ b/lab_0/FormSimpleBusCollection.cs
@@ -0,0 +1,300 @@
+using ProjectBus.MovementStrategy;
+using ProjectBus.Drawnings;
+using ProjectBus.CollectionGenericObject;
+
+namespace ProjectBus;
+
+public partial class FormSimpleBusCollection : Form
+{
+ ///
+ /// Хранилише коллекций
+ ///
+ private readonly StorageCollection _storageCollection;
+
+ ///
+ /// Компания
+ ///
+ private AbstractCompany? _company = null;
+
+ ///
+ /// Конструктор
+ ///
+ public FormSimpleBusCollection()
+ {
+ InitializeComponent();
+ _storageCollection = new();
+ }
+
+ ///
+ /// Выбор компании
+ ///
+ ///
+ ///
+ private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "хранилище":
+ _company = new BusStation(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
+ break;
+ }
+ }
+
+ ///
+ /// Добавление обычного автомобиля
+ ///
+ ///
+ ///
+ private void ButtonAddSimpleBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSimpleBus));
+
+ ///
+ /// Добавление спортивного автомобиля
+ ///
+ ///
+ ///
+ private void ButtonAddBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBus));
+
+ ///
+ /// Создание объекта класса-перемещения
+ ///
+ /// Тип создаваемого объекта
+ private void CreateObject(string type)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+ Random random = new();
+ DrawningSimpleBus drawningSimpleBus;
+ switch (type)
+ {
+ case nameof(DrawningSimpleBus):
+ drawningSimpleBus = new DrawningSimpleBus(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
+ break;
+ case nameof(DrawningBus):
+ // вызов диалогового окна для выбора цвета
+ drawningSimpleBus = new DrawningBus(random.Next(100, 300), random.Next(1000, 3000),
+ GetColor(random),
+ GetColor(random),
+ Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+
+ if (_company + drawningSimpleBus != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ _ = MessageBox.Show(drawningSimpleBus.ToString());
+ }
+ }
+
+ ///
+ /// Получение цвета
+ ///
+ /// Генератор случайных чисел
+ ///
+ private static Color GetColor(Random random)
+ {
+ 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;
+ }
+
+ return color;
+ }
+
+ ///
+ /// Удаление объекта
+ ///
+ ///
+ ///
+ private void buttonDelBus_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
+ {
+ return;
+ }
+
+ if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ return;
+ }
+
+ int pos = Convert.ToInt32(maskedTextBox.Text);
+ if (_company - pos != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+
+ }
+
+ ///
+ /// Перерисовка коллекции
+ ///
+ ///
+ ///
+ private void ButtonRefresh_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ pictureBox.Image = _company.Show();
+
+ }
+
+ ///
+ /// Передача объекта в другую форму
+ ///
+ ///
+ ///
+ private void ButtonGoToCheck_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ DrawningSimpleBus? simplebus = null;
+ int counter = 100;
+ while (simplebus == null)
+ {
+ simplebus = _company.GetRandomObject();
+ counter--;
+ if (counter <= 0)
+ {
+ break;
+ }
+ }
+
+ if (simplebus == null)
+ {
+ return;
+ }
+
+ FormBus form = new()
+ {
+ SetSimpleBus = simplebus
+ };
+ form.ShowDialog();
+
+ }
+
+ ///
+ /// Добавление коллекции
+ ///
+ ///
+ ///
+ private void ButtonCollectionAdd_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
+ {
+ MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ CollectionType collectionType = CollectionType.None;
+ if (radioButtonMassive.Checked)
+ {
+ collectionType = CollectionType.Massive;
+ }
+ else if (radioButtonList.Checked)
+ {
+ collectionType = CollectionType.List;
+ }
+
+ _storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
+ RerfreshListBoxItems();
+
+ }
+
+ ///
+ /// Удаление коллекции
+ ///
+ ///
+ ///
+ private void ButtonCollectionDel_Click(object sender, EventArgs e)
+ {
+ if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+ if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ return;
+ }
+ _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
+ RerfreshListBoxItems();
+
+ }
+
+ ///
+ /// Обновление списка в listBoxCollection
+ ///
+ private void RerfreshListBoxItems()
+ {
+ listBoxCollection.Items.Clear();
+ for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
+ {
+ string? colName = _storageCollection.Keys?[i];
+ if (!string.IsNullOrEmpty(colName))
+ {
+ listBoxCollection.Items.Add(colName);
+ }
+ }
+
+ }
+
+ ///
+ /// Создание компании
+ ///
+ ///
+ ///
+ private void ButtonCreateCompany_Click(object sender, EventArgs e)
+ {
+ if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+
+ ICollectionGenericObjects? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
+ if (collection == null)
+ {
+ MessageBox.Show("Коллекция не проинициализирована");
+ return;
+ }
+
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "хранилище":
+ _company = new BusStation(pictureBox.Width, pictureBox.Height, collection);
+ break;
+ }
+
+ panelCompanyTools.Enabled = true;
+ RerfreshListBoxItems();
+ }
+
+
+
+}
+
+
+
+
+
diff --git a/lab_0/FormSimpleBusCollection.resx b/lab_0/FormSimpleBusCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/lab_0/FormSimpleBusCollection.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/lab_0/MovementStrategy/AbstractStrategy.cs b/lab_0/MovementStrategy/AbstractStrategy.cs
new file mode 100644
index 0000000..aeb8914
--- /dev/null
+++ b/lab_0/MovementStrategy/AbstractStrategy.cs
@@ -0,0 +1,139 @@
+namespace ProjectBus.MovementStrategy;
+
+///
+/// Класс-стратегия перемещения объекта
+///
+public abstract class AbstractStrategy
+{
+ ///
+ /// Перемещаемый объект
+ ///
+ private IMoveableObject? _moveableObject;
+
+ ///
+ /// Статус перемещения
+ ///
+ private StrategyStatus _state = StrategyStatus.NotInit;
+
+ ///
+ /// Ширина поля
+ ///
+ protected int FieldWidth { get; private set; }
+
+ ///
+ /// Высота поля
+ ///
+ protected int FieldHeight { get; private set; }
+
+ ///
+ /// Статус перемещения
+ ///
+ public StrategyStatus GetStatus() { return _state; }
+
+ ///
+ /// Установка данных
+ ///
+ /// Перемещаемый объект
+ /// Ширина поля
+ /// Высота поля
+ public void SetData(IMoveableObject moveableObject, int width, int height)
+ {
+ if (moveableObject == null)
+ {
+ _state = StrategyStatus.NotInit;
+ return;
+ }
+
+ _state = StrategyStatus.InProgress;
+ _moveableObject = moveableObject;
+ FieldWidth = width;
+ FieldHeight = height;
+ }
+
+ ///
+ /// Шаг перемещения
+ ///
+ public void MakeStep()
+ {
+ if (_state != StrategyStatus.InProgress)
+ {
+ return;
+ }
+
+ if (IsTargetDestinaion())
+ {
+ _state = StrategyStatus.Finish;
+ return;
+ }
+
+ MoveToTarget();
+ }
+
+ ///
+ /// Перемещение влево
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveLeft() => MoveTo(MovementDirection.Left);
+
+ ///
+ /// Перемещение вправо
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveRight() => MoveTo(MovementDirection.Right);
+
+ ///
+ /// Перемещение вверх
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveUp() => MoveTo(MovementDirection.Up);
+
+ ///
+ /// Перемещение вниз
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveDown() => MoveTo(MovementDirection.Down);
+
+ ///
+ /// Параметры объекта
+ ///
+ protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
+
+ ///
+ /// Шаг объекта
+ ///
+ ///
+ protected int? GetStep()
+ {
+ if (_state != StrategyStatus.InProgress)
+ {
+ return null;
+ }
+ return _moveableObject?.GetStep;
+ }
+
+ ///
+ /// Перемещение к цели
+ ///
+ protected abstract void MoveToTarget();
+
+ ///
+ /// Достигнута ли цель
+ ///
+ ///
+ protected abstract bool IsTargetDestinaion();
+
+ ///
+ /// Попытка перемещения в требуемом направлении
+ ///
+ /// Направление
+ /// Результат попытки (true - удалось переместиться, false - неудача)
+ private bool MoveTo(MovementDirection movementDirection)
+ {
+ if (_state != StrategyStatus.InProgress)
+ {
+ return false;
+ }
+
+ return _moveableObject?.TryMoveObject(movementDirection) ?? false;
+ }
+}
\ No newline at end of file
diff --git a/lab_0/MovementStrategy/IMoveableObject.cs b/lab_0/MovementStrategy/IMoveableObject.cs
new file mode 100644
index 0000000..6b7c9e4
--- /dev/null
+++ b/lab_0/MovementStrategy/IMoveableObject.cs
@@ -0,0 +1,24 @@
+namespace ProjectBus.MovementStrategy;
+
+///
+/// Интерфейс для работы с перемещаемым объектом
+///
+public interface IMoveableObject
+{
+ ///
+ /// Получение координаты объекта
+ ///
+ ObjectParameters? GetObjectPosition { get; }
+
+ ///
+ /// Шаг объекта
+ ///
+ int GetStep { get; }
+
+ ///
+ /// Попытка переместить объект в указанном направлении
+ ///
+ /// Направление
+ /// true - объект перемещен, false - перемещение невозможно
+ bool TryMoveObject(MovementDirection direction);
+}
diff --git a/lab_0/MovementStrategy/MoveToBorder.cs b/lab_0/MovementStrategy/MoveToBorder.cs
new file mode 100644
index 0000000..6323474
--- /dev/null
+++ b/lab_0/MovementStrategy/MoveToBorder.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBus.MovementStrategy;
+public class MoveToBorder : AbstractStrategy
+{
+ protected override bool IsTargetDestinaion()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return false;
+ }
+ return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth
+ && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth &&
+ objParams.ObjectMiddleVertical - GetStep() <= FieldHeight
+ && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight;
+ }
+
+ protected override void MoveToTarget()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return;
+ }
+ int diffX = objParams.ObjectMiddleHorizontal - FieldWidth;
+ if (Math.Abs(diffX) > GetStep())
+ {
+ if (diffX > 0)
+ {
+ MoveLeft();
+ }
+ else
+ {
+ MoveRight();
+ }
+ }
+ int diffY = objParams.ObjectMiddleVertical - FieldHeight;
+ if (Math.Abs(diffY) > GetStep())
+ {
+ if (diffY > 0)
+ {
+ MoveUp();
+ }
+ else
+ {
+ MoveDown();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/lab_0/MovementStrategy/MoveToCenter.cs b/lab_0/MovementStrategy/MoveToCenter.cs
new file mode 100644
index 0000000..59df3bb
--- /dev/null
+++ b/lab_0/MovementStrategy/MoveToCenter.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBus.MovementStrategy;
+
+public class MoveToCenter : AbstractStrategy
+{
+ protected override bool IsTargetDestinaion()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return false;
+ }
+ return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2
+ && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
+ objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2
+ && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
+ }
+ protected override void MoveToTarget()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return;
+ }
+ int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
+ if (Math.Abs(diffX) > GetStep())
+ {
+ if (diffX > 0)
+ {
+ MoveLeft();
+ }
+ else
+ {
+ MoveRight();
+ }
+ }
+ int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
+ if (Math.Abs(diffY) > GetStep())
+ {
+ if (diffY > 0)
+ {
+ MoveUp();
+ }
+ else
+ {
+ MoveDown();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/lab_0/MovementStrategy/MoveableSimpleBus.cs b/lab_0/MovementStrategy/MoveableSimpleBus.cs
new file mode 100644
index 0000000..3c83c2c
--- /dev/null
+++ b/lab_0/MovementStrategy/MoveableSimpleBus.cs
@@ -0,0 +1,66 @@
+using ProjectBus.Drawnings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBus.MovementStrategy;
+
+///
+/// Класс-реализация IMoveableObject с использованием DrawingSimpleBus
+///
+
+public class MoveableSimpleBus : IMoveableObject
+{
+ //
+ /// Поле-объект класса DrawningTrans или его наследника
+ ///
+ private readonly DrawningSimpleBus? _simplebus = null;
+
+ ///
+ /// Конструктор
+ ///
+ /// Объект класса DrawningSimpleBus
+ public MoveableSimpleBus(DrawningSimpleBus simplebus)
+ {
+ _simplebus = simplebus;
+ }
+
+ public ObjectParameters? GetObjectPosition
+ {
+ get
+ {
+ if (_simplebus == null || _simplebus.EntitySimpleBus == null || !_simplebus.GetPosX.HasValue || !_simplebus.GetPosY.HasValue)
+ {
+ return null;
+ }
+ return new ObjectParameters(_simplebus.GetPosX.Value, _simplebus.GetPosY.Value, _simplebus.GetWidth, _simplebus.GetHeight);
+ }
+ }
+ public int GetStep => (int)(_simplebus?.EntitySimpleBus ?.Step ?? 0);
+ public bool TryMoveObject(MovementDirection direction)
+ {
+ if (_simplebus == null || _simplebus.EntitySimpleBus == null)
+ {
+ return false;
+ }
+ return _simplebus.MoveTransport(GetDirectionType(direction));
+ }
+ ///
+ /// Конвертация из MovementDirection в DirectionType
+ ///
+ /// MovementDirection
+ /// DirectionType
+ private static DirectionType GetDirectionType(MovementDirection direction)
+ {
+ return direction switch
+ {
+ MovementDirection.Left => DirectionType.Left,
+ MovementDirection.Right => DirectionType.Right,
+ MovementDirection.Up => DirectionType.Up,
+ MovementDirection.Down => DirectionType.Down,
+ _ => DirectionType.Unknow,
+ };
+ }
+}
diff --git a/lab_0/MovementStrategy/MovementDirection.cs b/lab_0/MovementStrategy/MovementDirection.cs
new file mode 100644
index 0000000..593381a
--- /dev/null
+++ b/lab_0/MovementStrategy/MovementDirection.cs
@@ -0,0 +1,28 @@
+namespace ProjectBus.MovementStrategy;
+
+///
+/// Направление перемещения
+///
+public enum MovementDirection
+{
+ ///
+ /// Неизвестное направление
+ ///
+ Unknow = -1,
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+ ///
+ /// Влево
+ ///
+ Left = 3,
+ ///
+ /// Вправо
+ ///
+ Right = 4
+}
diff --git a/lab_0/MovementStrategy/ObjectParameters.cs b/lab_0/MovementStrategy/ObjectParameters.cs
new file mode 100644
index 0000000..5d99dbb
--- /dev/null
+++ b/lab_0/MovementStrategy/ObjectParameters.cs
@@ -0,0 +1,72 @@
+namespace ProjectBus.MovementStrategy;
+
+///
+/// Параметры-координаты объекта
+///
+public class ObjectParameters
+{
+ ///
+ /// Координата X
+ ///
+ private readonly int _x;
+
+ ///
+ /// Координата Y
+ ///
+ private readonly int _y;
+
+ ///
+ /// Ширина объекта
+ ///
+ private readonly int _width;
+
+ ///
+ /// Высота объекта
+ ///
+ private readonly int _height;
+
+ ///
+ /// Левая граница
+ ///
+ public int LeftBorder => _x;
+
+ ///
+ /// Верхняя граница
+ ///
+ public int TopBorder => _y;
+
+ ///
+ /// Правая граница
+ ///
+ public int RightBorder => _x + _width;
+
+ ///
+ /// Нижняя граница
+ ///
+ public int DownBorder => _y + _height;
+
+ ///
+ /// Середина объекта
+ ///
+ public int ObjectMiddleHorizontal => _x + _width / 2;
+
+ ///
+ /// Середина объекта
+ ///
+ public int ObjectMiddleVertical => _y + _height / 2;
+
+ ///
+ /// Конструктор
+ ///
+ /// Координата X
+ /// Координата Y
+ /// Ширина объекта
+ /// Высота объекта
+ public ObjectParameters(int x, int y, int width, int height)
+ {
+ _x = x;
+ _y = y;
+ _width = width;
+ _height = height;
+ }
+}
diff --git a/lab_0/MovementStrategy/StrategyStatus.cs b/lab_0/MovementStrategy/StrategyStatus.cs
new file mode 100644
index 0000000..42abe03
--- /dev/null
+++ b/lab_0/MovementStrategy/StrategyStatus.cs
@@ -0,0 +1,22 @@
+namespace ProjectBus.MovementStrategy;
+
+///
+/// Статус выполнения операции перемещения
+///
+public enum StrategyStatus
+{
+ ///
+ /// Все готово к началу
+ ///
+ NotInit,
+
+ ///
+ /// Выполняется
+ ///
+ InProgress,
+
+ ///
+ /// Завершено
+ ///
+ Finish
+}
\ No newline at end of file
diff --git a/lab_0/Program.cs b/lab_0/Program.cs
index 4536664..beb3124 100644
--- a/lab_0/Program.cs
+++ b/lab_0/Program.cs
@@ -1,3 +1,5 @@
+using ProjectBus;
+
namespace lab_0
{
internal static class Program
@@ -11,7 +13,7 @@ namespace lab_0
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ Application.Run(new FormSimpleBusCollection());
}
}
}
\ No newline at end of file
diff --git a/lab_0/ProjectBus.csproj b/lab_0/ProjectBus.csproj
new file mode 100644
index 0000000..244387d
--- /dev/null
+++ b/lab_0/ProjectBus.csproj
@@ -0,0 +1,26 @@
+
+
+
+ WinExe
+ net7.0-windows
+ enable
+ true
+ enable
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
\ No newline at end of file
diff --git a/lab_0/Properties/Resources.Designer.cs b/lab_0/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..9fa5a26
--- /dev/null
+++ b/lab_0/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace ProjectBus.Properties {
+ using System;
+
+
+ ///
+ /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
+ ///
+ // Этот класс создан автоматически классом 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() {
+ }
+
+ ///
+ /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
+ ///
+ [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("ProjectBus.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Перезаписывает свойство CurrentUICulture текущего потока для всех
+ /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowDown {
+ get {
+ object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowLeft {
+ get {
+ object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowRight {
+ get {
+ object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowUp {
+ get {
+ object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/lab_0/Properties/Resources.resx b/lab_0/Properties/Resources.resx
new file mode 100644
index 0000000..369dce5
--- /dev/null
+++ b/lab_0/Properties/Resources.resx
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\Resources\arrowUp.jpeg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\arrowRight.jpeg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\arrowLeft.jpeg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\arrowDown.jpeg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/lab_0/Resources/arrowDown.jpeg b/lab_0/Resources/arrowDown.jpeg
new file mode 100644
index 0000000..dc51ade
Binary files /dev/null and b/lab_0/Resources/arrowDown.jpeg differ
diff --git a/lab_0/Resources/arrowLeft.jpeg b/lab_0/Resources/arrowLeft.jpeg
new file mode 100644
index 0000000..1569857
Binary files /dev/null and b/lab_0/Resources/arrowLeft.jpeg differ
diff --git a/lab_0/Resources/arrowRight.jpeg b/lab_0/Resources/arrowRight.jpeg
new file mode 100644
index 0000000..2257a1c
Binary files /dev/null and b/lab_0/Resources/arrowRight.jpeg differ
diff --git a/lab_0/Resources/arrowUp.jpeg b/lab_0/Resources/arrowUp.jpeg
new file mode 100644
index 0000000..11e8323
Binary files /dev/null and b/lab_0/Resources/arrowUp.jpeg differ
diff --git a/lab_0/lab_0.csproj b/lab_0/lab_0.csproj
deleted file mode 100644
index e1a0735..0000000
--- a/lab_0/lab_0.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- WinExe
- net7.0-windows
- enable
- true
- enable
-
-
-
\ No newline at end of file
diff --git a/lab_0/lab_0.sln b/lab_0/lab_0.sln
index 6e03fb8..27b89b0 100644
--- a/lab_0/lab_0.sln
+++ b/lab_0/lab_0.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab_0", "lab_0.csproj", "{7F126B40-AEDE-40A9-840E-4158D2218B6F}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectBus", "ProjectBus.csproj", "{7F126B40-AEDE-40A9-840E-4158D2218B6F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/кнопки/arrowDown.jpeg b/кнопки/arrowDown.jpeg
new file mode 100644
index 0000000..dc51ade
Binary files /dev/null and b/кнопки/arrowDown.jpeg differ
diff --git a/кнопки/arrowLeft.jpeg b/кнопки/arrowLeft.jpeg
new file mode 100644
index 0000000..1569857
Binary files /dev/null and b/кнопки/arrowLeft.jpeg differ
diff --git a/кнопки/arrowRight.jpeg b/кнопки/arrowRight.jpeg
new file mode 100644
index 0000000..2257a1c
Binary files /dev/null and b/кнопки/arrowRight.jpeg differ
diff --git a/кнопки/arrowUp.jpeg b/кнопки/arrowUp.jpeg
new file mode 100644
index 0000000..11e8323
Binary files /dev/null and b/кнопки/arrowUp.jpeg differ