2024-03-27 01:48:45 +04:00
|
|
|
|
using ProjectMonorail.CollectionGenericObject;
|
|
|
|
|
using ProjectMonorail.Drawings;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ProjectMonorail.CollectionGenericObjects;
|
|
|
|
|
|
|
|
|
|
public class TrainSharingService : AbstractCompany
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Конструктор
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="picWidth"></param>
|
|
|
|
|
/// <param name="picHeight"></param>
|
|
|
|
|
/// <param name="collection"></param>
|
|
|
|
|
public TrainSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawingTrain> collection) : base(picWidth, picHeight, collection)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void DrawBackground(Graphics g)
|
|
|
|
|
{
|
|
|
|
|
Pen pen = new(Color.Black, 3);
|
|
|
|
|
int posX = 0;
|
|
|
|
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
|
|
|
|
{
|
|
|
|
|
int posY = 0;
|
|
|
|
|
g.DrawLine(pen, posX, posY, posX, posY + _placeSizeHeight * (_pictureHeight / _placeSizeHeight));
|
|
|
|
|
for (int j = 0; j <= _pictureHeight / _placeSizeHeight; j++)
|
|
|
|
|
{
|
|
|
|
|
g.DrawLine(pen, posX, posY, posX + _placeSizeWidth - 30, posY);
|
|
|
|
|
posY += _placeSizeHeight;
|
|
|
|
|
}
|
|
|
|
|
posX += _placeSizeWidth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetObjectsPosition()
|
|
|
|
|
{
|
|
|
|
|
int counter = 0;
|
|
|
|
|
int valPlaceY = _pictureHeight / _placeSizeHeight;
|
2024-03-27 18:41:43 +04:00
|
|
|
|
for (int y = ((valPlaceY - 1) * _placeSizeHeight) + 30; y >= 0; y -= _placeSizeHeight)
|
2024-03-27 01:48:45 +04:00
|
|
|
|
{
|
2024-03-27 18:41:43 +04:00
|
|
|
|
for (int x = 10; x + _placeSizeWidth < _pictureWidth; x += _placeSizeWidth)
|
2024-03-27 01:48:45 +04:00
|
|
|
|
{
|
|
|
|
|
_collection?.Get(counter)?.SetPictureSize(_pictureWidth, _pictureHeight);
|
|
|
|
|
_collection?.Get(counter)?.SetPosition(x, y);
|
|
|
|
|
counter++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|