From 025bd88523b6e4e8766715c3c09f80d0a6213e3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?=
=?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com>
Date: Mon, 18 Sep 2023 13:32:20 +0400
Subject: [PATCH 1/3] new branch
---
.../ElectricLocomotive/DirectionType.cs | 19 ++
.../DrawningElectricLocomotive.cs | 200 +++++++++++++++
.../ElectricLocomotive.Designer.cs | 138 +++++++++++
.../ElectricLocomotive/ElectricLocomotive.cs | 64 +++++
.../ElectricLocomotive.csproj | 15 ++
.../ElectricLocomotive.resx | 234 ++++++++++++++++++
.../EntityElectricLocomotive.cs | 35 +++
.../ElectricLocomotive/Form1.Designer.cs | 39 ---
.../ElectricLocomotive/Form1.cs | 10 -
.../ElectricLocomotive/Program.cs | 2 +-
.../Properties/Resources.Designer.cs | 63 +++++
.../{Form1.resx => Properties/Resources.resx} | 0
12 files changed, 769 insertions(+), 50 deletions(-)
create mode 100644 ElectricLocomotive/ElectricLocomotive/DirectionType.cs
create mode 100644 ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs
create mode 100644 ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.Designer.cs
create mode 100644 ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs
create mode 100644 ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.resx
create mode 100644 ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs
delete mode 100644 ElectricLocomotive/ElectricLocomotive/Form1.Designer.cs
delete mode 100644 ElectricLocomotive/ElectricLocomotive/Form1.cs
create mode 100644 ElectricLocomotive/ElectricLocomotive/Properties/Resources.Designer.cs
rename ElectricLocomotive/ElectricLocomotive/{Form1.resx => Properties/Resources.resx} (100%)
diff --git a/ElectricLocomotive/ElectricLocomotive/DirectionType.cs b/ElectricLocomotive/ElectricLocomotive/DirectionType.cs
new file mode 100644
index 0000000..ab57b68
--- /dev/null
+++ b/ElectricLocomotive/ElectricLocomotive/DirectionType.cs
@@ -0,0 +1,19 @@
+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/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs
new file mode 100644
index 0000000..6c76064
--- /dev/null
+++ b/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs
@@ -0,0 +1,200 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms.VisualStyles;
+
+namespace ElectricLocomotive
+{
+ public class DrawningElectricLocomotive
+ {
+ private EntityElectricLocomotive enitity_electric_locomotive = new EntityElectricLocomotive();
+
+
+ private int _startPosX;
+
+ private int _startPosY;
+
+ private const int _LengthLocomotive = 120;
+
+ private const int _HeightLocomorive=90;
+
+
+ public bool Init(int speed, double weight, Color bodyColor, Color additionalColor)
+ {
+ if (speed < 0 || bodyColor == additionalColor)
+ {
+ return false;
+ }
+ else
+ {
+ enitity_electric_locomotive.Init(speed, weight, bodyColor, additionalColor);
+
+ return true;
+ }
+ }
+
+ public void SetPosition(int x, int y)
+ {
+ if (x < 0 || y < 0 || x + _LengthLocomotive > ElectricLocomotive.ActiveForm.Size.Width || y + _HeightLocomorive > ElectricLocomotive.ActiveForm.Size.Height)
+ {
+ return ;
+ }
+ else
+ {
+ _startPosX = x;
+
+ _startPosY = y;
+ }
+ }
+
+ public void MoveTransport(DirectionType direction)
+ {
+ if (enitity_electric_locomotive == null)
+ {
+ return;
+ }
+
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX - enitity_electric_locomotive.Step > 0)
+ {
+ _startPosX -= (int)enitity_electric_locomotive.Step;
+ }
+ break;
+
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY - enitity_electric_locomotive.Step > 0)
+ {
+ _startPosY -= (int)enitity_electric_locomotive.Step;
+ }
+ break;
+
+ // вправо
+ case DirectionType.Right: // TODO: Продумать логику
+ if (_startPosX+_LengthLocomotive+(int)enitity_electric_locomotive.Step < ElectricLocomotive.ActiveForm.Size.Width)
+ {
+ _startPosX += (int)enitity_electric_locomotive.Step;
+ }
+ break;
+
+ //вниз
+ case DirectionType.Down: // TODO: Продумать логику
+ if (_startPosY + _HeightLocomorive + (int)enitity_electric_locomotive.Step < ElectricLocomotive.ActiveForm.Size.Height)
+ {
+ _startPosY += (int)enitity_electric_locomotive.Step;
+ }
+ break;
+ }
+ }
+
+
+
+
+ public void DrawTransport(Graphics g)
+ {
+ if (enitity_electric_locomotive == null)
+ {
+ return;
+ }
+
+ Pen pen = new(enitity_electric_locomotive.AdditionalColor);
+ Brush brush = new SolidBrush(enitity_electric_locomotive.BodyColor);
+
+ ///ВЛ60к-1595
+
+ ///ходовая
+ g.FillRectangle(brush, new Rectangle(_startPosX + 20, _startPosY + 45, 15, 5));
+ g.FillRectangle(brush, new Rectangle(_startPosX + 65, _startPosY + 45, 15, 5));
+
+ g.FillEllipse(brush, _startPosX + 15, _startPosY + 45, 10, 10);
+ g.FillEllipse(brush, _startPosX + 30, _startPosY + 45, 10, 10);
+ g.FillEllipse(brush, _startPosX + 60, _startPosY + 45, 10, 10);
+ g.FillEllipse(brush, _startPosX + 75, _startPosY + 45, 10, 10);
+ PointF[] chassis =
+ {
+ new Point(_startPosX+10, _startPosY+50),
+ new Point(_startPosX, _startPosY+50),
+ new Point(_startPosX+10, _startPosY +40),
+ new Point(_startPosX + 90, _startPosY+40),
+ new Point(_startPosX+100, _startPosY+50),
+ new Point(_startPosX+90,_startPosY+ 50),
+ new Point(_startPosX+85, _startPosY+45),
+ new Point(_startPosX+15, _startPosY+45),
+ };
+ g.FillPolygon(brush, chassis);
+
+ ///обводка ходовой
+ Point[] chassisCont =
+ {
+ new Point(_startPosX+10, _startPosY+50),
+ new Point(_startPosX, _startPosY+50),
+ new Point(_startPosX+10, _startPosY +40),
+ new Point(_startPosX + 90, _startPosY+40),
+ new Point(_startPosX+100, _startPosY+50),
+ new Point(_startPosX+90,_startPosY+ 50),
+ new Point(_startPosX+85, _startPosY+45),
+ new Point(_startPosX+15, _startPosY+45),
+ };
+ g.DrawPolygon(pen, chassisCont);
+
+ ///кабина
+ Point[] cabin =
+ {
+ new Point(_startPosX+20, _startPosY+10),
+ new Point(_startPosX+90,_startPosY+10),
+ new Point(_startPosX+90,_startPosY + 40),
+ new Point(_startPosX+10,_startPosY+40),
+ new Point(_startPosX+10,_startPosY+25)
+ };
+ g.DrawPolygon(pen, cabin);
+ g.DrawLine(pen, _startPosX + 10, _startPosY + 25, _startPosX + 90, _startPosY + 25);
+
+ ///окна
+ g.FillRectangle(brush, _startPosX + 20, _startPosY + 15, 10, 10);
+ g.FillRectangle(brush, _startPosX + 35, _startPosY + 15, 10, 10);
+
+ g.FillRectangle(brush, _startPosX + 75, _startPosY + 15, 10, 10);
+
+ ///дверь
+ g.FillRectangle(brush, _startPosX + 50, _startPosY + 15, 10, 25);
+
+ ///рога
+ g.FillRectangle(brush, _startPosX + 25, _startPosY + 5, 15, 5);
+
+ Point[] horns =
+ {
+ new Point(_startPosX+25, _startPosY+10),
+ new Point(_startPosX+25, _startPosY+5),
+ new Point(_startPosX+33,_startPosY+5),
+ new Point(_startPosX+50, _startPosY),
+ new Point(_startPosX+33,_startPosY+5),
+ new Point(_startPosX+40,_startPosY+5),
+ new Point(_startPosX+40,_startPosY+10)
+ };
+ g.DrawPolygon(pen, horns);
+
+ g.FillRectangle(brush, _startPosX + 65, _startPosY + 5, 15, 5);
+ Point[] horns2 =
+ {
+ new Point(_startPosX+65, _startPosY+10),
+ new Point(_startPosX+65, _startPosY+5),
+ new Point(_startPosX+73,_startPosY+5),
+ new Point(_startPosX+90, _startPosY),
+ new Point(_startPosX+73,_startPosY+5),
+ new Point(_startPosX+80,_startPosY+5),
+ new Point(_startPosX+80,_startPosY+10)
+ };
+ g.DrawPolygon(pen, horns2);
+
+ ///Батарея
+ g.FillRectangle(brush, _startPosX + 45, _startPosY + 5, 15, 5);
+
+ }
+ }
+}
diff --git a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.Designer.cs b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.Designer.cs
new file mode 100644
index 0000000..f765a9b
--- /dev/null
+++ b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.Designer.cs
@@ -0,0 +1,138 @@
+namespace ElectricLocomotive
+{
+ partial class ElectricLocomotive
+ {
+ ///
+ /// 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()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ElectricLocomotive));
+ pictureBoxElectroLocomotiv = new PictureBox();
+ buttonUp = new Button();
+ buttonRight = new Button();
+ buttonDown = new Button();
+ buttonLeft = new Button();
+ buttonCreate = new Button();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxElectroLocomotiv).BeginInit();
+ SuspendLayout();
+ //
+ // pictureBoxElectroLocomotiv
+ //
+ pictureBoxElectroLocomotiv.AccessibleRole = AccessibleRole.Client;
+ pictureBoxElectroLocomotiv.Dock = DockStyle.Fill;
+ pictureBoxElectroLocomotiv.Location = new Point(0, 0);
+ pictureBoxElectroLocomotiv.Name = "pictureBoxElectroLocomotiv";
+ pictureBoxElectroLocomotiv.Size = new Size(854, 467);
+ pictureBoxElectroLocomotiv.SizeMode = PictureBoxSizeMode.AutoSize;
+ pictureBoxElectroLocomotiv.TabIndex = 5;
+ pictureBoxElectroLocomotiv.TabStop = false;
+ //
+ // buttonUp
+ //
+ buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
+ buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonUp.Location = new Point(777, 389);
+ buttonUp.Name = "buttonUp";
+ buttonUp.Size = new Size(30, 30);
+ buttonUp.TabIndex = 10;
+ buttonUp.UseVisualStyleBackColor = true;
+ buttonUp.Click += buttonMove_Click;
+ //
+ // buttonRight
+ //
+ buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
+ buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonRight.Location = new Point(813, 425);
+ buttonRight.Name = "buttonRight";
+ buttonRight.Size = new Size(30, 30);
+ buttonRight.TabIndex = 9;
+ buttonRight.UseVisualStyleBackColor = true;
+ buttonRight.Click += buttonMove_Click;
+ //
+ // buttonDown
+ //
+ buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
+ buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonDown.Location = new Point(777, 425);
+ buttonDown.Name = "buttonDown";
+ buttonDown.Size = new Size(30, 30);
+ buttonDown.TabIndex = 8;
+ buttonDown.UseVisualStyleBackColor = true;
+ buttonDown.Click += buttonMove_Click;
+ //
+ // buttonLeft
+ //
+ buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
+ buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
+ buttonLeft.Location = new Point(741, 425);
+ buttonLeft.Name = "buttonLeft";
+ buttonLeft.Size = new Size(30, 30);
+ buttonLeft.TabIndex = 7;
+ buttonLeft.UseVisualStyleBackColor = true;
+ buttonLeft.Click += buttonMove_Click;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonCreate.Location = new Point(13, 425);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(108, 34);
+ buttonCreate.TabIndex = 6;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += buttonCreate_Click;
+ //
+ // ElectricLocomotive
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(854, 467);
+ Controls.Add(buttonUp);
+ Controls.Add(buttonRight);
+ Controls.Add(buttonDown);
+ Controls.Add(buttonLeft);
+ Controls.Add(buttonCreate);
+ Controls.Add(pictureBoxElectroLocomotiv);
+ Name = "ElectricLocomotive";
+ Text = "ElectricLocomotive";
+ ((System.ComponentModel.ISupportInitialize)pictureBoxElectroLocomotiv).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private PictureBox pictureBoxElectroLocomotiv;
+ private Button buttonUp;
+ private Button buttonRight;
+ private Button buttonDown;
+ private Button buttonLeft;
+ private Button buttonCreate;
+ }
+}
\ No newline at end of file
diff --git a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs
new file mode 100644
index 0000000..360e4bd
--- /dev/null
+++ b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs
@@ -0,0 +1,64 @@
+namespace ElectricLocomotive
+{
+ public partial class ElectricLocomotive : Form
+ {
+ private DrawningElectricLocomotive? _drawningElectricLocomotive;
+ public ElectricLocomotive()
+ {
+ InitializeComponent();
+ }
+
+ private void Draw()
+ {
+ if (_drawningElectricLocomotive == null)
+ {
+ return;
+ }
+
+ Bitmap bmp = new(pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _drawningElectricLocomotive.DrawTransport(gr);
+ pictureBoxElectroLocomotiv.Image = bmp;
+
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ Random random = new();
+ _drawningElectricLocomotive = new DrawningElectricLocomotive();
+ _drawningElectricLocomotive.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)));
+ _drawningElectricLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
+
+ Draw();
+ }
+ private void buttonMove_Click(object sender, EventArgs e)
+ {
+ if (_drawningElectricLocomotive == null)
+ {
+ return;
+ }
+
+ string name = ((Button)sender)?.Name ?? string.Empty;
+
+ switch (name)
+ {
+ case "buttonUp":
+ _drawningElectricLocomotive.MoveTransport(DirectionType.Up);
+ break;
+ case "buttonDown":
+ _drawningElectricLocomotive.MoveTransport(DirectionType.Down);
+ break;
+ case "buttonLeft":
+ _drawningElectricLocomotive.MoveTransport(DirectionType.Left);
+ break;
+ case "buttonRight":
+ _drawningElectricLocomotive.MoveTransport(DirectionType.Right);
+ break;
+ }
+
+ Draw();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.csproj b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.csproj
index b57c89e..13ee123 100644
--- a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.csproj
+++ b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.csproj
@@ -8,4 +8,19 @@
enable
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
\ No newline at end of file
diff --git a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.resx b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.resx
new file mode 100644
index 0000000..c147ad4
--- /dev/null
+++ b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.resx
@@ -0,0 +1,234 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAX1JREFUaEPt
+ 2T0rhXEcxvHjqbwGg+IVyMxIJpOyGEweFpPYZbBQMpmYFEViZGWR1yJi8Ox71bnr390lHbq5f/l/61P6
+ 36dzX4fOGZxGLpfL5epaL+Ywix4dRGocd3hvusEYQjSJJxTjC4+YQK2bwjPK4wsvmEYtm8cr3PDUGxZQ
+ q5bhxn5GL2IRtajV8ak1/FltWIcb1oot6Ll+Nd1QN3aDvmMb7fiVOrALN+Qn9tCJStMNDuEGFM7NWeHM
+ nKX03PoFVdZXb9hTdJfOUrp2UjorW0JlXcLdVA7QBeWui9Jj9uGuywUq6xjupnpPpH969xgp0mN34B5z
+ hMoaxAPSG+rTqPwJkl5PpemTbBPp9XsMoNL6sQrdfFQHpnRUyjWCDaygTwd1yI2XMLnxEiY3XsLkxkuY
+ 3HgJkxsvYXLjJUxuvITJjZcwufESJjdewuTGS5jceAmTGy9hcv9e1FmYrlF+AVcI0zBuUYzXz0MIlb7U
+ mGkK9wVHLpfL/YsajQ+TA0YtgOqCtwAAAABJRU5ErkJggg==
+
+
+
+
+ iVBORw0KGgoAAAANS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/ryKvoSb7+Tk4mu46CIiooKDOut3
+ ay+EklQXexO5Bw4kaYac0hYxUhR/qcJNIo2DYwafiTQOjjnkABoHhwZIowHSaIA0GiCNBkijAdJogDQa
+ II0GSKMB0miANBogjQb8khKcwkY8s/NtQBlOYCWe5cQC0sHucEALFr4JqMM9pD1rWsiLFeTDuSI+BTTh
+ AfKeHcwN+r+f7xxpi8gKaMEj5Os32IO5UoNmxAOOIeMKaMMT5GsUP4QiZEXYAjrwDM39YodnXBHpgC68
+ GGu0bwS9IB1Bj8XSmNNX62rM6ZnvQ69IR7j06s6n+RTh9eEZV0QQh2dsL3Ywh2coYgvpy+P6ueE9BVh8
+ D5V/JIpe+j/GQF3wLqYAAAAASUVORK5CYII=
+
+
+
+
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAMNJREFUaEPt
+ 1T0OAVEUhuGbWAYW4GcBGksgbIZSSWxKBDugwgZmBWh4T6K4ubmmUMg98T3J20wyyXeamSAiIiIi/6VN
+ ezpR1x54YuMv9Hy3JjfS8Q8akgu58RNyoUWux59J438tN35KLrge36R4vLWheSHNqE8fbSkeX2IVNShr
+ R7mXSqr2APthXSl+4UCrQlpQj2qlf907jcgVHVEKHVGK3BFjcsWOiD+xNxqQK+kRS3LHjrA/9pE69kBE
+ RERE5AshvACI8cWowOkNEgAAAABJRU5ErkJggg==
+
+
+
\ No newline at end of file
diff --git a/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs
new file mode 100644
index 0000000..6e42320
--- /dev/null
+++ b/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ElectricLocomotive
+{
+ public class EntityElectricLocomotive
+ {
+
+ 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 double Step => (double)Speed * 100 / Weight;
+
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor)
+ {
+
+ Speed = speed;
+
+ Weight = weight;
+
+ BodyColor = bodyColor;
+
+ AdditionalColor = additionalColor;
+
+ }
+ }
+}
diff --git a/ElectricLocomotive/ElectricLocomotive/Form1.Designer.cs b/ElectricLocomotive/ElectricLocomotive/Form1.Designer.cs
deleted file mode 100644
index 370aa92..0000000
--- a/ElectricLocomotive/ElectricLocomotive/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace ElectricLocomotive
-{
- 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
- }
-}
\ No newline at end of file
diff --git a/ElectricLocomotive/ElectricLocomotive/Form1.cs b/ElectricLocomotive/ElectricLocomotive/Form1.cs
deleted file mode 100644
index e2660af..0000000
--- a/ElectricLocomotive/ElectricLocomotive/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace ElectricLocomotive
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/ElectricLocomotive/ElectricLocomotive/Program.cs b/ElectricLocomotive/ElectricLocomotive/Program.cs
index 107b7fb..cfc9721 100644
--- a/ElectricLocomotive/ElectricLocomotive/Program.cs
+++ b/ElectricLocomotive/ElectricLocomotive/Program.cs
@@ -11,7 +11,7 @@ namespace ElectricLocomotive
// 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 ElectricLocomotive());
}
}
}
\ No newline at end of file
diff --git a/ElectricLocomotive/ElectricLocomotive/Properties/Resources.Designer.cs b/ElectricLocomotive/ElectricLocomotive/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..50bd099
--- /dev/null
+++ b/ElectricLocomotive/ElectricLocomotive/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace ElectricLocomotive.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("ElectricLocomotive.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;
+ }
+ }
+ }
+}
diff --git a/ElectricLocomotive/ElectricLocomotive/Form1.resx b/ElectricLocomotive/ElectricLocomotive/Properties/Resources.resx
similarity index 100%
rename from ElectricLocomotive/ElectricLocomotive/Form1.resx
rename to ElectricLocomotive/ElectricLocomotive/Properties/Resources.resx
--
2.25.1
From d1f9a5eead22ee368af8d82286ccda4ab6000de9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?=
=?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com>
Date: Fri, 6 Oct 2023 12:54:51 +0400
Subject: [PATCH 2/3] Sdano
---
.../DrawningElectricLocomotive.cs | 102 +++++++++---------
.../ElectricLocomotive/ElectricLocomotive.cs | 4 +-
.../EntityElectricLocomotive.cs | 43 ++++++--
3 files changed, 89 insertions(+), 60 deletions(-)
diff --git a/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs
index 6c76064..5ea4c7c 100644
--- a/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs
+++ b/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
+using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.VisualStyles;
@@ -10,35 +11,38 @@ namespace ElectricLocomotive
{
public class DrawningElectricLocomotive
{
- private EntityElectricLocomotive enitity_electric_locomotive = new EntityElectricLocomotive();
+ public EntityElectricLocomotive? _ElectricLocomotive { get; private set; }
+
+ private int _pictureWidth;
+
+ private int _pictureHeight;
private int _startPosX;
private int _startPosY;
- private const int _LengthLocomotive = 120;
+ private readonly int _LocomotiveWidth = 100;
- private const int _HeightLocomorive=90;
+ private readonly int _LocomoriveHeight =50;
- public bool Init(int speed, double weight, Color bodyColor, Color additionalColor)
+ public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool horns, int width, int height)
{
- if (speed < 0 || bodyColor == additionalColor)
+ _pictureWidth = width;
+ _pictureHeight = height;
+ if ((_pictureHeight < _LocomoriveHeight) || (_pictureWidth < _LocomotiveWidth))
{
return false;
}
- else
- {
- enitity_electric_locomotive.Init(speed, weight, bodyColor, additionalColor);
-
- return true;
- }
+ _ElectricLocomotive = new EntityElectricLocomotive();
+ _ElectricLocomotive.Init(speed, weight, bodyColor, additionalColor, horns);
+ return true;
}
public void SetPosition(int x, int y)
{
- if (x < 0 || y < 0 || x + _LengthLocomotive > ElectricLocomotive.ActiveForm.Size.Width || y + _HeightLocomorive > ElectricLocomotive.ActiveForm.Size.Height)
+ if (x < 0 || y < 0 || x + _LocomotiveWidth > _pictureWidth || y + _LocomoriveHeight > _pictureHeight)
{
return ;
}
@@ -52,7 +56,7 @@ namespace ElectricLocomotive
public void MoveTransport(DirectionType direction)
{
- if (enitity_electric_locomotive == null)
+ if (_ElectricLocomotive == null)
{
return;
}
@@ -61,33 +65,33 @@ namespace ElectricLocomotive
{
//влево
case DirectionType.Left:
- if (_startPosX - enitity_electric_locomotive.Step > 0)
+ if (_startPosX - _ElectricLocomotive.Step > 0)
{
- _startPosX -= (int)enitity_electric_locomotive.Step;
+ _startPosX -= (int)_ElectricLocomotive.Step;
}
break;
//вверх
case DirectionType.Up:
- if (_startPosY - enitity_electric_locomotive.Step > 0)
+ if (_startPosY - _ElectricLocomotive.Step > 0)
{
- _startPosY -= (int)enitity_electric_locomotive.Step;
+ _startPosY -= (int)_ElectricLocomotive.Step;
}
break;
// вправо
case DirectionType.Right: // TODO: Продумать логику
- if (_startPosX+_LengthLocomotive+(int)enitity_electric_locomotive.Step < ElectricLocomotive.ActiveForm.Size.Width)
+ if (_startPosX+ _LocomotiveWidth + (int)_ElectricLocomotive.Step < _pictureWidth)
{
- _startPosX += (int)enitity_electric_locomotive.Step;
+ _startPosX += (int)_ElectricLocomotive.Step;
}
break;
//вниз
case DirectionType.Down: // TODO: Продумать логику
- if (_startPosY + _HeightLocomorive + (int)enitity_electric_locomotive.Step < ElectricLocomotive.ActiveForm.Size.Height)
+ if (_startPosY + _LocomoriveHeight + (int)_ElectricLocomotive.Step < _pictureHeight)
{
- _startPosY += (int)enitity_electric_locomotive.Step;
+ _startPosY += (int)_ElectricLocomotive.Step;
}
break;
}
@@ -98,13 +102,13 @@ namespace ElectricLocomotive
public void DrawTransport(Graphics g)
{
- if (enitity_electric_locomotive == null)
+ if (_ElectricLocomotive == null)
{
return;
}
- Pen pen = new(enitity_electric_locomotive.AdditionalColor);
- Brush brush = new SolidBrush(enitity_electric_locomotive.BodyColor);
+ Pen pen = new(_ElectricLocomotive.AdditionalColor);
+ Brush brush = new SolidBrush(_ElectricLocomotive.BodyColor);
///ВЛ60к-1595
@@ -165,33 +169,35 @@ namespace ElectricLocomotive
g.FillRectangle(brush, _startPosX + 50, _startPosY + 15, 10, 25);
///рога
- g.FillRectangle(brush, _startPosX + 25, _startPosY + 5, 15, 5);
-
- Point[] horns =
+ if (_ElectricLocomotive.Horns == true)
{
- new Point(_startPosX+25, _startPosY+10),
- new Point(_startPosX+25, _startPosY+5),
- new Point(_startPosX+33,_startPosY+5),
- new Point(_startPosX+50, _startPosY),
- new Point(_startPosX+33,_startPosY+5),
- new Point(_startPosX+40,_startPosY+5),
- new Point(_startPosX+40,_startPosY+10)
- };
- g.DrawPolygon(pen, horns);
+ g.FillRectangle(brush, _startPosX + 25, _startPosY + 5, 15, 5);
- g.FillRectangle(brush, _startPosX + 65, _startPosY + 5, 15, 5);
- Point[] horns2 =
- {
- new Point(_startPosX+65, _startPosY+10),
- new Point(_startPosX+65, _startPosY+5),
- new Point(_startPosX+73,_startPosY+5),
- new Point(_startPosX+90, _startPosY),
- new Point(_startPosX+73,_startPosY+5),
- new Point(_startPosX+80,_startPosY+5),
- new Point(_startPosX+80,_startPosY+10)
- };
- g.DrawPolygon(pen, horns2);
+ Point[] horns =
+ {
+ new Point(_startPosX+25, _startPosY+10),
+ new Point(_startPosX+25, _startPosY+5),
+ new Point(_startPosX+33,_startPosY+5),
+ new Point(_startPosX+50, _startPosY),
+ new Point(_startPosX+33,_startPosY+5),
+ new Point(_startPosX+40,_startPosY+5),
+ new Point(_startPosX+40,_startPosY+10)
+ };
+ g.DrawPolygon(pen, horns);
+ g.FillRectangle(brush, _startPosX + 65, _startPosY + 5, 15, 5);
+ Point[] horns2 =
+ {
+ new Point(_startPosX+65, _startPosY+10),
+ new Point(_startPosX+65, _startPosY+5),
+ new Point(_startPosX+73,_startPosY+5),
+ new Point(_startPosX+90, _startPosY),
+ new Point(_startPosX+73,_startPosY+5),
+ new Point(_startPosX+80,_startPosY+5),
+ new Point(_startPosX+80,_startPosY+10)
+ };
+ g.DrawPolygon(pen, horns2);
+ }
///Батарея
g.FillRectangle(brush, _startPosX + 45, _startPosY + 5, 15, 5);
diff --git a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs
index 360e4bd..744b4dc 100644
--- a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs
+++ b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs
@@ -28,7 +28,9 @@ namespace ElectricLocomotive
_drawningElectricLocomotive = new DrawningElectricLocomotive();
_drawningElectricLocomotive.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)));
+ Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
+ Convert.ToBoolean(random.Next(0, 2)), pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height);
+
_drawningElectricLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
diff --git a/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs
index 6e42320..779c84e 100644
--- a/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs
+++ b/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs
@@ -8,28 +8,49 @@ namespace ElectricLocomotive
{
public class EntityElectricLocomotive
{
-
+ ///
+ /// Скорость
+ ///
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 Horns { get; private set; }
+ ///
+ /// Признак (опция) roga
+ ///
- public double Step => (double)Speed * 100 / Weight;
+ public double Step => (double)Speed * 100 / Weight; ///свойство с лямбда выражением
+ ///
+ /// Инициализация полей объекта-класса электролокоматива
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия рогов
- public void Init(int speed, double weight, Color bodyColor, Color additionalColor)
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool horns)
{
-
Speed = speed;
-
Weight = weight;
-
BodyColor = bodyColor;
-
AdditionalColor = additionalColor;
-
+ Horns = horns;
}
}
+
}
+
--
2.25.1
From b9ea3213ee583f49fb51ef60ed711147fe65c671 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?=
=?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com>
Date: Fri, 6 Oct 2023 12:58:55 +0400
Subject: [PATCH 3/3] laba is done
---
.../ElectricLocomotive/DrawningElectricLocomotive.cs | 1 -
ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs | 1 -
2 files changed, 2 deletions(-)
diff --git a/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs
index 5ea4c7c..7b811a7 100644
--- a/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs
+++ b/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs
@@ -17,7 +17,6 @@ namespace ElectricLocomotive
private int _pictureHeight;
-
private int _startPosX;
private int _startPosY;
diff --git a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs
index 744b4dc..65f0e26 100644
--- a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs
+++ b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs
@@ -19,7 +19,6 @@ namespace ElectricLocomotive
Graphics gr = Graphics.FromImage(bmp);
_drawningElectricLocomotive.DrawTransport(gr);
pictureBoxElectroLocomotiv.Image = bmp;
-
}
private void buttonCreate_Click(object sender, EventArgs e)
--
2.25.1