From 307d615227499047f76d2e569a817530b1af6f7a Mon Sep 17 00:00:00 2001 From: Timourka Date: Tue, 26 Sep 2023 21:33:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=98=D0=B1=D0=B4-21=20=D0=9A=D1=83?= =?UTF-8?q?=D0=B2=D1=88=D0=B8=D0=BD=D0=BE=D0=B2=20=D0=A2=D0=B8=D0=BC=D1=83?= =?UTF-8?q?=D1=80=201=20=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Laba1Loco/Laba1Loco.sln | 25 ++ Laba1Loco/Laba1Loco/App.config | 6 + Laba1Loco/Laba1Loco/Direction.cs | 29 ++ Laba1Loco/Laba1Loco/DrawingLoco.cs | 393 ++++++++++++++++++ Laba1Loco/Laba1Loco/EntityLoco.cs | 67 +++ .../Laba1Loco/FormLocomotive.Designer.cs | 140 +++++++ Laba1Loco/Laba1Loco/FormLocomotive.cs | 97 +++++ Laba1Loco/Laba1Loco/FormLocomotive.resx | 123 ++++++ Laba1Loco/Laba1Loco/Laba1Loco.csproj | 102 +++++ Laba1Loco/Laba1Loco/Program.cs | 22 + .../Laba1Loco/Properties/AssemblyInfo.cs | 36 ++ .../Properties/Resources.Designer.cs | 113 +++++ Laba1Loco/Laba1Loco/Properties/Resources.resx | 136 ++++++ .../Laba1Loco/Properties/Settings.Designer.cs | 30 ++ .../Laba1Loco/Properties/Settings.settings | 7 + Laba1Loco/Laba1Loco/arow340x259.png | Bin 0 -> 541 bytes Laba1Loco/Laba1Loco/arowDown340x259.png | Bin 0 -> 546 bytes Laba1Loco/Laba1Loco/arowL340x259.png | Bin 0 -> 518 bytes Laba1Loco/Laba1Loco/arowR340x259.png | Bin 0 -> 513 bytes Laba1Loco/Laba1Loco/arowUp340x259.png | Bin 0 -> 541 bytes 20 files changed, 1326 insertions(+) create mode 100644 Laba1Loco/Laba1Loco.sln create mode 100644 Laba1Loco/Laba1Loco/App.config create mode 100644 Laba1Loco/Laba1Loco/Direction.cs create mode 100644 Laba1Loco/Laba1Loco/DrawingLoco.cs create mode 100644 Laba1Loco/Laba1Loco/EntityLoco.cs create mode 100644 Laba1Loco/Laba1Loco/FormLocomotive.Designer.cs create mode 100644 Laba1Loco/Laba1Loco/FormLocomotive.cs create mode 100644 Laba1Loco/Laba1Loco/FormLocomotive.resx create mode 100644 Laba1Loco/Laba1Loco/Laba1Loco.csproj create mode 100644 Laba1Loco/Laba1Loco/Program.cs create mode 100644 Laba1Loco/Laba1Loco/Properties/AssemblyInfo.cs create mode 100644 Laba1Loco/Laba1Loco/Properties/Resources.Designer.cs create mode 100644 Laba1Loco/Laba1Loco/Properties/Resources.resx create mode 100644 Laba1Loco/Laba1Loco/Properties/Settings.Designer.cs create mode 100644 Laba1Loco/Laba1Loco/Properties/Settings.settings create mode 100644 Laba1Loco/Laba1Loco/arow340x259.png create mode 100644 Laba1Loco/Laba1Loco/arowDown340x259.png create mode 100644 Laba1Loco/Laba1Loco/arowL340x259.png create mode 100644 Laba1Loco/Laba1Loco/arowR340x259.png create mode 100644 Laba1Loco/Laba1Loco/arowUp340x259.png diff --git a/Laba1Loco/Laba1Loco.sln b/Laba1Loco/Laba1Loco.sln new file mode 100644 index 0000000..6263144 --- /dev/null +++ b/Laba1Loco/Laba1Loco.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33424.131 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Laba1Loco", "Laba1Loco\Laba1Loco.csproj", "{9F9C9603-3EF7-403E-A895-04EA0CBC5586}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9F9C9603-3EF7-403E-A895-04EA0CBC5586}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F9C9603-3EF7-403E-A895-04EA0CBC5586}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F9C9603-3EF7-403E-A895-04EA0CBC5586}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F9C9603-3EF7-403E-A895-04EA0CBC5586}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EF8E2621-D5D1-4E60-BC18-2388B1EB5E59} + EndGlobalSection +EndGlobal diff --git a/Laba1Loco/Laba1Loco/App.config b/Laba1Loco/Laba1Loco/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/Laba1Loco/Laba1Loco/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Laba1Loco/Laba1Loco/Direction.cs b/Laba1Loco/Laba1Loco/Direction.cs new file mode 100644 index 0000000..b30b47d --- /dev/null +++ b/Laba1Loco/Laba1Loco/Direction.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Laba1Loco +{ + public enum Direction + { + /// + /// Вверх + /// + Up = 1, + /// + /// Вниз + /// + Down = 2, + /// + /// Влево + /// + Left = 3, + /// + /// Вправо + /// + Right = 4 + } + +} diff --git a/Laba1Loco/Laba1Loco/DrawingLoco.cs b/Laba1Loco/Laba1Loco/DrawingLoco.cs new file mode 100644 index 0000000..212f248 --- /dev/null +++ b/Laba1Loco/Laba1Loco/DrawingLoco.cs @@ -0,0 +1,393 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Laba1Loco +{ + internal class DrawingLoco + { + /// + /// Класс-сущность + /// + public EntityLoco EntityLoco { get; private set; } + /// + /// Ширина окна + /// + private int _pictureWidth; + /// + /// Высота окна + /// + private int _pictureHeight; + /// + /// Левая координата прорисовки локомотива + /// + private int _startPosX; + /// + /// Верхняя кооридната прорисовки локомотива + /// + private int _startPosY; + /// + /// Ширина прорисовки локомотива + /// + private int _locoWidth => (EntityLoco?.FuelTank ?? false) ? 169 : 83; + /// + /// Высота прорисовки локомотива + /// + private readonly int _locoHeight = 41; + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Цвет кузова + /// Дополнительный цвет + /// Признак наличия трубы + /// Признак наличия бака + /// Признак наличия паровозной полосы + /// Ширина картинки + /// Высота картинки + /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах + public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool tube, bool fuelTank, bool locoLine, int width, int height) + { + _pictureWidth = width; + _pictureHeight = height; + if (_pictureHeight < _locoHeight || _pictureWidth < _locoWidth) + return false; + EntityLoco = new EntityLoco(); + EntityLoco.Init(speed, weight, bodyColor, additionalColor, tube, fuelTank, locoLine); + + return true; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + _startPosX = Math.Min(x, _pictureWidth-_locoWidth); + _startPosY = Math.Min(y, _pictureHeight-_locoHeight); + } + /// + /// Изменение направления перемещения + /// + /// Направление + public void MoveTransport(Direction direction) + { + if (EntityLoco == null){ + return; + } + switch (direction) + { + //влево + case Direction.Left: + if (_startPosX - EntityLoco.Step > 0) + { + _startPosX -= (int)EntityLoco.Step; + } + break; + //вверх + case Direction.Up: + if (_startPosY - EntityLoco.Step > 0) + { + _startPosY -= (int)EntityLoco.Step; + } + break; + // вправо + case Direction.Right: + if (_startPosX + _locoWidth + EntityLoco.Step < _pictureWidth) + { + _startPosX += (int)EntityLoco.Step; + } + break; + //вниз + case Direction.Down: + if (_startPosY + _locoHeight + EntityLoco.Step < _pictureHeight) + { + _startPosY += (int)EntityLoco.Step; + } + break; + } + } + /// + /// класс облака + /// + class cloud + { + /// + /// просто рандом + /// + Random random; + /// + /// координаты облака + /// + int x, y; + /// + /// размер облака + /// + int size; + /// + /// прозрачность облака + /// + public int opasity; + /// + /// intialisation облака + /// + /// координата облака по горизонтали + /// координата облака по вертикали + public cloud(int x_, int y_) + { + random = new Random(); + x = x_; + y = y_ - 5; + size = 10; + opasity = 255; + } + /// + /// шаг времени для облака + /// + public void timeTick() + { + y -= 3; + size += 5; + opasity -= 20; + + /// добавляем случайности + y += random.Next(-1, 2); + x += random.Next(-1, 2); + size += random.Next(-1, 2); + opasity += random.Next(-1, 2); + } + /// + /// отрисовка облака + /// + /// + public void Draw(Graphics g) + { + g.DrawEllipse(new Pen(Color.FromArgb(opasity, Pens.Gray.Color)), x - size / 2, y-size/2, size, size); + } + + } + /// + /// массив облачков + /// + List clouds = new List(); + + /// + /// шаг времени для облаков + /// + public void timeTick() + { + if (EntityLoco != null) + { + if (clouds.Count < 10) + clouds.Add(new cloud(_startPosX+40, EntityLoco.Tube ? _startPosY : _startPosY + 9)); + } + for (int i = 0; i < clouds.Count; i++) + { + if (i < clouds.Count) + { + clouds[i].timeTick(); + if (clouds[i].opasity < 20) + { + clouds.RemoveAt(i); + } + } + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityLoco == null) + { + return; + } + Pen pen = new Pen(EntityLoco.BodyColor); + Brush brush = new SolidBrush(EntityLoco.BodyColor); + Pen additionalPen = new Pen(EntityLoco.AdditionalColor); + Brush additionalBrush = new SolidBrush(EntityLoco.AdditionalColor); + + //smoke + foreach(var it in clouds){ + it.Draw(g); + } + + // body + g.DrawLines(pen, + new Point[] { + new Point(_startPosX + 8, _startPosY+10), + new Point(_startPosX + 79, _startPosY+10), + new Point(_startPosX + 79, _startPosY+32), + new Point(_startPosX + 4, _startPosY+32), + new Point(_startPosX + 4, _startPosY+20), + new Point(_startPosX + 8, _startPosY+10), + } + ); + g.DrawLines(pen, + new Point[] { + new Point(_startPosX + 4, _startPosY+21), + new Point(_startPosX + 29, _startPosY+21), + new Point(_startPosX + 29, _startPosY+14), + new Point(_startPosX + 37, _startPosY+14), + new Point(_startPosX + 37, _startPosY+21), + new Point(_startPosX + 79, _startPosY+21), + new Point(_startPosX + 37, _startPosY+21), + new Point(_startPosX + 37, _startPosY+29), + new Point(_startPosX + 29, _startPosY+29), + new Point(_startPosX + 29, _startPosY+21), + } + ); + + // trucks + g.FillPolygon(brush, + new Point[] { + new Point(_startPosX + 0, _startPosY+37), + new Point(_startPosX + 5, _startPosY+33), + new Point(_startPosX + 32, _startPosY+33), + new Point(_startPosX + 36, _startPosY+37), + } + ); + g.FillPolygon(brush, + new Point[] { + new Point(_startPosX + 44, _startPosY+37), + new Point(_startPosX + 49, _startPosY+33), + new Point(_startPosX + 76, _startPosY+33), + new Point(_startPosX + 80, _startPosY+37), + } + ); + + //back + g.FillPolygon(brush, + new Point[] { + new Point(_startPosX + 79, _startPosY+12), + new Point(_startPosX + 82, _startPosY+12), + new Point(_startPosX + 82, _startPosY+30), + new Point(_startPosX + 79, _startPosY+30), + } + ); + + //windows + g.DrawRectangle(Pens.Blue, _startPosX + 10, _startPosY + 12, 6, 7); + g.DrawRectangle(Pens.Blue, _startPosX + 19, _startPosY + 12, 6, 7); + g.DrawRectangle(Pens.Blue, _startPosX + 72, _startPosY + 12, 6, 7); + + //wheels + g.FillEllipse(brush, _startPosX + 3, _startPosY + 34, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 4, _startPosY + 35, 6, 6); + g.FillEllipse(brush, _startPosX + 26, _startPosY + 34, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 27, _startPosY + 35, 6, 6); + g.FillEllipse(brush, _startPosX + 46, _startPosY + 34, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 47, _startPosY + 35, 6, 6); + g.FillEllipse(brush, _startPosX + 72, _startPosY + 34, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 73, _startPosY + 35, 6, 6); + + if (EntityLoco.Tube) + { + g.DrawLines(additionalPen, + new Point[] { + new Point(_startPosX + 40, _startPosY+9), + new Point(_startPosX + 40, _startPosY+3), + new Point(_startPosX + 45, _startPosY+3), + new Point(_startPosX + 41, _startPosY+3), + new Point(_startPosX + 41, _startPosY), + new Point(_startPosX + 44, _startPosY), + new Point(_startPosX + 44, _startPosY+3), + new Point(_startPosX + 45, _startPosY+3), + new Point(_startPosX + 45, _startPosY+9), + }); + } + if (EntityLoco.LocoLine) + { + g.DrawLines(additionalPen, + new Point[] { + new Point(_startPosX + 60, _startPosY+10), + new Point(_startPosX + 38, _startPosY+32), + }); + g.DrawLines(additionalPen, + new Point[] { + new Point(_startPosX + 65, _startPosY+10), + new Point(_startPosX + 43, _startPosY+32), + }); + g.DrawLines(additionalPen, + new Point[] { + new Point(_startPosX + 70, _startPosY+10), + new Point(_startPosX + 48, _startPosY+32), + }); + } + if (EntityLoco.FuelTank) + { + // body + g.DrawLines(pen, + new Point[] { + new Point(_startPosX + 89, _startPosY+10), + new Point(_startPosX + 164, _startPosY+10), + new Point(_startPosX + 164, _startPosY+32), + new Point(_startPosX + 89, _startPosY+32), + new Point(_startPosX + 89, _startPosY+10), + } + ); + g.DrawLines(pen, + new Point[] { + new Point(_startPosX + 89, _startPosY+21), + new Point(_startPosX + 164, _startPosY+21), + } + ); + + // trucks + g.FillPolygon(brush, + new Point[] { + new Point(_startPosX + 0+85, _startPosY+37), + new Point(_startPosX + 5+85, _startPosY+33), + new Point(_startPosX + 32+85, _startPosY+33), + new Point(_startPosX + 36+85, _startPosY+37), + } + ); + g.FillPolygon(brush, + new Point[] { + new Point(_startPosX + 44+85, _startPosY+37), + new Point(_startPosX + 49+85, _startPosY+33), + new Point(_startPosX + 76+85, _startPosY+33), + new Point(_startPosX + 80+85, _startPosY+37), + } + ); + + //front + g.FillPolygon(brush, + new Point[] { + new Point(_startPosX + 86, _startPosY+12), + new Point(_startPosX + 89, _startPosY+12), + new Point(_startPosX + 89, _startPosY+30), + new Point(_startPosX + 86, _startPosY+30), + } + ); + + //back + g.FillPolygon(brush, + new Point[] { + new Point(_startPosX + 79+85, _startPosY+12), + new Point(_startPosX + 82+85, _startPosY+12), + new Point(_startPosX + 82+85, _startPosY+30), + new Point(_startPosX + 79+85, _startPosY+30), + } + ); + + //wheels + g.FillEllipse(brush, _startPosX + 3 + 85, _startPosY + 34, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 4, _startPosY + 35, 6, 6); + g.FillEllipse(brush, _startPosX + 26 + 85, _startPosY + 34, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 27, _startPosY + 35, 6, 6); + g.FillEllipse(brush, _startPosX + 46 + 85, _startPosY + 34, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 47, _startPosY + 35, 6, 6); + g.FillEllipse(brush, _startPosX + 72 + 85, _startPosY + 34, 8, 8); + g.FillEllipse(additionalBrush, _startPosX + 73, _startPosY + 35, 6, 6); + } + } + } +} diff --git a/Laba1Loco/Laba1Loco/EntityLoco.cs b/Laba1Loco/Laba1Loco/EntityLoco.cs new file mode 100644 index 0000000..3d68c9a --- /dev/null +++ b/Laba1Loco/Laba1Loco/EntityLoco.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Laba1Loco +{ + internal class EntityLoco + { + /// + /// Скорость + /// + 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 Tube { get; private set; } + /// + /// Признак (опция) наличия топливного бака + /// + public bool FuelTank { get; private set; } + /// + /// Признак (опция) наличия паровозной полосы + /// + public bool LocoLine { get; private set; } + /// + /// Шаг перемещения поезда + /// + public double Step => (double)Speed * 100 / Weight; + /// + /// Инициализация полей объекта-класса Локомотива + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия трубы + /// Признак наличия бака + /// Признак наличия паровозной полосы + public void Init(int speed, double weight, Color bodyColor, Color + additionalColor, bool tube, bool fuelTank, bool locoLine) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Tube = tube; + FuelTank = fuelTank; + LocoLine = locoLine; + } + + } +} diff --git a/Laba1Loco/Laba1Loco/FormLocomotive.Designer.cs b/Laba1Loco/Laba1Loco/FormLocomotive.Designer.cs new file mode 100644 index 0000000..318ed48 --- /dev/null +++ b/Laba1Loco/Laba1Loco/FormLocomotive.Designer.cs @@ -0,0 +1,140 @@ +namespace Laba1Loco +{ + partial class FormLocomotive + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором форм Windows + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.pictureBox = new System.Windows.Forms.PictureBox(); + this.create = new System.Windows.Forms.Button(); + this.left = new System.Windows.Forms.Button(); + this.up = new System.Windows.Forms.Button(); + this.down = new System.Windows.Forms.Button(); + this.right = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox + // + this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox.Location = new System.Drawing.Point(0, 0); + this.pictureBox.Name = "pictureBox"; + this.pictureBox.Size = new System.Drawing.Size(800, 450); + this.pictureBox.TabIndex = 0; + this.pictureBox.TabStop = false; + // + // create + // + this.create.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.create.Location = new System.Drawing.Point(12, 415); + this.create.Name = "create"; + this.create.Size = new System.Drawing.Size(75, 23); + this.create.TabIndex = 1; + this.create.Text = "create"; + this.create.UseVisualStyleBackColor = true; + this.create.Click += new System.EventHandler(this.create_Click); + // + // left + // + this.left.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.left.Image = global::Laba1Loco.Properties.Resources.arowL340x259; + this.left.Location = new System.Drawing.Point(632, 390); + this.left.Name = "left"; + this.left.Size = new System.Drawing.Size(48, 48); + this.left.TabIndex = 3; + this.left.UseVisualStyleBackColor = true; + this.left.Click += new System.EventHandler(this.Click); + // + // up + // + this.up.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.up.Image = global::Laba1Loco.Properties.Resources.arowUp340x259; + this.up.Location = new System.Drawing.Point(686, 336); + this.up.Name = "up"; + this.up.Size = new System.Drawing.Size(48, 48); + this.up.TabIndex = 4; + this.up.UseVisualStyleBackColor = true; + this.up.Click += new System.EventHandler(this.Click); + // + // down + // + this.down.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.down.Image = global::Laba1Loco.Properties.Resources.arowDown340x259; + this.down.Location = new System.Drawing.Point(686, 390); + this.down.Name = "down"; + this.down.Size = new System.Drawing.Size(48, 48); + this.down.TabIndex = 5; + this.down.UseVisualStyleBackColor = true; + this.down.Click += new System.EventHandler(this.Click); + // + // right + // + this.right.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.right.Image = global::Laba1Loco.Properties.Resources.arowR340x259; + this.right.Location = new System.Drawing.Point(740, 390); + this.right.Name = "right"; + this.right.Size = new System.Drawing.Size(48, 48); + this.right.TabIndex = 6; + this.right.UseVisualStyleBackColor = true; + this.right.Click += new System.EventHandler(this.Click); + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // FormLocomotive + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.right); + this.Controls.Add(this.down); + this.Controls.Add(this.up); + this.Controls.Add(this.left); + this.Controls.Add(this.create); + this.Controls.Add(this.pictureBox); + this.Name = "FormLocomotive"; + this.Text = "Locomotive(moving)"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox; + private System.Windows.Forms.Button create; + private System.Windows.Forms.Button left; + private System.Windows.Forms.Button up; + private System.Windows.Forms.Button down; + private System.Windows.Forms.Button right; + private System.Windows.Forms.Timer timer1; + } +} + diff --git a/Laba1Loco/Laba1Loco/FormLocomotive.cs b/Laba1Loco/Laba1Loco/FormLocomotive.cs new file mode 100644 index 0000000..f067f25 --- /dev/null +++ b/Laba1Loco/Laba1Loco/FormLocomotive.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Laba1Loco +{ + public partial class FormLocomotive : Form + { + /// + /// Поле-объект для прорисовки объекта + /// + private DrawingLoco _drawingLoco; + /// + /// Инициализация формы + /// + public FormLocomotive() + { + InitializeComponent(); + } + + /// + /// Метод прорисовки локомотива + /// + private void Draw() + { + if (_drawingLoco == null) + { + return; + } + Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawingLoco.DrawTransport(gr); + pictureBox.Image = bmp; + } + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void create_Click(object sender, EventArgs e) + { + Random random = new Random(); + _drawingLoco = new DrawingLoco(); + _drawingLoco.Init(random.Next(100, 300), random.Next(2000, 4000), 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)), Convert.ToBoolean(random.Next(0, 2)), pictureBox.Width, pictureBox.Height); + _drawingLoco.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Draw(); + } + /// + /// клик движения мышки + /// + /// + /// + private void Click(object sender, EventArgs e) + { + if (_drawingLoco == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "up": + _drawingLoco.MoveTransport(Direction.Up); + break; + case "down": + _drawingLoco.MoveTransport(Direction.Down); + break; + case "left": + _drawingLoco.MoveTransport(Direction.Left); + break; + case "right": + _drawingLoco.MoveTransport(Direction.Right); + break; + } + Draw(); + + } + /// + /// таймер для дымка + /// + /// + /// + private void timer1_Tick(object sender, EventArgs e) + { + if (_drawingLoco != null) + _drawingLoco.timeTick(); + Draw(); + } + } +} diff --git a/Laba1Loco/Laba1Loco/FormLocomotive.resx b/Laba1Loco/Laba1Loco/FormLocomotive.resx new file mode 100644 index 0000000..1f666f2 --- /dev/null +++ b/Laba1Loco/Laba1Loco/FormLocomotive.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/Laba1Loco/Laba1Loco/Laba1Loco.csproj b/Laba1Loco/Laba1Loco/Laba1Loco.csproj new file mode 100644 index 0000000..68d4bfc --- /dev/null +++ b/Laba1Loco/Laba1Loco/Laba1Loco.csproj @@ -0,0 +1,102 @@ + + + + + Debug + AnyCPU + {9F9C9603-3EF7-403E-A895-04EA0CBC5586} + WinExe + Laba1Loco + Laba1Loco + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + Form + + + FormLocomotive.cs + + + + + FormLocomotive.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Laba1Loco/Laba1Loco/Program.cs b/Laba1Loco/Laba1Loco/Program.cs new file mode 100644 index 0000000..ee9a3f9 --- /dev/null +++ b/Laba1Loco/Laba1Loco/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Laba1Loco +{ + internal static class Program + { + /// + /// Главная точка входа для приложения. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new FormLocomotive()); + } + } +} diff --git a/Laba1Loco/Laba1Loco/Properties/AssemblyInfo.cs b/Laba1Loco/Laba1Loco/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3f30958 --- /dev/null +++ b/Laba1Loco/Laba1Loco/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанных со сборкой. +[assembly: AssemblyTitle("Laba1Loco")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Laba1Loco")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, следует установить атрибут ComVisible в TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("9f9c9603-3ef7-403e-a895-04ea0cbc5586")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Laba1Loco/Laba1Loco/Properties/Resources.Designer.cs b/Laba1Loco/Laba1Loco/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b2a27ea --- /dev/null +++ b/Laba1Loco/Laba1Loco/Properties/Resources.Designer.cs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Laba1Loco.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("Laba1Loco.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 arow340x259 { + get { + object obj = ResourceManager.GetObject("arow340x259", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arowDown340x259 { + get { + object obj = ResourceManager.GetObject("arowDown340x259", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arowL340x259 { + get { + object obj = ResourceManager.GetObject("arowL340x259", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arowR340x259 { + get { + object obj = ResourceManager.GetObject("arowR340x259", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arowUp340x259 { + get { + object obj = ResourceManager.GetObject("arowUp340x259", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Laba1Loco/Laba1Loco/Properties/Resources.resx b/Laba1Loco/Laba1Loco/Properties/Resources.resx new file mode 100644 index 0000000..e418b24 --- /dev/null +++ b/Laba1Loco/Laba1Loco/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\arow340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\arowDown340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\arowL340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\arowR340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\arowUp340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Laba1Loco/Laba1Loco/Properties/Settings.Designer.cs b/Laba1Loco/Laba1Loco/Properties/Settings.Designer.cs new file mode 100644 index 0000000..62a7f82 --- /dev/null +++ b/Laba1Loco/Laba1Loco/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Laba1Loco.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Laba1Loco/Laba1Loco/Properties/Settings.settings b/Laba1Loco/Laba1Loco/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Laba1Loco/Laba1Loco/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Laba1Loco/Laba1Loco/arow340x259.png b/Laba1Loco/Laba1Loco/arow340x259.png new file mode 100644 index 0000000000000000000000000000000000000000..3d8743b00a1f9b37bebd129eab40f08749b02c44 GIT binary patch literal 541 zcmV+&0^Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0kTO%K~z{r?U*}K z!!Qtr4HsZ06%7rKhFj2c1}ct4l{2L07BoB>8mi220>~PzNBrKEcD0I!0lpcJY$vk5 z{43c>4nB4aKbWq9+mnm5Hw>%S$FvvYFtuTFIRcMc>5?GJtR9}mme^jNk8L!`aDtK? z!N<`gyObE^m>!ZLK^*w({(9Pa(JY9iMJYaxrr0Eiay257Zb4}ft)$XKv?iY{A<``00000NkvXXu0mjf6Bg`~ literal 0 HcmV?d00001 diff --git a/Laba1Loco/Laba1Loco/arowDown340x259.png b/Laba1Loco/Laba1Loco/arowDown340x259.png new file mode 100644 index 0000000000000000000000000000000000000000..1aef4dc4902c9d700c84472a0d898c2d889b1bff GIT binary patch literal 546 zcmV+-0^R+IP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0k=s+K~z{r?U*}K z!$1r`O)kJpDw;F_8g4<)8K`osRGfjHThQ=nXs9y72_S-1qR7%}rByF#%50XnJmdu759=Scz?0o5)lPqO5s~3p6ibUwazg2;TENKzINXo!I~Te=QgWS@q0cO zdL+#;sL5@R#+`7iRg$wKXuX2Ox5C3`X)uK2;`s#W{$>Pg%+D94C1ZWx!bp%m1z!z| z@MtMfl@<<&mOU|onk2nJ51yX@YKpa!xa1~{7`3wJ>D3;tCI?izdO7e8l&)$dO9Bj!Si5}1#!APom$QNB{r;07*qoM6N<$g6)v%*8l(j literal 0 HcmV?d00001 diff --git a/Laba1Loco/Laba1Loco/arowL340x259.png b/Laba1Loco/Laba1Loco/arowL340x259.png new file mode 100644 index 0000000000000000000000000000000000000000..a2e6f8bbe983e0d111ffd9ff4cd4c4dee275e233 GIT binary patch literal 518 zcmV+h0{Q)kP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0h>ugK~z{r?bbU^ z#6S$j@qr5)(Zb8GNp`k+J1duNpOP1q#+1@A!{t{xcTg(q< z!tTNMRN8Qd`S)h~Tfongi}@$AkTa;EcJI%5<;y+6(!`=B=>kUIPAxNV4IDC^L5bTv zz2w#O-sO2-#hk;T2?AEbA$jesdx9;Pj8D=MO}`6R!<{`|=T%CtR}XpR2O=Pwx0vGq zE8&p5j;K08iKAK&KFQv+iDQB)umnR9Q!4!d5~%{MQ+xZm%d3=5k8bm-oQ7-y3D-L{ zj+(nUPU-$5Uo7MBVW5W7U<(uijH&<;A$x)IQ*6co#&L*V)7~>=|FRIUc~5p=<5osB z197hrKLgqsSv;LUN+`Xiy=Un6JjK+e{}1v;r#X^_LqkAhon{G8OX5%yh)PJLL8EY} z3y3%pm7p9~+H|CDAZj6HULbI&8;B$lX;8w^CZ2{qNwA^ZR8A`5*7AlX$kV1NTYZAO zh|PPle_5DX1L*>y5;6*JK7(3xE+Z!!3fxETTfFc7fxc4u0Z7gPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0hUQbK~z{r?Ug-F z#4r#>4HrP#iiU=ThFj2c1}ct4#TmBe7Bu`cG*n2O0QO7lXf!($k28}HA)aKdH(F_* zU+m=Qdrw+1$N6)${0n*s75qHA>_#MEheQ(Fyg%pJbV3Sh)go%nz6ZUMiyRV-8?rdT7mBNmVdPjzUGPlA@p{R}-+H)zl=-f)=^Aulqbp>HOp_&t$AMCkaxK z18z@Kdicm+dNf%}&1S(-IRL=|69tm2RI^C>AJh<{gCbm$7D(?-iBqC2@-99QZ(tcg z;Z|Gm3*yh|pa|Dm_u$_<#bf;Ha}Zc0YiQK~mjj|8&?LvGEx=lhq6)TB79>fwR-=SJ zX1ENm)*=VGf|z(K*0ux{0~R?j2zn@slO(wqu*!kZTg+voYAtdgwBQ)6VueNC#Z%?L z?1COS5F)5ac;!II9xM!}IY6usDmVv=91;&J7fk5~fSW7Gxh?vk00000NkvXXu0mjf DO?%Py literal 0 HcmV?d00001 diff --git a/Laba1Loco/Laba1Loco/arowUp340x259.png b/Laba1Loco/Laba1Loco/arowUp340x259.png new file mode 100644 index 0000000000000000000000000000000000000000..3d8743b00a1f9b37bebd129eab40f08749b02c44 GIT binary patch literal 541 zcmV+&0^Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0kTO%K~z{r?U*}K z!!Qtr4HsZ06%7rKhFj2c1}ct4l{2L07BoB>8mi220>~PzNBrKEcD0I!0lpcJY$vk5 z{43c>4nB4aKbWq9+mnm5Hw>%S$FvvYFtuTFIRcMc>5?GJtR9}mme^jNk8L!`aDtK? z!N<`gyObE^m>!ZLK^*w({(9Pa(JY9iMJYaxrr0Eiay257Zb4}ft)$XKv?iY{A<``00000NkvXXu0mjf6Bg`~ literal 0 HcmV?d00001