From 5e7e145d60a7c6ecb178b6ca08e5a9ddb3891cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Tue, 20 Sep 2022 21:09:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GasolineTanker/DrawingGasolineTanker.cs | 5 +-- .../GasolineTanker/EnityGasolineTanker.cs | 2 +- .../FormGasolineTanker.Designer.cs | 45 ++++++++----------- .../GasolineTanker/FormGasolineTanker.cs | 3 +- 4 files changed, 23 insertions(+), 32 deletions(-) diff --git a/GasolineTanker/GasolineTanker/DrawingGasolineTanker.cs b/GasolineTanker/GasolineTanker/DrawingGasolineTanker.cs index 20b1dea..a80a5f2 100644 --- a/GasolineTanker/GasolineTanker/DrawingGasolineTanker.cs +++ b/GasolineTanker/GasolineTanker/DrawingGasolineTanker.cs @@ -16,10 +16,9 @@ namespace GasolineTanker private readonly int _gasolineTankerWidth = 160; private readonly int _gasolineTankerHeight = 55; - public void Init(int speed, float weight, Color bodyColor) + public DrawingGasolineTanker(int speed, float weight, Color bodyColor) { - GasolineTanker = new EnityGasolineTanker(); - GasolineTanker.Init(speed, weight, bodyColor); + GasolineTanker = new EnityGasolineTanker(speed, weight, bodyColor); } public void SetPosition(int x, int y, int width, int height) diff --git a/GasolineTanker/GasolineTanker/EnityGasolineTanker.cs b/GasolineTanker/GasolineTanker/EnityGasolineTanker.cs index e3f5b3b..dd369c1 100644 --- a/GasolineTanker/GasolineTanker/EnityGasolineTanker.cs +++ b/GasolineTanker/GasolineTanker/EnityGasolineTanker.cs @@ -12,7 +12,7 @@ namespace GasolineTanker 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) + public EnityGasolineTanker(int speed, float weight, Color bodyColor) { Random rnd = new Random(); Speed = speed <= 0 ? rnd.Next(50, 100) : speed; diff --git a/GasolineTanker/GasolineTanker/FormGasolineTanker.Designer.cs b/GasolineTanker/GasolineTanker/FormGasolineTanker.Designer.cs index 462148b..101c56a 100644 --- a/GasolineTanker/GasolineTanker/FormGasolineTanker.Designer.cs +++ b/GasolineTanker/GasolineTanker/FormGasolineTanker.Designer.cs @@ -46,9 +46,8 @@ // this.pictureBoxGasolineTanker.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBoxGasolineTanker.Location = new System.Drawing.Point(0, 0); - this.pictureBoxGasolineTanker.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.pictureBoxGasolineTanker.Name = "pictureBoxGasolineTanker"; - this.pictureBoxGasolineTanker.Size = new System.Drawing.Size(922, 574); + this.pictureBoxGasolineTanker.Size = new System.Drawing.Size(807, 428); this.pictureBoxGasolineTanker.TabIndex = 0; this.pictureBoxGasolineTanker.TabStop = false; // @@ -59,38 +58,36 @@ this.toolStripStatusSpeed, this.toolStripStatusWeight, this.toolStripStatusBodyColor}); - this.statusStrip1.Location = new System.Drawing.Point(0, 574); + this.statusStrip1.Location = new System.Drawing.Point(0, 428); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0); - this.statusStrip1.Size = new System.Drawing.Size(922, 26); + this.statusStrip1.Size = new System.Drawing.Size(807, 22); this.statusStrip1.TabIndex = 1; this.statusStrip1.Text = "statusStrip1"; // // toolStripStatusSpeed // this.toolStripStatusSpeed.Name = "toolStripStatusSpeed"; - this.toolStripStatusSpeed.Size = new System.Drawing.Size(51, 20); + this.toolStripStatusSpeed.Size = new System.Drawing.Size(39, 17); this.toolStripStatusSpeed.Text = "Speed"; // // toolStripStatusWeight // this.toolStripStatusWeight.Name = "toolStripStatusWeight"; - this.toolStripStatusWeight.Size = new System.Drawing.Size(56, 20); + this.toolStripStatusWeight.Size = new System.Drawing.Size(45, 17); this.toolStripStatusWeight.Text = "Weight"; // // toolStripStatusBodyColor // this.toolStripStatusBodyColor.Name = "toolStripStatusBodyColor"; - this.toolStripStatusBodyColor.Size = new System.Drawing.Size(45, 20); + this.toolStripStatusBodyColor.Size = new System.Drawing.Size(36, 17); this.toolStripStatusBodyColor.Text = "Color"; // // 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(14, 524); - this.buttonCreate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.buttonCreate.Location = new System.Drawing.Point(12, 393); this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(86, 31); + this.buttonCreate.Size = new System.Drawing.Size(75, 23); this.buttonCreate.TabIndex = 2; this.buttonCreate.Text = "Create"; this.buttonCreate.UseVisualStyleBackColor = true; @@ -101,10 +98,9 @@ this.keyDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyDown.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyDown; this.keyDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.keyDown.Location = new System.Drawing.Point(827, 515); - this.keyDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.keyDown.Location = new System.Drawing.Point(724, 386); this.keyDown.Name = "keyDown"; - this.keyDown.Size = new System.Drawing.Size(34, 40); + this.keyDown.Size = new System.Drawing.Size(30, 30); this.keyDown.TabIndex = 3; this.keyDown.UseVisualStyleBackColor = true; this.keyDown.Click += new System.EventHandler(this.ButtonMove_Click); @@ -114,10 +110,9 @@ this.keyUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyUp.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyUp; this.keyUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.keyUp.Location = new System.Drawing.Point(827, 467); - this.keyUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.keyUp.Location = new System.Drawing.Point(724, 350); this.keyUp.Name = "keyUp"; - this.keyUp.Size = new System.Drawing.Size(34, 40); + this.keyUp.Size = new System.Drawing.Size(30, 30); this.keyUp.TabIndex = 4; this.keyUp.UseVisualStyleBackColor = true; this.keyUp.Click += new System.EventHandler(this.ButtonMove_Click); @@ -127,10 +122,9 @@ this.keyLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyLeft.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyLeft; this.keyLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.keyLeft.Location = new System.Drawing.Point(786, 515); - this.keyLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.keyLeft.Location = new System.Drawing.Point(688, 386); this.keyLeft.Name = "keyLeft"; - this.keyLeft.Size = new System.Drawing.Size(34, 40); + this.keyLeft.Size = new System.Drawing.Size(30, 30); this.keyLeft.TabIndex = 5; this.keyLeft.UseVisualStyleBackColor = true; this.keyLeft.Click += new System.EventHandler(this.ButtonMove_Click); @@ -140,19 +134,18 @@ this.keyRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyRight.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyRight; this.keyRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.keyRight.Location = new System.Drawing.Point(868, 515); - this.keyRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.keyRight.Location = new System.Drawing.Point(760, 386); this.keyRight.Name = "keyRight"; - this.keyRight.Size = new System.Drawing.Size(34, 40); + this.keyRight.Size = new System.Drawing.Size(30, 30); this.keyRight.TabIndex = 6; this.keyRight.UseVisualStyleBackColor = true; this.keyRight.Click += new System.EventHandler(this.ButtonMove_Click); // // FormGasolineTanker // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(922, 600); + this.ClientSize = new System.Drawing.Size(807, 450); this.Controls.Add(this.keyRight); this.Controls.Add(this.keyLeft); this.Controls.Add(this.keyUp); @@ -160,9 +153,9 @@ this.Controls.Add(this.buttonCreate); this.Controls.Add(this.pictureBoxGasolineTanker); this.Controls.Add(this.statusStrip1); - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "FormGasolineTanker"; this.Text = "Gasoline tanker"; + this.Load += new System.EventHandler(this.FormGasolineTanker_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxGasolineTanker)).EndInit(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); diff --git a/GasolineTanker/GasolineTanker/FormGasolineTanker.cs b/GasolineTanker/GasolineTanker/FormGasolineTanker.cs index 46d150d..da801f3 100644 --- a/GasolineTanker/GasolineTanker/FormGasolineTanker.cs +++ b/GasolineTanker/GasolineTanker/FormGasolineTanker.cs @@ -23,8 +23,7 @@ namespace GasolineTanker private void buttonCreate_Click_1(object sender, EventArgs e) { Random rnd = new(); - _gasolineTanker = new DrawingGasolineTanker(); - _gasolineTanker.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _gasolineTanker = new DrawingGasolineTanker(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); _gasolineTanker.SetPosition(rnd.Next(10, 100),rnd.Next(50, 100), pictureBoxGasolineTanker.Width, pictureBoxGasolineTanker.Height); toolStripStatusSpeed.Text = $"Speed {_gasolineTanker.GasolineTanker.Speed}"; toolStripStatusWeight.Text = $"Weight {_gasolineTanker.GasolineTanker.Weight}";