From 7e1e6cafeb3b7d8a339875c9a444cc75f682d680 Mon Sep 17 00:00:00 2001 From: MayDayR Date: Tue, 14 Nov 2023 12:45:48 +0400 Subject: [PATCH] revert afd8d13476512f9c382b506bdf5b3c750aff1ebc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert Удалить 'DoubleDeckerBus/FormDoubleDeckerBus.cs' --- DoubleDeckerBus/FormDoubleDeckerBus.cs | 82 ++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 DoubleDeckerBus/FormDoubleDeckerBus.cs diff --git a/DoubleDeckerBus/FormDoubleDeckerBus.cs b/DoubleDeckerBus/FormDoubleDeckerBus.cs new file mode 100644 index 0000000..ca8a7f2 --- /dev/null +++ b/DoubleDeckerBus/FormDoubleDeckerBus.cs @@ -0,0 +1,82 @@ +namespace DoubleDeckerBus +{ + public partial class FormDoubleDeckerBus : Form + { + /// + /// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà + /// + private DrawingBus? _drawingBus; + /// + /// Èíèöèàëèçàöèÿ ôîðìû + /// + public FormDoubleDeckerBus() + { + InitializeComponent(); + } + /// + /// Ìåòîä ïðîðèñîâêè àâòîáóñà + /// + private void Draw() + { + if (_drawingBus == null) + { + return; + } + Bitmap bmp = new(pictureBoxBus.Width, pictureBoxBus.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawingBus.DrawTransport(gr); + pictureBoxBus.Image = bmp; + } + /// + /// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü" + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawingBus = new DrawingBus(); + EntityDoubleDeckerBus bus = new EntityDoubleDeckerBus(); + bus.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))); + _drawingBus.Init(bus, pictureBoxBus.Width, pictureBoxBus.Height); + _drawingBus.SetPosition(random.Next(10, 100), + random.Next(10, 100)); + Draw(); + } + /// + /// Èçìåíåíèå ðàçìåðîâ ôîðìû + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawingBus == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawingBus.MoveTransport(Direction.Up); + break; + case "buttonDown": + _drawingBus.MoveTransport(Direction.Down); + break; + case "buttonLeft": + _drawingBus.MoveTransport(Direction.Left); + break; + case "buttonRight": + _drawingBus.MoveTransport(Direction.Right); + break; + } + Draw(); + } + } +} \ No newline at end of file