done
This commit is contained in:
parent
5687431a0f
commit
a36cba0895
@ -106,8 +106,6 @@ namespace ContainerShip
|
||||
g.FillPolygon(brRed, shipBorder);
|
||||
//Заливка верхней палубы
|
||||
g.FillRectangle(brMain, _startPosX + 21, _startPosY + 1, 59, 29);
|
||||
|
||||
|
||||
}
|
||||
public void ChangeBorders(int width, int height)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ namespace ContainerShip
|
||||
{
|
||||
Random random = new Random();
|
||||
Speed = speed <= 0 ? random.Next(50, 150) : speed;
|
||||
Weight = weight <= 0 ? random.Next(50, 150) : weight;
|
||||
Weight = weight <= 0 ? random.Next(1000, 2000) : weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +132,7 @@
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 51);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(176, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 18;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||
this.comboBoxSelectorMap.TabIndex = 18;
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
|
@ -11,11 +11,7 @@ using System.Windows.Forms;
|
||||
namespace ContainerShip
|
||||
{
|
||||
public partial class FormMapWithSetShip : Form
|
||||
{
|
||||
|
||||
private MapWithSetShipGeneric<DrawingObjectShip, AbstractMap> _mapShipCollectionGeneric;
|
||||
|
||||
|
||||
{
|
||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||
{
|
||||
{ "Простая карта", new SimpleMap()},
|
||||
@ -75,32 +71,6 @@ namespace ContainerShip
|
||||
ReloadMaps();
|
||||
}
|
||||
|
||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
AbstractMap map = null;
|
||||
switch (comboBoxSelectorMap.Text)
|
||||
{
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Острова":
|
||||
map = new IslandsMap();
|
||||
break;
|
||||
case "Скалы":
|
||||
map = new RocksMap();
|
||||
break;
|
||||
}
|
||||
if (map != null)
|
||||
{
|
||||
_mapShipCollectionGeneric = new
|
||||
MapWithSetShipGeneric<DrawingObjectShip, AbstractMap>(
|
||||
pictureBox.Width, pictureBox.Height, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapShipCollectionGeneric = null;
|
||||
}
|
||||
}
|
||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formShipConfig = new FormShipConfig();
|
||||
@ -128,20 +98,23 @@ namespace ContainerShip
|
||||
|
||||
private void ButtonRemoveShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapShipCollectionGeneric - pos != null)
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -151,12 +124,12 @@ namespace ContainerShip
|
||||
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapShipCollectionGeneric == null)
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
|
||||
}
|
||||
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
|
@ -14,7 +14,7 @@ namespace ContainerShip
|
||||
{
|
||||
DrawingShip _ship = null;
|
||||
|
||||
private event ShipDelegate EventAddShip;
|
||||
private event Action<DrawingShip> EventAddShip;
|
||||
|
||||
public FormShipConfig()
|
||||
{
|
||||
@ -29,10 +29,7 @@ namespace ContainerShip
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
|
||||
buttonCancel.Click += (object sender, EventArgs e) =>
|
||||
{
|
||||
Close();
|
||||
};
|
||||
buttonCancel.Click += (object sender, EventArgs e) => Close();
|
||||
}
|
||||
|
||||
private void DrawShip()
|
||||
@ -45,11 +42,11 @@ namespace ContainerShip
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
public void AddEvent(ShipDelegate ev)
|
||||
public void AddEvent(Action<DrawingShip> ev)
|
||||
{
|
||||
if (EventAddShip == null)
|
||||
{
|
||||
EventAddShip = new ShipDelegate(ev);
|
||||
EventAddShip = new Action<DrawingShip>(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ContainerShip
|
||||
{
|
||||
public delegate void ShipDelegate(DrawingShip ship);
|
||||
}
|
Loading…
Reference in New Issue
Block a user