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