Практически доделанная Лаб работа 03

This commit is contained in:
alhimek17 2024-03-24 19:22:18 +04:00
parent 9c244adfba
commit 2bec551f18
3 changed files with 42 additions and 5 deletions

View File

@ -7,11 +7,11 @@ public abstract class AbstractCompany
/// <summary> /// <summary>
/// Размер места (ширина) /// Размер места (ширина)
/// </summary> /// </summary>
protected readonly int _placeSizeWidth = 210; protected readonly int _placeSizeWidth = 195;
/// <summary> /// <summary>
/// Размер места (высота) /// Размер места (высота)
/// </summary> /// </summary>
protected readonly int _placeSizeHeight = 80; protected readonly int _placeSizeHeight = 70;
/// <summary> /// <summary>
/// Ширина окна /// Ширина окна
/// </summary> /// </summary>

View File

@ -11,11 +11,48 @@ public class PlaneSharigService : AbstractCompany
protected override void DrawBackgound(Graphics g) protected override void DrawBackgound(Graphics g)
{ {
throw new NotImplementedException();
Pen pen = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth, j *
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
_placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
} }
protected override void SetObjectsPosition() protected override void SetObjectsPosition()
{ {
throw new NotImplementedException(); int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
int curWidth = width - 1;
int curHeight = 0;
for (int i = 0; i < (_collection?.Count ?? 0); i++)
{
if (_collection.Get(i) != null)
{
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 20, curHeight * _placeSizeHeight + 4);
}
if (curWidth > 0)
curWidth--;
else
{
curWidth = width - 1;
curHeight++;
}
if (curHeight > height)
{
return;
}
}
} }
} }

View File

@ -118,7 +118,7 @@
buttonAddPlane.Name = "buttonAddPlane"; buttonAddPlane.Name = "buttonAddPlane";
buttonAddPlane.Size = new Size(186, 50); buttonAddPlane.Size = new Size(186, 50);
buttonAddPlane.TabIndex = 1; buttonAddPlane.TabIndex = 1;
buttonAddPlane.Text = "Добавление самолёта"; buttonAddPlane.Text = "Добавление судна";
buttonAddPlane.UseVisualStyleBackColor = true; buttonAddPlane.UseVisualStyleBackColor = true;
buttonAddPlane.Click += ButtonAddPlane_Click; buttonAddPlane.Click += ButtonAddPlane_Click;
// //