setpos(); setpicsize() hotfix

This commit is contained in:
Данил Лопатин 2024-04-14 16:25:24 +03:00
parent cb303b9ca4
commit 69df949971

View File

@ -53,13 +53,39 @@ public class DrawningWarmlyLocomotive
public bool SetPictureSize(int width, int height)
{
if (width >= _drawningLocomotiveWidth && height >= _drawningLocomotiveHeight) {
if (width > _drawningLocomotiveWidth && height > _drawningLocomotiveHeight)
{
_pictureWidth = width;
_pictureHeight = height;
//todo
if (_startPosX != null && _startPosY != null)
{
//проверка х
if ((_startPosX.Value + _drawningLocomotiveWidth) > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningLocomotiveWidth;
}
else if (_startPosX.Value < 0)
{
_startPosX = 0;
}
//проверка у
if ((_startPosY.Value + _drawningLocomotiveHeight) > _pictureHeight)
{
_startPosY = _pictureHeight - _drawningLocomotiveHeight;
}
else if (_startPosY.Value < 0)
{
_startPosY = 0;
}
}
return true;
}
return false;
}
/// <summary>
/// Установка позиции
@ -77,7 +103,7 @@ public class DrawningWarmlyLocomotive
{
_startPosY = _pictureHeight - _drawningLocomotiveHeight;
}
else if(y < 0)
else if (y < 0)
{
_startPosY = 0;
}
@ -85,13 +111,13 @@ public class DrawningWarmlyLocomotive
{
_startPosY = y;
}
//проверка х
if ((x + _drawningLocomotiveWidth) > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningLocomotiveWidth;
}
else if(x < 0)
else if (x < 0)
{
_startPosX = 0;
}