From 9e4beecdc6ee7a919a4d32346b61aa0b36642ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=B8=D1=8F=20=D0=9A=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Wed, 14 Feb 2024 16:58:47 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=E2=84=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WinFormsAppExcavator/DrawingExcavator.cs | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) 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; + } + } ///