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 Catamaran
{
public partial class FormMap : Form
{
private AbstractMap _abstractMap;
public FormMap()
{
InitializeComponent();
_abstractMap = new SimpleMap();
}
///
/// Заполнение информации по объекту
///
///
private void SetData(DrawingBoat catamaran)
{
toolStripStatusLabelSpeed.Text = $"Скорость: {catamaran.Catamaran.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {catamaran.Catamaran.Weight}";
toolStripStatusLabelColor.Text = $"Цвет: { catamaran.Catamaran.BodyColor.Name}";
pictureBoxCatamaran.Image = _abstractMap.CreateMap(pictureBoxCatamaran.Width,pictureBoxCatamaran.Height,new DrawingObjectBoat(catamaran));
}
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new Random();
var _catamaran = new DrawingBoat(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
//_catamaran.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
//pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
SetData(_catamaran);
}
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;
}
pictureBoxCatamaran.Image = _abstractMap?.MoveObject(dir);
}
private void comboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxSelectorMap.Text)
{
case "SimpleMap":
_abstractMap = new SimpleMap();
break;
case "SecondMap":
_abstractMap = new SecondMap();
break;
}
}
private void buttonCreateModif_Click(object sender, EventArgs e)
{
Random rnd = new Random();
var catamaran = new DrawingCatamaran(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(catamaran);
}
}
}