2022-09-20 10:04:55 +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 PIbd_21_Potapov_N.S._Catamaran_Base
|
|
|
|
|
{
|
2022-10-12 12:40:12 +04:00
|
|
|
|
public partial class FormCatamaran : System.Windows.Forms.Form
|
2022-09-20 10:04:55 +04:00
|
|
|
|
{
|
2022-10-12 12:40:12 +04:00
|
|
|
|
DrawingCatamaran catamaranDrawObj;
|
2022-09-20 10:04:55 +04:00
|
|
|
|
|
2022-10-12 12:40:12 +04:00
|
|
|
|
public FormCatamaran()
|
2022-09-20 10:04:55 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
pictureBox.Image = new Bitmap(pictureBox.Width, pictureBox.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn_new_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2022-10-12 12:40:12 +04:00
|
|
|
|
Random rnd = new Random();
|
2022-09-20 10:04:55 +04:00
|
|
|
|
|
2022-10-12 12:40:12 +04:00
|
|
|
|
catamaranDrawObj = new DrawingCatamaran();
|
|
|
|
|
catamaranDrawObj.Init(rnd.Next(50, 100), rnd.Next(50, 100), Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)));
|
|
|
|
|
catamaranDrawObj.SetPosition(rnd.Next(10, 50), rnd.Next(10, 50), pictureBox.Width, pictureBox.Height - statusStrip.Height);
|
2022-09-20 22:16:44 +04:00
|
|
|
|
toolStripStatusLabelSpeed.Text = $"Скорость: {catamaranDrawObj.Catamaran.Speed}";
|
|
|
|
|
toolStripStatusLabelWeight.Text = $"Вес: {catamaranDrawObj.Catamaran.Weight}";
|
2022-10-12 12:40:12 +04:00
|
|
|
|
toolStripStatusLabelColor.Text = $"Цвет: {catamaranDrawObj.Catamaran.BodyColor.Name}";
|
2022-09-20 10:04:55 +04:00
|
|
|
|
RedrawCatamaran();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn_move_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (catamaranDrawObj == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string btnName = ((Button)sender).Name;
|
|
|
|
|
|
|
|
|
|
switch (btnName)
|
|
|
|
|
{
|
|
|
|
|
case "btn_up":
|
|
|
|
|
{
|
2022-10-12 12:40:12 +04:00
|
|
|
|
catamaranDrawObj.MoveTransport(Direction.Up);
|
2022-09-20 10:04:55 +04:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "btn_down":
|
|
|
|
|
{
|
2022-10-12 12:40:12 +04:00
|
|
|
|
catamaranDrawObj.MoveTransport(Direction.Down);
|
2022-09-20 10:04:55 +04:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "btn_left":
|
|
|
|
|
{
|
2022-10-12 12:40:12 +04:00
|
|
|
|
catamaranDrawObj.MoveTransport(Direction.Left);
|
2022-09-20 10:04:55 +04:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "btn_right":
|
|
|
|
|
{
|
2022-10-12 12:40:12 +04:00
|
|
|
|
catamaranDrawObj.MoveTransport(Direction.Right);
|
2022-09-20 10:04:55 +04:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
RedrawCatamaran();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RedrawCatamaran()
|
|
|
|
|
{
|
|
|
|
|
Graphics g = Graphics.FromImage(pictureBox.Image);
|
|
|
|
|
g.Clear(Color.White);
|
|
|
|
|
catamaranDrawObj.DrawTransport(g);
|
|
|
|
|
pictureBox.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|