diff --git a/DoubleDeckerBus/DoubleDeckerBus/DoubleDeckerBus.csproj b/DoubleDeckerBus/DoubleDeckerBus/DoubleDeckerBus.csproj
index 244387d..b2208b1 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/DoubleDeckerBus.csproj
+++ b/DoubleDeckerBus/DoubleDeckerBus/DoubleDeckerBus.csproj
@@ -23,4 +23,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/DoubleDeckerBus/DoubleDeckerBus/DirectionType.cs b/DoubleDeckerBus/DoubleDeckerBus/Drawnings/DirectionType.cs
similarity index 88%
rename from DoubleDeckerBus/DoubleDeckerBus/DirectionType.cs
rename to DoubleDeckerBus/DoubleDeckerBus/Drawnings/DirectionType.cs
index a05d391..abde908 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/DirectionType.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/Drawnings/DirectionType.cs
@@ -1,5 +1,4 @@
-
-namespace DoubleDeckerBus;
+namespace DoubleDeckerBus.Drawnings;
public enum DirectionType
{ ///
diff --git a/DoubleDeckerBus/DoubleDeckerBus/Drawnings/DrawingBus.cs b/DoubleDeckerBus/DoubleDeckerBus/Drawnings/DrawingBus.cs
new file mode 100644
index 0000000..b20aaeb
--- /dev/null
+++ b/DoubleDeckerBus/DoubleDeckerBus/Drawnings/DrawingBus.cs
@@ -0,0 +1,203 @@
+using DoubleDeckerBus.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DoubleDeckerBus.Drawnings;
+
+public class DrawingBus
+{
+ public EntityBus? EntityBus { get; private set; }
+
+ private int? _pictureWidth;
+
+ private int? _pictureHeight;
+
+ private int? _startPosX;
+
+ private int? _startPosY;
+
+ private readonly int _DrawingBusWidth = 120;
+
+ private readonly int _DrawingBusHight = 60;
+
+ public void Init(int speed, double weight, Color bodyColor)
+ {
+ EntityBus = new EntityBus(speed, weight, bodyColor);
+ EntityBus.Init(speed, weight, bodyColor);
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+ }
+ ///
+ /// размер окна
+ ///
+ ///
+ ///
+ ///
+ public bool SetPictureSize(int width, int hight)
+ {
+ if (_DrawingBusWidth > width || _DrawingBusHight > hight)
+ {
+ return false;
+ }
+
+
+ _pictureWidth = width;
+ _pictureHeight = hight;
+
+ if (_startPosX.HasValue && _startPosX.Value + _DrawingBusWidth > _pictureWidth)
+ {
+ _startPosX = _pictureWidth - _DrawingBusWidth;
+ }
+
+ if (_startPosY.HasValue && _startPosY + _DrawingBusHight > _pictureHeight)
+ {
+ _startPosY = _pictureHeight - _DrawingBusHight;
+ }
+
+ return true;
+
+ }
+ ///
+ /// установить начальную позицию
+ ///
+ ///
+ ///
+ public void SetPosition(int x, int y)
+ {
+ if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+ return;
+ }
+
+ if (x < 0)
+ {
+ x = -x;
+ }
+ if (y < 0)
+ {
+ y = -y;
+ }
+
+ if (x + _DrawingBusWidth > _pictureWidth)
+ {
+ _startPosX = _pictureWidth - _DrawingBusWidth;
+ }
+ else
+ {
+ _startPosX = x;
+ }
+
+ if (y + _DrawingBusHight > _pictureHeight)
+ {
+ _startPosY = _pictureHeight - _DrawingBusHight;
+ }
+ else
+ {
+ _startPosY = y;
+ }
+ }
+
+ public bool MoveTransport(DirectionType direction)
+ {
+ if (EntityBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return false;
+ }
+
+ switch (direction)
+ {
+ case DirectionType.Left:
+ if (_startPosX.Value - EntityBus.Step > 0)
+ {
+ _startPosX -= (int)EntityBus.Step;
+ }
+ return true;
+
+ case DirectionType.Up:
+ if (_startPosY.Value - EntityBus.Step > 0)
+ {
+ _startPosY -= (int)EntityBus.Step;
+ }
+ return true;
+ case DirectionType.Right:
+ if (_startPosX.Value + _DrawingBusWidth + EntityBus.Step < _pictureWidth)
+ {
+ _startPosX += (int)EntityBus.Step;
+ }
+ return true;
+ case DirectionType.Down:
+ if (_startPosY.Value + _DrawingBusHight + EntityBus.Step < _pictureHeight)
+ {
+ _startPosY += (int)EntityBus.Step;
+ }
+ return true;
+ default:
+ return false;
+
+ }
+ }
+
+ public void DrawTrasnport(Graphics g)
+ {
+ if (EntityBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+ Brush mainBrush = new SolidBrush(EntityBus.BodyColor);
+ Brush blueBr = new SolidBrush(Color.LightBlue);
+
+
+ //кузов 1го этажа
+ PointF[] bus = { new PointF((float)_startPosX + 5, (float)_startPosY + 20),
+ new PointF((float)_startPosX, (float)_startPosY + 45),
+ new PointF((float)_startPosX + 100, (float)_startPosY + 45),
+ new PointF((float)_startPosX + 100, (float)_startPosY + 25),
+ new PointF((float)_startPosX + 97, (float)_startPosY + 20) };
+ g.FillPolygon(mainBrush, bus);
+ g.DrawPolygon(pen, bus);
+
+ //окна 1ый этаж
+ g.FillRectangle(blueBr, _startPosX.Value + 2, _startPosY.Value + 25, 12, 10);
+ g.FillRectangle(blueBr, _startPosX.Value + 16, _startPosY.Value + 25, 12, 10);
+ g.FillRectangle(blueBr, _startPosX.Value + 42, _startPosY.Value + 25, 6, 10);
+ g.FillRectangle(blueBr, _startPosX.Value + 50, _startPosY.Value + 25, 13, 10);
+ g.FillRectangle(blueBr, _startPosX.Value + 66, _startPosY.Value + 25, 14, 10);
+
+ g.DrawRectangle(pen, _startPosX.Value + 2, _startPosY.Value + 25, 12, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 16, _startPosY.Value + 25, 12, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 42, _startPosY.Value + 25, 6, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value + 25, 13, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 66, _startPosY.Value + 25, 14, 10);
+
+ //переднее окно первый этаж
+ PointF[] window2 = { new PointF((float)_startPosX + 85, (float)_startPosY + 25),
+ new PointF((float)_startPosX + 100, (float)_startPosY + 25),
+ new PointF((float)_startPosX + 100, (float)_startPosY + 40),
+ new PointF((float)_startPosX + 85, (float)_startPosY + 35) };
+ g.FillPolygon(blueBr, window2);
+ g.DrawPolygon(pen, window2);
+
+ //дверь
+ Brush brownBr = new SolidBrush(Color.Brown);
+ g.FillRectangle(blueBr, _startPosX.Value + 30, _startPosY.Value + 25, 10, 15);
+ g.FillRectangle(brownBr, _startPosX.Value + 30, _startPosY.Value + 40, 10, 5);
+
+ g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 25, 10, 15);
+ g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 40, 10, 5);
+
+ //колёса
+ g.FillEllipse(brownBr, _startPosX.Value + 6, _startPosY.Value + 37, 16, 16);
+ g.FillEllipse(brownBr, _startPosX.Value + 78, _startPosY.Value + 37, 16, 16);
+
+ g.DrawEllipse(pen, _startPosX.Value + 6, _startPosY.Value + 37, 16, 16);
+ g.DrawEllipse(pen, _startPosX.Value + 78, _startPosY.Value + 37, 16, 16);
+
+ }
+}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/Drawnings/DrawingDoubleDeckerBus.cs
similarity index 97%
rename from DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs
rename to DoubleDeckerBus/DoubleDeckerBus/Drawnings/DrawingDoubleDeckerBus.cs
index 6d8f6ae..533472a 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/Drawnings/DrawingDoubleDeckerBus.cs
@@ -1,4 +1,6 @@
-namespace DoubleDeckerBus;
+using DoubleDeckerBus.Entities;
+
+namespace DoubleDeckerBus.Drawnings;
///
///
///
@@ -18,7 +20,7 @@ public class DrawingDoubleDeckerBus
private readonly int _DrawingBusHight = 60;
- public void Init(int speed, double weight, Color bodyColor, Color additionalColor,bool secondFloor, bool stripes)
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool secondFloor, bool stripes)
{
EntityDoubleDeckerBus = new EntityDoubleDeckerBus();
EntityDoubleDeckerBus.Init(speed, weight, bodyColor, additionalColor, secondFloor, stripes);
@@ -44,12 +46,12 @@ public class DrawingDoubleDeckerBus
_pictureWidth = width;
_pictureHeight = hight;
- if (_startPosX.HasValue && (_startPosX.Value + _DrawingBusWidth > _pictureWidth))
+ if (_startPosX.HasValue && _startPosX.Value + _DrawingBusWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _DrawingBusWidth;
}
- if (_startPosY.HasValue && (_startPosY + _DrawingBusHight > _pictureHeight))
+ if (_startPosY.HasValue && _startPosY + _DrawingBusHight > _pictureHeight)
{
_startPosY = _pictureHeight - _DrawingBusHight;
}
@@ -149,7 +151,7 @@ public class DrawingDoubleDeckerBus
Brush mainBrush = new SolidBrush(EntityDoubleDeckerBus.BodyColor);
Brush blueBr = new SolidBrush(Color.LightBlue);
-
+
//кузов 1го этажа
PointF[] bus = { new PointF((float)_startPosX + 5, (float)_startPosY + 20),
new PointF((float)_startPosX + 5, (float)_startPosY + 45),
@@ -167,7 +169,7 @@ public class DrawingDoubleDeckerBus
g.FillPolygon(additionalBrush, stripe);
}
-
+
//окна 1ый этаж
g.FillRectangle(blueBr, _startPosX.Value + 7, _startPosY.Value + 25, 12, 10);
g.FillRectangle(blueBr, _startPosX.Value + 21, _startPosY.Value + 25, 12, 10);
diff --git a/DoubleDeckerBus/DoubleDeckerBus/Entities/EntityBus.cs b/DoubleDeckerBus/DoubleDeckerBus/Entities/EntityBus.cs
new file mode 100644
index 0000000..3ab2f79
--- /dev/null
+++ b/DoubleDeckerBus/DoubleDeckerBus/Entities/EntityBus.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DoubleDeckerBus.Entities;
+///
+/// Класс сущность автобус
+///
+public class EntityBus
+{
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; private set; }
+ ///
+ /// Вес
+ ///
+ public double Weight { get; private set; }
+ ///
+ /// Основной цвет
+ ///
+ public Color BodyColor { get; private set; }
+ ///
+ /// Расстояние перемещения за раз
+ ///
+ public double Step => Speed * 100 / Weight;
+ ///
+ /// Конструктор базовой сущности
+ ///
+ ///
+ ///
+ ///
+ public EntityBus(int speed, double weight, Color bodyColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ }
+
+}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/Entities/EntityDoubleDeckerBus.cs
similarity index 65%
rename from DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
rename to DoubleDeckerBus/DoubleDeckerBus/Entities/EntityDoubleDeckerBus.cs
index bdfa702..ebdf755 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/Entities/EntityDoubleDeckerBus.cs
@@ -1,16 +1,7 @@
-namespace DoubleDeckerBus;
- public class EntityDoubleDeckerBus
+namespace DoubleDeckerBus.Entities;
+public class EntityDoubleDeckerBus
{
- public int Speed { get; private set; }
-
- public double Weight { get; private set; }
- ///
- /// Основной цвет
- ///
- public Color BodyColor { get; private set; }
- ///
- /// Дополнительный цвет (для опциональных элементов)
- ///
+
public Color AdditionalColor { get; private set; }
///
/// Признак (опция) наличия второго этажа
@@ -20,10 +11,7 @@
/// Признак (опция) наличия полосок на автобусе
///
public bool Stripes { get; private set; }
- ///
- /// Шаг перемещения автобуса
- ///
- public double Step => Speed * 100 / Weight;
+
///
///
///
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs
index e44a6c5..bcb3a94 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using DoubleDeckerBus.Drawnings;
namespace DoubleDeckerBus
{