diff --git a/WinFormsAppExcavator/WinFormsAppExcavator/DrawingExcavator.cs b/WinFormsAppExcavator/WinFormsAppExcavator/DrawingExcavator.cs
index 6d69187..3012094 100644
--- a/WinFormsAppExcavator/WinFormsAppExcavator/DrawingExcavator.cs
+++ b/WinFormsAppExcavator/WinFormsAppExcavator/DrawingExcavator.cs
@@ -33,7 +33,7 @@ public class DrawingExcavator
///
/// Ширина прорисовки экскаватора
///
- private readonly int _drawningExcavatorWidth = 175;
+ private readonly int _drawningExcavatorWidth = 174;
///
/// Высота прорисовки экскаватора
@@ -69,15 +69,26 @@ public class DrawingExcavator
/// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
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;
+ }
///
/// Установка позиции
@@ -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;
+ }
+
}
///