Event work
This commit is contained in:
parent
9120b18814
commit
6999084ee6
@ -50,25 +50,27 @@ namespace Liner
|
||||
}
|
||||
}
|
||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formShipConfig = new FormShipConfig();
|
||||
formShipConfig.AddEvent(AddShip);
|
||||
formShipConfig.Show();
|
||||
}
|
||||
private void AddShip(DrawingShip ship)
|
||||
{
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormShip form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObjectShip(ship) != -1)
|
||||
{
|
||||
DrawingObjectShip ship = new(form.SelectedShip);
|
||||
if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] + ship != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
|
||||
}
|
||||
private void ButtonRemoveShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
22
Liner/Liner/FormShipConfig.Designer.cs
generated
22
Liner/Liner/FormShipConfig.Designer.cs
generated
@ -204,6 +204,16 @@
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(88, 66);
|
||||
this.numericUpDownWeight.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWeight.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
this.numericUpDownWeight.Size = new System.Drawing.Size(150, 27);
|
||||
this.numericUpDownWeight.TabIndex = 3;
|
||||
@ -216,11 +226,21 @@
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(88, 33);
|
||||
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(150, 27);
|
||||
this.numericUpDownSpeed.TabIndex = 2;
|
||||
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||
60,
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
|
@ -13,6 +13,7 @@ namespace Liner
|
||||
public partial class FormShipConfig : Form
|
||||
{
|
||||
DrawingShip _ship=null;
|
||||
private event Action<DrawingShip> EventAddShip;
|
||||
public FormShipConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -34,6 +35,17 @@ namespace Liner
|
||||
_ship?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
public void AddEvent(Action<DrawingShip> ev)
|
||||
{
|
||||
if (EventAddShip == null)
|
||||
{
|
||||
EventAddShip = new Action<DrawingShip>(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddShip += ev;
|
||||
}
|
||||
}
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
@ -58,10 +70,10 @@ namespace Liner
|
||||
{
|
||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimple":
|
||||
case "labelSimpleObject":
|
||||
_ship = new DrawingShip((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
|
||||
break;
|
||||
case "labelModif":
|
||||
case "labelModifObject":
|
||||
_ship = new DrawningLiner((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black,
|
||||
checkBoxDopDeck.Checked, checkBoxPool.Checked);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user