2024-06-13 00:05:05 +04:00
|
|
|
|
using ProjectCruiser.DrawningSamples;
|
2024-06-15 09:05:36 +04:00
|
|
|
|
namespace ProjectCruiser.CollectionGenericObj;
|
2024-06-13 00:05:05 +04:00
|
|
|
|
|
|
|
|
|
public class ShipSharingService : AbstractCompany
|
|
|
|
|
{
|
|
|
|
|
protected int MaxInRow { get; private set; }
|
|
|
|
|
protected int MaxInColon { get; private set; }
|
|
|
|
|
|
|
|
|
|
private int fromBorder = 20, fromCeiling = 20, between = 30;
|
|
|
|
|
|
|
|
|
|
public ShipSharingService(int picWidth, int picHeight,
|
|
|
|
|
ICollectionGenObj<DrawningBase> collection)
|
|
|
|
|
: base(picWidth, picHeight, collection)
|
|
|
|
|
{
|
|
|
|
|
MaxInRow = (picWidth - fromBorder - fromCeiling)
|
|
|
|
|
/ (_placeSizeWidth + between);
|
|
|
|
|
MaxInColon = (picHeight - fromBorder - fromCeiling)
|
|
|
|
|
/ _placeSizeHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void DrawBackground(Graphics g)
|
|
|
|
|
{
|
|
|
|
|
Pen pen = new(Color.Black, 2);
|
|
|
|
|
|
2024-06-13 10:57:01 +04:00
|
|
|
|
int currentH = fromCeiling, currentW = fromBorder;
|
2024-06-13 00:05:05 +04:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < MaxInRow; i++)
|
|
|
|
|
{
|
2024-06-13 10:57:01 +04:00
|
|
|
|
currentH = fromCeiling;
|
2024-06-13 00:05:05 +04:00
|
|
|
|
for (int j = 0; j < MaxInColon; j++)
|
|
|
|
|
{
|
2024-06-13 10:57:01 +04:00
|
|
|
|
g.DrawLine(pen, currentW + _placeSizeWidth,
|
|
|
|
|
currentH, currentW, currentH);
|
|
|
|
|
|
|
|
|
|
g.DrawLine(pen, currentW, currentH,
|
|
|
|
|
currentW, currentH + _placeSizeHeight);
|
2024-06-13 00:05:05 +04:00
|
|
|
|
|
|
|
|
|
currentH += _placeSizeHeight + 1;
|
|
|
|
|
}
|
|
|
|
|
currentW += _placeSizeWidth + between;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-16 19:46:37 +04:00
|
|
|
|
protected override void SetObjectsPosition(int border)
|
2024-06-13 00:05:05 +04:00
|
|
|
|
{
|
|
|
|
|
int index_collection = 0;
|
2024-06-16 19:46:37 +04:00
|
|
|
|
int newY = fromCeiling + 4;
|
2024-06-13 00:05:05 +04:00
|
|
|
|
|
|
|
|
|
if (_collection != null)
|
|
|
|
|
{
|
2024-06-16 19:46:37 +04:00
|
|
|
|
for (int i = 0; i < MaxInColon; i++)
|
2024-06-13 00:05:05 +04:00
|
|
|
|
{
|
2024-06-16 19:46:37 +04:00
|
|
|
|
int newX = fromBorder + 2;
|
|
|
|
|
for (int j = 0; j < MaxInRow; j++)
|
2024-06-13 00:05:05 +04:00
|
|
|
|
{
|
2024-06-16 19:46:37 +04:00
|
|
|
|
// TRY / CATCH [?]
|
|
|
|
|
_collection.GetItem(index_collection).SetPictureSize(
|
|
|
|
|
_pictureWidth, _pictureHeight);
|
|
|
|
|
|
|
|
|
|
_collection.GetItem(index_collection).SetPosition(newX, newY);
|
|
|
|
|
|
|
|
|
|
newX += _placeSizeWidth + between + 2;
|
|
|
|
|
|
|
|
|
|
if (index_collection < border)
|
2024-06-13 00:05:05 +04:00
|
|
|
|
{
|
|
|
|
|
index_collection++;
|
|
|
|
|
}
|
2024-06-16 19:46:37 +04:00
|
|
|
|
else return;
|
2024-06-13 00:05:05 +04:00
|
|
|
|
}
|
2024-06-16 19:46:37 +04:00
|
|
|
|
newY += _placeSizeHeight + 1;
|
2024-06-13 00:05:05 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|