diff --git a/Excavator/DirectionType.cs b/Excavator/DirectionType.cs new file mode 100644 index 0000000..52fa6bd --- /dev/null +++ b/Excavator/DirectionType.cs @@ -0,0 +1,27 @@ +namespace Excavator; + +/// +/// Направление перемещения +/// +public enum DirectionType +{ + /// + /// Вверх + /// + Up = 1, + + /// + /// Вниз + /// + Down = 2, + + /// + /// Влево + /// + Left = 3, + + /// + /// Вправо + /// + Right = 4 +} \ No newline at end of file diff --git a/Excavator/DrawningExcavator.cs b/Excavator/DrawningExcavator.cs new file mode 100644 index 0000000..086785b --- /dev/null +++ b/Excavator/DrawningExcavator.cs @@ -0,0 +1,328 @@ +using System.Drawing.Drawing2D; +using System.Net.Sockets; + +namespace Excavator; + +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// +public class DrawningExcavator +{ + /// + /// Класс-сущность + /// + public EntityExcavator? EntityExcavator { get; private set; } + + /// + /// Ширина окна + /// + private int? _pictureWidth; + + /// + /// Высота окна + /// + private int? _pictureHeight; + + /// + /// Левая координата прорисовки эскаватора + /// + private int? _startPosX; + + /// + /// Верхняя кооридната прорисовки экскаватора + /// + private int? _startPosY; + + /// + /// Ширина прорисовки экскаватора + /// + private readonly int _drawningExcavatorWidth = 130; + + /// + /// Высота прорисовки экскаватора + /// + private readonly int _drawningExcavatorHeight = 140; + + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия ковша + /// Признак наличия опор + + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool supports) + { + EntityExcavator = new EntityExcavator(); + EntityExcavator.Init(speed, weight, bodyColor, additionalColor, bucket, supports); + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + } + + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах + + + public bool SetPictureSize(int width, int height) + { + if (width > _drawningExcavatorWidth && height > _drawningExcavatorHeight) + { + _pictureWidth = width; + _pictureHeight = height; + if (_startPosX != null && _startPosY != null) + { + if (_startPosX.Value < 0) + { + _startPosX = 0; + } + if (_startPosY.Value < 0) + { + _startPosY = 0; + } + if (_startPosX.Value + _drawningExcavatorWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawningExcavatorWidth; + } + if (_startPosY.Value + _drawningExcavatorHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawningExcavatorHeight; + } + } + + return true; + } + return false; + + } + + + + + + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + else + { + _startPosX = x; + _startPosY = y; + if (_startPosX.Value < 0) + { + _startPosX = 0; + } + if (_startPosY.Value < 0) + { + _startPosY = 0; + } + if (_startPosX + _drawningExcavatorWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawningExcavatorWidth; + } + if (_startPosY + _drawningExcavatorHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawningExcavatorHeight; + } + } + + } + + /// + /// Изменение направления перемещения + /// + /// Направление + /// true - перемещене выполнено, false - перемещение невозможно + public bool MoveTransport(DirectionType direction) + { + if (EntityExcavator == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return false; + } + + switch (direction) + { + //влево + case DirectionType.Left: + + if (_startPosX.Value - EntityExcavator.Step > 0) + { + _startPosX -= (int)EntityExcavator.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY.Value - EntityExcavator.Step > 0) + { + _startPosY -= (int)EntityExcavator.Step; + } + return true; + // вправо + case DirectionType.Right: + //TODO прописать логику сдвига в право + + if (_startPosX.Value + _drawningExcavatorWidth + EntityExcavator.Step < _pictureWidth) + { + + _startPosX += (int)EntityExcavator.Step; + + } + return true; + //вниз + case DirectionType.Down: + //TODO прописать логику сдвига в вниз + if (_startPosY.Value + _drawningExcavatorHeight + EntityExcavator.Step < _pictureHeight) + { + _startPosY += (int)EntityExcavator.Step; + } + return true; + default: + return false; + } + } + + + + + public static GraphicsPath RoundedRect(Graphics g, Rectangle bounds, int radius) + { + int diameter = radius * 2; + Size size = new Size(diameter, diameter); + Rectangle arc = new Rectangle(bounds.Location, size); + GraphicsPath path = new GraphicsPath(); + + if (radius == 0) + { + path.AddRectangle(bounds); + return path; + } + + // top left arc + path.AddArc(arc, 180, 90); + + // top right arc + arc.X = bounds.Right - diameter; + path.AddArc(arc, 270, 90); + + // bottom right arc + arc.Y = bounds.Bottom - diameter; + path.AddArc(arc, 0, 90); + + // bottom left arc + arc.X = bounds.Left; + path.AddArc(arc, 90, 90); + + g.FillPath(Brushes.Black, path); + + path.CloseFigure(); + return path; + } + + + /// + /// Прорисовка объекта + /// + /// + /// + + public void DrawTransport(Graphics g) + { + if (EntityExcavator == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + + Pen pen = new(Color.Black); + Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor); + Brush brBlue = new SolidBrush(Color.LightBlue); + Brush brGray = new SolidBrush(Color.Gray); + Brush brRed = new SolidBrush(Color.Red); + Brush brYellow = new SolidBrush(Color.Yellow); + Brush brBlack = new SolidBrush(Color.Black); + + //кузов + g.DrawRectangle(pen, _startPosX.Value , _startPosY.Value, 150, 150); + + g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 90, 40); + g.FillRectangle(brGray, _startPosX.Value, _startPosY.Value, 90, 40); + //труба + g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value - 35, 7, 35); + g.FillRectangle(brBlack, _startPosX.Value + 10, _startPosY.Value - 35, 7, 35); + + + //кабина + + g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value - 40, 40, 40); + g.FillRectangle(brBlue, _startPosX.Value + 50, _startPosY.Value - 40, 40, 40); + + //колеса + g.DrawPath(pen, RoundedRect(g, new Rectangle(_startPosX.Value - 10, _startPosY.Value + 44, 110, 40), 15)); + + Pen bPen = new(Color.Black); + bPen.Width = 3; + g.DrawEllipse(bPen, _startPosX.Value - 9, _startPosY.Value + 52, 25, 25); + g.DrawEllipse(bPen, _startPosX.Value + 73, _startPosY.Value + 52, 25, 25); + g.FillEllipse(brBlue, _startPosX.Value - 9, _startPosY.Value + 52, 25, 25); + g.FillEllipse(brBlue, _startPosX.Value + 73, _startPosY.Value + 52, 25, 25); + + //колеса + g.DrawEllipse(bPen, _startPosX.Value + 20, _startPosY.Value + 67, 13, 13); + g.DrawEllipse(bPen, _startPosX.Value + 40, _startPosY.Value + 67, 13, 13); + g.DrawEllipse(bPen, _startPosX.Value + 60, _startPosY.Value + 67, 13, 13); + g.FillEllipse(brRed, _startPosX.Value + 20, _startPosY.Value + 67, 13, 13); + g.FillEllipse(brRed, _startPosX.Value + 40, _startPosY.Value + 67, 13, 13); + g.FillEllipse(brRed, _startPosX.Value + 60, _startPosY.Value + 67, 13, 13); + + + + g.DrawEllipse(bPen, _startPosX.Value + 30, _startPosY.Value + 48, 9, 9); + g.DrawEllipse(bPen, _startPosX.Value + 55, _startPosY.Value + 48, 9, 9); + g.FillEllipse(brYellow, _startPosX.Value + 30, _startPosY.Value + 48, 9, 9); + g.FillEllipse(brYellow, _startPosX.Value + 55, _startPosY.Value + 48, 9, 9); + + + + // ковш + + if (EntityExcavator.Bucket) + { + + + g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 40, _startPosX.Value - 30, _startPosY.Value - 10); + g.DrawLine(pen, _startPosX.Value - 30, _startPosY.Value - 10, _startPosX.Value, _startPosY.Value - 10); + g.DrawLine(pen, _startPosX.Value, _startPosY.Value - 10, _startPosX.Value, _startPosY.Value + 40); + PointF[] p = [new PointF(_startPosX.Value, _startPosY.Value + 40), new PointF(_startPosX.Value - 30, _startPosY.Value - 10), new PointF(_startPosX.Value, _startPosY.Value - 10)]; + + g.FillPolygon(additionalBrush, p); + + } + + + + // опоры + if (EntityExcavator.Supports) + { + g.DrawLine(bPen, _startPosX.Value + 90, _startPosY.Value + 20, _startPosX.Value + 112, _startPosY.Value + 20); + g.DrawLine(bPen, _startPosX.Value + 112, _startPosY.Value + 20, _startPosX.Value + 112, _startPosY.Value + 80); + g.DrawLine(bPen, _startPosX.Value + 112, _startPosY.Value + 80, _startPosX.Value + 120, _startPosY.Value + 80); + + } + + + } +} + diff --git a/Excavator/EntityExcavator.cs b/Excavator/EntityExcavator.cs new file mode 100644 index 0000000..1ae8e23 --- /dev/null +++ b/Excavator/EntityExcavator.cs @@ -0,0 +1,66 @@ +namespace Excavator; + +/// +/// Класс-сущность "Экскаватор" +/// +public class EntityExcavator +{ + + public int m; + /// + /// Скорость + /// + public int Speed { get; private set; } + + /// + /// Вес + /// + public double Weight { get; private set; } + + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + + /// + /// Дополнительный цвет (для опциональных элементов) + /// + public Color AdditionalColor { get; private set; } + + /// + /// Признак (опция) наличия ковша + /// + public bool Bucket { get; private set; } + + /// + /// Признак (опция) наличия опор + /// + public bool Supports { get; private set; } + + + + /// + /// Шаг перемещения экскаватора + /// + public double Step => Speed * 100 / Weight; + + /// + /// Инициализация полей объекта-класса спортивного автомобиля + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия ковша + /// Признак наличия опор + + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool supports) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Bucket = bucket; + Supports = supports; + } +} \ No newline at end of file diff --git a/Excavator/Excavator.csproj b/Excavator/Excavator.csproj new file mode 100644 index 0000000..af03d74 --- /dev/null +++ b/Excavator/Excavator.csproj @@ -0,0 +1,26 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/Excavator/Excavator/DirectionType.cs b/Excavator/Excavator/DirectionType.cs new file mode 100644 index 0000000..52fa6bd --- /dev/null +++ b/Excavator/Excavator/DirectionType.cs @@ -0,0 +1,27 @@ +namespace Excavator; + +/// +/// Направление перемещения +/// +public enum DirectionType +{ + /// + /// Вверх + /// + Up = 1, + + /// + /// Вниз + /// + Down = 2, + + /// + /// Влево + /// + Left = 3, + + /// + /// Вправо + /// + Right = 4 +} \ No newline at end of file diff --git a/Excavator/Excavator/DrawningExcavator.cs b/Excavator/Excavator/DrawningExcavator.cs new file mode 100644 index 0000000..ed89564 --- /dev/null +++ b/Excavator/Excavator/DrawningExcavator.cs @@ -0,0 +1,347 @@ +using System.Drawing.Drawing2D; +using System.Net.Sockets; + +namespace Excavator; + +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// +public class DrawningExcavator +{ + /// + /// Класс-сущность + /// + public EntityExcavator? EntityExcavator { get; private set; } + + /// + /// Ширина окна + /// + private int? _pictureWidth; + + /// + /// Высота окна + /// + private int? _pictureHeight; + + /// + /// Левая координата прорисовки эскаватора + /// + private int? _startPosX; + + /// + /// Верхняя кооридната прорисовки экскаватора + /// + private int? _startPosY; + + /// + /// Ширина прорисовки экскаватора + /// + private readonly int _drawningExcavatorWidth = 145; + + /// + /// Высота прорисовки экскаватора + /// + private readonly int _drawningExcavatorHeight = 125; + + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия ковша + /// Признак наличия опор + + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool supports) + { + EntityExcavator = new EntityExcavator(); + EntityExcavator.Init(speed, weight, bodyColor, additionalColor, bucket, supports); + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + } + + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах + + + public bool SetPictureSize(int width, int height) + { + if (width > _drawningExcavatorWidth && height > _drawningExcavatorHeight) + { + _pictureWidth = width; + _pictureHeight = height; + if (_startPosX != null && _startPosY != null) + { + if (_startPosX.Value < 0) + { + _startPosX = 0; + } + if (_startPosY.Value < 0) + { + _startPosY = 0; + } + if (_startPosX.Value + _drawningExcavatorWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawningExcavatorWidth; + } + if (_startPosY.Value + _drawningExcavatorHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawningExcavatorHeight; + } + } + + return true; + } + return false; + + } + + + + + + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + else + { + _startPosX = x; + _startPosY = y; + if (_startPosX.Value < 0) + { + _startPosX = 0; + } + if (_startPosY.Value < 0) + { + _startPosY = 0; + } + if (_startPosX + _drawningExcavatorWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawningExcavatorWidth; + } + if (_startPosY + _drawningExcavatorHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawningExcavatorHeight; + } + } + + } + + /// + /// Изменение направления перемещения + /// + /// Направление + /// true - перемещене выполнено, false - перемещение невозможно + public bool MoveTransport(DirectionType direction) + { + if (EntityExcavator == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return false; + } + + switch (direction) + { + //влево + case DirectionType.Left: + + if (_startPosX.Value - EntityExcavator.Step > 0) + { + _startPosX -= (int)EntityExcavator.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY.Value - EntityExcavator.Step > 0) + { + _startPosY -= (int)EntityExcavator.Step; + } + return true; + // вправо + case DirectionType.Right: + //TODO прописать логику сдвига в право + + if (_startPosX.Value + _drawningExcavatorWidth + EntityExcavator.Step < _pictureWidth) + { + + _startPosX += (int)EntityExcavator.Step; + + } + return true; + //вниз + case DirectionType.Down: + //TODO прописать логику сдвига в вниз + if (_startPosY.Value + _drawningExcavatorHeight + EntityExcavator.Step < _pictureHeight) + { + _startPosY += (int)EntityExcavator.Step; + } + return true; + default: + return false; + } + } + + + + + public static GraphicsPath RoundedRect(Graphics g, Rectangle bounds, int radius) + { + int diameter = radius * 2; + Size size = new Size(diameter, diameter); + Rectangle arc = new Rectangle(bounds.Location, size); + GraphicsPath path = new GraphicsPath(); + + if (radius == 0) + { + path.AddRectangle(bounds); + return path; + } + + // top left arc + path.AddArc(arc, 180, 90); + + // top right arc + arc.X = bounds.Right - diameter; + path.AddArc(arc, 270, 90); + + // bottom right arc + arc.Y = bounds.Bottom - diameter; + path.AddArc(arc, 0, 90); + + // bottom left arc + arc.X = bounds.Left; + path.AddArc(arc, 90, 90); + + g.FillPath(Brushes.Black, path); + + path.CloseFigure(); + return path; + } + + + /// + /// Прорисовка объекта + /// + /// + /// + + public void DrawTransport(Graphics g) + { + if (EntityExcavator == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + + Pen pen = new(Color.Black); + Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor); + Brush brBlue = new SolidBrush(Color.LightBlue); + Brush brGray = new SolidBrush(Color.Gray); + Brush brRed = new SolidBrush(Color.Red); + Brush brYellow = new SolidBrush(Color.Yellow); + Brush brBlack = new SolidBrush(Color.Black); + + + + int bodyHeight = 90; + int cabineHeight = 40; + int pipeHeight = 35; + int bucketWidth = 30; + int pipeWidth = 7; + + int pipeOffsetX = 25; + int cabineOffsetX = 50; + + int wheelsOffsetX = 20; + int wheelsHeight = 40; + + //кузов + g.DrawRectangle(pen, _startPosX.Value + bucketWidth, _startPosY.Value + cabineHeight, bodyHeight, bodyHeight - cabineHeight); + g.FillRectangle(brGray, _startPosX.Value + bucketWidth, _startPosY.Value + cabineHeight, bodyHeight, bodyHeight - cabineHeight); + + //труба + g.DrawRectangle(pen, _startPosX.Value + bucketWidth + pipeOffsetX, _startPosY.Value + cabineHeight - pipeHeight, pipeWidth, pipeHeight); + g.FillRectangle(brBlack, _startPosX.Value + bucketWidth + pipeOffsetX, _startPosY.Value + cabineHeight - pipeHeight, pipeWidth, pipeHeight); + + //кабина + g.DrawRectangle(pen, _startPosX.Value + bucketWidth + cabineOffsetX, _startPosY.Value, cabineHeight, cabineHeight); + g.FillRectangle(brBlue, _startPosX.Value + bucketWidth + cabineOffsetX, _startPosY.Value, cabineHeight, cabineHeight); + + //трак + g.DrawPath(pen, RoundedRect(g, new Rectangle(_startPosX.Value + wheelsOffsetX, _startPosY.Value + bodyHeight, wheelsOffsetX + bodyHeight, wheelsHeight), 15)); + + Pen bPen = new(Color.Black); + bPen.Width = 3; + + Rectangle wheel1 = new Rectangle( + _startPosX.Value + bucketWidth + wheelsOffsetX - 25, + _startPosY.Value + bodyHeight + wheelsHeight / 4, + 25, 25); + + Rectangle wheel2 = new Rectangle( + _startPosX.Value + bucketWidth + (bodyHeight - wheelsOffsetX), + _startPosY.Value + bodyHeight + wheelsHeight / 4, + 25, 25); + + g.DrawEllipse(bPen, wheel1); + g.DrawEllipse(bPen, wheel2); + + g.FillEllipse(brBlue, wheel1); + g.FillEllipse(brBlue, wheel2); + + //колеса + g.DrawEllipse(bPen, _startPosX.Value + bucketWidth + wheelsOffsetX + 5, _startPosY.Value + bodyHeight + wheelsHeight / 2, 13, 13); + g.DrawEllipse(bPen, _startPosX.Value + bucketWidth + wheelsOffsetX + 20, _startPosY.Value + bodyHeight + wheelsHeight / 2, 13, 13); + g.DrawEllipse(bPen, _startPosX.Value + bucketWidth + wheelsOffsetX + 35, _startPosY.Value + bodyHeight + wheelsHeight / 2, 13, 13); + g.FillEllipse(brRed, _startPosX.Value + bucketWidth + wheelsOffsetX + 5, _startPosY.Value + bodyHeight + wheelsHeight / 2, 13, 13); + g.FillEllipse(brRed, _startPosX.Value + bucketWidth + wheelsOffsetX + 20, _startPosY.Value + bodyHeight + wheelsHeight / 2, 13, 13); + g.FillEllipse(brRed, _startPosX.Value + bucketWidth + wheelsOffsetX + 35, _startPosY.Value + bodyHeight + wheelsHeight / 2, 13, 13); + + g.DrawEllipse(bPen, _startPosX.Value + bucketWidth + wheelsOffsetX + 13, _startPosY.Value + bodyHeight + wheelsHeight / 6, 9, 9); + g.DrawEllipse(bPen, _startPosX.Value + bucketWidth + wheelsOffsetX + 28, _startPosY.Value + bodyHeight + wheelsHeight / 6, 9, 9); + g.FillEllipse(brYellow, _startPosX.Value + bucketWidth + wheelsOffsetX + 13, _startPosY.Value + bodyHeight + wheelsHeight / 6, 9, 9); + g.FillEllipse(brYellow, _startPosX.Value + bucketWidth + wheelsOffsetX + 28, _startPosY.Value + bodyHeight + wheelsHeight / 6, 9, 9); + + // ковш + if (EntityExcavator.Bucket) + { + PointF p1 = new Point(_startPosX.Value + bucketWidth, _startPosY.Value + cabineHeight); + PointF p2 = new Point(_startPosX.Value, _startPosY.Value + cabineHeight); + PointF p3 = new Point(_startPosX.Value + bucketWidth, _startPosY.Value + cabineHeight + bodyHeight / 2); + + g.DrawLine(pen, p1, p2); + g.DrawLine(pen, p2, p3); + g.DrawLine(pen, p3, p1); + + g.FillPolygon(additionalBrush, [p1, p2, p3]); + } + + // опоры + if (EntityExcavator.Supports) + { + g.DrawLine(bPen, + _startPosX.Value + bucketWidth + bodyHeight, _startPosY.Value + cabineHeight + 10, + _startPosX.Value + bucketWidth + bodyHeight + 15, _startPosY.Value + cabineHeight + 10); + g.DrawLine(bPen, + _startPosX.Value + bucketWidth + bodyHeight + 15, _startPosY.Value + cabineHeight + 10, + _startPosX.Value + bucketWidth + bodyHeight + 15, _startPosY.Value + bodyHeight + wheelsHeight); + g.DrawLine(bPen, + _startPosX.Value + bucketWidth + bodyHeight + 15, _startPosY.Value + bodyHeight + wheelsHeight, + _startPosX.Value + bucketWidth + bodyHeight + 30, _startPosY.Value + bodyHeight + wheelsHeight); + } + } +} + diff --git a/Excavator/Excavator/EntityExcavator.cs b/Excavator/Excavator/EntityExcavator.cs new file mode 100644 index 0000000..1ae8e23 --- /dev/null +++ b/Excavator/Excavator/EntityExcavator.cs @@ -0,0 +1,66 @@ +namespace Excavator; + +/// +/// Класс-сущность "Экскаватор" +/// +public class EntityExcavator +{ + + public int m; + /// + /// Скорость + /// + public int Speed { get; private set; } + + /// + /// Вес + /// + public double Weight { get; private set; } + + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + + /// + /// Дополнительный цвет (для опциональных элементов) + /// + public Color AdditionalColor { get; private set; } + + /// + /// Признак (опция) наличия ковша + /// + public bool Bucket { get; private set; } + + /// + /// Признак (опция) наличия опор + /// + public bool Supports { get; private set; } + + + + /// + /// Шаг перемещения экскаватора + /// + public double Step => Speed * 100 / Weight; + + /// + /// Инициализация полей объекта-класса спортивного автомобиля + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия ковша + /// Признак наличия опор + + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bucket, bool supports) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Bucket = bucket; + Supports = supports; + } +} \ No newline at end of file diff --git a/Excavator/Excavator/Excavator.csproj b/Excavator/Excavator/Excavator.csproj index 663fdb8..af03d74 100644 --- a/Excavator/Excavator/Excavator.csproj +++ b/Excavator/Excavator/Excavator.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/Excavator/Excavator/Form1.Designer.cs b/Excavator/Excavator/Form1.Designer.cs deleted file mode 100644 index 3437188..0000000 --- a/Excavator/Excavator/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Excavator -{ - partial class Form1 - { - /// - /// 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.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/Excavator/Excavator/Form1.cs b/Excavator/Excavator/Form1.cs deleted file mode 100644 index 5129c04..0000000 --- a/Excavator/Excavator/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Excavator -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/Excavator/Excavator/FormExcavator.Designer.cs b/Excavator/Excavator/FormExcavator.Designer.cs new file mode 100644 index 0000000..e3917bf --- /dev/null +++ b/Excavator/Excavator/FormExcavator.Designer.cs @@ -0,0 +1,136 @@ +namespace Excavator +{ + partial class FormExcavator + { + /// + /// 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() + { + pictureBoxExcavator = new PictureBox(); + buttonCreate = new Button(); + buttonLeft = new Button(); + buttonRight = new Button(); + buttonUp = new Button(); + buttonDown = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).BeginInit(); + SuspendLayout(); + // + // pictureBoxExcavator + // + pictureBoxExcavator.Dock = DockStyle.Fill; + pictureBoxExcavator.Location = new Point(0, 0); + pictureBoxExcavator.Name = "pictureBoxExcavator"; + pictureBoxExcavator.Size = new Size(824, 407); + pictureBoxExcavator.TabIndex = 0; + pictureBoxExcavator.TabStop = false; + + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(12, 366); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(94, 29); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.arrowLeft; + buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; + buttonLeft.Location = new Point(697, 360); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(35, 35); + buttonLeft.TabIndex = 2; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += ButtonMove_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.arrowRight; + buttonRight.BackgroundImageLayout = ImageLayout.Stretch; + buttonRight.Location = new Point(777, 360); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(35, 35); + buttonRight.TabIndex = 3; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += ButtonMove_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.arrowUp; + buttonUp.BackgroundImageLayout = ImageLayout.Stretch; + buttonUp.Location = new Point(736, 317); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(35, 35); + buttonUp.TabIndex = 4; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += ButtonMove_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.arrowDown; + buttonDown.BackgroundImageLayout = ImageLayout.Stretch; + buttonDown.Location = new Point(736, 360); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(35, 35); + buttonDown.TabIndex = 5; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += ButtonMove_Click; + // + // FormExcavator + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(824, 407); + Controls.Add(buttonDown); + Controls.Add(buttonUp); + Controls.Add(buttonRight); + Controls.Add(buttonLeft); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxExcavator); + Name = "FormExcavator"; + Text = "Экскаватор"; + + ((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).EndInit(); + ResumeLayout(false); + } + + #endregion + + private PictureBox pictureBoxExcavator; + private Button buttonCreate; + private Button buttonLeft; + private Button buttonRight; + private Button buttonUp; + private Button buttonDown; + } +} \ No newline at end of file diff --git a/Excavator/Excavator/FormExcavator.cs b/Excavator/Excavator/FormExcavator.cs new file mode 100644 index 0000000..51bc0fa --- /dev/null +++ b/Excavator/Excavator/FormExcavator.cs @@ -0,0 +1,99 @@ +namespace Excavator; + +/// +/// Форма работы с объектом "Экскаватор" +/// +public partial class FormExcavator : Form +{ + /// + /// Поле-объект для прорисовки объекта + /// + private DrawningExcavator? _drawningExcavator; + + + /// + /// Конструктор формы + /// + public FormExcavator() + { + InitializeComponent(); + } + /// + /// Метод прорисовки экскаватора + /// + + private void Draw() + { + if(_drawningExcavator == null) + { + return; + } + Bitmap bmp = new(pictureBoxExcavator.Width, pictureBoxExcavator.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningExcavator.DrawTransport(gr); + pictureBoxExcavator.Image = bmp; + + } + + + + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) + { + + Random random = new(); + _drawningExcavator = new DrawningExcavator(); + _drawningExcavator.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))); + _drawningExcavator.SetPictureSize(pictureBoxExcavator.Width, pictureBoxExcavator.Height); + _drawningExcavator.SetPosition(random.Next(10, 100), random.Next(10, 100)); + + + + Draw(); + } + + + /// + /// Перемещение объекта по форме (нажатие кнопок навигации) + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawningExcavator == null) + { + return; + } + + string name = ((Button)sender)?.Name ?? string.Empty; + bool result = false; + switch (name) + { + case "buttonUp": + result = _drawningExcavator.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + result = _drawningExcavator.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + result = _drawningExcavator.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + result = _drawningExcavator.MoveTransport(DirectionType.Right); + break; + } + + if (result) + { + Draw(); + } + } +} + diff --git a/Excavator/Excavator/FormExcavator.resx b/Excavator/Excavator/FormExcavator.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Excavator/Excavator/FormExcavator.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/Excavator/Excavator/Program.cs b/Excavator/Excavator/Program.cs index 0facf42..4f04208 100644 --- a/Excavator/Excavator/Program.cs +++ b/Excavator/Excavator/Program.cs @@ -11,7 +11,7 @@ namespace Excavator // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new FormExcavator()); } } } \ No newline at end of file diff --git a/Excavator/Excavator/Properties/Resources.Designer.cs b/Excavator/Excavator/Properties/Resources.Designer.cs new file mode 100644 index 0000000..51c3b56 --- /dev/null +++ b/Excavator/Excavator/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Excavator.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Excavator.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowDown { + get { + object obj = ResourceManager.GetObject("arrowDown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowLeft { + get { + object obj = ResourceManager.GetObject("arrowLeft", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowRight { + get { + object obj = ResourceManager.GetObject("arrowRight", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowUp { + get { + object obj = ResourceManager.GetObject("arrowUp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Excavator/Excavator/Properties/Resources.resx b/Excavator/Excavator/Properties/Resources.resx new file mode 100644 index 0000000..b354c7b --- /dev/null +++ b/Excavator/Excavator/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\arrowLeft.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowDown.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowRight.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowUp.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Excavator/Excavator/Resources/arrowDown.jpg b/Excavator/Excavator/Resources/arrowDown.jpg new file mode 100644 index 0000000..f21002e Binary files /dev/null and b/Excavator/Excavator/Resources/arrowDown.jpg differ diff --git a/Excavator/Excavator/Resources/arrowLeft.jpg b/Excavator/Excavator/Resources/arrowLeft.jpg new file mode 100644 index 0000000..61b8dae Binary files /dev/null and b/Excavator/Excavator/Resources/arrowLeft.jpg differ diff --git a/Excavator/Excavator/Resources/arrowRight.jpg b/Excavator/Excavator/Resources/arrowRight.jpg new file mode 100644 index 0000000..b440197 Binary files /dev/null and b/Excavator/Excavator/Resources/arrowRight.jpg differ diff --git a/Excavator/Excavator/Resources/arrowUp.jpg b/Excavator/Excavator/Resources/arrowUp.jpg new file mode 100644 index 0000000..e630cea Binary files /dev/null and b/Excavator/Excavator/Resources/arrowUp.jpg differ diff --git a/Excavator/FormExcavator.Designer.cs b/Excavator/FormExcavator.Designer.cs new file mode 100644 index 0000000..e3917bf --- /dev/null +++ b/Excavator/FormExcavator.Designer.cs @@ -0,0 +1,136 @@ +namespace Excavator +{ + partial class FormExcavator + { + /// + /// 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() + { + pictureBoxExcavator = new PictureBox(); + buttonCreate = new Button(); + buttonLeft = new Button(); + buttonRight = new Button(); + buttonUp = new Button(); + buttonDown = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).BeginInit(); + SuspendLayout(); + // + // pictureBoxExcavator + // + pictureBoxExcavator.Dock = DockStyle.Fill; + pictureBoxExcavator.Location = new Point(0, 0); + pictureBoxExcavator.Name = "pictureBoxExcavator"; + pictureBoxExcavator.Size = new Size(824, 407); + pictureBoxExcavator.TabIndex = 0; + pictureBoxExcavator.TabStop = false; + + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(12, 366); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(94, 29); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.arrowLeft; + buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; + buttonLeft.Location = new Point(697, 360); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(35, 35); + buttonLeft.TabIndex = 2; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += ButtonMove_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.arrowRight; + buttonRight.BackgroundImageLayout = ImageLayout.Stretch; + buttonRight.Location = new Point(777, 360); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(35, 35); + buttonRight.TabIndex = 3; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += ButtonMove_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.arrowUp; + buttonUp.BackgroundImageLayout = ImageLayout.Stretch; + buttonUp.Location = new Point(736, 317); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(35, 35); + buttonUp.TabIndex = 4; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += ButtonMove_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.arrowDown; + buttonDown.BackgroundImageLayout = ImageLayout.Stretch; + buttonDown.Location = new Point(736, 360); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(35, 35); + buttonDown.TabIndex = 5; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += ButtonMove_Click; + // + // FormExcavator + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(824, 407); + Controls.Add(buttonDown); + Controls.Add(buttonUp); + Controls.Add(buttonRight); + Controls.Add(buttonLeft); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxExcavator); + Name = "FormExcavator"; + Text = "Экскаватор"; + + ((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).EndInit(); + ResumeLayout(false); + } + + #endregion + + private PictureBox pictureBoxExcavator; + private Button buttonCreate; + private Button buttonLeft; + private Button buttonRight; + private Button buttonUp; + private Button buttonDown; + } +} \ No newline at end of file diff --git a/Excavator/FormExcavator.cs b/Excavator/FormExcavator.cs new file mode 100644 index 0000000..578df62 --- /dev/null +++ b/Excavator/FormExcavator.cs @@ -0,0 +1,99 @@ +namespace Excavator; + +/// +/// Форма работы с объектом "Экскаватор" +/// +public partial class FormExcavator : Form +{ + /// + /// Поле-объект для прорисовки объекта + /// + private DrawningExcavator? _drawningExcavator; + + + /// + /// Конструктор формы + /// + public FormExcavator() + { + InitializeComponent(); + } + /// + /// Метод прорисовки машины + /// + + private void Draw() + { + if(_drawningExcavator == null) + { + return; + } + Bitmap bmp = new(pictureBoxExcavator.Width, pictureBoxExcavator.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningExcavator.DrawTransport(gr); + pictureBoxExcavator.Image = bmp; + + } + + + + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) + { + + Random random = new(); + _drawningExcavator = new DrawningExcavator(); + _drawningExcavator.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))); + _drawningExcavator.SetPictureSize(pictureBoxExcavator.Width, pictureBoxExcavator.Height); + _drawningExcavator.SetPosition(random.Next(10, 100), random.Next(10, 100)); + + + + Draw(); + } + + + /// + /// Перемещение объекта по форме (нажатие кнопок навигации) + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawningExcavator == null) + { + return; + } + + string name = ((Button)sender)?.Name ?? string.Empty; + bool result = false; + switch (name) + { + case "buttonUp": + result = _drawningExcavator.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + result = _drawningExcavator.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + result = _drawningExcavator.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + result = _drawningExcavator.MoveTransport(DirectionType.Right); + break; + } + + if (result) + { + Draw(); + } + } +} + diff --git a/Excavator/FormExcavator.resx b/Excavator/FormExcavator.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Excavator/FormExcavator.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/Excavator/Program.cs b/Excavator/Program.cs new file mode 100644 index 0000000..4f04208 --- /dev/null +++ b/Excavator/Program.cs @@ -0,0 +1,17 @@ +namespace Excavator +{ + 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 FormExcavator()); + } + } +} \ No newline at end of file diff --git a/Excavator/Properties/Resources.Designer.cs b/Excavator/Properties/Resources.Designer.cs new file mode 100644 index 0000000..51c3b56 --- /dev/null +++ b/Excavator/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Excavator.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Excavator.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowDown { + get { + object obj = ResourceManager.GetObject("arrowDown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowLeft { + get { + object obj = ResourceManager.GetObject("arrowLeft", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowRight { + get { + object obj = ResourceManager.GetObject("arrowRight", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowUp { + get { + object obj = ResourceManager.GetObject("arrowUp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Excavator/Properties/Resources.resx b/Excavator/Properties/Resources.resx new file mode 100644 index 0000000..b354c7b --- /dev/null +++ b/Excavator/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\arrowLeft.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowDown.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowRight.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowUp.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Excavator/Resources/arrowDown.jpg b/Excavator/Resources/arrowDown.jpg new file mode 100644 index 0000000..f21002e Binary files /dev/null and b/Excavator/Resources/arrowDown.jpg differ diff --git a/Excavator/Resources/arrowLeft.jpg b/Excavator/Resources/arrowLeft.jpg new file mode 100644 index 0000000..61b8dae Binary files /dev/null and b/Excavator/Resources/arrowLeft.jpg differ diff --git a/Excavator/Resources/arrowRight.jpg b/Excavator/Resources/arrowRight.jpg new file mode 100644 index 0000000..b440197 Binary files /dev/null and b/Excavator/Resources/arrowRight.jpg differ diff --git a/Excavator/Resources/arrowUp.jpg b/Excavator/Resources/arrowUp.jpg new file mode 100644 index 0000000..e630cea Binary files /dev/null and b/Excavator/Resources/arrowUp.jpg differ