Bondarenko M.S. Lab Work 2 #6

Merged
eegov merged 4 commits from LabWork_02 into LabWork_01 2022-10-21 09:12:47 +04:00
2 changed files with 36 additions and 5 deletions
Showing only changes of commit f1930b5782 - Show all commits

View File

@ -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(101, 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;
}
}

View File

@ -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.SetPosition(random.Next(0, 100), random.Next(0, 100), 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 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(10, 100), random.Next(10, 100), pictureBox.Width, pictureBox.Height);
toolStripStatusSpeed.Text = $"Ñêîðîñòü: {_warmlyShip.warmlyShip?.Speed}";
toolStripStatusWeight.Text = $"Âåñ: {_warmlyShip.warmlyShip?.Weight}";
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_warmlyShip.warmlyShip?.BodyColor}";
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, 2)), Convert.ToBoolean(random.Next(0, 2)));
SetData();
Draw();
}
}
}