Изменил(а) на 'AirBus/FormAirbus.cs'
This commit is contained in:
parent
39427a0253
commit
4b83795a95
@ -1,95 +0,0 @@
|
||||
namespace AirBus
|
||||
{
|
||||
public partial class FormAirBus : Form
|
||||
{
|
||||
|
||||
// ïîëå-îáúåêò äëÿ ïðîðèñòîâêè ñàìîë¸òà
|
||||
private DrawningAirBus? _drawningAirBus;
|
||||
public FormAirBus()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// ïðîðèñîâêà ñàìîë¸òà
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningAirBus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureAirBus.Width, pictureAirBus.Height);
|
||||
Graphics g = Graphics.FromImage(bmp);
|
||||
_drawningAirBus.DrawTransport(g);
|
||||
pictureAirBus.Image = bmp;
|
||||
}
|
||||
|
||||
private void PictureBoxAirBus_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_drawningAirBus.ChangeBorders(pictureAirBus.Width, pictureAirBus.Height);
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonDown_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonUp_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonRight_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonLeft_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// êíîïêà "Ñîçäàòü"
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
_drawningAirBus = new DrawningAirBus();
|
||||
_drawningAirBus.Init(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||
pictureAirBus.Width, pictureAirBus.Height);
|
||||
|
||||
_drawningAirBus.SetPosition(random.Next(10,100), random.Next(10,100));
|
||||
Draw();
|
||||
|
||||
}
|
||||
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningAirBus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningAirBus.MoveTransport(Direction.Up); break;
|
||||
case "buttonDown":
|
||||
_drawningAirBus.MoveTransport(Direction.Down); break;
|
||||
case "buttonLeft":
|
||||
_drawningAirBus.MoveTransport(Direction.Left); break;
|
||||
case "buttonRight":
|
||||
_drawningAirBus.MoveTransport(Direction.Right); break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
63
AirBus/FormAirbus.cs
Normal file
63
AirBus/FormAirbus.cs
Normal file
@ -0,0 +1,63 @@
|
||||
namespace Airbus
|
||||
{
|
||||
public partial class FormAirbus : Form
|
||||
{
|
||||
|
||||
// поле-объект для прористовки самолёта
|
||||
private DrawningAirbus? _drawningAirbus;
|
||||
public FormAirbus()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// прорисовка самолёта
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningAirbus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureAirbus.Width, pictureAirbus.Height);
|
||||
Graphics g = Graphics.FromImage(bmp);
|
||||
_drawningAirbus.DrawTransport(g);
|
||||
pictureAirbus.Image = bmp;
|
||||
}
|
||||
|
||||
// кнопка "Создать"
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
_drawningAirbus = new DrawningAirbus();
|
||||
_drawningAirbus.Init(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||
pictureAirbus.Width, pictureAirbus.Height);
|
||||
|
||||
_drawningAirbus.SetPosition(random.Next(10,100), random.Next(10,100));
|
||||
Draw();
|
||||
|
||||
}
|
||||
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningAirbus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningAirbus.MoveTransport(Direction.Up); break;
|
||||
case "buttonDown":
|
||||
_drawningAirbus.MoveTransport(Direction.Down); break;
|
||||
case "buttonLeft":
|
||||
_drawningAirbus.MoveTransport(Direction.Left); break;
|
||||
case "buttonRight":
|
||||
_drawningAirbus.MoveTransport(Direction.Right); break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user