отрисовка

This commit is contained in:
pnevmoslon1 2024-04-23 01:55:46 +04:00
parent 37b09eeac5
commit 80ef61aef3
4 changed files with 27 additions and 15 deletions

View File

@ -9,7 +9,7 @@ public abstract class AbstractCompany
protected readonly int _placeSizeWidth = 150;
protected readonly int _placeSizeHeight = 80;
protected readonly int _placeSizeHeight = 85;
protected readonly int _pictureWidth;

View File

@ -36,17 +36,29 @@ namespace WarmlyShip.CollectionGenericObjects
protected override void SetObjectPosition()
{
int countOfHorizontal = _pictureWidth / (_placeSizeWidth + _placeSizeWidth / 2) + 1;
int countOfHorizontal = _pictureWidth / (_placeSizeWidth + _placeSizeWidth / 2);
int countOfVertical = _pictureHeight / _placeSizeHeight;
int countW = 0;
int countH = 0;
for (int i = 1; i < _collection.Count; i++)
{
if (countW == 4)
{
countW = 0;
countH++;
}
if (_collection.Get(i) != null)
{
_collection.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
_collection.Get(i)?.SetPosition((_placeSizeWidth + _placeSizeWidth / 2) * (i % countOfHorizontal - 1) + 5,
_placeSizeHeight * (i / countOfHorizontal - 1) + 5);
_collection.Get(i)?.SetPosition((_placeSizeWidth + _placeSizeWidth / 2) * (countOfHorizontal - countW - 1) + 5, _placeSizeHeight * countH + 5);
}
countW++;
}
}
}

View File

@ -159,23 +159,23 @@ public class DrawningShip
Point[] points = new Point[]
{
new Point(_startPosX.Value, _startPosY.Value+20),
new Point(_startPosX.Value + 150, _startPosY.Value+ 20),
new Point(_startPosX.Value + 120, _startPosY.Value + 50),
new Point(_startPosX.Value + 30, _startPosY.Value + 50)
new Point(_startPosX.Value, _startPosY.Value+50),
new Point(_startPosX.Value + 150, _startPosY.Value+ 50),
new Point(_startPosX.Value + 120, _startPosY.Value + 80),
new Point(_startPosX.Value + 30, _startPosY.Value + 80)
};
g.FillPolygon(brMain, points);
g.DrawPolygon(pen, points);
//палуба
g.FillRectangle(brMain, _startPosX.Value + 25, _startPosY.Value, 100, 20);
g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value, 100, 20);
g.FillRectangle(brMain, _startPosX.Value + 25, _startPosY.Value + 30, 100, 20);
g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value + 30, 100, 20);
//якорь
g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 23, _startPosX.Value + 30, _startPosY.Value + 40);
g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 40, _startPosX.Value + 37, _startPosY.Value + 40);
g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 30, _startPosX.Value + 37, _startPosY.Value + 30);
g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 53, _startPosX.Value + 30, _startPosY.Value + 70);
g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 70, _startPosX.Value + 37, _startPosY.Value + 70);
g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 60, _startPosX.Value + 37, _startPosY.Value + 60);

View File

@ -23,9 +23,9 @@ namespace WarmlyShip.Drawnings
return;
}
_startPosY += 30;
base.DrawTransport(g);
_startPosY -= 30;