Лабораторная работа 1

This commit is contained in:
Anastasia Yazykova 2024-03-14 18:19:52 +04:00
parent 02f8cc514d
commit af92c80989

View File

@ -66,13 +66,13 @@ public class DrawningTrolleybus
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
public bool SetPictureSize(int width, int height)
{
if (_pictureWidth < _drawningTrolleybusWidth || _pictureHeight < _drawningTrolleybusHeight)
if (width> _drawningTrolleybusWidth || height > _drawningTrolleybusHeight)
{
_pictureWidth = width;
_pictureHeight = height;
if (_startPosY.HasValue && _startPosX.HasValue)
{
if (_startPosX + _drawningTrolleybusWidth > width)
@ -89,27 +89,30 @@ public class DrawningTrolleybus
}
if (width < 0)
if (_startPosX < 0)
{
width = 0;
_startPosX = 0;
}
if (height < 0)
if (_startPosY < 0)
{
height = 0;
_startPosY = 0;
}
}
return true;
}
_pictureWidth = width;
_pictureHeight = height;
return true;
return false;
}
/// <summary>
/// Установка позиции
@ -122,7 +125,13 @@ public class DrawningTrolleybus
{
return;
}
_startPosX = x;
_startPosY = y;
if (_startPosX < 0)
{ _startPosX = 0; }
if (_startPosY < 0)
@ -143,15 +152,7 @@ public class DrawningTrolleybus
}
_startPosX = x;
_startPosY = y;
}
/// <summary>
/// Изменение направления перемещения