diff --git a/.gitignore b/.gitignore
index ca1c7a3..c8988a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -398,3 +398,31 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
+# Common IntelliJ Platform excludes
+
+# User specific
+**/.idea/**/workspace.xml
+**/.idea/**/tasks.xml
+**/.idea/shelf/*
+**/.idea/dictionaries
+**/.idea/httpRequests/
+
+# Sensitive or high-churn files
+**/.idea/**/dataSources/
+**/.idea/**/dataSources.ids
+**/.idea/**/dataSources.xml
+**/.idea/**/dataSources.local.xml
+**/.idea/**/sqlDataSources.xml
+**/.idea/**/dynamic.xml
+
+# Rider
+# Rider auto-generates .iml files, and contentModel.xml
+**/.idea/**/*.iml
+**/.idea/**/contentModel.xml
+**/.idea/**/modules.xml
+
+[Pp]ackages/
+.idea/
+Thumbs.db
+Desktop.ini
+.DS_Store
\ No newline at end of file
diff --git a/ElectricLocomotive.sln b/ElectricLocomotive.sln
new file mode 100644
index 0000000..0ea4b4e
--- /dev/null
+++ b/ElectricLocomotive.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.7.34024.191
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectricLocomotive", "lab1\ElectricLocomotive.csproj", "{1873D890-4FFF-4880-BEA6-DFF8127E35CC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1873D890-4FFF-4880-BEA6-DFF8127E35CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1873D890-4FFF-4880-BEA6-DFF8127E35CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1873D890-4FFF-4880-BEA6-DFF8127E35CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1873D890-4FFF-4880-BEA6-DFF8127E35CC}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {CFC6C768-9D70-4856-A850-6C5A15A7C83C}
+ EndGlobalSection
+EndGlobal
diff --git a/lab1/DirectionType.cs b/lab1/DirectionType.cs
new file mode 100644
index 0000000..88dcdec
--- /dev/null
+++ b/lab1/DirectionType.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ElectricLocomotive
+{
+ public enum DirectionType
+ {
+ Up = 1,
+ Down = 2,
+ Left = 3,
+ Right = 4
+ }
+}
diff --git a/lab1/DrawingLocomotiv.cs b/lab1/DrawingLocomotiv.cs
new file mode 100644
index 0000000..054f22d
--- /dev/null
+++ b/lab1/DrawingLocomotiv.cs
@@ -0,0 +1,120 @@
+using ElectricLocomotive;
+using System;
+using System.Collections.Generic;
+using System.Drawing.Imaging;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ElectricLocomotive
+{
+ public class DrawingLocomotiv
+ {
+ public EntityLocomotiv? EntityLocomotiv { get; private set; }
+ private int _pictureWidth;
+ private int _pictureHeight;
+ private int _startPosX;
+ private int _startPosY;
+ private readonly int _vehicleWidth = 170;
+ private readonly int _vehicleHeight = 110;
+
+ public bool Init(int speed, double weight,int width,int height)
+ {
+ if (width <= _vehicleWidth || height <= _vehicleHeight) {
+ return false;
+ }
+ _pictureWidth = width;
+ _pictureHeight = height;
+ EntityLocomotiv = new EntityLocomotiv();
+ EntityLocomotiv.Init(speed, weight);
+ return true;
+ }
+ public void SetPosition(int x,int y)
+ {
+ if (EntityLocomotiv == null) return;
+ _startPosX = x;
+ _startPosY = y;
+ if (x + _vehicleWidth >= _pictureWidth || y + _vehicleHeight >= _pictureHeight)
+ {
+ _startPosX = 1;
+ _startPosY = 1;
+ }
+ }
+ public void MoveTransport(DirectionType direction)
+ {
+ if (EntityLocomotiv == null) return;
+
+ switch (direction)
+ {
+ case DirectionType.Left:
+ if (_startPosX - EntityLocomotiv.Step > 0)
+ {
+ _startPosX -= (int)EntityLocomotiv.Step;
+ }
+ break;
+ case DirectionType.Right:
+ if (_startPosX + EntityLocomotiv.Step + _vehicleWidth < _pictureWidth)
+ {
+ _startPosX += (int)EntityLocomotiv.Step;
+ }
+ break;
+ case DirectionType.Up:
+ if (_startPosY - EntityLocomotiv.Step > 0)
+ {
+ _startPosY -= (int)EntityLocomotiv.Step;
+ }
+ break;
+ case DirectionType.Down:
+ if (_startPosY + EntityLocomotiv.Step + _vehicleHeight < _pictureHeight)
+ {
+ _startPosY += (int)EntityLocomotiv.Step;
+ }
+ break;
+ }
+ }
+ public void DrawLoco(Graphics g)
+ {
+ if (EntityLocomotiv == null) return;
+ Pen penBody = new(EntityLocomotiv.ColorBody, 3);
+ Pen penWindow = new(EntityLocomotiv.ColorWindow, 3);
+ SolidBrush doorBrush = new(EntityLocomotiv.ColorFillBody);
+ Pen penWheel = new(EntityLocomotiv.ColorBody, 2);
+ SolidBrush batteryBrush = new(EntityLocomotiv.ColorBody);
+ //Body
+ g.DrawRectangle(penBody, _startPosX, _startPosY + _vehicleHeight - 50, _vehicleWidth - 10, _vehicleHeight - 80);
+ Point[] upBodyPoints = { new Point(_startPosX, _startPosY + 60), new Point(_startPosX + 10, _startPosY + 30), new Point(_startPosX + 150, _startPosY + 30), new Point(_startPosX + 160, _startPosY + 60) };
+ g.DrawPolygon(penBody, upBodyPoints);
+ //Roga
+ g.DrawLine(penBody, new Point(_startPosX + _vehicleWidth / 2, _startPosY + 30), new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15));
+ g.DrawLine(penBody, new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15), new Point(_startPosX + _vehicleWidth / 2, _startPosY));
+ //Door
+ g.DrawRectangle(penBody, _startPosX + _vehicleWidth / 2 - 15, _startPosY + 45, _vehicleWidth / 10, _vehicleHeight / 2 - 10);
+ g.FillRectangle(doorBrush, _startPosX + _vehicleWidth / 2 - 14, _startPosY + 46, _vehicleWidth / 10 - 1, _vehicleHeight / 2 - 12);
+ //Windows
+ int xWindow = _startPosX + 15;
+ int yWindow = _startPosY + 37;
+ for (int i = 0; i < 2; i++)
+ {
+ g.DrawRectangle(penWindow, xWindow, yWindow, 15, 15);
+ xWindow += 25;
+ }
+ xWindow += 35;
+ for (int i = 0; i < 2; i++)
+ {
+ g.DrawRectangle(penWindow, xWindow, yWindow, 15, 15);
+ xWindow += 25;
+ }
+ //wheels
+ int xWheel = _startPosX + 5;
+ int yWheel = _startPosY + _vehicleHeight - 20;
+ for (int i = 0; i < 4; i++)
+ {
+ g.DrawEllipse(penWheel, xWheel, yWheel, 20, 20);
+ xWheel += 40;
+ }
+ //battery
+ Point[] batteryPoints = { new Point(_startPosX + _vehicleWidth - 10,_startPosY + _vehicleHeight - 25), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 20), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 55), new Point(_startPosX + _vehicleWidth - 10, _startPosY + _vehicleHeight - 50) };
+ g.FillPolygon(batteryBrush, batteryPoints);
+ }
+ }
+}
diff --git a/lab1/ElectricLocomotive.csproj b/lab1/ElectricLocomotive.csproj
new file mode 100644
index 0000000..b57c89e
--- /dev/null
+++ b/lab1/ElectricLocomotive.csproj
@@ -0,0 +1,11 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
\ No newline at end of file
diff --git a/lab1/EntityLocomotiv.cs b/lab1/EntityLocomotiv.cs
new file mode 100644
index 0000000..996ab24
--- /dev/null
+++ b/lab1/EntityLocomotiv.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ElectricLocomotive
+{
+ public class EntityLocomotiv
+ {
+ public int Speed { get; private set; }
+ public double Weight { get; private set; }
+ public double Step => (double)Speed * 100 / Weight;
+ public readonly Color ColorBody = Color.Black;
+ public readonly Color ColorWindow = Color.Blue;
+ public readonly Color ColorFillBody = Color.White;
+ public void Init(int speed,double weight)
+ {
+ Speed = speed;
+ Weight = weight;
+ }
+ }
+}
diff --git a/lab1/MainForm.Designer.cs b/lab1/MainForm.Designer.cs
new file mode 100644
index 0000000..449a465
--- /dev/null
+++ b/lab1/MainForm.Designer.cs
@@ -0,0 +1,132 @@
+namespace ElectricLocomotive
+{
+ partial class MainForm
+ {
+ ///
+ /// 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()
+ {
+ locoBox = new PictureBox();
+ moveRightButton = new Button();
+ moveDownButton = new Button();
+ moveLeftButton = new Button();
+ moveUpButton = new Button();
+ paintObjectButton = new Button();
+ ((System.ComponentModel.ISupportInitialize)locoBox).BeginInit();
+ SuspendLayout();
+ //
+ // locoBox
+ //
+ locoBox.Dock = DockStyle.Fill;
+ locoBox.Location = new Point(0, 0);
+ locoBox.Name = "locoBox";
+ locoBox.Size = new Size(1265, 731);
+ locoBox.SizeMode = PictureBoxSizeMode.AutoSize;
+ locoBox.TabIndex = 0;
+ locoBox.TabStop = false;
+ //
+ // moveRightButton
+ //
+ moveRightButton.Location = new Point(1168, 647);
+ moveRightButton.Margin = new Padding(0);
+ moveRightButton.Name = "moveRightButton";
+ moveRightButton.Size = new Size(76, 60);
+ moveRightButton.TabIndex = 4;
+ moveRightButton.Text = "Вправо";
+ moveRightButton.UseVisualStyleBackColor = true;
+ moveRightButton.Click += MoveButton_Click;
+ //
+ // moveDownButton
+ //
+ moveDownButton.Location = new Point(1083, 647);
+ moveDownButton.Margin = new Padding(0);
+ moveDownButton.Name = "moveDownButton";
+ moveDownButton.Size = new Size(76, 60);
+ moveDownButton.TabIndex = 3;
+ moveDownButton.Text = "Вниз";
+ moveDownButton.UseVisualStyleBackColor = true;
+ moveDownButton.Click += MoveButton_Click;
+ //
+ // moveLeftButton
+ //
+ moveLeftButton.Location = new Point(997, 647);
+ moveLeftButton.Margin = new Padding(0);
+ moveLeftButton.Name = "moveLeftButton";
+ moveLeftButton.Size = new Size(76, 60);
+ moveLeftButton.TabIndex = 2;
+ moveLeftButton.Text = "Влево";
+ moveLeftButton.UseVisualStyleBackColor = true;
+ moveLeftButton.Click += MoveButton_Click;
+ //
+ // moveUpButton
+ //
+ moveUpButton.Location = new Point(1083, 571);
+ moveUpButton.Margin = new Padding(0);
+ moveUpButton.Name = "moveUpButton";
+ moveUpButton.Size = new Size(76, 60);
+ moveUpButton.TabIndex = 1;
+ moveUpButton.Text = "Вверх";
+ moveUpButton.UseVisualStyleBackColor = true;
+ moveUpButton.Click += MoveButton_Click;
+ //
+ // paintObjectButton
+ //
+ paintObjectButton.Location = new Point(36, 643);
+ paintObjectButton.Name = "paintObjectButton";
+ paintObjectButton.Size = new Size(161, 68);
+ paintObjectButton.TabIndex = 0;
+ paintObjectButton.Text = "Нарисовать";
+ paintObjectButton.UseVisualStyleBackColor = true;
+ paintObjectButton.Click += PaintObjectButton_click;
+ //
+ // MainForm
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1265, 731);
+ Controls.Add(moveRightButton);
+ Controls.Add(moveDownButton);
+ Controls.Add(moveLeftButton);
+ Controls.Add(moveUpButton);
+ Controls.Add(paintObjectButton);
+ Controls.Add(locoBox);
+ FormBorderStyle = FormBorderStyle.FixedSingle;
+ Name = "MainForm";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Лабораторная работа 1";
+ ((System.ComponentModel.ISupportInitialize)locoBox).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+ private Button paintObjectButton;
+ private Button moveRightButton;
+ private Button moveDownButton;
+ private Button moveLeftButton;
+ private Button moveUpButton;
+ private PictureBox locoBox;
+ }
+}
\ No newline at end of file
diff --git a/lab1/MainForm.cs b/lab1/MainForm.cs
new file mode 100644
index 0000000..7c6ee6a
--- /dev/null
+++ b/lab1/MainForm.cs
@@ -0,0 +1,55 @@
+using ElectricLocomotive;
+
+namespace ElectricLocomotive
+{
+ public partial class MainForm : Form
+ {
+ private DrawingLocomotiv? _drawingLocomotiv;
+ public MainForm()
+ {
+ InitializeComponent();
+ }
+
+ private void Draw()
+ {
+ if (_drawingLocomotiv == null) return;
+ Bitmap bmp = new(locoBox.Width, locoBox.Height);
+ Graphics g = Graphics.FromImage(bmp);
+ _drawingLocomotiv.DrawLoco(g);
+ locoBox.Image = bmp;
+ }
+ private void PaintObjectButton_click(object sender, EventArgs e)
+ {
+ Random random = new();
+ _drawingLocomotiv = new DrawingLocomotiv();
+ _drawingLocomotiv.Init(random.Next(100, 300),random.Next(1000,3000),locoBox.Width,locoBox.Height);
+ _drawingLocomotiv.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ Draw();
+ }
+
+ private void MoveButton_Click(object sender, EventArgs e)
+ {
+ if (_drawingLocomotiv == null) return;
+
+ Control button = sender as Control;
+
+ string name = button.Name;
+ switch (name)
+ {
+ case "moveUpButton":
+ _drawingLocomotiv.MoveTransport(DirectionType.Up);
+ break;
+ case "moveDownButton":
+ _drawingLocomotiv.MoveTransport(DirectionType.Down);
+ break;
+ case "moveLeftButton":
+ _drawingLocomotiv.MoveTransport(DirectionType.Left);
+ break;
+ case "moveRightButton":
+ _drawingLocomotiv.MoveTransport(DirectionType.Right);
+ break;
+ }
+ Draw();
+ }
+ }
+}
\ No newline at end of file
diff --git a/lab1/MainForm.resx b/lab1/MainForm.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/lab1/MainForm.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/lab1/Program.cs b/lab1/Program.cs
new file mode 100644
index 0000000..47f0250
--- /dev/null
+++ b/lab1/Program.cs
@@ -0,0 +1,17 @@
+namespace ElectricLocomotive
+{
+ 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 MainForm());
+ }
+ }
+}
\ No newline at end of file