This commit is contained in:
NikGapon 2022-10-26 21:45:24 +04:00
parent 67dd4fbfa8
commit e42016dec6
4 changed files with 35 additions and 12 deletions

View File

@ -8,6 +8,7 @@ namespace Airbus
{ {
internal enum CountPorthole internal enum CountPorthole
{ {
None = 0,
Ten = 10, Ten = 10,
Twenty = 20, Twenty = 20,
Thirty = 30, Thirty = 30,

View File

@ -10,7 +10,7 @@ namespace Airbus
{ {
/// Класс-сущность /// Класс-сущность
public EntityAirbus airbus { private set; get; } public EntityAirbus airbus { private set; get; }
public DrawningPorthole porthole { private set; get; }
/// Левая координата отрисовки автомобиля /// Левая координата отрисовки автомобиля
private float _startPosX; private float _startPosX;
/// Верхняя кооридната отрисовки автомобиля /// Верхняя кооридната отрисовки автомобиля
@ -25,6 +25,7 @@ namespace Airbus
public void Init(int speed, float weight, Color bodyColor) public void Init(int speed, float weight, Color bodyColor)
{ {
airbus = new EntityAirbus(); airbus = new EntityAirbus();
porthole = new DrawningPorthole();
airbus.Init(speed, weight, bodyColor); airbus.Init(speed, weight, bodyColor);
} }
@ -39,7 +40,10 @@ namespace Airbus
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
} }
public void Upd_count_Porthole(CountPorthole count)
{
porthole.CountPorthole = (int)count;
}
public void MoveTransport(Direction direction) public void MoveTransport(Direction direction)
{ {
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) return; if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) return;
@ -63,6 +67,7 @@ namespace Airbus
public void DrawTransport(Graphics g) public void DrawTransport(Graphics g)
{ {
if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue) if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
{ {
return; return;
@ -86,15 +91,11 @@ namespace Airbus
new Point((int)(_startPosX), (int)(_startPosY)), new Point((int)(_startPosX), (int)(_startPosY)),
}); });
g.DrawEllipse(new(Color.Blue, 2), _startPosX, _startPosY + 15, 25, 5); g.DrawEllipse(new(Color.Blue, 2), _startPosX, _startPosY + 15, 25, 5);
/*g.DrawEllipse(new(Color.Red, 2), _startPosX + _airbusWidth - 40, _startPosY + 30, 20, 20);
g.DrawEllipse(new(Color.Red, 2), _startPosX + _airbusWidth - 65, _startPosY + 30, 20, 20);
g.DrawEllipse(new(Color.Red, 2), _startPosX + _airbusWidth - 90, _startPosY + 30, 20, 20);*/
g.DrawEllipse(new(Color.Black, 2), _startPosX + _airbusWidth - 30, _startPosY + _airbusHeight + 25, 4, 4); g.DrawEllipse(new(Color.Black, 2), _startPosX + _airbusWidth - 30, _startPosY + _airbusHeight + 25, 4, 4);
g.DrawEllipse(new(Color.Black, 2), _startPosX + _airbusWidth - 35, _startPosY + _airbusHeight + 25, 4, 4); g.DrawEllipse(new(Color.Black, 2), _startPosX + _airbusWidth - 35, _startPosY + _airbusHeight + 25, 4, 4);
g.DrawEllipse(new(Color.Black, 2), _startPosX , _startPosY + _airbusHeight + 25, 4, 4); g.DrawEllipse(new(Color.Black, 2), _startPosX , _startPosY + _airbusHeight + 25, 4, 4);
porthole.DrawPorthole(g, Color.Red, _startPosX, _startPosY);
} }
public void ChangeBorders(int width, int height) public void ChangeBorders(int width, int height)
@ -115,6 +116,7 @@ namespace Airbus
{ {
_startPosY = _pictureHeight.Value - _airbusHeight; _startPosY = _pictureHeight.Value - _airbusHeight;
} }
} }
} }

View File

@ -20,10 +20,12 @@ namespace Airbus
} }
public void DrawPorthole(Graphics g, Color color, float posX, float posY) public void DrawPorthole(Graphics g, Color color, float posX, float posY)
{ {
for (int i = 0; i < CountPorthole; i++)
for (int i = 0; i < (int)CountPorthole; i++)
{ {
g.DrawEllipse(new(color, 2), posX + 150 - i * 7, posY + 30, 5, 5); g.DrawEllipse(new(color, 2), posX + 150 - i * 7, posY + 30, 5, 5);
} }
} }
} }
} }

View File

@ -17,6 +17,7 @@ namespace Airbus
public FormAirbus() public FormAirbus()
{ {
InitializeComponent(); InitializeComponent();
} }
private void Draw() private void Draw()
@ -66,10 +67,27 @@ namespace Airbus
airbus?.ChangeBorders(pictureBox.Width, pictureBox.Height); airbus?.ChangeBorders(pictureBox.Width, pictureBox.Height);
Draw(); Draw();
} }
CountPorthole count_porthole = CountPorthole.None;
private void comboBoxPortholeSer_SelectedIndexChanged(object sender, EventArgs e) private void comboBoxPortholeSer_SelectedIndexChanged(object sender, EventArgs e)
{ {
switch (comboBoxPortholeSer.Text)
{
case "10":
count_porthole = CountPorthole.Ten;
toolStripStatusLabelSpeed.Text = Convert.ToString((int)count_porthole);
break;
case "20":
count_porthole = CountPorthole.Twenty;
break;
case "30":
count_porthole = CountPorthole.Thirty;
break;
}
airbus.Upd_count_Porthole(count_porthole);
Draw();
} }
} }
} }