74 lines
2.3 KiB
C#
74 lines
2.3 KiB
C#
using ProjectElectricLocomotive.Drawnings;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ProjectElectricLocomotive.CollectionGenericObjects;
|
|
|
|
public class LocomotiveDepo : AbstractCompany
|
|
{
|
|
public LocomotiveDepo(int picWidth, int picHeight, ICollectionGenericObjects<DrawningLocomotive> collection) : base(picWidth, picHeight, collection)
|
|
{
|
|
}
|
|
|
|
protected override void DrawBackgound(Graphics g)
|
|
{
|
|
Pen steel = new Pen(Color.Gray);
|
|
Pen wood = new Pen(Color.Brown);
|
|
g.DrawRectangle(steel,0, _pictureHeight - 50,_pictureWidth,40 );
|
|
for(int i = 0; i < _pictureWidth; i += 20)
|
|
{
|
|
g.DrawLine(wood, i, _pictureHeight - 50, i + 10, _pictureHeight - 10);
|
|
g.DrawLine(wood, i, _pictureHeight - 190, i + 10, _pictureHeight - 150);
|
|
g.DrawLine(wood, i, _pictureHeight - 325, i + 10, _pictureHeight - 285);
|
|
|
|
}
|
|
g.DrawRectangle(steel, 0, _pictureHeight - 190, _pictureWidth, 40);
|
|
g.DrawRectangle(steel, 0, _pictureHeight - 325, _pictureWidth, 40);
|
|
|
|
//g.DrawRectangle(steel, 0, _pictureHeight - 40, _pictureWidth, 1000);
|
|
|
|
}
|
|
|
|
protected override void SetObjectsPosition()
|
|
{
|
|
|
|
|
|
int width = _pictureWidth / _placeSizeWidth;
|
|
int height = _pictureHeight / _placeSizeHeight;
|
|
int positionWidth = 0;
|
|
int positionHeight = height;
|
|
|
|
if (_collection?.Count != null)
|
|
{
|
|
for (int i = 0; i < (_collection.Count); i++)
|
|
{
|
|
try
|
|
{
|
|
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
|
|
_collection.Get(i).SetPosition(_placeSizeWidth * positionWidth + 25, positionHeight * _placeSizeHeight + 10);
|
|
}
|
|
catch (Exception) { }
|
|
|
|
if (positionWidth < width - 1)
|
|
{
|
|
positionWidth++;
|
|
}
|
|
|
|
else
|
|
{
|
|
positionWidth = 0;
|
|
positionHeight--;
|
|
}
|
|
if (positionHeight < 0)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|