2022-09-12 22:17:57 +04:00
|
|
|
|
namespace Artilleries
|
2022-09-12 22:07:59 +04:00
|
|
|
|
{
|
2022-09-12 22:11:25 +04:00
|
|
|
|
public partial class FormArtillery : Form
|
2022-09-12 22:07:59 +04:00
|
|
|
|
{
|
2022-09-12 22:17:57 +04:00
|
|
|
|
private DrawingArtillery _artillery;
|
|
|
|
|
|
2022-09-30 20:17:08 +04:00
|
|
|
|
public DrawingArtillery SelectedArtillery { get; private set; }
|
|
|
|
|
|
2022-09-12 22:11:25 +04:00
|
|
|
|
public FormArtillery()
|
2022-09-12 22:07:59 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
2022-09-13 17:17:04 +04:00
|
|
|
|
|
2022-09-12 22:17:57 +04:00
|
|
|
|
private void Draw()
|
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new(pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
|
|
|
|
Graphics gr = Graphics.FromImage(bmp);
|
|
|
|
|
_artillery?.DrawTransport(gr);
|
|
|
|
|
pictureBoxArtilleries.Image = bmp;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-30 20:17:08 +04:00
|
|
|
|
private void SetData(DrawingArtillery artillery)
|
|
|
|
|
{
|
|
|
|
|
Random rnd = new();
|
|
|
|
|
artillery.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
2022-10-03 16:30:06 +04:00
|
|
|
|
SpeedStatusLabel.Text = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {artillery.Artillery.Speed}";
|
|
|
|
|
WeightStatusLabel.Text = $"<22><><EFBFBD>: {artillery.Artillery.Weight}";
|
|
|
|
|
ColorStatusLabel.Text = $"<22><><EFBFBD><EFBFBD>: {artillery.Artillery.BodyColor.Name}";
|
2022-09-30 20:17:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-26 22:02:22 +04:00
|
|
|
|
private void buttonCreate_Click(object sender, EventArgs e)
|
2022-09-26 19:55:09 +04:00
|
|
|
|
{
|
|
|
|
|
Random rnd = new();
|
2022-09-30 20:17:08 +04:00
|
|
|
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
|
|
|
|
ColorDialog dialog = new();
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
color = dialog.Color;
|
|
|
|
|
}
|
|
|
|
|
_artillery = new DrawingArtillery(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
|
|
|
|
SetData(_artillery);
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createAdvancedButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Random rnd = new();
|
|
|
|
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
|
|
|
|
ColorDialog dialog = new();
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
color = dialog.Color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
|
|
|
|
ColorDialog dialogDop = new();
|
|
|
|
|
if (dialogDop.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
dopColor = dialogDop.Color;
|
|
|
|
|
}
|
|
|
|
|
_artillery = new DrawingAdvancedArtillery(
|
|
|
|
|
rnd.Next(100, 300),
|
|
|
|
|
rnd.Next(1000, 2000),
|
|
|
|
|
color,
|
|
|
|
|
dopColor,
|
|
|
|
|
rnd.Next(0, 2) == 1, rnd.Next(0, 2) == 1
|
|
|
|
|
);
|
|
|
|
|
SetData(_artillery);
|
2022-09-12 22:17:57 +04:00
|
|
|
|
Draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonMove_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
|
|
|
switch (name)
|
|
|
|
|
{
|
|
|
|
|
case "buttonUp":
|
|
|
|
|
_artillery?.MoveTransport(Direction.Up);
|
|
|
|
|
break;
|
|
|
|
|
case "buttonDown":
|
|
|
|
|
_artillery?.MoveTransport(Direction.Down);
|
|
|
|
|
break;
|
|
|
|
|
case "buttonLeft":
|
|
|
|
|
_artillery?.MoveTransport(Direction.Left);
|
|
|
|
|
break;
|
|
|
|
|
case "buttonRight":
|
|
|
|
|
_artillery?.MoveTransport(Direction.Right);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pictureBoxArtilleries_Resize(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_artillery?.ChangeBorders(pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
2022-09-30 20:17:08 +04:00
|
|
|
|
|
|
|
|
|
private void selectArtilleryButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SelectedArtillery = _artillery;
|
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
}
|
2022-09-12 22:07:59 +04:00
|
|
|
|
}
|
|
|
|
|
}
|