diff --git a/Liner/Liner/FormMapWithSetShips.cs b/Liner/Liner/FormMapWithSetShips.cs index 340096c..bce36f8 100644 --- a/Liner/Liner/FormMapWithSetShips.cs +++ b/Liner/Liner/FormMapWithSetShips.cs @@ -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) { diff --git a/Liner/Liner/FormShipConfig.Designer.cs b/Liner/Liner/FormShipConfig.Designer.cs index 9bd35f7..44ad4be 100644 --- a/Liner/Liner/FormShipConfig.Designer.cs +++ b/Liner/Liner/FormShipConfig.Designer.cs @@ -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}); diff --git a/Liner/Liner/FormShipConfig.cs b/Liner/Liner/FormShipConfig.cs index 7a60a3e..e39ac7e 100644 --- a/Liner/Liner/FormShipConfig.cs +++ b/Liner/Liner/FormShipConfig.cs @@ -13,6 +13,7 @@ namespace Liner public partial class FormShipConfig : Form { DrawingShip _ship=null; + private event Action EventAddShip; public FormShipConfig() { InitializeComponent(); @@ -34,6 +35,17 @@ namespace Liner _ship?.DrawTransport(gr); pictureBoxObject.Image = bmp; } + public void AddEvent(Action ev) + { + if (EventAddShip == null) + { + EventAddShip = new Action(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;