2024-05-08 00:49:29 +04:00

52 lines
1.6 KiB
C#

using Tank.Drowings;
namespace Tank.CollectionGenericObjects;
public class TankSharingService : AbstractCompany
{
public TankSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningMachine> collection) : base(picWidth, picHeight, collection)
{
}
protected override void DrawBackgound(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 posX = 0;
int posY = 0;
for (int i = 0; i < _collection?.Count; i++)
{
if (_collection.Get(i) != null)
{
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
_collection?.Get(i)?.SetPosition(posX * _placeSizeWidth + 5, posY * _placeSizeHeight + 5);
}
if (posX < _pictureWidth/_placeSizeWidth - 1)
{
posX++;
}
else
{
posY++;
posX = 0;
}
if (posY > _pictureHeight/_placeSizeHeight) { return; }
}
}
}