55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using ProjectElectroTrans.Drawnings;
|
|
using ProjectElectroTrans.Entities;
|
|
using System;
|
|
|
|
namespace ProjectElectroTrans.CollectionGenericObjects;
|
|
|
|
/// <summary>
|
|
/// Реализация абстрактной компании - аренда поезда
|
|
/// </summary>
|
|
public class TransDepoService : AbstractCompany
|
|
{
|
|
/// <summary>
|
|
/// Конструктор
|
|
/// </summary>
|
|
/// <param name="picWidth"></param>
|
|
/// <param name="picHeight"></param>
|
|
/// <param name="collection"></param>
|
|
public TransDepoService(int picWidth, int picHeight, ICollectionGenericObjects<DrawingTrans> 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++)
|
|
{
|
|
DrawingTrans? drawingTrans = _collection?.Get(n);
|
|
n++;
|
|
if (drawingTrans != null)
|
|
{
|
|
drawingTrans.SetPictureSize(_pictureWidth, _pictureHeight);
|
|
drawingTrans.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |