From 94fd66d63a17b8b51414c8b8d462cc58969eedb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=20=D0=94?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=BB=D0=BE=D0=B2?= Date: Fri, 27 Oct 2023 19:48:57 +0400 Subject: [PATCH 1/2] Laba1 --- .../Project_DumpTruck/DirectionType.cs | 16 ++ .../Project_DumpTruck/DrawningDumpTruck.cs | 191 ++++++++++++++++++ .../Project_DumpTruck/EntityDumpTruck.cs | 58 ++++++ .../Project_DumpTruck/Form1.Designer.cs | 39 ---- Project_DumpTruck/Project_DumpTruck/Form1.cs | 10 - .../FormDumpTruck.Designer.cs | 137 +++++++++++++ .../Project_DumpTruck/FormDumpTruck.cs | 83 ++++++++ .../{Form1.resx => FormDumpTruck.resx} | 50 ++--- .../Project_DumpTruck/Program.cs | 2 +- .../Project_DumpTruck.csproj | 15 ++ .../Properties/Resources.Designer.cs | 103 ++++++++++ .../Properties/Resources.resx | 133 ++++++++++++ .../Project_DumpTruck/Resources/arrowDown.png | Bin 0 -> 418 bytes .../Project_DumpTruck/Resources/arrowLeft.png | Bin 0 -> 362 bytes .../Resources/arrowRight.png | Bin 0 -> 428 bytes .../Project_DumpTruck/Resources/arrowUp.png | Bin 0 -> 412 bytes 16 files changed, 762 insertions(+), 75 deletions(-) create mode 100644 Project_DumpTruck/Project_DumpTruck/DirectionType.cs create mode 100644 Project_DumpTruck/Project_DumpTruck/DrawningDumpTruck.cs create mode 100644 Project_DumpTruck/Project_DumpTruck/EntityDumpTruck.cs delete mode 100644 Project_DumpTruck/Project_DumpTruck/Form1.Designer.cs delete mode 100644 Project_DumpTruck/Project_DumpTruck/Form1.cs create mode 100644 Project_DumpTruck/Project_DumpTruck/FormDumpTruck.Designer.cs create mode 100644 Project_DumpTruck/Project_DumpTruck/FormDumpTruck.cs rename Project_DumpTruck/Project_DumpTruck/{Form1.resx => FormDumpTruck.resx} (93%) create mode 100644 Project_DumpTruck/Project_DumpTruck/Properties/Resources.Designer.cs create mode 100644 Project_DumpTruck/Project_DumpTruck/Properties/Resources.resx create mode 100644 Project_DumpTruck/Project_DumpTruck/Resources/arrowDown.png create mode 100644 Project_DumpTruck/Project_DumpTruck/Resources/arrowLeft.png create mode 100644 Project_DumpTruck/Project_DumpTruck/Resources/arrowRight.png create mode 100644 Project_DumpTruck/Project_DumpTruck/Resources/arrowUp.png diff --git a/Project_DumpTruck/Project_DumpTruck/DirectionType.cs b/Project_DumpTruck/Project_DumpTruck/DirectionType.cs new file mode 100644 index 0000000..5d8ffbb --- /dev/null +++ b/Project_DumpTruck/Project_DumpTruck/DirectionType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Project_DumpTruck +{ + public enum DirectionType + { + Up = 1, + Down = 2, + Left = 3, + Right = 4 + } +} diff --git a/Project_DumpTruck/Project_DumpTruck/DrawningDumpTruck.cs b/Project_DumpTruck/Project_DumpTruck/DrawningDumpTruck.cs new file mode 100644 index 0000000..469af20 --- /dev/null +++ b/Project_DumpTruck/Project_DumpTruck/DrawningDumpTruck.cs @@ -0,0 +1,191 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Project_DumpTruck +{ + internal class DrawningDumpTruck + { + /// + /// Класс-сущность + /// + public EntityDumpTruck? EntityDumpTruck { get; private set; } + /// + /// Левая координата отрисовки автомобиля + /// + private float _startPosX; + /// + /// Верхняя кооридната отрисовки автомобиля + /// + private float _startPosY; + /// + /// Ширина окна отрисовки + /// + private int? _pictureWidth; + /// + /// Высота окна отрисовки + /// + private int? _pictureHeight; + /// + /// Ширина отрисовки автомобиля + /// + private readonly int _dumptruckWidth = 110; + /// + /// Высота отрисовки автомобиля + /// + private readonly int _dumptruckHeight = 60; + + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес автомобиля + /// Цвет кузова + /// + /// Ширина картинки + /// Высота картинки + public bool Init(int speed, float weight, Color bodyColor, Color additionalColor, bool body, int width, int height) + { + // TODO: Продумать проверки + if (width < _dumptruckWidth || height < _dumptruckHeight) + return false; + + _pictureWidth = width; + _pictureHeight = height; + + EntityDumpTruck = new EntityDumpTruck(); + EntityDumpTruck.Init(speed, weight, bodyColor, additionalColor, body); + return true; + } + /// + /// Установка позиции автомобиля + /// + /// Координата X + /// Координата Y + /// Ширина картинки + /// Высота картинки + public void SetPosition(int x, int y) + { + if (x < 0 || y < 0 || x > _pictureWidth || y > _pictureHeight) + { + _startPosX = 0; + _startPosY = 0; + } + + _startPosX = x; + _startPosY = y; + } + /// + /// Изменение направления пермещения + /// + /// Направление + public void MoveTransport(DirectionType direction) + { + if (EntityDumpTruck == null) + { + return; + } + switch (direction) + { + // вправо + case DirectionType.Right: + if (_startPosX + _dumptruckWidth + EntityDumpTruck.Step < _pictureWidth) + { + _startPosX += (int)EntityDumpTruck.Step; + } + break; + //влево + case DirectionType.Left: + if (_startPosX - EntityDumpTruck.Step > 0) + { + _startPosX -= (int)EntityDumpTruck.Step; + } + break; + //вверх + case DirectionType.Up: + if (_startPosY - EntityDumpTruck.Step > 0) + { + _startPosY -= (int)EntityDumpTruck.Step; + } + break; + //вниз + case DirectionType.Down: + if (_startPosY + _dumptruckHeight + EntityDumpTruck.Step < _pictureHeight) + { + _startPosY += (int)EntityDumpTruck.Step; + } + break; + } + } + /// + /// Отрисовка автомобиля + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityDumpTruck == null) + { + return; + } + + Pen penBlack = new Pen(Color.Black); + Brush brushBodyColor = new SolidBrush(EntityDumpTruck.BodyColor); + Brush brushAdditionalColor = new SolidBrush(EntityDumpTruck.AdditionalColor); + Brush brushBlack = new SolidBrush(Color.Black); + Brush brushWhite = new SolidBrush(Color.White); + + //Кабина + g.FillRectangle(brushBodyColor, _startPosX + 80, _startPosY, 20, 30); + g.DrawRectangle(penBlack, _startPosX + 80, _startPosY, 20, 30); + + //Рама + g.FillRectangle(brushBodyColor, _startPosX, _startPosY + 30, 100, 5); + g.DrawRectangle(penBlack, _startPosX, _startPosY + 30, 100, 5); + + //Колёса + g.FillEllipse(brushBlack, _startPosX, _startPosY + 35, 20, 20); + g.FillEllipse(brushBlack, _startPosX + 22, _startPosY + 35, 20, 20); + g.FillEllipse(brushBlack, _startPosX + 80, _startPosY + 35, 20, 20); + + g.FillEllipse(brushWhite, _startPosX + 5, _startPosY + 40, 10, 10); + g.FillEllipse(brushWhite, _startPosX + 27, _startPosY + 40, 10, 10); + g.FillEllipse(brushWhite, _startPosX + 85, _startPosY + 40, 10, 10); + + g.DrawEllipse(penBlack, _startPosX, _startPosY + 35, 20, 20); + g.DrawEllipse(penBlack, _startPosX + 22, _startPosY + 35, 20, 20); + g.DrawEllipse(penBlack, _startPosX + 80, _startPosY + 35, 20, 20); + + if (EntityDumpTruck.BodyKit) + { + g.FillRectangle(brushAdditionalColor, _startPosX, _startPosY + 10, 70, 20); + g.DrawRectangle(penBlack, _startPosX, _startPosY + 10, 70, 20); + } + } + /// + /// Смена границ формы отрисовки + /// + /// Ширина картинки + /// Высота картинки + public void ChangeBorders(int width, int height) + { + _pictureWidth = width; + _pictureHeight = height; + if (_pictureWidth <= _dumptruckWidth || _pictureHeight <= _dumptruckHeight) + { + _pictureWidth = null; + _pictureHeight = null; + return; + } + if (_startPosX + _dumptruckWidth > _pictureWidth) + { + _startPosX = _pictureWidth.Value - _dumptruckWidth; + } + if (_startPosY + _dumptruckHeight > _pictureHeight) + { + _startPosY = _pictureHeight.Value - _dumptruckHeight; + } + } + } +} diff --git a/Project_DumpTruck/Project_DumpTruck/EntityDumpTruck.cs b/Project_DumpTruck/Project_DumpTruck/EntityDumpTruck.cs new file mode 100644 index 0000000..50aee12 --- /dev/null +++ b/Project_DumpTruck/Project_DumpTruck/EntityDumpTruck.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Project_DumpTruck +{ + internal class EntityDumpTruck + { + /// + /// Скорость + /// + 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 double Step => (double)Speed * 100 / Weight; + + /// + /// Инициализация полей объекта-класса автомобиля + /// + /// + /// + /// + /// + /// + public void Init(int speed, float weight, Color bodyColor, Color additionalColor, bool bodyKit) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + BodyKit = bodyKit; + } + } +} diff --git a/Project_DumpTruck/Project_DumpTruck/Form1.Designer.cs b/Project_DumpTruck/Project_DumpTruck/Form1.Designer.cs deleted file mode 100644 index 59cb242..0000000 --- a/Project_DumpTruck/Project_DumpTruck/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Project_DumpTruck -{ - 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/Project_DumpTruck/Project_DumpTruck/Form1.cs b/Project_DumpTruck/Project_DumpTruck/Form1.cs deleted file mode 100644 index a1464a6..0000000 --- a/Project_DumpTruck/Project_DumpTruck/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Project_DumpTruck -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.Designer.cs b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.Designer.cs new file mode 100644 index 0000000..4b29ca5 --- /dev/null +++ b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.Designer.cs @@ -0,0 +1,137 @@ +namespace Project_DumpTruck +{ + partial class FormDumpTruck + { + /// + /// 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() + { + pictureBoxDumpTruck = new PictureBox(); + buttonCreate = new Button(); + buttonLeft = new Button(); + buttonUp = new Button(); + buttonDown = new Button(); + buttonRight = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).BeginInit(); + SuspendLayout(); + // + // pictureBoxDumpTruck + // + pictureBoxDumpTruck.Dock = DockStyle.Fill; + pictureBoxDumpTruck.Location = new Point(0, 0); + pictureBoxDumpTruck.Name = "pictureBoxDumpTruck"; + pictureBoxDumpTruck.Size = new Size(884, 461); + pictureBoxDumpTruck.SizeMode = PictureBoxSizeMode.AutoSize; + pictureBoxDumpTruck.TabIndex = 0; + pictureBoxDumpTruck.TabStop = false; + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(12, 426); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(75, 23); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.arrowLeft; + buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; + buttonLeft.Location = new Point(770, 426); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(30, 30); + buttonLeft.TabIndex = 2; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += buttonMove_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.arrowUp; + buttonUp.BackgroundImageLayout = ImageLayout.Zoom; + buttonUp.Location = new Point(806, 390); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(30, 30); + buttonUp.TabIndex = 3; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += buttonMove_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.arrowDown; + buttonDown.BackgroundImageLayout = ImageLayout.Zoom; + buttonDown.Location = new Point(806, 426); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(30, 30); + buttonDown.TabIndex = 4; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += buttonMove_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.arrowRight; + buttonRight.BackgroundImageLayout = ImageLayout.Zoom; + buttonRight.Location = new Point(842, 426); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(30, 30); + buttonRight.TabIndex = 5; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += buttonMove_Click; + // + // Form1 + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(884, 461); + Controls.Add(buttonRight); + Controls.Add(buttonDown); + Controls.Add(buttonUp); + Controls.Add(buttonLeft); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxDumpTruck); + Name = "Form1"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Form1"; + ((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private PictureBox pictureBoxDumpTruck; + private Button buttonCreate; + private Button buttonLeft; + private Button buttonUp; + private Button buttonDown; + private Button buttonRight; + } +} \ No newline at end of file diff --git a/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.cs b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.cs new file mode 100644 index 0000000..b5c8836 --- /dev/null +++ b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.cs @@ -0,0 +1,83 @@ +namespace Project_DumpTruck +{ + public partial class FormDumpTruck : Form + { + /// + /// Поле-объект для прорисовки объекта + /// + private DrawningDumpTruck? _drawningDumpTruck; + + /// + /// Инициализация формы + /// + public FormDumpTruck() + { + InitializeComponent(); + } + + /// + /// Метод прорисовки машины + /// + private void Draw() + { + if (_drawningDumpTruck == null) + return; + Bitmap bmp = new(pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningDumpTruck.DrawTransport(gr); + pictureBoxDumpTruck.Image = bmp; + } + + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningDumpTruck = new DrawningDumpTruck(); + _drawningDumpTruck.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)), + Convert.ToBoolean(random.Next(0, 2)), + pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height); + _drawningDumpTruck.SetPosition(random.Next(10, 100), + random.Next(10, 100)); + + Draw(); + } + + /// + /// Изменение размеров формы + /// + /// + /// + private void buttonMove_Click(object sender, EventArgs e) + { + if (_drawningDumpTruck == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawningDumpTruck.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawningDumpTruck.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawningDumpTruck.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawningDumpTruck.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } + } +} \ No newline at end of file diff --git a/Project_DumpTruck/Project_DumpTruck/Form1.resx b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.resx similarity index 93% rename from Project_DumpTruck/Project_DumpTruck/Form1.resx rename to Project_DumpTruck/Project_DumpTruck/FormDumpTruck.resx index 1af7de1..af32865 100644 --- a/Project_DumpTruck/Project_DumpTruck/Form1.resx +++ b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.resx @@ -1,17 +1,17 @@  - diff --git a/Project_DumpTruck/Project_DumpTruck/Program.cs b/Project_DumpTruck/Project_DumpTruck/Program.cs index 61885ba..b342206 100644 --- a/Project_DumpTruck/Project_DumpTruck/Program.cs +++ b/Project_DumpTruck/Project_DumpTruck/Program.cs @@ -11,7 +11,7 @@ namespace Project_DumpTruck // 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 FormDumpTruck()); } } } \ No newline at end of file diff --git a/Project_DumpTruck/Project_DumpTruck/Project_DumpTruck.csproj b/Project_DumpTruck/Project_DumpTruck/Project_DumpTruck.csproj index b57c89e..13ee123 100644 --- a/Project_DumpTruck/Project_DumpTruck/Project_DumpTruck.csproj +++ b/Project_DumpTruck/Project_DumpTruck/Project_DumpTruck.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/Project_DumpTruck/Project_DumpTruck/Properties/Resources.Designer.cs b/Project_DumpTruck/Project_DumpTruck/Properties/Resources.Designer.cs new file mode 100644 index 0000000..6197095 --- /dev/null +++ b/Project_DumpTruck/Project_DumpTruck/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Project_DumpTruck.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("Project_DumpTruck.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 arrowDown { + get { + object obj = ResourceManager.GetObject("arrowDown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowLeft { + get { + object obj = ResourceManager.GetObject("arrowLeft", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowRight { + get { + object obj = ResourceManager.GetObject("arrowRight", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowUp { + get { + object obj = ResourceManager.GetObject("arrowUp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Project_DumpTruck/Project_DumpTruck/Properties/Resources.resx b/Project_DumpTruck/Project_DumpTruck/Properties/Resources.resx new file mode 100644 index 0000000..dc6b4c5 --- /dev/null +++ b/Project_DumpTruck/Project_DumpTruck/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Project_DumpTruck/Project_DumpTruck/Resources/arrowDown.png b/Project_DumpTruck/Project_DumpTruck/Resources/arrowDown.png new file mode 100644 index 0000000000000000000000000000000000000000..c8222f89bae0602a328321b3e0e1649adb45dd04 GIT binary patch literal 418 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc4d$LMjv*f2$r2g|IF@=c1wFd-f1!^-#kWtI zC!ZNOX6|YZ?0(7Srn^j9V(W~&geytA8X*F1jJvFM@d_=P^!NY&|NcKdJZxqNkx*w? z`SbVp{Dut;9{bmA%VQ3a&{nt+#uQaEue0+c!>PXvN7x%I7|u91@H)IE0%b%j<;KI?w9=#cGuNI+qw?U^GdjN+YqY#2|u zGU~_ejrs8YzkE|)GvlO9!Y3Zs*Z+%YD4KYXHAsh*ank3Hy|=G3H;QPK9zMXHki^t^ zQI6sBR^|=TpXIJhW!$*%&=8|WD1#)#jv{Hf3DS31!c`@xf3A_ zAMNY@>|k^W7B+Cov`9!wnW?X+*7xQx|M@sO(Uwgs*&f)j9b4WsW5bV16K}@{3{#eA zG5nU0Xy>~mWc0exhf!euH3o^M9-rA}xmpXBFEu#uK^lbYbB$V-RI?x*5XEJb!M&gZuyOJ5Pt}dbbogIy^Ys&i}=mc|k?H=*;^6|9Bg? zF0(g0k`3|X;O_Y1-1>sMWb4X!-M*$k1FjV;5)up|7o+FLKl!Qw3Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0YOPbK~zXfV;BXa zfbM`9N>cci2N4uc=0}MK0 zM9_i6r~+V#K~zu-Xer}=c4p39eSLlK#6UG5CoK<7-UfOG|I5nC`hY^zPu{=`suAEH z@Ki=p_T&8d3zC3*c91yLGb}KJ#sYnExvZ?*1}a1wAR;6ZDJm?c0_Bc^Q7|X~0|Nlx WnO}aK49 literal 0 HcmV?d00001 diff --git a/Project_DumpTruck/Project_DumpTruck/Resources/arrowUp.png b/Project_DumpTruck/Project_DumpTruck/Resources/arrowUp.png new file mode 100644 index 0000000000000000000000000000000000000000..0c80a4f97ff38cc21261925a85af0da7210d2efe GIT binary patch literal 412 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc4ThdBjv*f2$qM3YA~r5cxV+4lH9)WS!2kdM zWtSXT`k(n@wScsik5EF>C70&%_xChCyicrYFJg7bnIJL6-z1^sk_+2tH8F5=cQc0cWjJg(%FZw6GeJPuzoE#G!QspawYabaKFvqVQ@Bd5bo3r5H8 ztyi`>YD!GYvS;|n#v#nwaKxcVVFAMxXM>UtY+KiD%R9Vz`T3uXn%^EgKR=(JgM*`i zm;Gtt1}2S)Z=W=8%;A@}M literal 0 HcmV?d00001 -- 2.25.1 From 2b42cbf8bc03c05da6f0707dccc0ebab2cfb28e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=20=D0=94?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=BB=D0=BE=D0=B2?= Date: Fri, 27 Oct 2023 20:04:01 +0400 Subject: [PATCH 2/2] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Project_DumpTruck/DrawningDumpTruck.cs | 10 ++++++++-- Project_DumpTruck/Project_DumpTruck/EntityDumpTruck.cs | 8 +++++++- .../Project_DumpTruck/FormDumpTruck.Designer.cs | 4 ++-- Project_DumpTruck/Project_DumpTruck/FormDumpTruck.cs | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Project_DumpTruck/Project_DumpTruck/DrawningDumpTruck.cs b/Project_DumpTruck/Project_DumpTruck/DrawningDumpTruck.cs index 469af20..1e1e3ab 100644 --- a/Project_DumpTruck/Project_DumpTruck/DrawningDumpTruck.cs +++ b/Project_DumpTruck/Project_DumpTruck/DrawningDumpTruck.cs @@ -46,7 +46,7 @@ namespace Project_DumpTruck /// /// Ширина картинки /// Высота картинки - public bool Init(int speed, float weight, Color bodyColor, Color additionalColor, bool body, int width, int height) + public bool Init(int speed, float weight, Color bodyColor, Color additionalColor, bool body, bool tent, int width, int height) { // TODO: Продумать проверки if (width < _dumptruckWidth || height < _dumptruckHeight) @@ -56,7 +56,7 @@ namespace Project_DumpTruck _pictureHeight = height; EntityDumpTruck = new EntityDumpTruck(); - EntityDumpTruck.Init(speed, weight, bodyColor, additionalColor, body); + EntityDumpTruck.Init(speed, weight, bodyColor, additionalColor, body, tent); return true; } /// @@ -161,6 +161,12 @@ namespace Project_DumpTruck { g.FillRectangle(brushAdditionalColor, _startPosX, _startPosY + 10, 70, 20); g.DrawRectangle(penBlack, _startPosX, _startPosY + 10, 70, 20); + + if (EntityDumpTruck.Tent) + { + g.FillRectangle(brushWhite, _startPosX, _startPosY + 10, 70, 5); + g.DrawRectangle(penBlack, _startPosX, _startPosY + 10, 70, 5); + } } } /// diff --git a/Project_DumpTruck/Project_DumpTruck/EntityDumpTruck.cs b/Project_DumpTruck/Project_DumpTruck/EntityDumpTruck.cs index 50aee12..a6b95c3 100644 --- a/Project_DumpTruck/Project_DumpTruck/EntityDumpTruck.cs +++ b/Project_DumpTruck/Project_DumpTruck/EntityDumpTruck.cs @@ -33,6 +33,11 @@ namespace Project_DumpTruck /// public bool BodyKit { get; private set; } + /// + /// Признак (опция) наличия тента + /// + public bool Tent { get; private set; } + /// /// Шаг перемещения автомобиля /// @@ -46,13 +51,14 @@ namespace Project_DumpTruck /// /// /// - public void Init(int speed, float weight, Color bodyColor, Color additionalColor, bool bodyKit) + public void Init(int speed, float weight, Color bodyColor, Color additionalColor, bool bodyKit, bool tent) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; BodyKit = bodyKit; + Tent = tent; } } } diff --git a/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.Designer.cs b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.Designer.cs index 4b29ca5..d615664 100644 --- a/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.Designer.cs +++ b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.Designer.cs @@ -106,7 +106,7 @@ buttonRight.UseVisualStyleBackColor = true; buttonRight.Click += buttonMove_Click; // - // Form1 + // FormDumpTruck // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; @@ -117,7 +117,7 @@ Controls.Add(buttonLeft); Controls.Add(buttonCreate); Controls.Add(pictureBoxDumpTruck); - Name = "Form1"; + Name = "FormDumpTruck"; StartPosition = FormStartPosition.CenterScreen; Text = "Form1"; ((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).EndInit(); diff --git a/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.cs b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.cs index b5c8836..4881247 100644 --- a/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.cs +++ b/Project_DumpTruck/Project_DumpTruck/FormDumpTruck.cs @@ -43,6 +43,7 @@ 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)), pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height); _drawningDumpTruck.SetPosition(random.Next(10, 100), random.Next(10, 100)); -- 2.25.1