2022-11-13 20:39:23 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace WinFormsApp1
|
|
|
|
|
{
|
|
|
|
|
public partial class FormTractor : Form
|
|
|
|
|
{
|
|
|
|
|
private TractorDraw _Tractor;
|
|
|
|
|
|
|
|
|
|
public FormTractor()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Draw()
|
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new Bitmap(pictureBoxTractor.Width, pictureBoxTractor.Height);
|
|
|
|
|
Graphics gr = Graphics.FromImage(bmp);
|
|
|
|
|
_Tractor?.DrawEntity(gr);
|
|
|
|
|
pictureBoxTractor.Image = bmp;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-14 21:25:33 +04:00
|
|
|
|
private void SetData()
|
2022-11-13 20:39:23 +04:00
|
|
|
|
{
|
2022-11-14 21:25:33 +04:00
|
|
|
|
Random random = new();
|
2022-11-13 20:39:23 +04:00
|
|
|
|
_Tractor.SetPosition(random.Next(10, 50), random.Next(10, 50), pictureBoxTractor.Width, pictureBoxTractor.Height);
|
|
|
|
|
toolStripStatusLabelSpeed.Text = $"Скорость: {_Tractor.Tractor.Speed}";
|
|
|
|
|
toolStripStatusLabelWeight.Text = $"Вес: {_Tractor.Tractor.Weight}";
|
2022-11-14 21:25:33 +04:00
|
|
|
|
toolStripStatusLabelBodyColor.Text = $"Цвет кузова: {_Tractor.Tractor.BodyColor.Name}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
_Tractor = new TractorDraw(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
|
|
|
|
SetData();
|
2022-11-13 20:39:23 +04:00
|
|
|
|
Draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonMove_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
|
|
|
switch (name)
|
|
|
|
|
{
|
|
|
|
|
case "buttonUp":
|
|
|
|
|
_Tractor?.MoveTransport(Direction.Up);
|
|
|
|
|
break;
|
|
|
|
|
case "buttonDown":
|
|
|
|
|
_Tractor?.MoveTransport(Direction.Down);
|
|
|
|
|
break;
|
|
|
|
|
case "buttonLeft":
|
|
|
|
|
_Tractor?.MoveTransport(Direction.Left);
|
|
|
|
|
break;
|
|
|
|
|
case "buttonRight":
|
|
|
|
|
_Tractor?.MoveTransport(Direction.Right);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void pictureBoxTractor_Resize(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_Tractor?.ChangeBorders(pictureBoxTractor.Width, pictureBoxTractor.Height);
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
2022-11-14 21:25:33 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void buttonCreateModif_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
_Tractor = new MultiTraktorDraw(random.Next(100, 200), random.Next(2500, 5000),
|
|
|
|
|
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)));
|
|
|
|
|
SetData();
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
2022-11-13 20:39:23 +04:00
|
|
|
|
}
|
|
|
|
|
}
|