From 1c2289bc85eca6801c47c4b3a8f409713013983f Mon Sep 17 00:00:00 2001 From: bulatova_karina Date: Wed, 13 Sep 2023 11:00:36 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=D0=B0?= =?UTF-8?q?=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/Direction.cs | 32 +++ WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 240 ++++++++++++++++++ WarmlyShip/WarmlyShip/EntityWarmlyShip.cs | 65 +++++ WarmlyShip/WarmlyShip/Form1.cs | 10 - ...Designer.cs => FormWarmlyShip.Designer.cs} | 24 +- WarmlyShip/WarmlyShip/FormWarmlyShip.cs | 84 ++++++ WarmlyShip/WarmlyShip/FormWarmlyShip.resx | 60 +++++ WarmlyShip/WarmlyShip/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 103 ++++++++ .../{Form1.resx => Properties/Resources.resx} | 13 + .../WarmlyShip/Resources/down-arrow.png | Bin 0 -> 281 bytes .../WarmlyShip/Resources/left-arrow.png | Bin 0 -> 265 bytes .../WarmlyShip/Resources/right-arrow.png | Bin 0 -> 224 bytes .../WarmlyShip/Resources/upper-arrow.png | Bin 0 -> 264 bytes WarmlyShip/WarmlyShip/WarmlyShip.csproj | 15 ++ 15 files changed, 633 insertions(+), 15 deletions(-) create mode 100644 WarmlyShip/WarmlyShip/Direction.cs create mode 100644 WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs create mode 100644 WarmlyShip/WarmlyShip/EntityWarmlyShip.cs delete mode 100644 WarmlyShip/WarmlyShip/Form1.cs rename WarmlyShip/WarmlyShip/{Form1.Designer.cs => FormWarmlyShip.Designer.cs} (58%) create mode 100644 WarmlyShip/WarmlyShip/FormWarmlyShip.cs create mode 100644 WarmlyShip/WarmlyShip/FormWarmlyShip.resx create mode 100644 WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs rename WarmlyShip/WarmlyShip/{Form1.resx => Properties/Resources.resx} (83%) create mode 100644 WarmlyShip/WarmlyShip/Resources/down-arrow.png create mode 100644 WarmlyShip/WarmlyShip/Resources/left-arrow.png create mode 100644 WarmlyShip/WarmlyShip/Resources/right-arrow.png create mode 100644 WarmlyShip/WarmlyShip/Resources/upper-arrow.png diff --git a/WarmlyShip/WarmlyShip/Direction.cs b/WarmlyShip/WarmlyShip/Direction.cs new file mode 100644 index 0000000..3dc9572 --- /dev/null +++ b/WarmlyShip/WarmlyShip/Direction.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WarmlyShip +{ + /// + /// Направление перемещения + /// + public enum DirectionType + { + /// + /// Вверх + /// + Up = 1, + /// + /// Вниз + /// + Down = 2, + /// + /// Влево + /// + Left = 3, + /// + /// Вправо + /// + Right = 4 + + } +} diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs new file mode 100644 index 0000000..bb181e9 --- /dev/null +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -0,0 +1,240 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WarmlyShip +{ + /// + /// Класс, отвечающий за прорисовку и перемещение объекта-сущности + /// + public class DrawingWarmlyShip + { + /// + /// Класс-сущность + /// + public EntityWarmlyShip? EntityWarmlyShip { get; private set; } + /// + /// Ширина окна + /// + private int _pictureWidth; + /// + /// Высота окна + /// + private int _pictureHeight; + /// + /// Левая координата прорисовки автомобиля + /// + private int _startPosX; + /// + /// Верхняя кооридната прорисовки автомобиля + /// + private int _startPosY; + /// + /// Ширина прорисовки автомобиля + /// + private readonly int _carWidth = 110; + /// + /// Высота прорисовки автомобиля + /// + private readonly int _carHeight = 60; + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Цвет кузова + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + /// Ширина картинки + /// Высота картинки + /// true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах +public bool Init(int speed, double weight, Color bodyColor, Color +additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) + { + // TODO: Продумать проверки + _pictureWidth = width; + _pictureHeight = height; + EntityWarmlyShip = new EntityWarmlyShip(); + EntityWarmlyShip.Init(speed, weight, bodyColor, additionalColor, + bodyKit, wing, sportLine); + return true; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + // TODO: Изменение x, y + _startPosX = x; + _startPosY = y; + } + /// + /// Изменение направления перемещения + /// + /// Направление + public void MoveTransport(DirectionType direction) + { + if (EntityWarmlyShip == null) + { + return; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX - EntityWarmlyShip.Step > 0) + { + _startPosX -= (int)EntityWarmlyShip.Step; + } + break; + //вверх + case DirectionType.Up: + if (_startPosY - EntityWarmlyShip.Step > 0) + { + _startPosY -= (int)EntityWarmlyShip.Step; + } + break; + // вправо + case DirectionType.Right: + // TODO: Продумать логику + break; + //вниз + case DirectionType.Down: + // TODO: Продумать логику + break; + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityWarmlyShip == null) + { + return; + } + Pen pen = new(Color.Black); + Brush additionalBrush = new + SolidBrush(EntityWarmlyShip.AdditionalColor); + // обвесы + if (EntityWarmlyShip.BodyKit) + { + g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20); + g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, + 20); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, + 20, 40); + g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, + 15); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, + 15, 15); + g.FillEllipse(additionalBrush, _startPosX + 90, + _startPosY, 20, 20); + g.FillEllipse(additionalBrush, _startPosX + 90, + _startPosY + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX + 90, + _startPosY + 10, 20, 40); + g.FillRectangle(additionalBrush, _startPosX + 90, +_startPosY + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX + 90, + _startPosY + 45, 15, 15); + g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20); + g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20); + g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, + 40); + g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, + 15); + g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, + 14, 15); + g.FillEllipse(additionalBrush, _startPosX, _startPosY, + 20, 20); + g.FillEllipse(additionalBrush, _startPosX, _startPosY + + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX + 1, + _startPosY + 10, 25, 40); + g.FillRectangle(additionalBrush, _startPosX + 5, + _startPosY + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX + 5, + _startPosY + 45, 15, 15); + g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, + 15); + g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, + 39, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 1, 40, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 45, 40, 15); + } + //границы автомобиля + g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20); + g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); + g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10, + 30); + g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52); + //задние фары + Brush brRed = new SolidBrush(Color.Red); + g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20); + g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20, + 20); + //передние фары + Brush brYellow = new SolidBrush(Color.Yellow); + g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20, + 20); + g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, + 20); + //кузов + Brush br = new SolidBrush(EntityWarmlyShip.BodyColor); + g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30); + g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30); + g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50); + //стекла + Brush brBlue = new SolidBrush(Color.LightBlue); + g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5, + 40); + g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 10, 5, + 40); + g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35, + 2); + g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35, + 2); + //выделяем рамкой крышу + g.DrawRectangle(pen, _startPosX + 35, _startPosY + 10, 35, + 40); + g.DrawRectangle(pen, _startPosX + 75, _startPosY + 15, 25, + 30); + g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15, + 30); + // спортивная линия + if (EntityWarmlyShip.SportLine) + { + g.FillRectangle(additionalBrush, _startPosX + 75, + _startPosY + 23, 25, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 23, 35, 15); + g.FillRectangle(additionalBrush, _startPosX + 10, + _startPosY + 23, 20, 15); + } + // крыло + if (EntityWarmlyShip.Wing) + { + g.FillRectangle(additionalBrush, _startPosX, _startPosY + + 5, 10, 50); + g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, + 50); + } + } + + + + } +} diff --git a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs new file mode 100644 index 0000000..94f5114 --- /dev/null +++ b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WarmlyShip +{ + public class EntityWarmlyShip + { + /// + /// Скорость + /// + 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 => (double)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; + } + } +} diff --git a/WarmlyShip/WarmlyShip/Form1.cs b/WarmlyShip/WarmlyShip/Form1.cs deleted file mode 100644 index bca3f86..0000000 --- a/WarmlyShip/WarmlyShip/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace WarmlyShip -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/Form1.Designer.cs b/WarmlyShip/WarmlyShip/FormWarmlyShip.Designer.cs similarity index 58% rename from WarmlyShip/WarmlyShip/Form1.Designer.cs rename to WarmlyShip/WarmlyShip/FormWarmlyShip.Designer.cs index 3873b6f..9c525c9 100644 --- a/WarmlyShip/WarmlyShip/Form1.Designer.cs +++ b/WarmlyShip/WarmlyShip/FormWarmlyShip.Designer.cs @@ -1,6 +1,6 @@ namespace WarmlyShip { - partial class Form1 + partial class FormWarmlyShip { /// /// Required designer variable. @@ -28,12 +28,28 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.SuspendLayout(); + // + // FormWarmlyShip + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; + this.ClientSize = new System.Drawing.Size(882, 453); + this.Name = "FormWarmlyShip"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Теплоход"; + this.ResumeLayout(false); + } #endregion + + /*private PictureBox pictureBoxWarmlyShip; + private Button buttonRight; + private Button buttonLeft; + private Button buttonUp; + private Button buttonDown; + private Button buttonCreate;*/ + } } \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/FormWarmlyShip.cs b/WarmlyShip/WarmlyShip/FormWarmlyShip.cs new file mode 100644 index 0000000..82ddecc --- /dev/null +++ b/WarmlyShip/WarmlyShip/FormWarmlyShip.cs @@ -0,0 +1,84 @@ +namespace WarmlyShip +{ + public partial class FormWarmlyShip : Form + { + /// + /// - + /// + private DrawingWarmlyShip? _drawingWarmlyShip; + /// + /// + /// + public FormWarmlyShip() + { + InitializeComponent(); + } + /// + /// + /// + private void Draw() + { + if (_drawingWarmlyShip == null) + { + return; + } + Bitmap bmp = new(pictureBoxWarmlyShip.Width, + pictureBoxWarmlyShip.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawingWarmlyShip.DrawTransport(gr); + pictureBoxWarmlyShip.Image = bmp; + } + /// + /// "" + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawingWarmlyShip = new DrawingWarmlyShip(); + _drawingWarmlyShip.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)), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), + pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height); + _drawingWarmlyShip.SetPosition(random.Next(10, 100), + random.Next(10, 100)); + Draw(); + } + /// + /// + /// + /// + /// + private void buttonMove_Click(object sender, EventArgs e) + { + if (_drawingWarmlyShip == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawingWarmlyShip.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawingWarmlyShip.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawingWarmlyShip.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawingWarmlyShip.MoveTransport(DirectionType.Right); + break; + } + Draw(); + + } + } +} \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/FormWarmlyShip.resx b/WarmlyShip/WarmlyShip/FormWarmlyShip.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WarmlyShip/WarmlyShip/FormWarmlyShip.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/Program.cs b/WarmlyShip/WarmlyShip/Program.cs index 341c406..71da933 100644 --- a/WarmlyShip/WarmlyShip/Program.cs +++ b/WarmlyShip/WarmlyShip/Program.cs @@ -11,7 +11,7 @@ namespace WarmlyShip // 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 FormWarmlyShip()); } } } \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs b/WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs new file mode 100644 index 0000000..1ab343c --- /dev/null +++ b/WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace WarmlyShip.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("WarmlyShip.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 down_arrow { + get { + object obj = ResourceManager.GetObject("down-arrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap left_arrow { + get { + object obj = ResourceManager.GetObject("left-arrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap right_arrow { + get { + object obj = ResourceManager.GetObject("right-arrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap upper_arrow { + get { + object obj = ResourceManager.GetObject("upper-arrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/WarmlyShip/WarmlyShip/Form1.resx b/WarmlyShip/WarmlyShip/Properties/Resources.resx similarity index 83% rename from WarmlyShip/WarmlyShip/Form1.resx rename to WarmlyShip/WarmlyShip/Properties/Resources.resx index 1af7de1..4e13804 100644 --- a/WarmlyShip/WarmlyShip/Form1.resx +++ b/WarmlyShip/WarmlyShip/Properties/Resources.resx @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\down-arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\upper-arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\left-arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\right-arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/Resources/down-arrow.png b/WarmlyShip/WarmlyShip/Resources/down-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..9d67143363585e3432a1c1d203ab1b9c01976c50 GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oArNM~bhqvgQ1G;; zi(^Q|oVQcGxehr9xZG!PJ=iKPkv~* zc9Kx^`?K)}4&8QsA++)Z=NaeL@TnCH#^;@Tgv2kJgjw7>ZYuCH(qz)4*DH2Ru$Mb* cz?1ZWvE`jXwNtr}CD2<8p00i_>zopr0H3RI6#xJL literal 0 HcmV?d00001 diff --git a/WarmlyShip/WarmlyShip/Resources/left-arrow.png b/WarmlyShip/WarmlyShip/Resources/left-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..046470dd1579e2ce99e38e48677f93b995460f47 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oArNM~bhqvgP;j@W zi(^Q|oVU|#xtJVz+~TLPvK|zU=>9%IR50azvg(S67o|20$2W@PT-(3ZQ}D>v**$AM z9~3wt^4`$XaKfZXmnNm`XLx_4;d#{Y1DqBNvH2B@Ar5QPm(+f2is!A77T$Nb@L`vJ z!N<1uwhtDSGR)zvNq*OSE>?;q>{)3O*9}3RhUml3c6<6X?w%M??e!!o{lH-l9p`3y z&ohn7Cq`t%+o+y0?@ZL`y>m)cVfjVm7Hdm6Pg#bRdv?g zo_d7i&cBX%-Up_*C#c3a-842yRoo=xRhZ?*{Ndc)p1PG@KZIFQcRaRubCl_?gn{+W T1E1yqUB}?*>gTe~DWM4frWsJb literal 0 HcmV?d00001 diff --git a/WarmlyShip/WarmlyShip/Resources/upper-arrow.png b/WarmlyShip/WarmlyShip/Resources/upper-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..0bc323d4a84a7434e950a34a05d6b0cd4e0a1c26 GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oArNM~bhqvgP;i&0 zi(^Q|oVQbbxegf!xW#)r9MrC8xaTY)c*L7CcFT3a^G|}xyX^1!D7K_1`USOA8kl%4 zuawtak|5Fc@p(wlfHmbNxVQmhc^IrFsVWmFgSL${tdEQr8i?PC!r5 z-mCYs_=f9zf$C58UcX%ZI{$%y&F{@MtaofZ#Vy%)J(#?rbq3?~4jUeUwjGSzQ!Gv{ z%T?&_jecpHJ#SL+0#Aenable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file From 4ee93640af31c7e6f8654fe7316a101fd669b7a8 Mon Sep 17 00:00:00 2001 From: bulatova_karina Date: Fri, 22 Sep 2023 16:01:57 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=D0=B0?= =?UTF-8?q?=20=D1=84=D0=BE=D1=80=D0=BC=D0=BE=D1=87=D0=BA=D1=83=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D1=80=D1=83=20(=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D0=B0=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 4 +- .../WarmlyShip/FormWarmlyShip.Designer.cs | 93 +++++++++++++++++-- WarmlyShip/WarmlyShip/FormWarmlyShip.cs | 44 +++++++++ 3 files changed, 133 insertions(+), 8 deletions(-) diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index bb181e9..94787b5 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -102,11 +102,11 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) break; // вправо case DirectionType.Right: - // TODO: Продумать логику + _startPosX += (int)EntityWarmlyShip.Step; break; //вниз case DirectionType.Down: - // TODO: Продумать логику + _startPosY += (int)EntityWarmlyShip.Step; break; } } diff --git a/WarmlyShip/WarmlyShip/FormWarmlyShip.Designer.cs b/WarmlyShip/WarmlyShip/FormWarmlyShip.Designer.cs index 9c525c9..879ef5d 100644 --- a/WarmlyShip/WarmlyShip/FormWarmlyShip.Designer.cs +++ b/WarmlyShip/WarmlyShip/FormWarmlyShip.Designer.cs @@ -28,28 +28,109 @@ /// private void InitializeComponent() { + this.pictureBoxWarmlyShip = new System.Windows.Forms.PictureBox(); + this.buttonCreate = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonDown = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarmlyShip)).BeginInit(); this.SuspendLayout(); // + // pictureBoxWarmlyShip + // + this.pictureBoxWarmlyShip.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxWarmlyShip.Location = new System.Drawing.Point(0, 0); + this.pictureBoxWarmlyShip.Name = "pictureBoxWarmlyShip"; + this.pictureBoxWarmlyShip.Size = new System.Drawing.Size(882, 453); + this.pictureBoxWarmlyShip.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxWarmlyShip.TabIndex = 0; + this.pictureBoxWarmlyShip.TabStop = false; + // + // buttonCreate + // + this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreate.Location = new System.Drawing.Point(31, 411); + this.buttonCreate.Name = "buttonCreate"; + this.buttonCreate.Size = new System.Drawing.Size(94, 30); + this.buttonCreate.TabIndex = 1; + this.buttonCreate.Text = "Создать"; + this.buttonCreate.UseVisualStyleBackColor = true; + this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click_1); + // + // buttonLeft + // + this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonLeft.BackgroundImage = global::WarmlyShip.Properties.Resources.left_arrow; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonLeft.Location = new System.Drawing.Point(703, 411); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(30, 30); + this.buttonLeft.TabIndex = 2; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonUp + // + this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUp.BackgroundImage = global::WarmlyShip.Properties.Resources.upper_arrow; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonUp.Location = new System.Drawing.Point(739, 375); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(30, 30); + this.buttonUp.TabIndex = 3; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonRight + // + this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRight.BackgroundImage = global::WarmlyShip.Properties.Resources.right_arrow; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonRight.Location = new System.Drawing.Point(775, 411); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(30, 30); + this.buttonRight.TabIndex = 4; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonDown + // + this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDown.BackgroundImage = global::WarmlyShip.Properties.Resources.down_arrow; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonDown.Location = new System.Drawing.Point(739, 411); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(30, 30); + this.buttonDown.TabIndex = 5; + this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); + // // FormWarmlyShip // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(882, 453); + this.Controls.Add(this.buttonDown); + this.Controls.Add(this.buttonRight); + this.Controls.Add(this.buttonUp); + this.Controls.Add(this.buttonLeft); + this.Controls.Add(this.buttonCreate); + this.Controls.Add(this.pictureBoxWarmlyShip); this.Name = "FormWarmlyShip"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Теплоход"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarmlyShip)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion - /*private PictureBox pictureBoxWarmlyShip; - private Button buttonRight; + private PictureBox pictureBoxWarmlyShip; + private Button buttonCreate; private Button buttonLeft; private Button buttonUp; + private Button buttonRight; private Button buttonDown; - private Button buttonCreate;*/ - } } \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/FormWarmlyShip.cs b/WarmlyShip/WarmlyShip/FormWarmlyShip.cs index 82ddecc..706e1fa 100644 --- a/WarmlyShip/WarmlyShip/FormWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/FormWarmlyShip.cs @@ -80,5 +80,49 @@ namespace WarmlyShip Draw(); } + + private void buttonCreate_Click_1(object sender, EventArgs e) + { + Random random = new(); + _drawingWarmlyShip = new DrawingWarmlyShip (); + _drawingWarmlyShip.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)), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), + pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height); + _drawingWarmlyShip.SetPosition(random.Next(10, 100), + random.Next(10, 100)); + Draw(); + + } + + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawingWarmlyShip == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawingWarmlyShip.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawingWarmlyShip.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawingWarmlyShip.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawingWarmlyShip.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } } } \ No newline at end of file From 5a20381dea6be0f8f6796c3a0915d02d8b0466f7 Mon Sep 17 00:00:00 2001 From: bulatova_karina Date: Fri, 22 Sep 2023 18:31:19 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=9D=D0=B0=D1=80=D0=B8=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BB=D0=B0=20=D1=80=D0=B8=D1=81=D1=83=D0=BD=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 161 ++++++--------------- 1 file changed, 41 insertions(+), 120 deletions(-) diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index 94787b5..ce8b835 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -32,13 +32,13 @@ namespace WarmlyShip /// private int _startPosY; /// - /// Ширина прорисовки автомобиля + /// Ширина прорисовки теплохода /// - private readonly int _carWidth = 110; + private readonly int _WarmlyShipWidth = 170; /// - /// Высота прорисовки автомобиля + /// Высота прорисовки теплохода /// - private readonly int _carHeight = 60; + private readonly int _WarmlyShipHeight = 180; /// /// Инициализация свойств /// @@ -102,11 +102,17 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) break; // вправо case DirectionType.Right: - _startPosX += (int)EntityWarmlyShip.Step; + if (_startPosX + _WarmlyShipWidth + EntityWarmlyShip.Step < _pictureWidth) + { + _startPosX += (int)EntityWarmlyShip.Step; + } break; //вниз case DirectionType.Down: - _startPosY += (int)EntityWarmlyShip.Step; + if (_startPosY + _WarmlyShipHeight + EntityWarmlyShip.Step < _pictureHeight) + { + _startPosY += (int)EntityWarmlyShip.Step; + } break; } } @@ -120,121 +126,36 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) { return; } - Pen pen = new(Color.Black); - Brush additionalBrush = new - SolidBrush(EntityWarmlyShip.AdditionalColor); - // обвесы - if (EntityWarmlyShip.BodyKit) + Pen pen = new(Color.Black, 2); + Pen anchor = new(Color.Black, 4); + Brush additionalBrush = new SolidBrush(EntityWarmlyShip.BodyColor); + //корпус теплохода + Point[] hull = new Point[] { - g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20); - g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, - 20); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, - 20, 40); - g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, - 15); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, - 15, 15); - g.FillEllipse(additionalBrush, _startPosX + 90, - _startPosY, 20, 20); - g.FillEllipse(additionalBrush, _startPosX + 90, - _startPosY + 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX + 90, - _startPosY + 10, 20, 40); - g.FillRectangle(additionalBrush, _startPosX + 90, -_startPosY + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX + 90, - _startPosY + 45, 15, 15); - g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20); - g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20); - g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, - 40); - g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, - 15); - g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, - 14, 15); - g.FillEllipse(additionalBrush, _startPosX, _startPosY, - 20, 20); - g.FillEllipse(additionalBrush, _startPosX, _startPosY + - 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX + 1, - _startPosY + 10, 25, 40); - g.FillRectangle(additionalBrush, _startPosX + 5, - _startPosY + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX + 5, - _startPosY + 45, 15, 15); - g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, - 15); - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, - 39, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 1, 40, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 45, 40, 15); - } - //границы автомобиля - g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20); - g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); - g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10, - 30); - g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52); - //задние фары - Brush brRed = new SolidBrush(Color.Red); - g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20); - g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20, - 20); - //передние фары - Brush brYellow = new SolidBrush(Color.Yellow); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20, - 20); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, - 20); - //кузов - Brush br = new SolidBrush(EntityWarmlyShip.BodyColor); - g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30); - g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30); - g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50); - //стекла - Brush brBlue = new SolidBrush(Color.LightBlue); - g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5, - 40); - g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 10, 5, - 40); - g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35, - 2); - g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35, - 2); - //выделяем рамкой крышу - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 10, 35, - 40); - g.DrawRectangle(pen, _startPosX + 75, _startPosY + 15, 25, - 30); - g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15, - 30); - // спортивная линия - if (EntityWarmlyShip.SportLine) - { - g.FillRectangle(additionalBrush, _startPosX + 75, - _startPosY + 23, 25, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 23, 35, 15); - g.FillRectangle(additionalBrush, _startPosX + 10, - _startPosY + 23, 20, 15); - } - // крыло - if (EntityWarmlyShip.Wing) - { - g.FillRectangle(additionalBrush, _startPosX, _startPosY - + 5, 10, 50); - g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, - 50); - } + new Point(_startPosX + 10, _startPosY + 115), + new Point(_startPosX + 190, _startPosY + 115), + new Point(_startPosX + 150, _startPosY + 190), + new Point(_startPosX + 50, _startPosY + 190), + }; + g.FillPolygon(additionalBrush, hull); + g.DrawPolygon(pen, hull); + Brush bra = new SolidBrush(EntityWarmlyShip.AdditionalColor); + //палуба + g.FillRectangle(bra, _startPosX + 35, _startPosY + 85, 130, 30); + g.DrawRectangle(pen, _startPosX + 35, _startPosY + 85, 130, 30); + //отсек для топлива + Brush brGray = new SolidBrush(Color.Gray); + g.FillEllipse(brGray, _startPosX + 140, _startPosY + 130, 20, 20); + g.DrawEllipse(pen, _startPosX + 140, _startPosY + 130, 20, 20); + //трубы + g.FillRectangle(additionalBrush, _startPosX + 65, _startPosY + 5, 25, 80); + g.DrawRectangle(pen, _startPosX + 65, _startPosY + 5, 25, 80); + g.FillRectangle(additionalBrush, _startPosX + 100, _startPosY + 25, 25, 60); + g.DrawRectangle(pen, _startPosX + 100, _startPosY + 25, 25, 60); + //якорь + g.DrawLine(anchor, new Point(_startPosX + 50, _startPosY + 130), new Point(_startPosX + 50,_startPosY + 150)); + g.DrawLine(anchor, new Point(_startPosX + 40, _startPosY + 140), new Point(_startPosX + 60, _startPosY + 140)); + g.DrawLine(anchor, new Point(_startPosX + 45, _startPosY + 150), new Point(_startPosX + 55, _startPosY + 150)); } - - - } } From 289e6b619251a911b2b37e12ec5e834291983115 Mon Sep 17 00:00:00 2001 From: bulatova_karina Date: Tue, 26 Sep 2023 13:29:10 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=B4=D1=83=D0=BC=D0=B0?= =?UTF-8?q?=D0=BB=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 65 ++++++++++++---------- WarmlyShip/WarmlyShip/EntityWarmlyShip.cs | 30 ++++------ WarmlyShip/WarmlyShip/FormWarmlyShip.cs | 11 ++-- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index ce8b835..12347d2 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -24,43 +24,44 @@ namespace WarmlyShip /// private int _pictureHeight; /// - /// Левая координата прорисовки автомобиля + /// Левая координата прорисовки теплохода /// private int _startPosX; /// - /// Верхняя кооридната прорисовки автомобиля + /// Верхняя кооридната прорисовки теплохода /// private int _startPosY; /// /// Ширина прорисовки теплохода /// - private readonly int _WarmlyShipWidth = 170; + private readonly int _WarmlyShipWidth = 180; /// /// Высота прорисовки теплохода /// - private readonly int _WarmlyShipHeight = 180; + private readonly int _WarmlyShipHeight = 185; /// /// Инициализация свойств /// /// Скорость /// Вес - /// Цвет кузова + /// Цвет корпуса /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы + /// Признак наличия труб + /// Признак наличия отсека для топлива /// Ширина картинки /// Высота картинки /// true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах -public bool Init(int speed, double weight, Color bodyColor, Color -additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) + public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pipes, bool section, + int width, int height) { - // TODO: Продумать проверки + if (width <_WarmlyShipWidth || height <_WarmlyShipHeight) + { + return false; + } _pictureWidth = width; _pictureHeight = height; EntityWarmlyShip = new EntityWarmlyShip(); - EntityWarmlyShip.Init(speed, weight, bodyColor, additionalColor, - bodyKit, wing, sportLine); + EntityWarmlyShip.Init(speed, weight, bodyColor, additionalColor, pipes, section); return true; } /// @@ -70,9 +71,11 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) /// Координата Y public void SetPosition(int x, int y) { - // TODO: Изменение x, y - _startPosX = x; - _startPosY = y; + if (x >= 0 && x + _WarmlyShipWidth <= _pictureWidth && y >= 0 && y + _WarmlyShipHeight <= _pictureHeight) + { + _startPosX = x; + _startPosY = y; + } } /// /// Изменение направления перемещения @@ -132,26 +135,32 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) //корпус теплохода Point[] hull = new Point[] { - new Point(_startPosX + 10, _startPosY + 115), - new Point(_startPosX + 190, _startPosY + 115), - new Point(_startPosX + 150, _startPosY + 190), - new Point(_startPosX + 50, _startPosY + 190), + new Point(_startPosX, _startPosY + 110), + new Point(_startPosX + 180, _startPosY + 110), + new Point(_startPosX + 140, _startPosY + 185), + new Point(_startPosX + 40, _startPosY + 185), }; g.FillPolygon(additionalBrush, hull); g.DrawPolygon(pen, hull); Brush bra = new SolidBrush(EntityWarmlyShip.AdditionalColor); //палуба - g.FillRectangle(bra, _startPosX + 35, _startPosY + 85, 130, 30); - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 85, 130, 30); + g.FillRectangle(bra, _startPosX + 25, _startPosY + 80, 130, 30); + g.DrawRectangle(pen, _startPosX + 25, _startPosY + 80, 130, 30); //отсек для топлива Brush brGray = new SolidBrush(Color.Gray); - g.FillEllipse(brGray, _startPosX + 140, _startPosY + 130, 20, 20); - g.DrawEllipse(pen, _startPosX + 140, _startPosY + 130, 20, 20); + if (EntityWarmlyShip.Section) + { + g.FillEllipse(brGray, _startPosX + 130, _startPosY + 130, 20, 20); + g.DrawEllipse(pen, _startPosX + 130, _startPosY + 130, 20, 20); + } //трубы - g.FillRectangle(additionalBrush, _startPosX + 65, _startPosY + 5, 25, 80); - g.DrawRectangle(pen, _startPosX + 65, _startPosY + 5, 25, 80); - g.FillRectangle(additionalBrush, _startPosX + 100, _startPosY + 25, 25, 60); - g.DrawRectangle(pen, _startPosX + 100, _startPosY + 25, 25, 60); + if (EntityWarmlyShip.Pipes) + { + g.FillRectangle(brGray, _startPosX + 55, _startPosY, 25, 80); + g.DrawRectangle(pen, _startPosX + 55, _startPosY, 25, 80); + g.FillRectangle(brGray, _startPosX + 90, _startPosY + 20, 25, 60); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 20, 25, 60); + } //якорь g.DrawLine(anchor, new Point(_startPosX + 50, _startPosY + 130), new Point(_startPosX + 50,_startPosY + 150)); g.DrawLine(anchor, new Point(_startPosX + 40, _startPosY + 140), new Point(_startPosX + 60, _startPosY + 140)); diff --git a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs index 94f5114..6e78824 100644 --- a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs @@ -25,41 +25,35 @@ namespace WarmlyShip /// public Color AdditionalColor { get; private set; } /// - /// Признак (опция) наличия обвеса + /// Признак (опция) наличия труб /// - public bool BodyKit { get; private set; } + public bool Pipes { get; private set; } /// - /// Признак (опция) наличия антикрыла + /// Признак (опция) наличия отсека для топлива /// - public bool Wing { get; private set; } + public bool Section { get; private set; } /// - /// Признак (опция) наличия гоночной полосы - /// - public bool SportLine { get; private set; } - /// - /// Шаг перемещения автомобиля + /// Шаг перемещения теплохода /// public double Step => (double)Speed * 100 / Weight; /// - /// Инициализация полей объекта-класса спортивного автомобиля + /// Инициализация полей объекта-класса теплохода /// /// Скорость - /// Вес автомобиля + /// Вес теплохода /// Основной цвет /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы + /// Признак наличия труб + /// Признак наличия отсека для топлива public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool bodyKit, bool wing, bool sportLine) + additionalColor, bool pipes, bool section) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; - BodyKit = bodyKit; - Wing = wing; - SportLine = sportLine; + Pipes = pipes; + Section = section; } } } diff --git a/WarmlyShip/WarmlyShip/FormWarmlyShip.cs b/WarmlyShip/WarmlyShip/FormWarmlyShip.cs index 706e1fa..74a8a85 100644 --- a/WarmlyShip/WarmlyShip/FormWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/FormWarmlyShip.cs @@ -44,10 +44,9 @@ namespace WarmlyShip 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)), + Convert.ToBoolean(random.Next(0, 2)), pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height); - _drawingWarmlyShip.SetPosition(random.Next(10, 100), - random.Next(10, 100)); + _drawingWarmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } /// @@ -92,12 +91,10 @@ namespace WarmlyShip 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)), + Convert.ToBoolean(random.Next(0, 2)), pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height); - _drawingWarmlyShip.SetPosition(random.Next(10, 100), - random.Next(10, 100)); + _drawingWarmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); - } private void ButtonMove_Click(object sender, EventArgs e)