diff --git a/Bulldozer/Bulldozer/Bulldozer.csproj b/Bulldozer/Bulldozer/Bulldozer.csproj
deleted file mode 100644
index 13ee123..0000000
--- a/Bulldozer/Bulldozer/Bulldozer.csproj
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
- WinExe
- net6.0-windows
- enable
- true
- enable
-
-
-
-
- True
- True
- Resources.resx
-
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
-
-
\ No newline at end of file
diff --git a/Bulldozer/Bulldozer/FormBulldozer.cs b/Bulldozer/Bulldozer/FormBulldozer.cs
deleted file mode 100644
index 9e861dc..0000000
--- a/Bulldozer/Bulldozer/FormBulldozer.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-namespace Bulldozer
-{
- public partial class FormBulldozer : Form
- {
- private DrawingBulldozer? _bulldozer;
- private EntityBulldozer? Bulldozer { get; set; }
- public FormBulldozer()
- {
- InitializeComponent();
- }
-
- private void Draw()
- {
- Bitmap bmp = new(pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
- Graphics gr = Graphics.FromImage(bmp);
- _bulldozer?.DrawTransport(gr, Bulldozer);
- pictureBoxBulldozer.Image = bmp;
- }
-
- private void ButtonCreate_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- _bulldozer = new DrawingBulldozer();
- Bulldozer = new EntityBulldozer();
-
- _bulldozer.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Bulldozer);
- _bulldozer.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
- pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
- toolStripStatusLabelSpeed.Text = $": {Bulldozer.Speed}";
- toolStripStatusLabelWeight.Text = $": {Bulldozer.Weight}";
- toolStripStatusLabelBodyColor.Text = $": {Bulldozer.BodyColor.Name} ";
- Draw();
- }
-
- private void ButtonMove_Click(object sender, EventArgs e)
- {
- string name = ((Button)sender)?.Name ?? string.Empty;
- switch (name)
- {
- case "buttonUp":
- _bulldozer?.MoveTransport(Direction.Up, Bulldozer);
- break;
- case "buttonDown":
- _bulldozer?.MoveTransport(Direction.Down, Bulldozer);
- break;
- case "buttonLeft":
- _bulldozer?.MoveTransport(Direction.Left, Bulldozer);
- break;
- case "buttonRight":
- _bulldozer?.MoveTransport(Direction.Right, Bulldozer);
- break;
- }
- Draw();
- }
-
- private void pictureBoxBulldozer_Resize(object sender, EventArgs e)
- {
- _bulldozer?.ChangeBorders(pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
- Draw();
- }
- }
-}
\ No newline at end of file
diff --git a/Bulldozer/Bulldozer.sln b/HoistingCrane/HoistingCrane.sln
similarity index 54%
rename from Bulldozer/Bulldozer.sln
rename to HoistingCrane/HoistingCrane.sln
index afcf79d..8f24b76 100644
--- a/Bulldozer/Bulldozer.sln
+++ b/HoistingCrane/HoistingCrane.sln
@@ -1,25 +1,25 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.3.32825.248
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bulldozer", "Bulldozer\Bulldozer.csproj", "{E5F857A0-7B7F-4F53-8C92-330D2F451FBA}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E5F857A0-7B7F-4F53-8C92-330D2F451FBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E5F857A0-7B7F-4F53-8C92-330D2F451FBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E5F857A0-7B7F-4F53-8C92-330D2F451FBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E5F857A0-7B7F-4F53-8C92-330D2F451FBA}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {A2E69D0E-100A-4D29-BF23-5EB2E6ED3E33}
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.32112.339
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HoistingCrane", "HoistingCrane\HoistingCrane.csproj", "{D80E7B00-5088-4976-A795-E42A2FE183D6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D80E7B00-5088-4976-A795-E42A2FE183D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D80E7B00-5088-4976-A795-E42A2FE183D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D80E7B00-5088-4976-A795-E42A2FE183D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D80E7B00-5088-4976-A795-E42A2FE183D6}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F67B9958-A88C-4E5E-9405-BA7150E626AF}
+ EndGlobalSection
+EndGlobal
diff --git a/HoistingCrane/HoistingCrane/AbstractMap.cs b/HoistingCrane/HoistingCrane/AbstractMap.cs
new file mode 100644
index 0000000..bf5f15c
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/AbstractMap.cs
@@ -0,0 +1,176 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoistingCrane
+{
+ internal abstract class AbstractMap
+ {
+ private IDrawingObject _drawingObject = null;
+ protected int[,] _map = null;
+ protected int _width;
+ protected int _height;
+ protected float _size_x;
+ protected float _size_y;
+ protected readonly Random _random = new();
+ protected readonly int _freeRoad = 0;
+ protected readonly int _barrier = 1;
+ public Bitmap CreateMap(int width, int height, IDrawingObject drawingObject)
+ {
+ _width = width;
+ _height = height;
+ _drawingObject = drawingObject;
+ GenerateMap();
+ while (!SetObjectOnMap())
+ {
+ GenerateMap();
+ }
+ return DrawMapWithObject();
+ }
+ public Bitmap MoveObject(Direction direction)
+ {
+ bool isFree = true;
+ int startPosX = (int)(_drawingObject.GetCurrentPosition().Left / _size_x);
+ int startPosY = (int)(_drawingObject.GetCurrentPosition().Right / _size_y);
+ int hoistingCraneWidth = (int)(_drawingObject.GetCurrentPosition().Top / _size_x);
+ int hoistingCraneHeight = (int)(_drawingObject.GetCurrentPosition().Bottom / _size_y);
+
+ switch (direction)
+ {
+ // вправо
+ case Direction.Right:
+ for (int i = hoistingCraneWidth; i <= hoistingCraneWidth + (int)(_drawingObject.Step / _size_x); i++)
+ {
+ for (int j = startPosY; j <= hoistingCraneHeight; j++)
+ {
+ if (_map[i, j] == _barrier)
+ {
+ isFree = false;
+ break;
+ }
+ }
+ }
+ break;
+ //влево
+ case Direction.Left:
+ for (int i = startPosX; i >= (int)(_drawingObject.Step / _size_x); i--)
+ {
+ for (int j = startPosY; j <= hoistingCraneHeight; j++)
+ {
+ if (_map[i, j] == _barrier)
+ {
+ isFree = false;
+ break;
+ }
+ }
+ }
+ break;
+ //вверх
+ case Direction.Up:
+ for (int i = startPosX; i <= hoistingCraneWidth; i++)
+ {
+ for (int j = startPosY; j >= (int)(_drawingObject.Step / _size_y); j--)
+ {
+ if (_map[i, j] == _barrier)
+ {
+ isFree = false;
+ break;
+ }
+ }
+ }
+ break;
+ //вниз
+ case Direction.Down:
+ for (int i = startPosX; i <= hoistingCraneWidth; i++)
+ {
+ for (int j = hoistingCraneHeight; j <= hoistingCraneHeight + (int)(_drawingObject.Step / _size_y); j++)
+ {
+ if (_map[i, j] == _barrier)
+ {
+ isFree = false;
+ break;
+ }
+ }
+ }
+ break;
+ }
+ if (isFree)
+ {
+ _drawingObject.MoveObject(direction);
+ }
+ else _drawingObject.MoveObject(SetOppositDirection(direction));
+ return DrawMapWithObject();
+ }
+
+ private Direction SetOppositDirection(Direction dir)
+ {
+ switch (dir)
+ {
+ case Direction.Up:
+ return Direction.Down;
+ case Direction.Down:
+ return Direction.Up;
+ case Direction.Left:
+ return Direction.Right;
+ case Direction.Right:
+ return Direction.Left;
+ }
+ return Direction.None;
+ }
+ private bool SetObjectOnMap()
+ {
+ if (_drawingObject == null || _map == null)
+ {
+ return false;
+ }
+ int x = _random.Next(0, 10);
+ int y = _random.Next(0, 10);
+ _drawingObject.SetObject(x, y, _width, _height);
+ int startPosX = (int)(_drawingObject.GetCurrentPosition().Left / _size_x);
+ int startPosY = (int)(_drawingObject.GetCurrentPosition().Right / _size_y);
+ int hoistingcraneWidth = (int)(_drawingObject.GetCurrentPosition().Top / _size_x);
+ int hoistingCraneHeight = (int)(_drawingObject.GetCurrentPosition().Bottom / _size_y);
+ for (int i = startPosX; i <= hoistingcraneWidth; i++)
+ {
+ for (int j = startPosY; j <= hoistingCraneHeight; j++)
+ {
+ if (_map[i, j] == _barrier)
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ private Bitmap DrawMapWithObject()
+ {
+ Bitmap bmp = new(_width, _height);
+ if (_drawingObject == null || _map == null)
+ {
+ return bmp;
+ }
+ Graphics gr = Graphics.FromImage(bmp);
+ for (int i = 0; i < _map.GetLength(0); i++)
+ {
+ for (int j = 0; j < _map.GetLength(1); j++)
+ {
+ if (_map[i, j] == _freeRoad)
+ {
+ DrawRoadPart(gr, i, j);
+ }
+ else if (_map[i, j] == _barrier)
+ {
+ DrawBarrierPart(gr, i, j);
+ }
+ }
+ }
+ _drawingObject.DrawingObject(gr);
+ return bmp;
+ }
+ protected abstract void GenerateMap();
+ protected abstract void DrawRoadPart(Graphics g, int i, int j);
+ protected abstract void DrawBarrierPart(Graphics g, int i, int j);
+ }
+}
diff --git a/Bulldozer/Bulldozer/Direction.cs b/HoistingCrane/HoistingCrane/Direction.cs
similarity index 74%
rename from Bulldozer/Bulldozer/Direction.cs
rename to HoistingCrane/HoistingCrane/Direction.cs
index 1c0ea86..e3d1a91 100644
--- a/Bulldozer/Bulldozer/Direction.cs
+++ b/HoistingCrane/HoistingCrane/Direction.cs
@@ -4,13 +4,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Bulldozer
+namespace HoistingCrane
{
- internal enum Direction
+ public enum Direction
{
+ None = 0,
Up = 1,
Down = 2,
Left = 3,
Right = 4
}
-}
+}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/DrawingAdvancedHoistingCrane.cs b/HoistingCrane/HoistingCrane/DrawingAdvancedHoistingCrane.cs
new file mode 100644
index 0000000..faae436
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/DrawingAdvancedHoistingCrane.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoistingCrane
+{
+ internal class DrawingAdvancedHoistingCrane : DrawingHoistingCrane
+ {
+ public DrawingAdvancedHoistingCrane(int speed, float weight, Color bodyColor, Color dopColor, bool bucket, bool ripper) :
+ base(speed, weight, bodyColor, 152, 65)
+ {
+ HoistingCrane = new EntityAdvancedHoistingCrane(speed, weight, bodyColor, dopColor, bucket, ripper);
+ }
+ public override void DrawTransport(Graphics g)
+ {
+ if (HoistingCrane is not EntityAdvancedHoistingCrane advancedHoistingCrane)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black, 3);
+ Brush dopBrush = new SolidBrush(advancedHoistingCrane.DopColor);
+ if (advancedHoistingCrane.Сounterweight)
+ {
+ g.DrawLine(pen, _startPosX + 15, _startPosY + 60, _startPosX + 40, _startPosY + 75);
+ g.DrawLine(pen, _startPosX + 15, _startPosY + 45, _startPosX + 45, _startPosY + 65);
+
+ g.FillRectangle(dopBrush, _startPosX + 4, _startPosY + 38, 12, 25);
+ g.DrawRectangle(pen, _startPosX + 4, _startPosY + 38, 12, 25);
+
+ }
+ if (advancedHoistingCrane.Crane)
+ {
+ g.FillRectangle(dopBrush, _startPosX + 100, _startPosY + 30, 10, 25);
+ g.DrawRectangle(pen, _startPosX + 100, _startPosY + 30, 10, 25);
+ g.FillRectangle(dopBrush, _startPosX + 110, _startPosY + 15, 10, 25);
+ g.DrawRectangle(pen, _startPosX + 110, _startPosY + 15, 10, 25);
+ g.FillRectangle(dopBrush, _startPosX + 120, _startPosY + 15, 25, 10);
+ g.DrawRectangle(pen, _startPosX + 120, _startPosY + 15, 25, 10);
+ g.FillRectangle(dopBrush, _startPosX + 145, _startPosY + 15, 10, 60);
+ g.DrawRectangle(pen, _startPosX + 145, _startPosY + 15, 10, 60);
+ g.FillRectangle(dopBrush, _startPosX + 145, _startPosY + 65, 25, 10);
+ g.DrawRectangle(pen, _startPosX + 145, _startPosY + 65, 25, 10);
+ }
+ _startPosX += 40;
+ _startPosY += 30;
+ base.DrawTransport(g);
+ _startPosY -= 30;
+ _startPosX -= 40;
+ }
+ }
+}
diff --git a/Bulldozer/Bulldozer/DrawingBulldozer.cs b/HoistingCrane/HoistingCrane/DrawingHoistingCrane.cs
similarity index 62%
rename from Bulldozer/Bulldozer/DrawingBulldozer.cs
rename to HoistingCrane/HoistingCrane/DrawingHoistingCrane.cs
index 8f5762d..abe97e9 100644
--- a/Bulldozer/Bulldozer/DrawingBulldozer.cs
+++ b/HoistingCrane/HoistingCrane/DrawingHoistingCrane.cs
@@ -4,37 +4,40 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Bulldozer
+namespace HoistingCrane
{
- internal class DrawingBulldozer
+ public class DrawingHoistingCrane
{
+ public EntityHoistingCrane HoistingCrane { get; protected set; }
-
-
- private float _startPosX;
- private float _startPosY;
+ protected float _startPosX;
+ protected float _startPosY;
private int? _pictureWidth = null;
private int? _pictureHeight = null;
- private readonly int _bulldozerWidth = 80;
- private readonly int _bulldozerHeight = 80;
+ private readonly int _hoistingCraneWidth = 80;
+ private readonly int _hoistingCraneHeight = 50;
- public void Init(int speed, float weight, Color bodyColor, EntityBulldozer Bulldozer)
+ protected DrawingHoistingCrane(int speed, float weight, Color bodyColor, int hoistingCraneWidth, int hoistingCraneHeigth) :
+ this(speed, weight, bodyColor)
{
-
- Bulldozer.Init(speed, weight, bodyColor);
+ _hoistingCraneHeight = hoistingCraneHeigth;
+ _hoistingCraneWidth = hoistingCraneWidth;
+ }
+ public DrawingHoistingCrane(int speed, float weight, Color bodyColor)
+ {
+ HoistingCrane = new EntityHoistingCrane(speed, weight, bodyColor);
}
public void SetPosition(int x, int y, int width, int height)
{
-
- if (x < 0 || x + _bulldozerWidth >= width || y < 0 || y + _bulldozerHeight >= height) return;
- _startPosX = x;
- _startPosY = y;
- _pictureWidth = width;
- _pictureHeight = height;
+ // TODO checks
+ _startPosX = x;
+ _startPosY = y;
+ _pictureWidth = width;
+ _pictureHeight = height;
}
- public void MoveTransport(Direction direction, EntityBulldozer Bulldozer)
+ public void MoveTransport(Direction direction)
{
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
{
@@ -42,33 +45,37 @@ namespace Bulldozer
}
switch (direction)
{
+ // вправо
case Direction.Right:
- if (_startPosX + _bulldozerWidth + Bulldozer.Step < _pictureWidth)
+ if (_startPosX + _hoistingCraneWidth + HoistingCrane.Step < _pictureWidth)
{
- _startPosX += Bulldozer.Step;
+ _startPosX += HoistingCrane.Step;
}
break;
+ //влево
case Direction.Left:
- if (_startPosX - Bulldozer.Step > 0)
+ if (_startPosX - HoistingCrane.Step > 0)
{
- _startPosX -= Bulldozer.Step;
+ _startPosX -= HoistingCrane.Step;
}
break;
+ //вверх
case Direction.Up:
- if (_startPosY - Bulldozer.Step > 0)
+ if (_startPosY - HoistingCrane.Step > 0)
{
- _startPosY -= Bulldozer.Step;
+ _startPosY -= HoistingCrane.Step;
}
break;
+ //вниз
case Direction.Down:
- if (_startPosY + _bulldozerHeight + Bulldozer.Step < _pictureHeight)
+ if (_startPosY + _hoistingCraneHeight + HoistingCrane.Step < _pictureHeight)
{
- _startPosY += Bulldozer.Step;
+ _startPosY += HoistingCrane.Step;
}
break;
}
}
- public void DrawTransport(Graphics g, EntityBulldozer Bulldozer)
+ public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
@@ -91,26 +98,21 @@ namespace Bulldozer
g.DrawEllipse(pen, _startPosX + 50, _startPosY + 53, 10, 10);
g.DrawRectangle(pen, _startPosX + 30, _startPosY + 45, 4, 6);
g.DrawRectangle(pen, _startPosX + 45, _startPosY + 45, 4, 6);
-
//корпус
- Brush br = new SolidBrush(Bulldozer?.BodyColor ?? Color.Black);
+ Brush br = new SolidBrush(HoistingCrane?.BodyColor ?? Color.Black);
g.FillRectangle(br, _startPosX, _startPosY + 25, 75, 25);
g.FillRectangle(br, _startPosX, _startPosY, 25, 25);
-
//окно
Brush brBlue = new SolidBrush(Color.Blue);
g.FillRectangle(brBlue, _startPosX + 4, _startPosY + 4, 17, 17);
-
//выхлопная труба
Brush brBrown = new SolidBrush(Color.DarkGray);
g.FillRectangle(brBrown, _startPosX + 52, _startPosY + 7, 6, 18);
-
//гусеница
Brush brDarkGray = new SolidBrush(Color.DarkGray);
g.FillEllipse(brDarkGray, _startPosX - 5, _startPosY + 45, 20, 20);
g.FillEllipse(brDarkGray, _startPosX + 63, _startPosY + 45, 20, 20);
g.FillRectangle(brDarkGray, _startPosX + 5, _startPosY + 45, 68, 20);
-
Brush brBlack = new SolidBrush(Color.Black);
g.FillEllipse(brBlack, _startPosX - 1, _startPosY + 46, 18, 18);
g.FillEllipse(brBlack, _startPosX + 62, _startPosY + 46, 18, 18);
@@ -119,28 +121,30 @@ namespace Bulldozer
g.FillEllipse(brBlack, _startPosX + 50, _startPosY + 53, 10, 10);
g.FillRectangle(brBlack, _startPosX + 30, _startPosY + 45, 4, 6);
g.FillRectangle(brBlack, _startPosX + 45, _startPosY + 45, 4, 6);
-
-
}
public void ChangeBorders(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
- if (_pictureWidth <= _bulldozerWidth || _pictureHeight <= _bulldozerHeight)
+ if (_pictureWidth <= _hoistingCraneWidth || _pictureHeight <= _hoistingCraneHeight)
{
_pictureWidth = null;
_pictureHeight = null;
return;
}
- if (_startPosX + _bulldozerWidth > _pictureWidth)
+ if (_startPosX + _hoistingCraneWidth > _pictureWidth)
{
- _startPosX = _pictureWidth.Value - _bulldozerWidth;
+ _startPosX = _pictureWidth.Value - _hoistingCraneWidth;
}
- if (_startPosY + _bulldozerHeight > _pictureHeight)
+ if (_startPosY + _hoistingCraneHeight > _pictureHeight)
{
- _startPosY = _pictureHeight.Value - _bulldozerHeight;
+ _startPosY = _pictureHeight.Value - _hoistingCraneHeight;
}
}
+ public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
+ {
+ return (_startPosX, _startPosY, _startPosX + _hoistingCraneWidth, _startPosY + _hoistingCraneHeight);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs b/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs
new file mode 100644
index 0000000..22138d0
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoistingCrane
+{
+ internal class DrawingObjectHoistingCrane : IDrawingObject
+ {
+ private DrawingHoistingCrane _hoistingCrane = null;
+ public DrawingObjectHoistingCrane(DrawingHoistingCrane hoistingCrane)
+ {
+ _hoistingCrane = hoistingCrane;
+ }
+ public float Step => _hoistingCrane?.HoistingCrane?.Step ?? 0;
+ public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
+ {
+ return _hoistingCrane?.GetCurrentPosition() ?? default;
+ }
+ public void MoveObject(Direction direction)
+ {
+ _hoistingCrane?.MoveTransport(direction);
+ }
+ public void SetObject(int x, int y, int width, int height)
+ {
+ _hoistingCrane.SetPosition(x, y, width, height);
+ }
+ public void DrawingObject(Graphics g)
+ {
+ _hoistingCrane?.DrawTransport(g);
+ }
+ }
+}
diff --git a/HoistingCrane/HoistingCrane/EntityAdvancedHoistingCrane.cs b/HoistingCrane/HoistingCrane/EntityAdvancedHoistingCrane.cs
new file mode 100644
index 0000000..0011652
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/EntityAdvancedHoistingCrane.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoistingCrane
+{
+ internal class EntityAdvancedHoistingCrane : EntityHoistingCrane
+ {
+ // наличие крана
+ public bool Crane { get; private set; }
+ // наличие противовеса
+ public bool Сounterweight { get; private set; }
+ public Color DopColor { get; private set; }
+
+ public EntityAdvancedHoistingCrane(int speed, float weight, Color bodyColor, Color dopColor, bool crane, bool counterweight) :
+ base(speed, weight, bodyColor)
+ {
+ Crane = crane;
+ Сounterweight = counterweight;
+ DopColor = dopColor;
+ }
+ }
+}
diff --git a/Bulldozer/Bulldozer/EntityBulldozer.cs b/HoistingCrane/HoistingCrane/EntityHoistingCrane.cs
similarity index 62%
rename from Bulldozer/Bulldozer/EntityBulldozer.cs
rename to HoistingCrane/HoistingCrane/EntityHoistingCrane.cs
index 5ea5077..b8b5b05 100644
--- a/Bulldozer/Bulldozer/EntityBulldozer.cs
+++ b/HoistingCrane/HoistingCrane/EntityHoistingCrane.cs
@@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Bulldozer
+namespace HoistingCrane
{
- internal class EntityBulldozer
+ public class EntityHoistingCrane
{
public int Speed { get; private set; }
@@ -16,11 +16,11 @@ namespace Bulldozer
public float Step => Speed * 100 / Weight;
- public void Init(int speed, float weight, Color bodyColor)
+ public EntityHoistingCrane(int speed, float weight, Color bodyColor)
{
Random rnd = new();
- Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
- Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
+ Speed = speed <= 0 ? rnd.Next(30, 100) : speed;
+ Weight = weight <= 0 ? rnd.Next(300, 500) : weight;
BodyColor = bodyColor;
}
}
diff --git a/Bulldozer/Bulldozer/FormBulldozer.Designer.cs b/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs
similarity index 74%
rename from Bulldozer/Bulldozer/FormBulldozer.Designer.cs
rename to HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs
index 3b7c469..a85331e 100644
--- a/Bulldozer/Bulldozer/FormBulldozer.Designer.cs
+++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs
@@ -1,11 +1,10 @@
-namespace Bulldozer
+namespace HoistingCrane
{
- partial class FormBulldozer
+ partial class FormHoistingCrane
{
-
private System.ComponentModel.IContainer components = null;
-
+
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@@ -16,8 +15,6 @@
}
#region Windows Form Designer generated code
-
-
private void InitializeComponent()
{
this.buttonUp = new System.Windows.Forms.Button();
@@ -29,15 +26,13 @@
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
- this.pictureBoxBulldozer = new System.Windows.Forms.PictureBox();
+ this.pictureBoxHoistingCrane = new System.Windows.Forms.PictureBox();
this.statusStrip1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBulldozer)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).BeginInit();
this.SuspendLayout();
- //
- // buttonUp
- //
+
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonUp.BackgroundImage = global::Bulldozer.Properties.Resources.up;
+ this.buttonUp.BackgroundImage = global::HoistingCrane.Properties.Resources.up;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonUp.Location = new System.Drawing.Point(722, 353);
this.buttonUp.Name = "buttonUp";
@@ -45,11 +40,9 @@
this.buttonUp.TabIndex = 0;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonLeft
- //
+
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonLeft.BackgroundImage = global::Bulldozer.Properties.Resources.left;
+ this.buttonLeft.BackgroundImage = global::HoistingCrane.Properties.Resources.left;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonLeft.Location = new System.Drawing.Point(686, 389);
this.buttonLeft.Name = "buttonLeft";
@@ -57,11 +50,9 @@
this.buttonLeft.TabIndex = 1;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonRight
- //
+
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonRight.BackgroundImage = global::Bulldozer.Properties.Resources.right;
+ this.buttonRight.BackgroundImage = global::HoistingCrane.Properties.Resources.right;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonRight.Location = new System.Drawing.Point(758, 389);
this.buttonRight.Name = "buttonRight";
@@ -69,11 +60,9 @@
this.buttonRight.TabIndex = 2;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonDown
- //
+
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDown.BackgroundImage = global::Bulldozer.Properties.Resources.down;
+ this.buttonDown.BackgroundImage = global::HoistingCrane.Properties.Resources.down;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonDown.Location = new System.Drawing.Point(722, 389);
this.buttonDown.Name = "buttonDown";
@@ -81,9 +70,7 @@
this.buttonDown.TabIndex = 3;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonCreate
- //
+
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreate.Location = new System.Drawing.Point(12, 393);
this.buttonCreate.Name = "buttonCreate";
@@ -92,9 +79,7 @@
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
- //
- // statusStrip1
- //
+
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
@@ -104,40 +89,27 @@
this.statusStrip1.Size = new System.Drawing.Size(800, 22);
this.statusStrip1.TabIndex = 5;
this.statusStrip1.Text = "statusStrip1";
- //
- // toolStripStatusLabelSpeed
- //
+
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
this.toolStripStatusLabelSpeed.Text = "Скорость:";
- //
- // toolStripStatusLabelWeight
- //
+
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17);
this.toolStripStatusLabelWeight.Text = "Вес:";
- //
- // toolStripStatusLabelBodyColor
- //
+
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
- //
- // pictureBoxBulldozer
- //
- this.pictureBoxBulldozer.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
- this.pictureBoxBulldozer.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pictureBoxBulldozer.Location = new System.Drawing.Point(0, 0);
- this.pictureBoxBulldozer.Name = "pictureBoxBulldozer";
- this.pictureBoxBulldozer.Size = new System.Drawing.Size(800, 450);
- this.pictureBoxBulldozer.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxBulldozer.TabIndex = 6;
- this.pictureBoxBulldozer.TabStop = false;
- this.pictureBoxBulldozer.Click += new System.EventHandler(this.pictureBoxBulldozer_Resize);
- this.pictureBoxBulldozer.Resize += new System.EventHandler(this.pictureBoxBulldozer_Resize);
- //
- // FormBulldozer
- //
+
+ this.pictureBoxHoistingCrane.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBoxHoistingCrane.Location = new System.Drawing.Point(0, 0);
+ this.pictureBoxHoistingCrane.Name = "pictureBoxHoistingCrane";
+ this.pictureBoxHoistingCrane.Size = new System.Drawing.Size(800, 450);
+ this.pictureBoxHoistingCrane.TabIndex = 6;
+ this.pictureBoxHoistingCrane.TabStop = false;
+ this.pictureBoxHoistingCrane.Click += new System.EventHandler(this.pictureBoxHoistingCrane_Click);
+
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
@@ -147,19 +119,18 @@
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonUp);
- this.Controls.Add(this.pictureBoxBulldozer);
- this.Name = "FormBulldozer";
- this.Text = "Трактор";
+ this.Controls.Add(this.pictureBoxHoistingCrane);
+ this.Name = "FormHoistingCrane";
+ this.Text = "Подъёмный кран";
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBulldozer)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
-
private Button buttonUp;
private Button buttonLeft;
private Button buttonRight;
@@ -169,6 +140,6 @@
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
- private PictureBox pictureBoxBulldozer;
+ private PictureBox pictureBoxHoistingCrane;
}
}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/FormHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs
new file mode 100644
index 0000000..6c738b9
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs
@@ -0,0 +1,109 @@
+namespace HoistingCrane
+{
+ public partial class FormHoistingCrane : Form
+ {
+ private DrawingHoistingCrane _hoistingCrane;
+ public DrawingHoistingCrane SelectedHoistingCrane { get; private set; }
+ public FormHoistingCrane()
+ {
+ InitializeComponent();
+ }
+
+ private void Draw()
+ {
+ Bitmap bmp = new(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _hoistingCrane?.DrawTransport(gr);
+ pictureBoxHoistingCrane.Image = bmp;
+ }
+
+ private void SetData()
+ {
+ Random rnd = new();
+ _hoistingCrane.SetPosition(rnd.Next(80, 100), rnd.Next(80, 100), pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
+ toolStripStatusLabelSpeed.Text = $"Скорость: {_hoistingCrane.HoistingCrane.Speed}";
+ toolStripStatusLabelWeight.Text = $"Вес: {_hoistingCrane.HoistingCrane.Weight}";
+ toolStripStatusLabelBodyColor.Text = $"Цвет:{_hoistingCrane.HoistingCrane.BodyColor.Name}";
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),
+ rnd.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+ _hoistingCrane = new DrawingHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500), color);
+ SetData();
+ Draw();
+ }
+
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ switch (name)
+ {
+ case "buttonUp":
+ _hoistingCrane?.MoveTransport(Direction.Up);
+ break;
+ case "buttonDown":
+ _hoistingCrane?.MoveTransport(Direction.Down);
+ break;
+ case "buttonLeft":
+ _hoistingCrane?.MoveTransport(Direction.Left);
+ break;
+ case "buttonRight":
+ _hoistingCrane?.MoveTransport(Direction.Right);
+ break;
+ }
+ Draw();
+ }
+
+ private void PictureBoxHoistingCrane_Resize(object sender, EventArgs e)
+ {
+ _hoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
+ Draw();
+ }
+
+ private void ButtonCreateModify_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ Color selectedColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),
+ rnd.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ selectedColor = dialog.Color;
+ }
+ Color advancedSelectedColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),
+ rnd.Next(0, 256));
+ ColorDialog dialogDop = new();
+ if (dialogDop.ShowDialog() == DialogResult.OK)
+ {
+ advancedSelectedColor = dialogDop.Color;
+ }
+ _hoistingCrane = new DrawingAdvancedHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500),
+ selectedColor, advancedSelectedColor, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
+ SetData();
+ Draw();
+ }
+
+ private void pictureBoxHoistingCrane_Click(object sender, EventArgs e)
+ {
+
+ }
+ private void ButtonSelect_Click(object sender, EventArgs e)
+ {
+ SelectedHoistingCrane = _hoistingCrane;
+ DialogResult = DialogResult.OK;
+ }
+ private void pictureBoxHoistingCrane_Resize(object sender, EventArgs e)
+ {
+ _hoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
+ Draw();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Bulldozer/Bulldozer/FormBulldozer.resx b/HoistingCrane/HoistingCrane/FormHoistingCrane.resx
similarity index 88%
rename from Bulldozer/Bulldozer/FormBulldozer.resx
rename to HoistingCrane/HoistingCrane/FormHoistingCrane.resx
index 796091e..f298a7b 100644
--- a/Bulldozer/Bulldozer/FormBulldozer.resx
+++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.resx
@@ -57,10 +57,4 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- 17, 17
-
-
- 25
-
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/FormMap.Designer.cs b/HoistingCrane/HoistingCrane/FormMap.Designer.cs
new file mode 100644
index 0000000..ba07c1c
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormMap.Designer.cs
@@ -0,0 +1,208 @@
+namespace HoistingCrane
+{
+ partial class FormMap
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonRight = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.statusStrip = new System.Windows.Forms.StatusStrip();
+ this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
+ this.pictureBoxHoistingCrane = new System.Windows.Forms.PictureBox();
+ this.buttonCreateModify = new System.Windows.Forms.Button();
+ this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+ this.statusStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonUp
+ //
+ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUp.BackgroundImage = global::HoistingCrane.Properties.Resources.up;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonUp.Location = new System.Drawing.Point(722, 353);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ this.buttonUp.TabIndex = 0;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonLeft
+ //
+ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonLeft.BackgroundImage = global::HoistingCrane.Properties.Resources.left;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonLeft.Location = new System.Drawing.Point(686, 389);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(30, 30);
+ this.buttonLeft.TabIndex = 1;
+ this.buttonLeft.UseVisualStyleBackColor = true;
+ this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonRight
+ //
+ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRight.BackgroundImage = global::HoistingCrane.Properties.Resources.right;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonRight.Location = new System.Drawing.Point(758, 389);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(30, 30);
+ this.buttonRight.TabIndex = 2;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonDown
+ //
+ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDown.BackgroundImage = global::HoistingCrane.Properties.Resources.down;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonDown.Location = new System.Drawing.Point(722, 389);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 3;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCreate.Location = new System.Drawing.Point(12, 393);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(75, 23);
+ this.buttonCreate.TabIndex = 4;
+ this.buttonCreate.Text = "Создать";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
+ //
+ // statusStrip
+ //
+ this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripStatusLabelSpeed,
+ this.toolStripStatusLabelWeight,
+ this.toolStripStatusLabelBodyColor});
+ this.statusStrip.Location = new System.Drawing.Point(0, 428);
+ this.statusStrip.Name = "statusStrip";
+ this.statusStrip.Size = new System.Drawing.Size(800, 22);
+ this.statusStrip.TabIndex = 5;
+ this.statusStrip.Text = "statusStrip";
+ //
+ // toolStripStatusLabelSpeed
+ //
+ this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
+ this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
+ this.toolStripStatusLabelSpeed.Text = "Скорость:";
+ //
+ // toolStripStatusLabelWeight
+ //
+ this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
+ this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17);
+ this.toolStripStatusLabelWeight.Text = "Вес:";
+ //
+ // toolStripStatusLabelBodyColor
+ //
+ this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
+ this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
+ this.toolStripStatusLabelBodyColor.Text = "Цвет:";
+ //
+ // pictureBoxBulldozer
+ //
+ this.pictureBoxHoistingCrane.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBoxHoistingCrane.Location = new System.Drawing.Point(0, 0);
+ this.pictureBoxHoistingCrane.Name = "pictureBoxHoistingCrane";
+ this.pictureBoxHoistingCrane.Size = new System.Drawing.Size(800, 428);
+ this.pictureBoxHoistingCrane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBoxHoistingCrane.TabIndex = 6;
+ this.pictureBoxHoistingCrane.TabStop = false;
+ this.pictureBoxHoistingCrane.Click += new System.EventHandler(this.pictureBoxHoistingCrane_Click);
+ //
+ // buttonCreateModify
+ //
+ this.buttonCreateModify.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCreateModify.Location = new System.Drawing.Point(93, 393);
+ this.buttonCreateModify.Name = "buttonCreateModify";
+ this.buttonCreateModify.Size = new System.Drawing.Size(100, 23);
+ this.buttonCreateModify.TabIndex = 7;
+ this.buttonCreateModify.Text = "Модификация";
+ this.buttonCreateModify.UseVisualStyleBackColor = true;
+ this.buttonCreateModify.Click += new System.EventHandler(this.ButtonCreateModify_Click);
+ //
+ // comboBoxSelectorMap
+ //
+ this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxSelectorMap.FormattingEnabled = true;
+ this.comboBoxSelectorMap.Items.AddRange(new object[] {
+ "Простая карта",
+ "Вторая карта"});
+ this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
+ this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23);
+ this.comboBoxSelectorMap.TabIndex = 8;
+ this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
+ //
+ // FormMap
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.comboBoxSelectorMap);
+ this.Controls.Add(this.buttonCreateModify);
+ this.Controls.Add(this.buttonCreate);
+ this.Controls.Add(this.buttonDown);
+ this.Controls.Add(this.buttonRight);
+ this.Controls.Add(this.buttonLeft);
+ this.Controls.Add(this.buttonUp);
+ this.Controls.Add(this.pictureBoxHoistingCrane);
+ this.Controls.Add(this.statusStrip);
+ this.Name = "FormMap";
+ this.Text = "FormMap";
+ this.statusStrip.ResumeLayout(false);
+ this.statusStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+ private Button buttonUp;
+ private Button buttonLeft;
+ private Button buttonRight;
+ private Button buttonDown;
+ private Button buttonCreate;
+ private StatusStrip statusStrip;
+ private ToolStripStatusLabel toolStripStatusLabelSpeed;
+ private ToolStripStatusLabel toolStripStatusLabelWeight;
+ private ToolStripStatusLabel toolStripStatusLabelBodyColor;
+ private PictureBox pictureBoxHoistingCrane;
+ private Button buttonCreateModify;
+ private ComboBox comboBoxSelectorMap;
+ }
+}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/FormMap.cs b/HoistingCrane/HoistingCrane/FormMap.cs
new file mode 100644
index 0000000..35f3052
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormMap.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace HoistingCrane
+{
+ public partial class FormMap : Form
+ {
+ private AbstractMap _abstractMap;
+ public FormMap()
+ {
+ InitializeComponent();
+ _abstractMap = new SimpleMap();
+ _abstractMap = new SecondMap();
+ }
+
+ private void SetData(DrawingHoistingCrane hoistingCrane)
+ {
+ toolStripStatusLabelSpeed.Text = $"Скорость: {hoistingCrane.HoistingCrane.Speed}";
+ toolStripStatusLabelWeight.Text = $"Вес: {hoistingCrane.HoistingCrane.Weight}";
+ toolStripStatusLabelBodyColor.Text = $"Цвет:{hoistingCrane.HoistingCrane.BodyColor.Name}";
+ pictureBoxHoistingCrane.Image = _abstractMap.CreateMap(pictureBoxHoistingCrane.Width,
+ pictureBoxHoistingCrane.Height, new DrawingObjectHoistingCrane(hoistingCrane));
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ var bulldozer = new DrawingHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ SetData(bulldozer);
+ }
+
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ Direction dir = Direction.None;
+ switch (name)
+ {
+ case "buttonUp":
+ dir = Direction.Up;
+ break;
+ case "buttonDown":
+ dir = Direction.Down;
+ break;
+ case "buttonLeft":
+ dir = Direction.Left;
+ break;
+ case "buttonRight":
+ dir = Direction.Right;
+ break;
+ }
+ pictureBoxHoistingCrane.Image = _abstractMap.MoveObject(dir);
+ }
+ private void ButtonCreateModify_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ var hoistingCrane = new DrawingAdvancedHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Color.FromArgb(rnd.Next(0, 256),
+ rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
+ SetData(hoistingCrane);
+ }
+
+ private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "Простая карта":
+ _abstractMap = new SimpleMap();
+ break;
+ case "Вторая карта":
+ _abstractMap = new SecondMap();
+ break;
+ }
+ }
+
+ private void pictureBoxHoistingCrane_Click(object sender, EventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/HoistingCrane/HoistingCrane/FormMap.resx b/HoistingCrane/HoistingCrane/FormMap.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormMap.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/HoistingCrane.csproj b/HoistingCrane/HoistingCrane/HoistingCrane.csproj
new file mode 100644
index 0000000..b57c89e
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/HoistingCrane.csproj
@@ -0,0 +1,11 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/IDrawingObject.cs b/HoistingCrane/HoistingCrane/IDrawingObject.cs
new file mode 100644
index 0000000..cbdd2ac
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/IDrawingObject.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoistingCrane
+{
+ internal interface IDrawingObject
+ {
+ public float Step { get; }
+ void SetObject(int x, int y, int width, int height);
+ void MoveObject(Direction direction);
+ void DrawingObject(Graphics g);
+ (float Left, float Right, float Top, float Bottom) GetCurrentPosition();
+ }
+}
diff --git a/Bulldozer/Bulldozer/Program.cs b/HoistingCrane/HoistingCrane/Program.cs
similarity index 65%
rename from Bulldozer/Bulldozer/Program.cs
rename to HoistingCrane/HoistingCrane/Program.cs
index e8221a5..aaa3628 100644
--- a/Bulldozer/Bulldozer/Program.cs
+++ b/HoistingCrane/HoistingCrane/Program.cs
@@ -1,14 +1,17 @@
-namespace Bulldozer
+namespace HoistingCrane
{
internal static class Program
{
+ ///
+ /// The main entry point for the application.
+ ///
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormBulldozer());
+ Application.Run(new FormMap());
}
}
}
\ No newline at end of file
diff --git a/Bulldozer/Bulldozer/Properties/Resources.Designer.cs b/HoistingCrane/HoistingCrane/Properties/Resources.Designer.cs
similarity index 96%
rename from Bulldozer/Bulldozer/Properties/Resources.Designer.cs
rename to HoistingCrane/HoistingCrane/Properties/Resources.Designer.cs
index afbb674..6f27a21 100644
--- a/Bulldozer/Bulldozer/Properties/Resources.Designer.cs
+++ b/HoistingCrane/HoistingCrane/Properties/Resources.Designer.cs
@@ -8,7 +8,7 @@
//
//------------------------------------------------------------------------------
-namespace Bulldozer.Properties {
+namespace HoistingCrane.Properties {
using System;
@@ -39,7 +39,7 @@ namespace Bulldozer.Properties {
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Bulldozer.Properties.Resources", typeof(Resources).Assembly);
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HoistingCrane.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
diff --git a/Bulldozer/Bulldozer/Properties/Resources.resx b/HoistingCrane/HoistingCrane/Properties/Resources.resx
similarity index 100%
rename from Bulldozer/Bulldozer/Properties/Resources.resx
rename to HoistingCrane/HoistingCrane/Properties/Resources.resx
diff --git a/Bulldozer/Bulldozer/Resources/down.png b/HoistingCrane/HoistingCrane/Resources/down.png
similarity index 100%
rename from Bulldozer/Bulldozer/Resources/down.png
rename to HoistingCrane/HoistingCrane/Resources/down.png
diff --git a/Bulldozer/Bulldozer/Resources/left.png b/HoistingCrane/HoistingCrane/Resources/left.png
similarity index 100%
rename from Bulldozer/Bulldozer/Resources/left.png
rename to HoistingCrane/HoistingCrane/Resources/left.png
diff --git a/Bulldozer/Bulldozer/Resources/right.png b/HoistingCrane/HoistingCrane/Resources/right.png
similarity index 100%
rename from Bulldozer/Bulldozer/Resources/right.png
rename to HoistingCrane/HoistingCrane/Resources/right.png
diff --git a/Bulldozer/Bulldozer/Resources/up.png b/HoistingCrane/HoistingCrane/Resources/up.png
similarity index 100%
rename from Bulldozer/Bulldozer/Resources/up.png
rename to HoistingCrane/HoistingCrane/Resources/up.png
diff --git a/HoistingCrane/HoistingCrane/SecondMap.cs b/HoistingCrane/HoistingCrane/SecondMap.cs
new file mode 100644
index 0000000..486f95b
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/SecondMap.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoistingCrane
+{
+ internal class SecondMap : AbstractMap
+ {
+ private readonly Brush barrierColor = new SolidBrush(Color.Black);
+ private readonly Brush roadColor = new SolidBrush(Color.Yellow);
+ protected override void DrawBarrierPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
+ }
+ protected override void DrawRoadPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
+ }
+ protected override void GenerateMap()
+ {
+ _map = new int[100, 100];
+ _size_x = (float)_width / _map.GetLength(0);
+ _size_y = (float)_height / _map.GetLength(1);
+ int counter = 0;
+ for (int i = 0; i < _map.GetLength(0); ++i)
+ {
+ for (int j = 0; j < _map.GetLength(1); ++j)
+ {
+ _map[i, j] = _freeRoad;
+ }
+ }
+ while (counter < 20)
+ {
+ int x = _random.Next(0, 100);
+ int y = _random.Next(0, 100);
+ if (_map[x, y] == _freeRoad)
+ {
+ _map[x, y] = _barrier;
+ counter++;
+ }
+ }
+ }
+ }
+}
diff --git a/HoistingCrane/HoistingCrane/SimpleMap.cs b/HoistingCrane/HoistingCrane/SimpleMap.cs
new file mode 100644
index 0000000..b59499a
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/SimpleMap.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoistingCrane
+{
+ internal class SimpleMap : AbstractMap
+ {
+ private readonly Brush barrierColor = new SolidBrush(Color.Black);
+ private readonly Brush roadColor = new SolidBrush(Color.Gray);
+ protected override void DrawBarrierPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
+ }
+ protected override void DrawRoadPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
+ }
+ protected override void GenerateMap()
+ {
+ _map = new int[100, 100];
+ _size_x = (float)_width / _map.GetLength(0);
+ _size_y = (float)_height / _map.GetLength(1);
+ int counter = 0;
+ for (int i = 0; i < _map.GetLength(0); ++i)
+ {
+ for (int j = 0; j < _map.GetLength(1); ++j)
+ {
+ _map[i, j] = _freeRoad;
+ }
+ }
+ while (counter < 50)
+ {
+ int x = _random.Next(0, 100);
+ int y = _random.Next(0, 100);
+ if (_map[x, y] == _freeRoad)
+ {
+ _map[x, y] = _barrier;
+ counter++;
+ }
+ }
+ }
+ }
+}