From fe5fe24f5a20e41c7aa5154715d41e0f7f89c4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Tue, 4 Oct 2022 19:49:57 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawningMotorShip.cs | 17 ++++++++++--- ...ingWarmlyShip.cs => DrawningWarmlyShip.cs} | 6 ++--- WarmlyShip/WarmlyShip/EntityMotorShip.cs | 12 ++++----- WarmlyShip/WarmlyShip/FormClass.Designer.cs | 14 +++++++++++ WarmlyShip/WarmlyShip/FormClass.cs | 25 ++++++++++++++++--- 5 files changed, 56 insertions(+), 18 deletions(-) rename WarmlyShip/WarmlyShip/{DrawingWarmlyShip.cs => DrawningWarmlyShip.cs} (94%) diff --git a/WarmlyShip/WarmlyShip/DrawningMotorShip.cs b/WarmlyShip/WarmlyShip/DrawningMotorShip.cs index d296623..7ef8c2c 100644 --- a/WarmlyShip/WarmlyShip/DrawningMotorShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningMotorShip.cs @@ -6,20 +6,29 @@ using System.Threading.Tasks; namespace WarmlyShip { - internal class DrawningMotorShip : DrawingWarmlyShip + internal class DrawningMotorShip : DrawningWarmlyShip { - public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) : base(speed, weight, bodyColor, 110, 60) + public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor, 110, 60) { - warmlyShip = new EntityMotorShip(speed, weight, bodyColor, dopColor, bodyKit, wing, sportLine); + warmlyShip = new EntityMotorShip(speed, weight, bodyColor, dopColor, tubes , cistern); } public override void DrawTransport(Graphics g) { - if (warmlyShip is not EntityMotorShip sportCar) + if (warmlyShip is not EntityMotorShip motorShip) { return; } + if (motorShip.Tubes) + { + + } + + if (motorShip.Cistern) + { + + } } } } \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs similarity index 94% rename from WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs rename to WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs index 097b8b1..b3e03f1 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace WarmlyShip { - internal class DrawingWarmlyShip + internal class DrawningWarmlyShip { public EntityWarmlyShip warmlyShip { protected set; get; } //Класс-сущность protected float _startPosX; //Координаты отрисовки по оси x @@ -17,12 +17,12 @@ namespace WarmlyShip private readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля //Конструктор класса - public DrawingWarmlyShip(int speed, float weight, Color bodyColor) + public DrawningWarmlyShip(int speed, float weight, Color bodyColor) { warmlyShip = new EntityWarmlyShip(speed, weight, bodyColor); } - protected DrawingWarmlyShip(int speed, float weight, Color bodyColor, int warmlyWidth, int warmlyHeight) : this(speed, weight, bodyColor) + protected DrawningWarmlyShip(int speed, float weight, Color bodyColor, int warmlyWidth, int warmlyHeight) : this(speed, weight, bodyColor) { _warmlyShipWidth = warmlyWidth; _warmlyShipHeight = warmlyHeight; diff --git a/WarmlyShip/WarmlyShip/EntityMotorShip.cs b/WarmlyShip/WarmlyShip/EntityMotorShip.cs index a2d5d38..55ddeb5 100644 --- a/WarmlyShip/WarmlyShip/EntityMotorShip.cs +++ b/WarmlyShip/WarmlyShip/EntityMotorShip.cs @@ -9,16 +9,14 @@ namespace WarmlyShip internal class EntityMotorShip : EntityWarmlyShip { public Color DopColor { get; private set; } - public bool BodyKit { get; private set; } - public bool Wing { get; private set; } - public bool SportLine { get; private set; } + public bool Tubes { get; private set; } + public bool Cistern { get; private set; } - public EntityMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) : base(speed, weight, bodyColor) + public EntityMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor) { DopColor = dopColor; - BodyKit = bodyKit; - Wing = wing; - SportLine = sportLine; + Tubes = tubes; + Cistern = cistern; } } diff --git a/WarmlyShip/WarmlyShip/FormClass.Designer.cs b/WarmlyShip/WarmlyShip/FormClass.Designer.cs index 26dca06..f23d522 100644 --- a/WarmlyShip/WarmlyShip/FormClass.Designer.cs +++ b/WarmlyShip/WarmlyShip/FormClass.Designer.cs @@ -38,6 +38,7 @@ this.buttonLeft = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.ButtonCreate = new System.Windows.Forms.Button(); + this.buttonCreateModif = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.statusStrip.SuspendLayout(); this.SuspendLayout(); @@ -142,11 +143,23 @@ this.ButtonCreate.UseVisualStyleBackColor = true; this.ButtonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); // + // buttonCreateModif + // + this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreateModif.Location = new System.Drawing.Point(93, 402); + this.buttonCreateModif.Name = "buttonCreateModif"; + this.buttonCreateModif.Size = new System.Drawing.Size(100, 23); + this.buttonCreateModif.TabIndex = 8; + this.buttonCreateModif.Text = "Модификация "; + this.buttonCreateModif.UseVisualStyleBackColor = true; + this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); + // // FormClass // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonCreateModif); this.Controls.Add(this.ButtonCreate); this.Controls.Add(this.buttonDown); this.Controls.Add(this.buttonLeft); @@ -176,5 +189,6 @@ private Button buttonLeft; private Button buttonDown; private Button ButtonCreate; + private Button buttonCreateModif; } } \ No newline at end of file diff --git a/WarmlyShip/WarmlyShip/FormClass.cs b/WarmlyShip/WarmlyShip/FormClass.cs index 02796ed..c28b163 100644 --- a/WarmlyShip/WarmlyShip/FormClass.cs +++ b/WarmlyShip/WarmlyShip/FormClass.cs @@ -2,7 +2,7 @@ namespace WarmlyShip { public partial class FormClass : Form { - private DrawingWarmlyShip _warmlyShip; + private DrawningWarmlyShip _warmlyShip; public FormClass() { @@ -17,14 +17,20 @@ namespace WarmlyShip pictureBox.Image = bmp; } - private void ButtonCreate_Click(object sender, EventArgs e) - { + private void SetData() + { Random random = new Random(); - _warmlyShip = new DrawingWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); _warmlyShip.SetPosition(random.Next(pictureBox.Width - 150, pictureBox.Width - 125), random.Next(pictureBox.Height - 150, pictureBox.Height - 50), pictureBox.Width, pictureBox.Height); toolStripStatusSpeed.Text = $": {_warmlyShip.warmlyShip?.Speed}"; toolStripStatusWeight.Text = $": {_warmlyShip.warmlyShip?.Weight}"; toolStripStatusLabelBodyColor.Text = $": {_warmlyShip.warmlyShip?.BodyColor}"; + } + + private void ButtonCreate_Click(object sender, EventArgs e) + { + Random random = new Random(); + _warmlyShip = new DrawningWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + SetData(); Draw(); } @@ -54,5 +60,16 @@ namespace WarmlyShip _warmlyShip?.ChangeBorders(pictureBox.Width, pictureBox.Height); Draw(); } + + private void ButtonCreateModif_Click(object sender, EventArgs e) + { + Random random = new Random(); + _warmlyShip = new DrawningMotorShip(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, 1)), Convert.ToBoolean(random.Next(0, 1))); + SetData(); + Draw(); + } } } \ No newline at end of file