Лабораторная работа №1

This commit is contained in:
Иван Захаров 2024-02-12 12:14:04 +04:00
parent 0a8089d384
commit 310e1cf561
2 changed files with 39 additions and 17 deletions

View File

@ -70,10 +70,13 @@ public class DrawningAirFighter
{
// проверка, что объект "влезает" в размеры поля
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
if (_drawningPlaneWidth > width || _drawningPlaneHeight > height) return false;
_pictureWidth = width;
_pictureHeight = height;
return true;
if (_drawningPlaneWidth <= width && _drawningPlaneHeight <= height)
{
_pictureWidth = width;
_pictureHeight = height;
return true;
}
return false;
}
/// <summary>
@ -171,20 +174,27 @@ public class DrawningAirFighter
Pen pen = new(Color.Black);
Brush brBlack = new SolidBrush(Color.Black);
// создание точек треугольника
Point point1 = new Point(_startPosX.Value, _startPosY.Value + 75);
Point point2 = new Point(_startPosX.Value + 20, _startPosY.Value + 70);
Point point3 = new Point(_startPosX.Value + 20, _startPosY.Value + 80);
Point[] triangle = {point1, point2, point3};
g.FillPolygon(brBlack, triangle);
Pen br = new(EntityAirFighter.BodyColor);
Brush hd = new SolidBrush(EntityAirFighter.BodyColor);
// отрисовка корпуса истребителя
g.FillRectangle(hd, _startPosX.Value + 20, _startPosY.Value + 70, 130, 10);
// отрисовка передних крыльев
g.DrawLine(br, _startPosX.Value + 40, _startPosY.Value + 70, _startPosX.Value + 40, _startPosY.Value);
g.DrawLine(br, _startPosX.Value + 40, _startPosY.Value, _startPosX.Value + 50, _startPosY.Value);
g.DrawLine(br, _startPosX.Value + 50, _startPosY.Value, _startPosX.Value + 55, _startPosY.Value + 70);
g.DrawLine(br, _startPosX.Value + 40, _startPosY.Value + 80, _startPosX.Value + 40, _startPosY.Value + 150);
g.DrawLine(br, _startPosX.Value + 40, _startPosY.Value + 150, _startPosX.Value + 50, _startPosY.Value + 150);
g.DrawLine(br, _startPosX.Value + 50, _startPosY.Value + 150, _startPosX.Value + 55, _startPosY.Value + 80);
// отрисовка задних крыльев
g.DrawLine(br, _startPosX.Value + 150, _startPosY.Value + 70, _startPosX.Value + 150, _startPosY.Value + 55);
g.DrawLine(br, _startPosX.Value + 150, _startPosY.Value + 55, _startPosX.Value + 135, _startPosY.Value + 65);
g.DrawLine(br, _startPosX.Value + 135, _startPosY.Value + 65, _startPosX.Value + 135, _startPosY.Value + 70);
@ -195,11 +205,14 @@ public class DrawningAirFighter
Pen additionalPen = new(EntityAirFighter.AdditionalColor);
Brush additionalBrush = new SolidBrush(EntityAirFighter.AdditionalColor);
// отрисовка двигателей
if (EntityAirFighter.Engines)
{
g.FillEllipse(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 30, 10, 10);
g.FillEllipse(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 120, 10, 10);
}
// отрисовка дополнительных крыльев
if (EntityAirFighter.ExtraWings)
{
g.DrawLine(additionalPen, _startPosX.Value + 65, _startPosY.Value + 70, _startPosX.Value + 90, _startPosY.Value + 20);
@ -209,6 +222,8 @@ public class DrawningAirFighter
g.DrawLine(additionalPen, _startPosX.Value + 90, _startPosY.Value + 130, _startPosX.Value + 110, _startPosY.Value + 130);
g.DrawLine(additionalPen, _startPosX.Value + 110, _startPosY.Value + 130, _startPosX.Value + 85, _startPosY.Value + 80);
}
// отрисовка ракет
if (EntityAirFighter.Rockets)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 32, _startPosY.Value + 4, 8, 6);

View File

@ -41,17 +41,19 @@
//
pictureBoxAirFighter.Dock = DockStyle.Fill;
pictureBoxAirFighter.Location = new Point(0, 0);
pictureBoxAirFighter.Margin = new Padding(3, 4, 3, 4);
pictureBoxAirFighter.Name = "pictureBoxAirFighter";
pictureBoxAirFighter.Size = new Size(800, 450);
pictureBoxAirFighter.Size = new Size(882, 673);
pictureBoxAirFighter.TabIndex = 0;
pictureBoxAirFighter.TabStop = false;
//
// buttonCreateAirFighter
//
buttonCreateAirFighter.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateAirFighter.Location = new Point(12, 415);
buttonCreateAirFighter.Location = new Point(14, 626);
buttonCreateAirFighter.Margin = new Padding(3, 4, 3, 4);
buttonCreateAirFighter.Name = "buttonCreateAirFighter";
buttonCreateAirFighter.Size = new Size(75, 23);
buttonCreateAirFighter.Size = new Size(86, 31);
buttonCreateAirFighter.TabIndex = 1;
buttonCreateAirFighter.Text = "Создать";
buttonCreateAirFighter.UseVisualStyleBackColor = true;
@ -62,9 +64,10 @@
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
buttonLeft.Location = new Point(671, 403);
buttonLeft.Location = new Point(735, 610);
buttonLeft.Margin = new Padding(3, 4, 3, 4);
buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(35, 35);
buttonLeft.Size = new Size(40, 47);
buttonLeft.TabIndex = 2;
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += ButtonMove_Click;
@ -74,9 +77,10 @@
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
buttonUp.Location = new Point(712, 362);
buttonUp.Location = new Point(782, 556);
buttonUp.Margin = new Padding(3, 4, 3, 4);
buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(35, 35);
buttonUp.Size = new Size(40, 47);
buttonUp.TabIndex = 3;
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += ButtonMove_Click;
@ -86,9 +90,10 @@
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
buttonRight.Location = new Point(753, 403);
buttonRight.Location = new Point(829, 610);
buttonRight.Margin = new Padding(3, 4, 3, 4);
buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(35, 35);
buttonRight.Size = new Size(40, 47);
buttonRight.TabIndex = 4;
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click;
@ -98,24 +103,26 @@
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
buttonDown.Location = new Point(712, 403);
buttonDown.Location = new Point(782, 610);
buttonDown.Margin = new Padding(3, 4, 3, 4);
buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(35, 35);
buttonDown.Size = new Size(40, 47);
buttonDown.TabIndex = 5;
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += ButtonMove_Click;
//
// FormAirFighter
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
ClientSize = new Size(882, 673);
Controls.Add(buttonDown);
Controls.Add(buttonRight);
Controls.Add(buttonUp);
Controls.Add(buttonLeft);
Controls.Add(buttonCreateAirFighter);
Controls.Add(pictureBoxAirFighter);
Margin = new Padding(3, 4, 3, 4);
Name = "FormAirFighter";
Text = "Истребитель";
((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).EndInit();