63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using DoubleDeckerBus.Drawnings;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DoubleDeckerBus.CollectionGenericObjects;
|
|
|
|
public class BusStation : AbstractCompany
|
|
{
|
|
|
|
private int[]? _arrayOfCoordinates;
|
|
|
|
public BusStation(int picWidth, int picHeight, ICollectionGenericObjects<DrawingBus> collection) : base(picWidth, picHeight, collection)
|
|
{
|
|
}
|
|
|
|
protected override void DrawBackground(Graphics g)
|
|
{
|
|
Pen pen = new Pen(Color.Black, 3);
|
|
|
|
int gap = 15;
|
|
int y = gap;
|
|
int size_of_array = 2;
|
|
|
|
while (y + _placeSizeHeight < _pictureHeight - gap)
|
|
{
|
|
int x = _pictureWidth - gap;
|
|
|
|
while (x - _placeSizeWidth > gap)
|
|
{
|
|
g.DrawLine(pen, x, y, x - _placeSizeWidth, y);
|
|
g.DrawLine(pen, x, y, x, y + _placeSizeHeight);
|
|
g.DrawLine(pen, x, y + _placeSizeHeight, x - _placeSizeWidth, y + _placeSizeHeight);
|
|
|
|
Array.Resize(ref _arrayOfCoordinates, size_of_array);
|
|
_arrayOfCoordinates[size_of_array - 2] = x - 120;
|
|
_arrayOfCoordinates[size_of_array - 1] = y + gap;
|
|
|
|
x -= (_placeSizeWidth + (_placeSizeWidth/2));
|
|
size_of_array += 2;
|
|
}
|
|
y += _placeSizeHeight;
|
|
}
|
|
}
|
|
|
|
protected override void SetObjectsPosition()
|
|
{
|
|
if (_arrayOfCoordinates == null || _collection == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (int i = 0, coordinate_index = 0; i < _collection.Count; i++, coordinate_index += 2)
|
|
{
|
|
_collection.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
|
|
_collection.Get(i)?.SetPosition(_arrayOfCoordinates[coordinate_index], _arrayOfCoordinates[coordinate_index + 1]);
|
|
|
|
}
|
|
}
|
|
}
|