Исправления

This commit is contained in:
Андрей Байгулов 2023-11-12 22:01:56 +04:00
parent 0feb1800b4
commit 26e3503e00
2 changed files with 14 additions and 14 deletions

View File

@ -15,8 +15,8 @@ namespace ProjectElectricLocomotive.DrawingObjects
{ {
public EntityLocomotive? EntityLocomotive { get; protected set; } public EntityLocomotive? EntityLocomotive { get; protected set; }
protected int _pictureWidth; public int _pictureWidth;
protected int _pictureHeight; public int _pictureHeight;
protected int _startPosX; protected int _startPosX;
protected int _startPosY; protected int _startPosY;
protected readonly int _locomWidth = 80; protected readonly int _locomWidth = 80;

View File

@ -48,6 +48,9 @@ namespace ProjectElectricLocomotive
} }
public void AddLocomotive(DrawingLocomotive loco) public void AddLocomotive(DrawingLocomotive loco)
{ {
loco._pictureWidth = pictureBoxCollection.Width;
loco._pictureHeight = pictureBoxCollection.Height;
if (listBoxStorages.SelectedIndex == -1) return; if (listBoxStorages.SelectedIndex == -1) return;
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
@ -55,19 +58,16 @@ namespace ProjectElectricLocomotive
{ {
return; return;
} }
FormElectricLocomotive form = new();
if (form.ShowDialog() == DialogResult.OK) //проверяем, удалось ли нам загрузить объект
if (obj + loco > -1)
{ {
//проверяем, удалось ли нам загрузить объект MessageBox.Show("Объект добавлен");
if (obj + form.SelectedLocomotive > -1) pictureBoxCollection.Image = obj.ShowLocomotives();
{ }
MessageBox.Show("Объект добавлен"); else
pictureBoxCollection.Image = obj.ShowLocomotives(); {
} MessageBox.Show("Не удалось добавить объект");
else
{
MessageBox.Show("Не удалось добавить объект");
}
} }
} }
private void buttonRemoveLocomotive_Click(object sender, EventArgs e) private void buttonRemoveLocomotive_Click(object sender, EventArgs e)