From bd746e928870a62316697671aa6adaffda9ad5ca Mon Sep 17 00:00:00 2001 From: gettterot Date: Wed, 21 Feb 2024 16:54:00 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=20=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=BC=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D1=8B=D0=BC=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectLiner/ProjectLiner/DrawningLiner.cs | 10 ++++++---- ProjectLiner/ProjectLiner/FormLiner.cs | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ProjectLiner/ProjectLiner/DrawningLiner.cs b/ProjectLiner/ProjectLiner/DrawningLiner.cs index d5023a3..35d42b6 100644 --- a/ProjectLiner/ProjectLiner/DrawningLiner.cs +++ b/ProjectLiner/ProjectLiner/DrawningLiner.cs @@ -50,10 +50,9 @@ public class DrawningLiner /// Признак наличия якоря /// Признак наличия шлюпок /// Признак наличия трубы - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool anchor, bool boats, bool pipe) + public void Init(EntityLiner liner) { - EntityLiner = new EntityLiner(); - EntityLiner.Init(speed, weight, bodyColor, additionalColor, anchor, boats, pipe); + EntityLiner = liner; _pictureWidth = null; _pictureHeight = null; _startPosX = null; @@ -108,7 +107,10 @@ public class DrawningLiner { _startPosX = x; _startPosY = y; - + if (_startPosX.Value < 0) + _startPosX = 0; + if (_startPosY.Value < 0) + _startPosY = 0; if (_startPosX.Value + _drawningLinerWidth > _pictureWidth) { _startPosX = _pictureWidth - _drawningLinerWidth; diff --git a/ProjectLiner/ProjectLiner/FormLiner.cs b/ProjectLiner/ProjectLiner/FormLiner.cs index e370c8b..c72187d 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.cs @@ -42,11 +42,13 @@ namespace ProjectLiner private void buttonCreate_Click(object sender, EventArgs e) { Random random = new(); - _drawningLiner = new DrawningLiner(); - _drawningLiner.Init(random.Next(100, 300), random.Next(1000, 3000), + EntityLiner liner = new EntityLiner(); + liner.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + _drawningLiner = new DrawningLiner(); + _drawningLiner.Init(liner); _drawningLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height); _drawningLiner.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw();