PIbd-22_Fedorenko_G.Y._Hydr.../Hydroplane/Form1.cs

82 lines
2.7 KiB
C#
Raw Normal View History

2023-09-22 18:54:14 +04:00
namespace Hydroplane
{
public partial class Form1 : Form
{
/// <summary>
/// <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
2023-09-22 23:38:10 +04:00
private DrawningHydroplane? _drawningHydroplane;
2023-09-22 18:54:14 +04:00
public Form1()
{
InitializeComponent();
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
private void Draw()
{
2023-09-22 23:38:10 +04:00
if (_drawningHydroplane == null)
{
return;
}
Bitmap bmp = new(pictureBoxHydroplane.Width,
pictureBoxHydroplane.Height);
Graphics gr = Graphics.FromImage(bmp);
2023-09-22 23:38:10 +04:00
_drawningHydroplane.DrawTransport(gr);
pictureBoxHydroplane.Image = bmp;
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new();
2023-09-22 23:38:10 +04:00
_drawningHydroplane = new DrawningHydroplane();
_drawningHydroplane.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)),
pictureBoxHydroplane.Width, pictureBoxHydroplane.Height);
2023-09-22 23:38:10 +04:00
_drawningHydroplane.SetPosition(random.Next(10, 100),
random.Next(10, 100));
Draw();
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonMove_Click(object sender, EventArgs e)
{
2023-09-22 23:38:10 +04:00
if (_drawningHydroplane == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
2023-09-22 23:38:10 +04:00
_drawningHydroplane.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
2023-09-22 23:38:10 +04:00
_drawningHydroplane.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
2023-09-22 23:38:10 +04:00
_drawningHydroplane.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
2023-09-22 23:38:10 +04:00
_drawningHydroplane.MoveTransport(DirectionType.Right);
break;
}
Draw();
}
2023-09-22 18:54:14 +04:00
}
}