From aa09b6df1f412ae820e32e02739e2b0d56be3972 Mon Sep 17 00:00:00 2001 From: RomanovEgor Date: Mon, 10 Oct 2022 20:50:04 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'HoistingCrane/HoistingCrane/FormMap.c?= =?UTF-8?q?s'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HoistingCrane/HoistingCrane/FormMap.cs | 88 ++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 HoistingCrane/HoistingCrane/FormMap.cs diff --git a/HoistingCrane/HoistingCrane/FormMap.cs b/HoistingCrane/HoistingCrane/FormMap.cs new file mode 100644 index 0000000..f6b7a14 --- /dev/null +++ b/HoistingCrane/HoistingCrane/FormMap.cs @@ -0,0 +1,88 @@ +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 HoistingCrane +{ + public partial class FormMap : Form + { + private AbstractMap _abstractMap; + public FormMap() + { + InitializeComponent(); + _abstractMap = new SimpleMap(); + _abstractMap = new SecondMap(); + } + + private void SetData(DrawingHoistingCrane hoistingCrane) + { + toolStripStatusLabelSpeed.Text = $"Скорость: {hoistingCrane.HoistingCrane.Speed}"; + toolStripStatusLabelWeight.Text = $"Вес: {hoistingCrane.HoistingCrane.Weight}"; + toolStripStatusLabelBodyColor.Text = $"Цвет:{hoistingCrane.HoistingCrane.BodyColor.Name}"; + pictureBoxHoistingCrane.Image = _abstractMap.CreateMap(pictureBoxHoistingCrane.Width, + pictureBoxHoistingCrane.Height, new DrawingObjectHoistingCrane(hoistingCrane)); + } + + private void ButtonCreate_Click(object sender, EventArgs e) + { + Random rnd = new(); + var hoistingCrane = new DrawingHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500), + Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + SetData(bulldozer); + } + + private void ButtonMove_Click(object sender, EventArgs e) + { + string name = ((Button)sender)?.Name ?? string.Empty; + Direction dir = Direction.None; + switch (name) + { + case "buttonUp": + dir = Direction.Up; + break; + case "buttonDown": + dir = Direction.Down; + break; + case "buttonLeft": + dir = Direction.Left; + break; + case "buttonRight": + dir = Direction.Right; + break; + } + pictureBoxHoistingCrane.Image = _abstractMap.MoveObject(dir); + } + private void ButtonCreateModify_Click(object sender, EventArgs e) + { + Random rnd = new(); + var hoistingCrane = new DrawingAdvancedHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500), + Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Color.FromArgb(rnd.Next(0, 256), + rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); + SetData(hoistingCrane); + } + + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) + { + switch (comboBoxSelectorMap.Text) + { + case "Простая карта": + _abstractMap = new SimpleMap(); + break; + case "Вторая карта": + _abstractMap = new SecondMap(); + break; + } + } + + private void pictureBoxHoistingCrane_Click(object sender, EventArgs e) + { + + } + } +}