Пофиксила
This commit is contained in:
parent
ad1b457f40
commit
9a5a57c959
@ -125,61 +125,6 @@
|
||||
|
||||
}
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreateSportCar_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningCruiser = new DrawningCruiser();
|
||||
_drawningCruiser.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)), Convert.ToBoolean(random.Next(0, 2)), pictureBox1.Width, pictureBox1.Height);
|
||||
_drawningCruiser.SetPosition(random.Next(10, 100),
|
||||
random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningCruiser.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningCruiser.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningCruiser.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningCruiser.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBox1.Width,
|
||||
pictureBox1.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningCruiser.DrawTransport(gr);
|
||||
pictureBox1.Image = bmp;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
75
Cruiser/Cruiser/CruiserForm.cs
Normal file
75
Cruiser/Cruiser/CruiserForm.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
|
||||
public partial class CruiserForm : Form
|
||||
{
|
||||
private DrawningCruiser? _drawningCruiser;
|
||||
public CruiserForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void ButtonCreateSportCar_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningCruiser = new DrawningCruiser();
|
||||
_drawningCruiser.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)), Convert.ToBoolean(random.Next(0, 2)), pictureBox1.Width, pictureBox1.Height);
|
||||
_drawningCruiser.SetPosition(random.Next(10, 100),
|
||||
random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningCruiser.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningCruiser.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningCruiser.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningCruiser.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBox1.Width,
|
||||
pictureBox1.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningCruiser.DrawTransport(gr);
|
||||
pictureBox1.Image = bmp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
|
||||
public partial class CruiserForm : Form
|
||||
{
|
||||
private DrawningCruiser? _drawningCruiser;
|
||||
public CruiserForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user