diff --git a/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs index 115e12f..c16041b 100644 --- a/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs @@ -15,8 +15,8 @@ namespace ProjectElectricLocomotive.DrawingObjects { public EntityLocomotive? EntityLocomotive { get; protected set; } - protected int _pictureWidth; - protected int _pictureHeight; + public int _pictureWidth; + public int _pictureHeight; protected int _startPosX; protected int _startPosY; protected readonly int _locomWidth = 80; diff --git a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs index 46defbc..9f5fe1d 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs @@ -48,6 +48,9 @@ namespace ProjectElectricLocomotive } public void AddLocomotive(DrawingLocomotive loco) { + loco._pictureWidth = pictureBoxCollection.Width; + loco._pictureHeight = pictureBoxCollection.Height; + if (listBoxStorages.SelectedIndex == -1) return; var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; @@ -55,19 +58,16 @@ namespace ProjectElectricLocomotive { return; } - FormElectricLocomotive form = new(); - if (form.ShowDialog() == DialogResult.OK) + + //проверяем, удалось ли нам загрузить объект + if (obj + loco > -1) { - //проверяем, удалось ли нам загрузить объект - if (obj + form.SelectedLocomotive > -1) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowLocomotives(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowLocomotives(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); } } private void buttonRemoveLocomotive_Click(object sender, EventArgs e)