57 lines
2.0 KiB
C#
57 lines
2.0 KiB
C#
|
using ProjectBus.Drawnings;
|
|||
|
using ProjectBus.Entities;
|
|||
|
using System;
|
|||
|
|
|||
|
namespace ProjectBus.CollectionGenericObject;
|
|||
|
/// <summary>
|
|||
|
/// Реализация абстрактной компании - аренда поезда
|
|||
|
/// </summary>
|
|||
|
public class BusStation : AbstractCompany
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Конструктор
|
|||
|
/// </summary>
|
|||
|
/// <param name="picWidth"></param>
|
|||
|
/// <param name="picHeight"></param>
|
|||
|
/// <param name="collection"></param>
|
|||
|
public BusStation(int picWidth, int picHeight, ICollectionGenericObjects<DrawningSimpleBus> 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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|