Compare commits

...

2 Commits
Lab8 ... master

2 changed files with 20 additions and 20 deletions

View File

@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.pictureBoxCar = new System.Windows.Forms.PictureBox();
this.pictureBoxAirplane = new System.Windows.Forms.PictureBox();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
@ -38,20 +38,20 @@
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
//
// pictureBoxCar
// pictureBoxAirplane
//
this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxCar.Location = new System.Drawing.Point(0, 0);
this.pictureBoxCar.Name = "pictureBoxCar";
this.pictureBoxCar.Size = new System.Drawing.Size(800, 428);
this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxCar.TabIndex = 0;
this.pictureBoxCar.TabStop = false;
this.pictureBoxCar.Resize += new System.EventHandler(this.PictureBoxCar_Resize);
this.pictureBoxAirplane.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxAirplane.Location = new System.Drawing.Point(0, 0);
this.pictureBoxAirplane.Name = "pictureBoxAirplane";
this.pictureBoxAirplane.Size = new System.Drawing.Size(800, 428);
this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxAirplane.TabIndex = 0;
this.pictureBoxAirplane.TabStop = false;
this.pictureBoxAirplane.Resize += new System.EventHandler(this.PictureBoxAirplane_Resize);
//
// statusStrip
//
@ -151,11 +151,11 @@
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxCar);
this.Controls.Add(this.pictureBoxAirplane);
this.Controls.Add(this.statusStrip);
this.Name = "FormAirBomber";
this.Text = "Самолет";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
this.ResumeLayout(false);
@ -165,7 +165,7 @@
#endregion
private PictureBox pictureBoxCar;
private PictureBox pictureBoxAirplane;
private StatusStrip statusStrip;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;

View File

@ -9,14 +9,14 @@ namespace AirBomber
InitializeComponent();
}
/// <summary>
/// Ìåòîä ïðîðèñîâêè ìàøèíû
/// Ìåòîä ïðîðèñîâêè ñàìîëåòà
/// </summary>
private void Draw()
{
Bitmap bmp = new(pictureBoxCar.Width, pictureBoxCar.Height);
Bitmap bmp = new(pictureBoxAirplane.Width, pictureBoxAirplane.Height);
Graphics gr = Graphics.FromImage(bmp);
_airplane?.DrawTransport(gr);
pictureBoxCar.Image = bmp;
pictureBoxAirplane.Image = bmp;
}
/// <summary>
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü"
@ -28,7 +28,7 @@ namespace AirBomber
Random rnd = new();
_airplane = new DrawningAirplane();
_airplane.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height);
_airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_airplane.Airplane.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_airplane.Airplane.Weight}";
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_airplane.Airplane.BodyColor.Name}";
@ -65,9 +65,9 @@ namespace AirBomber
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PictureBoxCar_Resize(object sender, EventArgs e)
private void PictureBoxAirplane_Resize(object sender, EventArgs e)
{
_airplane?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height);
_airplane?.ChangeBorders(pictureBoxAirplane.Width, pictureBoxAirplane.Height);
Draw();
}
}