From d8fa13de94eafc7bfe3c8e060d3ae815d51bd694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=A8=D0=B8=D0=BF?= =?UTF-8?q?=D0=B8=D0=BB=D0=BE=D0=B2?= <116575516+LAYT73@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:08:19 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20SetPictureSize=20=D0=B2=20DrawingSeaplane?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSeaplane/DrawingSeaplane.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs index b5649e3..7b49d3f 100644 --- a/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs @@ -35,8 +35,27 @@ public class DrawingSeaplane public bool SetPictureSize(int width, int height) { - _pictureHeight = height; + if (_drawingSeaplaneWidth > width || _drawingSeaplaneHeight > height) + { + return false; + } _pictureWidth = width; + _pictureHeight = height; + + if (_startPosX.HasValue || _startPosY.HasValue) + { + + if (_startPosX + _drawingSeaplaneWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawingSeaplaneWidth; + } + else if (_startPosX < 0) _startPosX = 0; + if (_startPosY + _drawingSeaplaneHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawingSeaplaneHeight; + } + else if (_startPosY < 0) _startPosY = 0; + } return true; } @@ -144,7 +163,7 @@ public class DrawingSeaplane new Point(_startPosX.Value + 190, _startPosY.Value + 20) }; g.DrawPolygon(pen, pointsFaceBottom); - + Point[] pointsKeel = { new Point(_startPosX.Value + 10, _startPosY.Value - 30), new Point(_startPosX.Value + 10, _startPosY.Value + 5),