88 lines
2.9 KiB
C#
88 lines
2.9 KiB
C#
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 DoubleDeckerBus
|
||
{
|
||
public partial class FormMap : Form
|
||
{
|
||
private AbstractMap _abstractMap;
|
||
public FormMap()
|
||
{
|
||
InitializeComponent();
|
||
_abstractMap = new SimpleMap();
|
||
comboBoxSelectorMap.SelectedIndex = 0;
|
||
}
|
||
|
||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||
{
|
||
Random rnd = new();
|
||
var bus = new DrawingBus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||
SetData(bus);
|
||
}
|
||
|
||
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;
|
||
}
|
||
pictureBoxBus.Image = _abstractMap?.MoveObject(dir);
|
||
}
|
||
|
||
private void SetData(DrawingBus bus)
|
||
{
|
||
toolStripStatusLabelSpeed.Text = $"Скорость: {bus.Bus.Speed}";
|
||
toolStripStatusLabelWeight.Text = $"Вес: {bus.Bus.Weight}";
|
||
toolStripStatusLabelBodyColor.Text = $"Цвет: {bus.Bus.BodyColor.Name}";
|
||
pictureBoxBus.Image = _abstractMap.CreateMap(pictureBoxBus.Width, pictureBoxBus.Height,
|
||
new DrawingObjectBus(bus));
|
||
}
|
||
|
||
private void ButtonСreateExtra_Click(object sender, EventArgs e)
|
||
{
|
||
Random rnd = new();
|
||
var bus = new DrawingDDB(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||
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(bus);
|
||
}
|
||
|
||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
switch (comboBoxSelectorMap.Text)
|
||
{
|
||
case "Простая карта":
|
||
_abstractMap = new SimpleMap();
|
||
break;
|
||
case "Водная карта":
|
||
_abstractMap = new WaterMap();
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|