2023-11-11 16:50:29 +04:00
|
|
|
|
namespace DoubleDeckerBus
|
|
|
|
|
{
|
2023-11-11 22:37:44 +04:00
|
|
|
|
public partial class FormDoubleDeckerBus : Form
|
2023-11-11 16:50:29 +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>
|
|
|
|
|
private DrawingBus? _drawingBus;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
2023-11-11 22:37:44 +04:00
|
|
|
|
public FormDoubleDeckerBus()
|
2023-11-11 16:50:29 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Draw()
|
|
|
|
|
{
|
|
|
|
|
if (_drawingBus == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Bitmap bmp = new(pictureBoxBus.Width, pictureBoxBus.Height);
|
|
|
|
|
Graphics gr = Graphics.FromImage(bmp);
|
|
|
|
|
_drawingBus.DrawTransport(gr);
|
|
|
|
|
pictureBoxBus.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();
|
|
|
|
|
_drawingBus = new DrawingBus();
|
|
|
|
|
EntityDoubleDeckerBus bus = new EntityDoubleDeckerBus();
|
|
|
|
|
bus.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)));
|
|
|
|
|
_drawingBus.Init(bus, pictureBoxBus.Width, pictureBoxBus.Height);
|
|
|
|
|
_drawingBus.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)
|
|
|
|
|
{
|
|
|
|
|
if (_drawingBus == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
|
|
|
switch (name)
|
|
|
|
|
{
|
|
|
|
|
case "buttonUp":
|
|
|
|
|
_drawingBus.MoveTransport(Direction.Up);
|
|
|
|
|
break;
|
|
|
|
|
case "buttonDown":
|
|
|
|
|
_drawingBus.MoveTransport(Direction.Down);
|
|
|
|
|
break;
|
|
|
|
|
case "buttonLeft":
|
|
|
|
|
_drawingBus.MoveTransport(Direction.Left);
|
|
|
|
|
break;
|
|
|
|
|
case "buttonRight":
|
|
|
|
|
_drawingBus.MoveTransport(Direction.Right);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|