Небольшое изменение отрисовки

This commit is contained in:
Denis 2022-10-06 01:03:40 +04:00
parent fccecf9ba0
commit 09803f8fff
2 changed files with 29 additions and 34 deletions

View File

@ -13,8 +13,8 @@ namespace AirplaneWithRadar
private float _startPosY;
private int? _pictureWidth = null;
private int? _pictureHeight = null;
private readonly int _airplaneWithRadarWidth = 60;
private readonly int _airplaneWithRadarHeight = 50;
private readonly int _airplaneWithRadarWidth = 50;
private readonly int _airplaneWithRadarHeight = 27;
public void Init(int speed, float weight, Color bodyColor)
{
AirplaneWithRadar = new EntityAirplaneWithRadar();
@ -61,7 +61,7 @@ namespace AirplaneWithRadar
break;
//вниз
case Direction.Down:
if (_startPosY + _airplaneWithRadarHeight + AirplaneWithRadar.Step < _pictureHeight)
if (_startPosY + _airplaneWithRadarHeight + AirplaneWithRadar.Step + 30 < _pictureHeight)
{
_startPosY += AirplaneWithRadar.Step;
}
@ -77,23 +77,28 @@ namespace AirplaneWithRadar
Pen pen = new(Color.Black);
// Корпус
g.DrawRectangle(pen, _startPosX, _startPosY + 10, 40, 10);
// Окно
Brush darkBrush = new SolidBrush(AirplaneWithRadar?.BodyColor ?? Color.Black);
g.FillRectangle(darkBrush, _startPosX + 12, _startPosY + 13, 20, 2);
// Хвост
darkBrush = new SolidBrush(Color.Black);
g.DrawLine(pen, _startPosX, _startPosY + 12, _startPosX, _startPosY);
g.DrawLine(pen, _startPosX, _startPosY, _startPosX + 10, _startPosY + 10);
g.FillEllipse(darkBrush, _startPosX - 3, _startPosY + 9, 10, 5);
// Заднее шасси
g.FillRectangle(darkBrush, _startPosX + 10, _startPosY + 21, 2, 2);
g.FillRectangle(darkBrush, _startPosX + 13, _startPosY + 23, 4, 4);
g.FillRectangle(darkBrush, _startPosX + 8, _startPosY + 23, 2, 4);
// Переднее шасси
g.FillRectangle(darkBrush, _startPosX + 35, _startPosY + 21, 2, 2);
g.FillRectangle(darkBrush, _startPosX + 35, _startPosY + 23, 4, 4);
// Нос
g.DrawLine(pen, _startPosX + 40, _startPosY + 10, _startPosX + 47, _startPosY + 15);
g.DrawLine(pen, _startPosX + 40, _startPosY + 20, _startPosX + 50, _startPosY + 15);
}

View File

@ -44,14 +44,11 @@
//
// pictureBoxAirplaneWithRadar
//
this.pictureBoxAirplaneWithRadar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBoxAirplaneWithRadar.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxAirplaneWithRadar.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pictureBoxAirplaneWithRadar.Location = new System.Drawing.Point(0, 2);
this.pictureBoxAirplaneWithRadar.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBoxAirplaneWithRadar.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxAirplaneWithRadar.Location = new System.Drawing.Point(0, 0);
this.pictureBoxAirplaneWithRadar.Name = "pictureBoxAirplaneWithRadar";
this.pictureBoxAirplaneWithRadar.Size = new System.Drawing.Size(700, 312);
this.pictureBoxAirplaneWithRadar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxAirplaneWithRadar.Size = new System.Drawing.Size(800, 451);
this.pictureBoxAirplaneWithRadar.TabIndex = 0;
this.pictureBoxAirplaneWithRadar.TabStop = false;
this.pictureBoxAirplaneWithRadar.Click += new System.EventHandler(this.ButtonMove_Click);
@ -63,38 +60,36 @@
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelBodyColor});
this.statusStrip1.Location = new System.Drawing.Point(0, 316);
this.statusStrip1.Location = new System.Drawing.Point(0, 425);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 12, 0);
this.statusStrip1.Size = new System.Drawing.Size(700, 22);
this.statusStrip1.Size = new System.Drawing.Size(800, 26);
this.statusStrip1.TabIndex = 1;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabelSpeed
//
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(76, 20);
this.toolStripStatusLabelSpeed.Text = "Скорость:";
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17);
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(36, 20);
this.toolStripStatusLabelWeight.Text = "Вес:";
//
// toolStripStatusLabelBodyColor
//
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(45, 20);
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
//
// 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(10, 294);
this.buttonCreate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCreate.Location = new System.Drawing.Point(11, 392);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(82, 22);
this.buttonCreate.Size = new System.Drawing.Size(94, 29);
this.buttonCreate.TabIndex = 2;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
@ -105,10 +100,9 @@
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.arrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(592, 293);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonLeft.Location = new System.Drawing.Point(677, 391);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(26, 22);
this.buttonLeft.Size = new System.Drawing.Size(30, 29);
this.buttonLeft.TabIndex = 3;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
@ -118,10 +112,9 @@
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.arrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(623, 293);
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDown.Location = new System.Drawing.Point(712, 391);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(26, 22);
this.buttonDown.Size = new System.Drawing.Size(30, 29);
this.buttonDown.TabIndex = 4;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
@ -131,10 +124,9 @@
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.arrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(654, 294);
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRight.Location = new System.Drawing.Point(747, 392);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(26, 22);
this.buttonRight.Size = new System.Drawing.Size(30, 29);
this.buttonRight.TabIndex = 5;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
@ -144,19 +136,18 @@
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.arrowUp;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(623, 266);
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUp.Location = new System.Drawing.Point(712, 355);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(26, 22);
this.buttonUp.Size = new System.Drawing.Size(30, 29);
this.buttonUp.TabIndex = 6;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// FormAirplaneWithRadar
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(700, 338);
this.ClientSize = new System.Drawing.Size(800, 451);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
@ -164,7 +155,6 @@
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.pictureBoxAirplaneWithRadar);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormAirplaneWithRadar";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplaneWithRadar)).EndInit();