From 7fc885a6f51e850023ab9ea4c2d346900aae1c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Tue, 20 Dec 2022 16:25:13 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DoubleDeckerBus/DoubleDeckerBus/Direction.cs | 17 ++ .../DoubleDeckerBus/DoubleDeckerBus.csproj | 15 ++ DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs | 133 +++++++++++++ DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs | 24 +++ .../DoubleDeckerBus/Form1.Designer.cs | 39 ---- DoubleDeckerBus/DoubleDeckerBus/Form1.cs | 10 - .../DoubleDeckerBus/FormBus.Designer.cs | 182 ++++++++++++++++++ DoubleDeckerBus/DoubleDeckerBus/FormBus.cs | 58 ++++++ DoubleDeckerBus/DoubleDeckerBus/FormBus.resx | 66 +++++++ DoubleDeckerBus/DoubleDeckerBus/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 103 ++++++++++ .../{Form1.resx => Properties/Resources.resx} | 13 ++ .../DoubleDeckerBus/Resources/Frame 3.png | Bin 0 -> 776 bytes .../DoubleDeckerBus/Resources/Frame 4.png | Bin 0 -> 707 bytes .../DoubleDeckerBus/Resources/Frame 5.png | Bin 0 -> 775 bytes .../DoubleDeckerBus/Resources/Frame 6.png | Bin 0 -> 734 bytes 16 files changed, 612 insertions(+), 50 deletions(-) create mode 100644 DoubleDeckerBus/DoubleDeckerBus/Direction.cs create mode 100644 DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs create mode 100644 DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs delete mode 100644 DoubleDeckerBus/DoubleDeckerBus/Form1.Designer.cs delete mode 100644 DoubleDeckerBus/DoubleDeckerBus/Form1.cs create mode 100644 DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs create mode 100644 DoubleDeckerBus/DoubleDeckerBus/FormBus.cs create mode 100644 DoubleDeckerBus/DoubleDeckerBus/FormBus.resx create mode 100644 DoubleDeckerBus/DoubleDeckerBus/Properties/Resources.Designer.cs rename DoubleDeckerBus/DoubleDeckerBus/{Form1.resx => Properties/Resources.resx} (83%) create mode 100644 DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 3.png create mode 100644 DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 4.png create mode 100644 DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 5.png create mode 100644 DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 6.png diff --git a/DoubleDeckerBus/DoubleDeckerBus/Direction.cs b/DoubleDeckerBus/DoubleDeckerBus/Direction.cs new file mode 100644 index 0000000..dab6276 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/Direction.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DoubleDeckerBus +{ + internal enum Direction + { + None = 0, + Up = 1, + Down = 2, + Left = 3, + Right = 4 + } +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/DoubleDeckerBus.csproj b/DoubleDeckerBus/DoubleDeckerBus/DoubleDeckerBus.csproj index b57c89e..13ee123 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/DoubleDeckerBus.csproj +++ b/DoubleDeckerBus/DoubleDeckerBus/DoubleDeckerBus.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs new file mode 100644 index 0000000..a25f495 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DoubleDeckerBus +{ + internal class DrawingBus + { + public EntityBus Bus { get; private set; } + + private float _startPosX; + private float _startPosY; + private int? _pictureWidth = null; + private int? _pictureHeight = null; + private readonly int _busWidth = 100; + private readonly int _busHeight = 50; + + public void Init(int speed, float weight, Color bodyColor) + { + Bus = new EntityBus(); + Bus.Init(speed, weight, bodyColor); + } + + public void SetPosition(int x, int y, int width, int height) + { + if (_pictureWidth <= _busWidth || _pictureHeight <= _busHeight) + { + _pictureWidth = null; + _pictureHeight = null; + return; + } + _startPosX = x; + _startPosY = y; + _pictureWidth = width; + _pictureHeight = height; + } + + public void MoveTransport(Direction direction) + { + if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) + { + return; + } + switch (direction) + { + case Direction.Right: + if (_startPosX + _busWidth + Bus.Step < _pictureWidth) + { + _startPosX += Bus.Step; + } + break; + case Direction.Left: + if (_startPosX - Bus.Step >= 0) + { + _startPosX -= Bus.Step; + } + break; + case Direction.Up: + if (_startPosY - Bus.Step >= 0) + { + _startPosY -= Bus.Step; + } + break; + case Direction.Down: + if (_startPosY + _busHeight + Bus.Step < _pictureHeight) + { + _startPosY += Bus.Step; + } + break; + } + } + + public void DrawTransport(Graphics g) + { + if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + //границы автобуса + Pen pen = new(Color.Black); + g.DrawRectangle(pen, _startPosX + 10, _startPosY + 10, 150, 50); + + //кузов + Brush br = new SolidBrush(Bus?.BodyColor ?? Color.Black); + g.FillRectangle(br, _startPosX + 11, _startPosY + 11, 149, 49); + //колеса + Brush brBlack = new SolidBrush(Color.Black); + g.FillEllipse(brBlack, _startPosX + 20, _startPosY + 50, 20, 20); + g.FillEllipse(brBlack, _startPosX + 130, _startPosY + 50, 20, 20); + Brush brGray = new SolidBrush(Color.Gray); + g.FillEllipse(brGray, _startPosX + 25, _startPosY + 55, 10, 10); + g.FillEllipse(brGray, _startPosX + 135, _startPosY + 55, 10, 10); + + //стекла + Brush brBlue = new SolidBrush(Color.LightBlue); + g.FillRectangle(brBlue, _startPosX + 10, _startPosY + 20, 10, 20); + g.DrawRectangle(pen, _startPosX + 10, _startPosY + 20, 10, 20); + g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 20, 30, 20); + g.DrawRectangle(pen, _startPosX + 30, _startPosY + 20, 30, 20); + g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 20, 15, 40); + g.DrawRectangle(pen, _startPosX + 70, _startPosY + 20, 15, 40); + g.FillRectangle(brBlue, _startPosX + 85, _startPosY + 20, 15, 40); + g.DrawRectangle(pen, _startPosX + 85, _startPosY + 20, 15, 40); + g.FillRectangle(brBlue, _startPosX + 110, _startPosY + 20, 30, 20); + g.DrawRectangle(pen, _startPosX + 110, _startPosY + 20, 30, 20); + g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 20, 10, 20); + g.DrawRectangle(pen, _startPosX + 150, _startPosY + 20, 10, 20); + + } + + public void ChangeBorders(int width, int height) + { + _pictureWidth = width; + _pictureHeight = height; + if (_pictureWidth <= _busWidth || _pictureHeight <= _busHeight) + { + _pictureWidth = null; + _pictureHeight = null; + return; + } + if (_startPosX + _busWidth > _pictureWidth) + { + _startPosX = _pictureWidth.Value - _busWidth; + } + if (_startPosY + _busHeight > _pictureHeight) + { + _startPosY = _pictureHeight.Value - _busHeight; + } + } + } +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs new file mode 100644 index 0000000..7c73c54 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DoubleDeckerBus +{ + internal class EntityBus + { + public int Speed { get; private set; } + public float Weight { get; private set; } + public Color BodyColor { get; private set; } + public float Step => Speed * 100 / Weight; + + public void Init(int speed, float weight, Color bodyColor) + { + Random rnd = new Random(); + Speed = speed <= 0 ? rnd.Next(50, 150) : speed; + Weight = weight <= 0 ? rnd.Next(40, 70) : weight; + BodyColor = bodyColor; + } + } +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/Form1.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/Form1.Designer.cs deleted file mode 100644 index 3ca1fa2..0000000 --- a/DoubleDeckerBus/DoubleDeckerBus/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace DoubleDeckerBus -{ - 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/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/FormBus.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs new file mode 100644 index 0000000..2760e72 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs @@ -0,0 +1,182 @@ +namespace DoubleDeckerBus +{ + partial class FormBus + { + /// + /// 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.pictureBoxBus = new System.Windows.Forms.PictureBox(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); + this.buttonCreate = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit(); + this.statusStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // pictureBoxBus + // + this.pictureBoxBus.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxBus.Location = new System.Drawing.Point(0, 0); + this.pictureBoxBus.Name = "pictureBoxBus"; + this.pictureBoxBus.Size = new System.Drawing.Size(810, 456); + this.pictureBoxBus.TabIndex = 0; + this.pictureBoxBus.TabStop = false; + this.pictureBoxBus.Click += new System.EventHandler(this.ButtonMove_Click); + this.pictureBoxBus.Resize += new System.EventHandler(this.PictureBoxBus_Resize); + // + // statusStrip1 + // + this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabelSpeed, + this.toolStripStatusLabelWeight, + this.toolStripStatusLabelBodyColor}); + this.statusStrip1.Location = new System.Drawing.Point(0, 456); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(810, 26); + this.statusStrip1.TabIndex = 1; + this.statusStrip1.Text = "statusStrip1"; + // + // toolStripStatusLabelSpeed + // + this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed"; + this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(76, 20); + this.toolStripStatusLabelSpeed.Text = "Скорость:"; + // + // toolStripStatusLabelWeight + // + this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight"; + this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(36, 20); + this.toolStripStatusLabelWeight.Text = "Вес:"; + // + // toolStripStatusLabelBodyColor + // + this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; + this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(45, 20); + this.toolStripStatusLabelBodyColor.Text = "Цвет:"; + // + // buttonCreate + // + this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreate.BackColor = System.Drawing.SystemColors.HotTrack; + this.buttonCreate.Location = new System.Drawing.Point(12, 395); + this.buttonCreate.Name = "buttonCreate"; + this.buttonCreate.Size = new System.Drawing.Size(162, 48); + this.buttonCreate.TabIndex = 2; + this.buttonCreate.Text = "Создать"; + this.buttonCreate.UseVisualStyleBackColor = false; + this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_6; + this.button2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.button2.Location = new System.Drawing.Point(662, 398); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(45, 45); + this.button2.TabIndex = 3; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.ButtonMove_Click); + // + // button3 + // + this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button3.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_5; + this.button3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.button3.Location = new System.Drawing.Point(708, 398); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(45, 45); + this.button3.TabIndex = 4; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.ButtonMove_Click); + // + // button4 + // + this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button4.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_4; + this.button4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.button4.Location = new System.Drawing.Point(753, 398); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(45, 45); + this.button4.TabIndex = 5; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.ButtonMove_Click); + // + // button5 + // + this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button5.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_3; + this.button5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.button5.Location = new System.Drawing.Point(708, 353); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(45, 45); + this.button5.TabIndex = 6; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.ButtonMove_Click); + // + // FormBus + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(810, 482); + this.Controls.Add(this.button5); + this.Controls.Add(this.button4); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.buttonCreate); + this.Controls.Add(this.pictureBoxBus); + this.Controls.Add(this.statusStrip1); + this.Name = "FormBus"; + this.Text = "Автобус"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).EndInit(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private PictureBox pictureBoxBus; + private StatusStrip statusStrip1; + private ToolStripStatusLabel toolStripStatusLabelSpeed; + private ToolStripStatusLabel toolStripStatusLabelWeight; + private ToolStripStatusLabel toolStripStatusLabelBodyColor; + private Button buttonCreate; + private Button button2; + private Button button3; + private Button button4; + private Button button5; + } +} \ No newline at end of file diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs new file mode 100644 index 0000000..f193c67 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs @@ -0,0 +1,58 @@ +namespace DoubleDeckerBus +{ + public partial class FormBus : Form + { + private DrawingBus _bus; + public FormBus() + { + InitializeComponent(); + } + + private void Draw() + { + Bitmap bmp = new(pictureBoxBus.Width, pictureBoxBus.Height); + Graphics gr = Graphics.FromImage(bmp); + _bus?.DrawTransport(gr); + pictureBoxBus.Image = bmp; + } + + private void ButtonCreate_Click(object sender, EventArgs e) + { + Random rnd = new(); + _bus = new DrawingBus(); + _bus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _bus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxBus.Width, pictureBoxBus.Height); + toolStripStatusLabelSpeed.Text = $": {_bus.Bus.Speed}"; + toolStripStatusLabelWeight.Text = $": {_bus.Bus.Weight}"; + toolStripStatusLabelBodyColor.Text = $": {_bus.Bus.BodyColor.Name}"; + Draw(); + } + + private void ButtonMove_Click(object sender, EventArgs e) + { + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _bus?.MoveTransport(Direction.Up); + break; + case "buttonDown": + _bus?.MoveTransport(Direction.Down); + break; + case "buttonLeft": + _bus?.MoveTransport(Direction.Left); + break; + case "buttonRight": + _bus?.MoveTransport(Direction.Right); + break; + } + Draw(); + } + + private void PictureBoxBus_Resize(object sender, EventArgs e) + { + _bus?.ChangeBorders(pictureBoxBus.Width, pictureBoxBus.Height); + Draw(); + } + } +} \ No newline at end of file diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.resx b/DoubleDeckerBus/DoubleDeckerBus/FormBus.resx new file mode 100644 index 0000000..70b7ea9 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.resx @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 87 + + \ No newline at end of file diff --git a/DoubleDeckerBus/DoubleDeckerBus/Program.cs b/DoubleDeckerBus/DoubleDeckerBus/Program.cs index 1cce65b..cecbba3 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 FormBus()); } } } \ No newline at end of file diff --git a/DoubleDeckerBus/DoubleDeckerBus/Properties/Resources.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9530c41 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace DoubleDeckerBus.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("DoubleDeckerBus.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 Frame_3 { + get { + object obj = ResourceManager.GetObject("Frame 3", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Frame_4 { + get { + object obj = ResourceManager.GetObject("Frame 4", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Frame_5 { + get { + object obj = ResourceManager.GetObject("Frame 5", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Frame_6 { + get { + object obj = ResourceManager.GetObject("Frame 6", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/Form1.resx b/DoubleDeckerBus/DoubleDeckerBus/Properties/Resources.resx similarity index 83% rename from DoubleDeckerBus/DoubleDeckerBus/Form1.resx rename to DoubleDeckerBus/DoubleDeckerBus/Properties/Resources.resx index 1af7de1..3e48675 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/Form1.resx +++ b/DoubleDeckerBus/DoubleDeckerBus/Properties/Resources.resx @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Frame 3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Frame 4.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Frame 5.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Frame 6.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 3.png b/DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 3.png new file mode 100644 index 0000000000000000000000000000000000000000..9d0e33bd9a4f7aac1cbd333c21f6ee87c3f4f108 GIT binary patch literal 776 zcmeAS@N?(olHy`uVBq!ia0vp^DIm``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&di3`}!9T^vIy7~jr$o6BSLQKw12_76g zoQ;Z#1}ZFVEe9qDNZ=4m7I2z&I(5d`v_y`QM27TN&p-cs{yxQs(^;WvU)bu{>`^#>z)}%C{~tE@!-98HHJ;` zNrjDA>yzs?XOHfkAX1#%`?Ka};Cw??)zVzctOwKgs0& zo^*fq|KpcsVmWt;7iYiuUTyxlSoKNZnY9mf*nVql@mJOdGCp^|5iZWw5##=26U%Y( z;@7EH3y+?*6aQzU^7dKV75hW0RU{Ml#Rhc=}qT}G5NAo&&n#!0|q$O7B zzY0E(Y_NGlxydJ?<(D}v)7MNWKXONE<-y0#dPRz=b$)9eFq{#3L0zhn^F^Wl@)_mF z@7OUU8!VqOZS`X=12$u>%!?q{$3<@TCrgEIn=Wm96a8)VJk|cWebvmY zm#r6to>|M-b#NPN1kjcV5;^8OT!8`^AIh4a+p0=6NaPrANIkPQ@z0gTXAiWv#U1*z z(tYxcY}w-MC%1I^t7qS1JmOZzfB5meZOoIB@^}|7m%GhtHrH>lIZsl-?t>?Q_P&;Q z^DX=0%gt3ks;-wFRQ{#Pjw@n`PXa`#{J}P}Br%d>U$q@D;WBu-`njxgN@xNA{u4G1 literal 0 HcmV?d00001 diff --git a/DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 4.png b/DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 4.png new file mode 100644 index 0000000000000000000000000000000000000000..1e84516b4469e9ac598257d5e47c972d57394a89 GIT binary patch literal 707 zcmeAS@N?(olHy`uVBq!ia0vp^DIm``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&di3``N8E{-7;jBoE`_bNGxI6O=eRbZ4+U}S&L z@PL86fmud@703%<;LBR+X|;Rio5htO*I&N-topZFZ_W}u%@aIM9EKc^-37WF6L^@C z1tgjeNU$7JFkovmAm*$_U+uy(VB8UC^+5Gh<-d}rdTK6oD z)l=?xM2wEukDJxPONy-K?kel~*uG}5^Y2#sl-QRNuMgBc2?CsFI$C>^<|R96FO`{OR>kzG3@qej}+~J~~ zJkw9BK6%nFlQqk4dHnsi_TRiK-b|n1d*$*a!);M(KgmP~>Yv^iZ?oxM$=XJ`b zzyG$)*?!wVu7CfuzwWNKsoQTq-TS+1)zbotBgfU()+pB5DqfmD>C&Tl=b!uTi#sRn z&oybCpV@5R&efGb4(Fq%N-7@B)rS=RPwG?OzkrEFbB8+5r&z0beLOGli)9* zBI|!MFN62foHy5H*;caeQU4{X5?g-YyNi8Oh|r| zO8(W0l#d7RZvL^}RKcJ9`;qwhj-jqR|9Ch^jYs4JV9%JT#;=nwjqeLE%`teo`njxg HN@xNA7l;>q literal 0 HcmV?d00001 diff --git a/DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 5.png b/DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 5.png new file mode 100644 index 0000000000000000000000000000000000000000..2f917da539901dc61b4d6181952ed497f5392619 GIT binary patch literal 775 zcmeAS@N?(olHy`uVBq!ia0vp^DIm``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&di3`}!8T^vIy7~jtQU&t6J(mLOV>jI-yK$B2O z1K*Yf%vuhrUI9$97Y_DjyB&Lz(sHBr{qEVH&(7JO^yp^3`S&ybI{ds&205IO)8Bph z<&usXl}0D01P=}#&PGK=0~MCGmID(6B!rlpsV*4V`lf96Yv%u@Pt0Fc%|HBbLQ(Qg zBdJ~;slyL16y+_R^7CxY=9>{B*It+AN&am8^1If0uAdlVeD=GylWSMV_aEO9wN_~E z(WJuIY|c&ZS?}gu*E@V^#gAKFInzTP`Crq0{PD&LAGOK<)sGafJm{9Z|NitTfngjQ z*``Z8kx-oXv?x=A>uSt20r?LtQg51N3Q8hA7Dqn+EE(9m{dVrgS>#68rEZ05dx zCrg4`)A9lL^_XP>{+&`hl23dT?Lvy3C7whm&YNQ@QBm@t<;kjpQ)YFGKbm>|`8AUb zj_1T4eJu9!Wn8_}u*D>@`LB=h*W%>XidicTUT~Ci_7I+4y|DR@^^4z|UhTUR{b|!1 z?FHXw?8@4}U-Uor%XyG7e#^h7dBmerHhOK*on_o8DED<;#|E`KBp!hLY zXuv0^Y*?ryrHn)f5p+b&u3!$8?*9i6z92{-l!LQ zxp|AziN#Vfxf8ZKbv$2wdM{&kUUf^z`Qk?X({^(&_&*GLU)2*;{Ql$n9ot0a+@8Ft z`JjU9bK|WIH*=;{?TyP~UTfiWtL5KhW|9)dM^=puqNPW8R{jR2TLw>8KbLh*2~7Zj C3`q+B literal 0 HcmV?d00001 diff --git a/DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 6.png b/DoubleDeckerBus/DoubleDeckerBus/Resources/Frame 6.png new file mode 100644 index 0000000000000000000000000000000000000000..1870bc6f5c69d9a092d8f44f7f52931c75722c52 GIT binary patch literal 734 zcmeAS@N?(olHy`uVBq!ia0vp^DIm``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&di3{1tIE{-7;jBn>$%w;kZaG9&Y8o;CqMzRj< z7Z_C?)TcOb0uf(dQIL@A1LbY`YL))8^2`3Jyx%ydf>ZGbgV7$g2~3Jf3NAb?9gPBp z0!nO7M;tmNI0TtV5&Xlg`1z-eO#kr*PJdR<^jrS1z~TtsQ#VJgWjo8+65=&Wc==_`X)asCGZpvG73R>K z68)O5rDwv^qR3DdC!@)m-)VFnNX+K?xl=5^^+e-qj!Z*!fk`u~vp$@NMA%aHF<`g{F6;auHcjNu{hreoS9Viy5<>e4e)u>Bdd;Rsr`72^pDygKd z(XW5Er$#Qp^pfecXI``PC%ETK+~V-0J2C85-Gj2-sililR9c@dnlWL0QdC?rQ~O%o zCElxlF1oO~b;6V_zr8*$RnyuV#qlzzc;AYzS&B=%d++;)RBsiywDd_$;QOmi9$qW6 z&nyh*R$O{y#+S^%C);hRduM)04@}9wl>AA+P^~snq|(@Vo#EtpI$dXkKEKGVoE!&a zo!k2}=~A=n#OBM}+YDFUU36mkq4?~MG_%>YG0A*e!~XlqwjKPR+DU#4!xG3n#?ov@ V!FTcIKY+=R!PC{xWt~$(697wG9Yg>C literal 0 HcmV?d00001 -- 2.25.1 From f90cbcb4cf2b7b6a953287670d8a90bef978d3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Thu, 22 Dec 2022 12:06:05 +0400 Subject: [PATCH 2/2] =?UTF-8?q?=D0=A1=D0=B4=D0=B0=D0=BD=D0=BD=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DoubleDeckerBus/DoubleDeckerBus/CountDoor.cs | 16 ++ DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs | 22 +-- .../DoubleDeckerBus/DrawingDoor.cs | 72 +++++++++ .../DoubleDeckerBus/FormBus.Designer.cs | 138 +++++++++++------- DoubleDeckerBus/DoubleDeckerBus/FormBus.cs | 2 + 5 files changed, 187 insertions(+), 63 deletions(-) create mode 100644 DoubleDeckerBus/DoubleDeckerBus/CountDoor.cs create mode 100644 DoubleDeckerBus/DoubleDeckerBus/DrawingDoor.cs diff --git a/DoubleDeckerBus/DoubleDeckerBus/CountDoor.cs b/DoubleDeckerBus/DoubleDeckerBus/CountDoor.cs new file mode 100644 index 0000000..a41ba1e --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/CountDoor.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DoubleDeckerBus +{ + + internal enum CountDoor + { + One = 3, + Two = 4, + Three = 5 + } +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs index a25f495..02ec481 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs @@ -9,18 +9,21 @@ namespace DoubleDeckerBus internal class DrawingBus { public EntityBus Bus { get; private set; } + public DrawingDoor DrawingDoor { get; private set; } private float _startPosX; private float _startPosY; private int? _pictureWidth = null; private int? _pictureHeight = null; - private readonly int _busWidth = 100; - private readonly int _busHeight = 50; + private readonly int _busWidth = 157; + private readonly int _busHeight = 65 ; public void Init(int speed, float weight, Color bodyColor) { Bus = new EntityBus(); Bus.Init(speed, weight, bodyColor); + DrawingDoor = new(); + DrawingDoor.SetCountDoor = 3; } public void SetPosition(int x, int y, int width, int height) @@ -95,18 +98,17 @@ namespace DoubleDeckerBus //стекла Brush brBlue = new SolidBrush(Color.LightBlue); - g.FillRectangle(brBlue, _startPosX + 10, _startPosY + 20, 10, 20); - g.DrawRectangle(pen, _startPosX + 10, _startPosY + 20, 10, 20); - g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 20, 30, 20); - g.DrawRectangle(pen, _startPosX + 30, _startPosY + 20, 30, 20); - g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 20, 15, 40); - g.DrawRectangle(pen, _startPosX + 70, _startPosY + 20, 15, 40); - g.FillRectangle(brBlue, _startPosX + 85, _startPosY + 20, 15, 40); - g.DrawRectangle(pen, _startPosX + 85, _startPosY + 20, 15, 40); + + + + + g.FillRectangle(brBlue, _startPosX + 110, _startPosY + 20, 30, 20); g.DrawRectangle(pen, _startPosX + 110, _startPosY + 20, 30, 20); + g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 20, 10, 20); g.DrawRectangle(pen, _startPosX + 150, _startPosY + 20, 10, 20); + DrawingDoor.DrawningDoor(g, Bus.BodyColor, _startPosX, _startPosY); } diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawingDoor.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawingDoor.cs new file mode 100644 index 0000000..176c75a --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/DrawingDoor.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DoubleDeckerBus +{ + internal class DrawingDoor + { + private CountDoor _countDoor; + + private float _startPosX; + private float _startPosY; + + public int SetCountDoor + { + set + { + switch (value) + { + case 1: + _countDoor = CountDoor.Three; + break; + case 2: + _countDoor = CountDoor.One; + break; + case 3: + _countDoor = CountDoor.Two; + break; + default: + _countDoor = CountDoor.Three; + break; + } + } + } + + + public void DrawningDoor(Graphics g, Color colorDoor, float PosX, float PosY) + { + if ((int)_countDoor == 3) + { + Pen pen = new(Color.White); + Brush brBlue = new SolidBrush(Color.Black); + g.FillRectangle(brBlue, PosX + 11, PosY + 21, 10, 40); + g.FillRectangle(brBlue, PosX + 40, PosY + 21, 10, 40); + g.FillRectangle(brBlue, PosX + 65, PosY + 21, 10, 40); + } + + if ((int)_countDoor == 4) + { + Pen pen = new(Color.White); + Brush brBlue = new SolidBrush(Color.Black); + g.FillRectangle(brBlue, PosX+11, PosY + 21, 10, 40); + g.FillRectangle(brBlue, PosX + 40, PosY + 21, 10, 40); + g.FillRectangle(brBlue, PosX + 65, PosY + 21, 10, 40); + g.FillRectangle(brBlue, PosX + 80, PosY + 21, 10, 40); + } + + if ((int)_countDoor == 5) + { + Pen pen = new(Color.White); + Brush brBlue = new SolidBrush(Color.Black); + g.FillRectangle(brBlue, PosX + 11, PosY + 21, 10, 40); + g.FillRectangle(brBlue, PosX + 40, PosY + 21, 10, 40); + g.FillRectangle(brBlue, PosX + 65, PosY + 21, 10, 40); + g.FillRectangle(brBlue, PosX + 80, PosY + 21, 10, 40); + g.FillRectangle(brBlue, PosX + 52, PosY + 21, 10, 40); + } + } + } +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs index 2760e72..b72f890 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs @@ -33,13 +33,16 @@ this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelDoor = new System.Windows.Forms.ToolStripStatusLabel(); this.buttonCreate = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.button3 = new System.Windows.Forms.Button(); - this.button4 = new System.Windows.Forms.Button(); - this.button5 = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonDown = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.countDoorBox = new System.Windows.Forms.NumericUpDown(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit(); this.statusStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.countDoorBox)).BeginInit(); this.SuspendLayout(); // // pictureBoxBus @@ -59,7 +62,8 @@ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabelSpeed, this.toolStripStatusLabelWeight, - this.toolStripStatusLabelBodyColor}); + this.toolStripStatusLabelBodyColor, + this.toolStripStatusLabelDoor}); this.statusStrip1.Location = new System.Drawing.Point(0, 456); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(810, 26); @@ -84,6 +88,12 @@ this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(45, 20); this.toolStripStatusLabelBodyColor.Text = "Цвет:"; // + // toolStripStatusLabelDoor + // + this.toolStripStatusLabelDoor.Name = "toolStripStatusLabelDoor"; + this.toolStripStatusLabelDoor.Size = new System.Drawing.Size(147, 20); + this.toolStripStatusLabelDoor.Text = "Количество дверей:"; + // // buttonCreate // this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -96,63 +106,82 @@ this.buttonCreate.UseVisualStyleBackColor = false; this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); // - // button2 + // buttonLeft // - this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button2.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_6; - this.button2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.button2.Location = new System.Drawing.Point(662, 398); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(45, 45); - this.button2.TabIndex = 3; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.ButtonMove_Click); + this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonLeft.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_6; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonLeft.Location = new System.Drawing.Point(662, 398); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(45, 45); + this.buttonLeft.TabIndex = 3; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); // - // button3 + // buttonDown // - this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button3.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_5; - this.button3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.button3.Location = new System.Drawing.Point(708, 398); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(45, 45); - this.button3.TabIndex = 4; - this.button3.UseVisualStyleBackColor = true; - this.button3.Click += new System.EventHandler(this.ButtonMove_Click); + this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDown.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_5; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonDown.Location = new System.Drawing.Point(708, 398); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(45, 45); + this.buttonDown.TabIndex = 4; + this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); // - // button4 + // buttonRight // - this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button4.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_4; - this.button4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.button4.Location = new System.Drawing.Point(753, 398); - this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(45, 45); - this.button4.TabIndex = 5; - this.button4.UseVisualStyleBackColor = true; - this.button4.Click += new System.EventHandler(this.ButtonMove_Click); + this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRight.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_4; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonRight.Location = new System.Drawing.Point(753, 398); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(45, 45); + this.buttonRight.TabIndex = 5; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); // - // button5 + // buttonUp // - this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button5.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_3; - this.button5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.button5.Location = new System.Drawing.Point(708, 353); - this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(45, 45); - this.button5.TabIndex = 6; - this.button5.UseVisualStyleBackColor = true; - this.button5.Click += new System.EventHandler(this.ButtonMove_Click); + this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUp.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_3; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonUp.Location = new System.Drawing.Point(708, 353); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(45, 45); + this.buttonUp.TabIndex = 6; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); + // + // countDoorBox + // + this.countDoorBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.countDoorBox.Location = new System.Drawing.Point(197, 407); + this.countDoorBox.Maximum = new decimal(new int[] { + 5, + 0, + 0, + 0}); + this.countDoorBox.Name = "countDoorBox"; + this.countDoorBox.Size = new System.Drawing.Size(131, 27); + this.countDoorBox.TabIndex = 8; + this.countDoorBox.Value = new decimal(new int[] { + 2, + 0, + 0, + 0}); // // FormBus // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(810, 482); - this.Controls.Add(this.button5); - this.Controls.Add(this.button4); - this.Controls.Add(this.button3); - this.Controls.Add(this.button2); + this.Controls.Add(this.countDoorBox); + this.Controls.Add(this.buttonUp); + this.Controls.Add(this.buttonRight); + this.Controls.Add(this.buttonDown); + this.Controls.Add(this.buttonLeft); this.Controls.Add(this.buttonCreate); this.Controls.Add(this.pictureBoxBus); this.Controls.Add(this.statusStrip1); @@ -161,6 +190,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).EndInit(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.countDoorBox)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -174,9 +204,11 @@ private ToolStripStatusLabel toolStripStatusLabelWeight; private ToolStripStatusLabel toolStripStatusLabelBodyColor; private Button buttonCreate; - private Button button2; - private Button button3; - private Button button4; - private Button button5; + private Button buttonLeft; + private Button buttonDown; + private Button buttonRight; + private Button buttonUp; + private ToolStripStatusLabel toolStripStatusLabelDoor; + private NumericUpDown countDoorBox; } } \ No newline at end of file diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs index f193c67..c6f9caa 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs @@ -21,10 +21,12 @@ namespace DoubleDeckerBus Random rnd = new(); _bus = new DrawingBus(); _bus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _bus.DrawingDoor.SetCountDoor = ((int)countDoorBox.Value); _bus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxBus.Width, pictureBoxBus.Height); toolStripStatusLabelSpeed.Text = $": {_bus.Bus.Speed}"; toolStripStatusLabelWeight.Text = $": {_bus.Bus.Weight}"; toolStripStatusLabelBodyColor.Text = $": {_bus.Bus.BodyColor.Name}"; + toolStripStatusLabelDoor.Text = $" : {(int)countDoorBox.Value}"; Draw(); } -- 2.25.1