Лабораторная работа №1
This commit is contained in:
parent
4a17242de7
commit
9e4beecdc6
@ -33,7 +33,7 @@ public class DrawingExcavator
|
||||
/// <summary>
|
||||
/// Ширина прорисовки экскаватора
|
||||
/// </summary>
|
||||
private readonly int _drawningExcavatorWidth = 175;
|
||||
private readonly int _drawningExcavatorWidth = 174;
|
||||
|
||||
/// <summary>
|
||||
/// Высота прорисовки экскаватора
|
||||
@ -69,15 +69,26 @@ public class DrawingExcavator
|
||||
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
||||
public bool SetPictureSize(int width, int height)
|
||||
{
|
||||
|
||||
|
||||
if (_drawningExcavatorWidth < width && _drawningExcavatorHeight < height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_startPosX.HasValue && _startPosY.HasValue)
|
||||
{
|
||||
if (_startPosX+_drawningExcavatorWidth>=_pictureWidth
|
||||
|| _startPosY+_drawningExcavatorHeight>=_pictureHeight)
|
||||
{
|
||||
_startPosX = 0;
|
||||
_startPosY = 0;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
@ -90,16 +101,21 @@ public class DrawingExcavator
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (x > 0 && y > 0 && x + _drawningExcavatorWidth < _pictureWidth && _drawningExcavatorHeight + y < _pictureHeight)
|
||||
if (x + _drawningExcavatorWidth < _pictureWidth && _drawningExcavatorHeight + y < _pictureHeight && x>0 && y>0)
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
else
|
||||
if (x + _drawningExcavatorWidth >_pictureWidth || x < 0)
|
||||
{
|
||||
_startPosX = 10;
|
||||
_startPosY = 10;
|
||||
_startPosX = 0;
|
||||
|
||||
}
|
||||
if (y+_drawningExcavatorHeight > _pictureHeight || y < 0)
|
||||
{
|
||||
_startPosY = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user