From 051f96a96e89842d9e450051953d5b34caabf866 Mon Sep 17 00:00:00 2001 From: strwbrry1 Date: Wed, 21 Feb 2024 15:23:31 +0400 Subject: [PATCH] minor fix 2 --- Catamaran/Catamaran/DrawingCatamaran.cs | 34 ++++++++++--------------- Catamaran/Catamaran/FormCatamaran.cs | 1 - 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Catamaran/Catamaran/DrawingCatamaran.cs b/Catamaran/Catamaran/DrawingCatamaran.cs index 5dc4be3..babb72d 100644 --- a/Catamaran/Catamaran/DrawingCatamaran.cs +++ b/Catamaran/Catamaran/DrawingCatamaran.cs @@ -39,6 +39,20 @@ namespace Catamaran { _pictureWidth = width; _pictureHeight = height; + if (_startPosX != null && _startPosY != null) + { + if (_startPosX.Value < 0) _startPosX = 0; + if (_startPosY.Value < 0) _startPosY = 0; + if (_startPosX.Value + _drawingCatamaranWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawingCatamaranWidth; + } + if (_startPosY.Value + _drawingCatamaranHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawingCatamaranHeight; + } + } + return true; } return false; @@ -67,26 +81,6 @@ namespace Catamaran } - public void CheckPos() - { - //if ((!_startPosX.HasValue || !_startPosY.HasValue) && (!_pictureHeight.HasValue || !_pictureWidth.HasValue)) - //{ - // return; - //} - if (_startPosX == null || _startPosY == null) - { - return; - } - if (_startPosX.Value + _drawingCatamaranWidth > _pictureWidth) - { - _startPosX = _pictureWidth - _drawingCatamaranWidth; - } - if (_startPosY.Value + _drawingCatamaranHeight > _pictureHeight) - { - _startPosY = _pictureHeight - _drawingCatamaranHeight; - } - } - public bool MoveTransport(DirectionType direction) { if (EntityCatamaran == null || !_startPosX.HasValue || !_startPosY.HasValue) diff --git a/Catamaran/Catamaran/FormCatamaran.cs b/Catamaran/Catamaran/FormCatamaran.cs index 9deb9c2..681aeb5 100644 --- a/Catamaran/Catamaran/FormCatamaran.cs +++ b/Catamaran/Catamaran/FormCatamaran.cs @@ -79,7 +79,6 @@ namespace Catamaran if (_drawingCatamaran.SetPictureSize(pictureBox1.Width, pictureBox1.Height)) { - _drawingCatamaran.CheckPos(); Draw(); }