Добавление проверки выхода за верхнюю и левую границы

This commit is contained in:
ivans 2024-03-12 12:44:07 +04:00
parent 070132467e
commit 42aa45de02

View File

@ -106,10 +106,18 @@ public class DrawingMonorail
{ {
return; return;
} }
if (x < 0)
{
x = 0;
}
if (x + _drawingMonorailWidth > _pictureWidth.Value) if (x + _drawingMonorailWidth > _pictureWidth.Value)
{ {
x = _pictureWidth.Value - _drawingMonorailWidth; x = _pictureWidth.Value - _drawingMonorailWidth;
} }
if (y < 0)
{
y = 0;
}
if (y + _drawingMonorailHeight > _pictureHeight.Value) if (y + _drawingMonorailHeight > _pictureHeight.Value)
{ {
y = _pictureHeight.Value - _drawingMonorailHeight; y = _pictureHeight.Value - _drawingMonorailHeight;