79 lines
2.7 KiB
C#
79 lines
2.7 KiB
C#
|
namespace HoistingCrane
|
|||
|
{
|
|||
|
public partial class FormHoistingCrane : Form
|
|||
|
{
|
|||
|
private DrawingHoistingCrane _hoistingCrane;
|
|||
|
public FormHoistingCrane()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
private void Draw()
|
|||
|
{
|
|||
|
Bitmap bmp = new(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
|
|||
|
Graphics gr = Graphics.FromImage(bmp);
|
|||
|
_hoistingCrane?.DrawTransport(gr);
|
|||
|
pictureBoxHoistingCrane.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 rnd = new();
|
|||
|
_hoistingCrane = new DrawingHoistingCrane();
|
|||
|
_hoistingCrane.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
|||
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|||
|
_hoistingCrane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
|||
|
pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
|
|||
|
toolStripStatusLabelSpeed.Text = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {_hoistingCrane.HoistingCrane.Speed}";
|
|||
|
toolStripStatusLabelWeight.Text = $"<22><><EFBFBD>: {_hoistingCrane.HoistingCrane.Weight}";
|
|||
|
toolStripStatusLabelBodyColor.Text = $"<22><><EFBFBD><EFBFBD>: {_hoistingCrane.HoistingCrane.BodyColor.Name} ";
|
|||
|
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)
|
|||
|
{
|
|||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
|||
|
switch (name)
|
|||
|
{
|
|||
|
case "buttonUp":
|
|||
|
_hoistingCrane?.MoveTransport(Direction.Up);
|
|||
|
break;
|
|||
|
case "buttonDown":
|
|||
|
_hoistingCrane?.MoveTransport(Direction.Down);
|
|||
|
break;
|
|||
|
case "buttonLeft":
|
|||
|
_hoistingCrane?.MoveTransport(Direction.Left);
|
|||
|
break;
|
|||
|
case "buttonRight":
|
|||
|
_hoistingCrane?.MoveTransport(Direction.Right);
|
|||
|
break;
|
|||
|
}
|
|||
|
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 PictureBoxBulldozer_Resize(object sender, EventArgs e)
|
|||
|
{
|
|||
|
_hoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
|
|||
|
Draw();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|