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); } } } } }