Изменил(а) на 'HoistingCrane/HoistingCrane/FormMap.cs'

This commit is contained in:
RomanovEgor 2022-10-10 20:50:04 +04:00 committed by 10Г Егор Романов
parent 14eec9e07f
commit f2aea31b76

View File

@ -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)
{
}
}
}