This commit is contained in:
Baryshev Dmitry 2024-03-20 14:58:40 +04:00
parent ceca79942a
commit 1490a99c0f
2 changed files with 42 additions and 3 deletions

View File

@ -15,11 +15,50 @@ public class Autopark : AbstractCompany
protected override void DrawBackgound(Graphics g) protected override void DrawBackgound(Graphics g)
{ {
throw new NotImplementedException(); Pen pen = new(Color.Black, 2);
Pen widerPen = new(Color.Black, 5);
for (int i = 0; i < _pictureHeight / _placeSizeHeight; i++)
{
int y = _placeSizeHeight;
y *= i;
for (int j = 0; j <= _pictureWidth / _placeSizeWidth; j++)
{
int x = _placeSizeWidth;
x *= j;
g.DrawLine(widerPen, x, y, x + _placeSizeWidth / 2, y);
g.DrawLine(widerPen, x, y + _placeSizeHeight - 10, x + _placeSizeWidth / 2, y + _placeSizeHeight - 10);
g.DrawLine(pen, x, y, x, y + _placeSizeHeight - 10);
g.DrawLine(pen, x + _placeSizeWidth / 2, y, x + _placeSizeWidth / 2, y + _placeSizeHeight - 10);
}
}
} }
protected override void SetObjectsPosition() protected override void SetObjectsPosition()
{ {
throw new NotImplementedException(); int n = 0;
int m = 0;
for (int i = 0; i < (_collection?.Count ?? 0); i++)
{
if (_collection?.Get(i) != null)
{
int x = 5 + _placeSizeWidth * n;
int y = (10 + _placeSizeHeight * (_pictureHeight / _placeSizeHeight - 1)) - _placeSizeHeight * m;
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
_collection?.Get(i)?.SetPosition(x, y);
}
if (n < _pictureWidth / _placeSizeWidth)
n++;
else
{
n = 0;
m++;
}
}
} }
} }

View File

@ -64,7 +64,7 @@ public partial class FormTruckCollection : Form
case nameof(DrawningDumpTruck): case nameof(DrawningDumpTruck):
drawningTruck = new DrawningDumpTruck(random.Next(100, 300), random.Next(1000, 3000), drawningTruck = new DrawningDumpTruck(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), GetColor(random),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break; break;