решение1

This commit is contained in:
elbek 2025-02-16 20:31:25 +04:00
parent 6fdfa5e294
commit b216138896
2 changed files with 141 additions and 38 deletions

View File

@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace ProjectAircraft12;
@ -40,7 +43,7 @@ public class DrawningAircraft
/// <summary>
/// Ширина прорисовки самолета
/// </summary>
private readonly int _drawingAircraftWidth = 80;
private readonly int _drawingAircraftWidth = 100;
/// <summary>
/// Высота прорисовки самолета
@ -114,7 +117,6 @@ public class DrawningAircraft
switch (direction)
{
// влево
case DirectionType.Left:
if (_startPosX.Value - EntityAircraft.Step > 0)
{
@ -122,7 +124,6 @@ public class DrawningAircraft
}
return true;
// вверх
case DirectionType.Up:
if (_startPosY.Value - EntityAircraft.Step > 0)
{
@ -130,24 +131,92 @@ public class DrawningAircraft
}
return true;
// вправо
case DirectionType.Right:
if (_startPosX.Value + EntityAircraft.Step < _pictureWidth)
if (_startPosX.Value + EntityAircraft.Step < _pictureWidth-60) //-60
{
_startPosX += (int)EntityAircraft.Step;
_startPosX += (int)EntityAircraft.Step-20;
}
return true;
// вниз
case DirectionType.Down:
if (_startPosY.Value + EntityAircraft.Step < _pictureHeight)
{
_startPosY += (int)EntityAircraft.Step;
}
return true;
}
default:
return false;
// Если вдруг передали неизвестное направление — возврат по умолчанию
return false;
}
//public bool MoveTransport(DirectionType direction)
//{
// if (EntityAircraft == null || !_startPosX.HasValue || !_startPosY.HasValue)
// {
// return false;
// }
// switch (direction)
// {
// // влево
// case DirectionType.Left:
// if (_startPosX.Value - EntityAircraft.Step > 0)
// {
// _startPosX -= (int)EntityAircraft.Step;
// }
// return true;
// // вверх
// case DirectionType.Up:
// if (_startPosY.Value - EntityAircraft.Step > 0)
// {
// _startPosY -= (int)EntityAircraft.Step;
// }
// return true;
// // вправо
// case DirectionType.Right:
// if (_startPosX.Value + EntityAircraft.Step < _pictureWidth)
// {
// _startPosX += (int)EntityAircraft.Step;
// }
// return true;
// // вниз
// case DirectionType.Down:
// if (_startPosY.Value + EntityAircraft.Step < _pictureHeight)
// {
// _startPosY += (int)EntityAircraft.Step;
// }
// return true;
// default:
// return false;
// }
//}
private GraphicsPath CreateRoundedRectangle(Rectangle rect, int radius)
{
GraphicsPath path = new GraphicsPath();
int d = radius * 2;
// Добавляем скруглённые углы
path.AddArc(rect.X, rect.Y, d, d, 180, 90); // Верхний левый
path.AddArc(rect.Right - d, rect.Y, d, d, 270, 90); // Верхний правый
path.AddArc(rect.Right - d, rect.Bottom - d, d, d, 0, 90); // Нижний правый
path.AddArc(rect.X, rect.Bottom - d, d, d, 90, 90); // Нижний левый
path.CloseFigure();
return path;
}
private void DrawRoundedRectangle(Graphics g, Brush brush, Pen pen, Rectangle rect, int radius)
{
using (GraphicsPath path = CreateRoundedRectangle(rect, radius))
{
g.FillPath(brush, path); // Закрашенный фон
g.DrawPath(pen, path); // Обводка
}
}
@ -166,36 +235,70 @@ public class DrawningAircraft
g.FillRectangle(bodyBrush, _startPosX.Value, _startPosY.Value + 10, _drawingAircraftWidth, 20);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 10, _drawingAircraftWidth, 20);
// Кабина
g.FillEllipse(bodyBrush, _startPosX.
Value + _drawingAircraftWidth - 15, _startPosY.Value + 5, 20, 30);
g.DrawEllipse(pen, _startPosX.Value + _drawingAircraftWidth - 15, _startPosY.Value + 5, 20, 30);
// orqa qanot
Point[] trianglePoints = {
new Point(_startPosX.Value, _startPosY.Value - 20), // Вершина
new Point(_startPosX.Value, _startPosY.Value+10), // Левый угол
new Point(_startPosX.Value + 30, _startPosY.Value+10) // Правый угол
};
// Крылья
g.FillRectangle(bodyBrush, _startPosX.Value + 30, _startPosY.Value - 5, 60, 10);
g.FillRectangle(bodyBrush, _startPosX.Value + 30, _startPosY.Value + 35, 60, 10);
g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value - 5, 60, 10);
g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 35, 60, 10);
g.FillPolygon(bodyBrush, trianglePoints); // Закрашенный треугольник
g.DrawPolygon(pen, trianglePoints); // Контур треугольника
// Хвостовое оперение
g.FillRectangle(bodyBrush, _startPosX.Value + 5, _startPosY.Value - 10, 20, 15);
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value - 10, 20, 15);
// Топливные баки (если есть)
if (EntityAircraft.ExtraFuelTanks)
{
g.FillEllipse(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 5, 15, 15);
g.FillEllipse(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 30, 15, 15);
g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 5, 15, 15);
g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 30, 15, 15);
}
// бак
Rectangle rect = new Rectangle(_startPosX.Value - 5, _startPosY.Value + 5, 30, 10); // Прямоугольник от заданной точки
int radius = 4; // Радиус скругления
DrawRoundedRectangle(g, bodyBrush, Pens.Black, rect, radius);
// oldi uchburchak
Point[] triangle_right = {
new Point(_startPosX.Value+120, _startPosY.Value + 20), // Вершина
new Point(_startPosX.Value+100, _startPosY.Value+10), // Левый угол
new Point(_startPosX.Value+100, _startPosY.Value+30) // Правый угол
};
g.FillPolygon(bodyBrush, triangle_right); // Закрашенный треугольник
g.DrawPolygon(pen, triangle_right); // Контур треугольника
Pen line_triangle_right = new Pen(Color.Black, 1); // Чёрная линия толщиной 2 пикселя
g.DrawLine(line_triangle_right, _startPosX.Value+100, _startPosY.Value+20, _startPosX.Value + 120, _startPosY.Value + 20);
//иллюминатор
Pen okno = new Pen(Color.Black, 3); // Чёрная линия толщиной 3 пикселя
g.DrawLine(okno, _startPosX.Value + 40, _startPosY.Value + 20, _startPosX.Value + 80, _startPosY.Value + 20);
// шасси
Pen shassi1 = new Pen(Color.Black, 2); // Чёрная линия толщиной 2 пикселя
g.DrawLine(shassi1, _startPosX.Value + 40, _startPosY.Value + 30, _startPosX.Value + 40, _startPosY.Value + 36);
Pen koliso1 = new Pen(Color.Black, 2); // Чёрная обводка толщиной 2 пикселя
g.DrawRectangle(koliso1, _startPosX.Value+35, _startPosY.Value+35, 4, 4);
Brush brush = new SolidBrush(Color.Black);
g.FillRectangle(brush, _startPosX.Value+35, _startPosY.Value+35, 4, 4);
Pen koliso2 = new Pen(Color.Black, 2); // Чёрная обводка толщиной 2 пикселя
g.DrawRectangle(koliso2, _startPosX.Value + 42, _startPosY.Value + 35, 4, 4);
g.FillRectangle(brush, _startPosX.Value + 42, _startPosY.Value + 35, 4, 4);
Pen shassi2 = new Pen(Color.Black, 2); // Чёрная линия толщиной 2 пикселя
g.DrawLine(shassi1, _startPosX.Value + 90, _startPosY.Value + 30, _startPosX.Value + 90, _startPosY.Value + 36);
Pen koliso3 = new Pen(Color.Black, 2); // Чёрная обводка толщиной 2 пикселя
g.DrawRectangle(koliso3, _startPosX.Value + 88, _startPosY.Value + 35, 4, 4);
g.FillRectangle(brush, _startPosX.Value + 88, _startPosY.Value + 35, 4, 4);
// radar
Rectangle radar = new Rectangle(_startPosX.Value + 50, _startPosY.Value-5, 20, 10); // Прямоугольник от заданной точки
int radius_radara = 6; // Радиус скругления
DrawRoundedRectangle(g, bodyBrush, Pens.Black, radar, radius_radara);
Pen os_radar = new Pen(Color.Black, 2); // Чёрная линия толщиной 1 пикселя
g.DrawLine(os_radar, _startPosX.Value + 60, _startPosY.Value + 10, _startPosX.Value + 60, _startPosY.Value+5);
// Радар (если есть)
if (EntityAircraft.Radar)
{
g.FillEllipse(additionalBrush, _startPosX.Value + _drawingAircraftWidth - 10, _startPosY.Value + 15, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + _drawingAircraftWidth - 10, _startPosY.Value + 15, 10, 10);
}
}
}

View File

@ -37,9 +37,9 @@ public class EntityAircraft
/// </summary>
public double Step => Speed * 100 / Weight;
public int WindowCount { get; internal set; }
public bool BodyKit { get; internal set; }
public bool Wing { get; internal set; }
//public int WindowCount { get; internal set; }
//public bool BodyKit { get; internal set; }
//public bool Wing { get; internal set; }
/// <summary>
/// Инициализация полей объекта-класса самолета