From 0619b0de35a7b78d14b7f70f705f1513b03c8ace Mon Sep 17 00:00:00 2001
From: IlyasValiulov <148232695+IlyasValiulov@users.noreply.github.com>
Date: Mon, 19 Feb 2024 15:29:36 +0400
Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=D1=80=D0=B0=D1=82?=
=?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=B0=20=E2=84=962=202?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Drawnings/DrawningShip.cs | 5 ----
.../Drawnings/DrawningWarmlyShip.cs | 11 --------
.../ProjectWarmlyShip/FormWarmlyShip.cs | 28 +++++++++----------
.../MovementStrategy/IMoveableObjects.cs | 1 -
.../MovementStrategy/MoveableShip.cs | 1 -
5 files changed, 14 insertions(+), 32 deletions(-)
diff --git a/ProjectWarmlyShip/ProjectWarmlyShip/Drawnings/DrawningShip.cs b/ProjectWarmlyShip/ProjectWarmlyShip/Drawnings/DrawningShip.cs
index fe33413..4fe08b1 100644
--- a/ProjectWarmlyShip/ProjectWarmlyShip/Drawnings/DrawningShip.cs
+++ b/ProjectWarmlyShip/ProjectWarmlyShip/Drawnings/DrawningShip.cs
@@ -8,27 +8,22 @@ public class DrawningShip
/// Класс-сущность
///
public EntityShip? EntityShip { get; protected set; }
-
///
/// Ширина окна
///
private int? _pictureWidth;
-
///
/// Высота окна
///
private int? _pictureHeight;
-
///
/// Левая координата прорисовки
///
protected int? _startPosX;
-
///
/// Верхняя кооридната прорисовки
///
protected int? _startPosY;
-
///
/// Ширина прорисовки
///
diff --git a/ProjectWarmlyShip/ProjectWarmlyShip/Drawnings/DrawningWarmlyShip.cs b/ProjectWarmlyShip/ProjectWarmlyShip/Drawnings/DrawningWarmlyShip.cs
index 134df93..fd00dc6 100644
--- a/ProjectWarmlyShip/ProjectWarmlyShip/Drawnings/DrawningWarmlyShip.cs
+++ b/ProjectWarmlyShip/ProjectWarmlyShip/Drawnings/DrawningWarmlyShip.cs
@@ -4,10 +4,6 @@ namespace ProjectWarmlyShip.Drawnings;
public class DrawningWarmlyShip : DrawningShip
{
- ///
- /// Класс-сущность
- ///
- public EntityWarmlyShip? EntityWarmlyShip { get; private set; }
///
/// Конструктор
///
@@ -36,15 +32,8 @@ public class DrawningWarmlyShip : DrawningShip
base.DrawTransport(g);
if (warmlyship.FuelTank)
{
- //if (EntityWarmlyShip.ShipPipes)
- //{
- // g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 120, 70, 10);
- //}
- //else
- // g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 60, 70, 10);
g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 60, 70, 10);
}
if (warmlyship.ShipPipes) _startPosY -= 60;
}
-
}
diff --git a/ProjectWarmlyShip/ProjectWarmlyShip/FormWarmlyShip.cs b/ProjectWarmlyShip/ProjectWarmlyShip/FormWarmlyShip.cs
index 2a47915..65c0832 100644
--- a/ProjectWarmlyShip/ProjectWarmlyShip/FormWarmlyShip.cs
+++ b/ProjectWarmlyShip/ProjectWarmlyShip/FormWarmlyShip.cs
@@ -12,6 +12,17 @@ namespace ProjectWarmlyShip
InitializeComponent();
_strategy = null;
}
+ private void Draw()
+ {
+ if (_drawningShip == null)
+ {
+ return;
+ }
+ Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _drawningShip.DrawTransport(gr);
+ pictureBoxWarmlyShip.Image = bmp;
+ }
private void CreateObject(string type)
{
Random random = new Random();
@@ -34,11 +45,7 @@ namespace ProjectWarmlyShip
_drawningShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
_strategy = null;
comboBoxStrategy.Enabled = true;
- Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
- Graphics gr = Graphics.FromImage(bmp);
- _drawningShip.DrawTransport(gr);
- pictureBoxWarmlyShip.Image = bmp;
-
+ Draw();
}
///
/// Кнопка создания теплохода
@@ -83,10 +90,7 @@ namespace ProjectWarmlyShip
}
if (result)
{
- Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
- Graphics gr = Graphics.FromImage(bmp);
- _drawningShip.DrawTransport(gr);
- pictureBoxWarmlyShip.Image = bmp;
+ Draw();
}
}
private void buttonStrategyStep_Click(object sender, EventArgs e)
@@ -116,10 +120,7 @@ namespace ProjectWarmlyShip
}
comboBoxStrategy.Enabled = false;
_strategy.MakeStep();
- Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
- Graphics gr = Graphics.FromImage(bmp);
- _drawningShip.DrawTransport(gr);
- pictureBoxWarmlyShip.Image = bmp;
+ Draw();
if (_strategy.GetStatus == StrategyStatus.Finish)
{
comboBoxStrategy.Enabled = true;
@@ -127,5 +128,4 @@ namespace ProjectWarmlyShip
}
}
}
-
}
diff --git a/ProjectWarmlyShip/ProjectWarmlyShip/MovementStrategy/IMoveableObjects.cs b/ProjectWarmlyShip/ProjectWarmlyShip/MovementStrategy/IMoveableObjects.cs
index 33f8030..efb09a7 100644
--- a/ProjectWarmlyShip/ProjectWarmlyShip/MovementStrategy/IMoveableObjects.cs
+++ b/ProjectWarmlyShip/ProjectWarmlyShip/MovementStrategy/IMoveableObjects.cs
@@ -2,7 +2,6 @@
public interface IMoveableObjects
{
- //Получение координаты обхекта
ObjectParameters? GetObjectPosition { get; }
///
/// Шаг объекта
diff --git a/ProjectWarmlyShip/ProjectWarmlyShip/MovementStrategy/MoveableShip.cs b/ProjectWarmlyShip/ProjectWarmlyShip/MovementStrategy/MoveableShip.cs
index caaffc7..23ac656 100644
--- a/ProjectWarmlyShip/ProjectWarmlyShip/MovementStrategy/MoveableShip.cs
+++ b/ProjectWarmlyShip/ProjectWarmlyShip/MovementStrategy/MoveableShip.cs
@@ -45,5 +45,4 @@ public class MoveableShip : IMoveableObjects
_ => DirectionType.Unknow,
};
}
-
}