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,
};
}
-
}