Доработка LabWork01
This commit is contained in:
parent
3d11a5e049
commit
afb87d1e2f
@ -38,12 +38,12 @@ public class DrawingAirbus
|
||||
/// <summary>
|
||||
/// Ширина прорисовки самолета(аэробуса)
|
||||
/// </summary>
|
||||
private readonly int _drawingCarWidth = 130;
|
||||
private readonly int _drawingAirbusWidth = 130;
|
||||
|
||||
/// <summary>
|
||||
/// Высота прорисовки самолета(аэробуса)
|
||||
/// </summary>
|
||||
private readonly int _drawingCarHeight = 60;
|
||||
private readonly int _drawingAirbusHeight = 60;
|
||||
|
||||
|
||||
|
||||
@ -56,8 +56,8 @@ public class DrawingAirbus
|
||||
/// <param name="weight">Вес самолета</param>
|
||||
/// <param name="bodyAirbus">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="bodySection">ПРизнак наличия отсека</param>
|
||||
/// <param name="motor">ПРизнак наличия дополнительных двигателей</param>
|
||||
/// <param name="bodySection">Признак наличия отсека</param>
|
||||
/// <param name="motor">Признак наличия дополнительных двигателей</param>
|
||||
public void Init(int speed, double weight, Color bodyAirbus, Color additionalColor, bool bodySection, bool motor)
|
||||
{
|
||||
EntityAirbus = new EntityAirbus();
|
||||
@ -78,9 +78,31 @@ public class DrawingAirbus
|
||||
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
||||
public bool SetPictureSize(int wigth, int height)
|
||||
{
|
||||
_pictureWidth = wigth;
|
||||
_pictureHeight = height;
|
||||
|
||||
if(wigth < _drawingAirbusWidth || height < _drawingAirbusHeight) { return false; };
|
||||
_pictureWidth = wigth;
|
||||
_pictureHeight = height;
|
||||
if(_startPosX !=null || _startPosY != null)
|
||||
{
|
||||
if(_startPosX + _drawingAirbusWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = -_drawingAirbusWidth + _pictureWidth;
|
||||
}
|
||||
else if(_startPosX < 0)
|
||||
{
|
||||
_startPosX = 0;
|
||||
}
|
||||
if(_startPosY + _drawingAirbusHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = - _drawingAirbusHeight + _pictureHeight;
|
||||
}
|
||||
else if(_startPosY < 0)
|
||||
{
|
||||
_startPosY = 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -95,8 +117,33 @@ public class DrawingAirbus
|
||||
{
|
||||
return;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
|
||||
if (x+_drawingAirbusWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _pictureWidth - _drawingAirbusWidth;
|
||||
}
|
||||
else if(x < 0)
|
||||
{
|
||||
_startPosX = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosX = x;
|
||||
}
|
||||
|
||||
if(y + _drawingAirbusHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = _pictureHeight - _drawingAirbusHeight;
|
||||
}
|
||||
else if(y < 0)
|
||||
{
|
||||
_startPosY = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_startPosY = y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -119,13 +166,13 @@ public class DrawingAirbus
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + _drawingCarWidth + EntityAirbus.step < _pictureWidth)
|
||||
if (_startPosX.Value + _drawingAirbusWidth + EntityAirbus.step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityAirbus.step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + _drawingCarHeight + EntityAirbus.step < _pictureHeight)
|
||||
if (_startPosY.Value + _drawingAirbusHeight + EntityAirbus.step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityAirbus.step;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user