From 65004508a9d90fd6305ef74167b12eec897f6863 Mon Sep 17 00:00:00 2001 From: tyxzo Date: Mon, 5 Feb 2024 14:53:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=BD=D0=B0=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DoubleDeckerBus/DirectionType.cs | 24 +++++ .../DoubleDeckerBus/DrawingDoubleDeckerBus.cs | 102 ++++++++++++++++++ .../DoubleDeckerBus/EntityDoubleDeckerBus.cs | 53 +++++++++ DoubleDeckerBus/DoubleDeckerBus/Form1.cs | 10 -- ...ner.cs => FormDoubleDeckerBus.Designer.cs} | 12 +-- .../DoubleDeckerBus/FormDoubleDeckerBus.cs | 20 ++++ .../{Form1.resx => FormDoubleDeckerBus.resx} | 0 DoubleDeckerBus/DoubleDeckerBus/Program.cs | 2 +- 8 files changed, 206 insertions(+), 17 deletions(-) create mode 100644 DoubleDeckerBus/DoubleDeckerBus/DirectionType.cs create mode 100644 DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs create mode 100644 DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs delete mode 100644 DoubleDeckerBus/DoubleDeckerBus/Form1.cs rename DoubleDeckerBus/DoubleDeckerBus/{Form1.Designer.cs => FormDoubleDeckerBus.Designer.cs} (75%) create mode 100644 DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs rename DoubleDeckerBus/DoubleDeckerBus/{Form1.resx => FormDoubleDeckerBus.resx} (100%) diff --git a/DoubleDeckerBus/DoubleDeckerBus/DirectionType.cs b/DoubleDeckerBus/DoubleDeckerBus/DirectionType.cs new file mode 100644 index 0000000..a05d391 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/DirectionType.cs @@ -0,0 +1,24 @@ + +namespace DoubleDeckerBus; + +public enum DirectionType +{ /// + /// вверх + /// + Up = 1, + + /// + /// вниз + /// + Down = 2, + + /// + /// влево + /// + Left = 3, + + /// + /// вправо + /// + Right = 4 +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs new file mode 100644 index 0000000..bac59df --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DoubleDeckerBus; +/// +/// +/// +public class DrawingDoubleDeckerBus +{ + public EntityDoubleDeckerBus? EntityDoubleDeckerBus { get; private set; } + + private int? _pictureWidth; + + private int? _pictureHeight; + + private int? _startPosX; + + private int? _startPosY; + + private readonly int _DrawingBusWidth; + + private readonly int _DrawingBusHight; + + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) + { + EntityDoubleDeckerBus = new EntityDoubleDeckerBus(); + EntityDoubleDeckerBus.Init(speed, weight, bodyColor, additionalColor, bodyKit, wing, sportLine); + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + } + + public bool SetPictureSize(int width, int hight) + { + _pictureWidth = width; + _pictureHeight = hight; + return true; + } + + public void SetPosition(int x, int y) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + + _startPosX = x; + _startPosY = y; + } + + public bool MoveTransport(DirectionType direction) + { + if (EntityDoubleDeckerBus == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return false; + } + + switch(direction) + { + case DirectionType.Left: + if (_startPosX.Value - EntityDoubleDeckerBus.Step > 0) + { + _startPosX -= (int)EntityDoubleDeckerBus.Step; + } + return true; + + case DirectionType.Up: + if (_startPosY.Value - EntityDoubleDeckerBus.Step > 0) + { + _startPosY -= (int)EntityDoubleDeckerBus.Step; + } + return true; + case DirectionType.Right: + if (_startPosX.Value + EntityDoubleDeckerBus.Step < _pictureWidth) + { + _startPosX += (int)EntityDoubleDeckerBus.Step; + } + return true; + case DirectionType.Down: + if (_startPosY.Value + EntityDoubleDeckerBus.Step < _pictureHeight) + { + _startPosX += (int)EntityDoubleDeckerBus.Step; + } + return true; + default: + return false; + + } + } + + public void DrawTrasnport(Graphics g) + { + if (EntityDoubleDeckerBus == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + } +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs new file mode 100644 index 0000000..82a7bb4 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs @@ -0,0 +1,53 @@ + + +namespace DoubleDeckerBus; + public class EntityDoubleDeckerBus +{ + 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 BodyKit { get; private set; } + /// + /// Признак (опция) наличия антикрыла + /// + public bool Wing { get; private set; } + /// + /// Признак (опция) наличия гоночной полосы + /// + public bool SportLine { get; private set; } + /// + /// Шаг перемещения автомобиля + /// + public double Step => Speed * 100 / Weight; + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + BodyKit = bodyKit; + Wing = wing; + SportLine = sportLine; + } +} \ No newline at end of file diff --git a/DoubleDeckerBus/DoubleDeckerBus/Form1.cs b/DoubleDeckerBus/DoubleDeckerBus/Form1.cs deleted file mode 100644 index fd2d1d7..0000000 --- a/DoubleDeckerBus/DoubleDeckerBus/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace DoubleDeckerBus -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/DoubleDeckerBus/DoubleDeckerBus/Form1.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.Designer.cs similarity index 75% rename from DoubleDeckerBus/DoubleDeckerBus/Form1.Designer.cs rename to DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.Designer.cs index 3ca1fa2..7e773ee 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/Form1.Designer.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.Designer.cs @@ -1,14 +1,14 @@ namespace DoubleDeckerBus { - partial class Form1 + partial class FormDoubleDeckerBus { /// - /// Required designer variable. + /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// - /// Clean up any resources being used. + /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) @@ -23,15 +23,15 @@ #region Windows Form Designer generated code /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. + /// 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"; + this.Text = "FormDoubleDeckerBus"; } #endregion diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs new file mode 100644 index 0000000..cea7f31 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs @@ -0,0 +1,20 @@ +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 DoubleDeckerBus +{ + public partial class FormDoubleDeckerBus : Form + { + public FormDoubleDeckerBus() + { + InitializeComponent(); + } + } +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/Form1.resx b/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.resx similarity index 100% rename from DoubleDeckerBus/DoubleDeckerBus/Form1.resx rename to DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.resx diff --git a/DoubleDeckerBus/DoubleDeckerBus/Program.cs b/DoubleDeckerBus/DoubleDeckerBus/Program.cs index 1cce65b..913b697 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/Program.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/Program.cs @@ -11,7 +11,7 @@ namespace DoubleDeckerBus // 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 FormDoubleDeckerBus()); } } } \ No newline at end of file