Files
ISEbd-11_Sharonov_I.A._Simple/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/PlanePark.cs
2024-05-21 22:03:41 +04:00

68 lines
2.0 KiB
C#

using ProjectSeaplane.Drawnings;
using ProjectSeaplane.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectSeaplane.CollectionGenericObjects;
public class PlanePark : AbstractCompany
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="collection"></param>
public PlanePark(int picWidth, int picHeight, ICollectionGenericObjects<DrawingBasicSeaplane> collection) : base(picWidth, picHeight, collection)
{
}
protected override void DrawBackgound(Graphics g)
{
int width = _pictureWidth - 1;
int height = _pictureHeight / 2;
Pen pen = new(Color.RosyBrown, 3);
g.DrawLine(pen, width, height, 5, height);
g.DrawLine(pen, width, height - 100, 5, height - 100);
Pen pen2 = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth; i+=50)
{
g.DrawLine(pen2, width-i, height - 50, width - (i+30), height -50);
}
}
protected override void SetObjectsPosition()
{
int count = 0;
int megacount = 0;
for (int y = _pictureHeight - 100; y - 50 > 0; y -= 100)
{
megacount++;
if (y < _pictureHeight / 2 && y > (_pictureHeight / 2) - 100)
{
y -= 200;
}
for (int x = _pictureWidth - 200; x - 120 > 0; x -= _placeSizeHeight + 75)
{
if (count < _collection?.Count)
{
try
{
_collection?.Get(count)?.SetPictureSize(_pictureWidth, _pictureHeight);
_collection?.Get(count)?.SetPosition(x, y);
count++;
}
catch (ObjectNotFoundException) { }
}
}
}
}
}