2023-09-22 18:54:14 +04:00
|
|
|
|
namespace Hydroplane
|
|
|
|
|
{
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
2023-09-22 21:05:01 +04:00
|
|
|
|
/// <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();
|
|
|
|
|
}
|
2023-09-22 21:05:01 +04:00
|
|
|
|
|
|
|
|
|
/// <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)
|
2023-09-22 21:05:01 +04:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Bitmap bmp = new(pictureBoxHydroplane.Width,
|
|
|
|
|
pictureBoxHydroplane.Height);
|
|
|
|
|
Graphics gr = Graphics.FromImage(bmp);
|
2023-09-22 23:38:10 +04:00
|
|
|
|
_drawningHydroplane.DrawTransport(gr);
|
2023-09-22 21:05:01 +04:00
|
|
|
|
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),
|
2023-09-22 21:05:01 +04:00
|
|
|
|
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),
|
2023-09-22 21:05:01 +04:00
|
|
|
|
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)
|
2023-09-22 21:05:01 +04:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
|
|
|
switch (name)
|
|
|
|
|
{
|
|
|
|
|
case "buttonUp":
|
2023-09-22 23:38:10 +04:00
|
|
|
|
_drawningHydroplane.MoveTransport(DirectionType.Up);
|
2023-09-22 21:05:01 +04:00
|
|
|
|
break;
|
|
|
|
|
case "buttonDown":
|
2023-09-22 23:38:10 +04:00
|
|
|
|
_drawningHydroplane.MoveTransport(DirectionType.Down);
|
2023-09-22 21:05:01 +04:00
|
|
|
|
break;
|
|
|
|
|
case "buttonLeft":
|
2023-09-22 23:38:10 +04:00
|
|
|
|
_drawningHydroplane.MoveTransport(DirectionType.Left);
|
2023-09-22 21:05:01 +04:00
|
|
|
|
break;
|
|
|
|
|
case "buttonRight":
|
2023-09-22 23:38:10 +04:00
|
|
|
|
_drawningHydroplane.MoveTransport(DirectionType.Right);
|
2023-09-22 21:05:01 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
2023-09-22 18:54:14 +04:00
|
|
|
|
}
|
|
|
|
|
}
|