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(); }