Nugaev D.N. Lab_work04 #4

Closed
Damir_Nugaev_ISEbd-22 wants to merge 7 commits from Lab_work04 into Lab_work03
2 changed files with 13 additions and 7 deletions
Showing only changes of commit ca865bc1f0 - Show all commits

View File

@ -1,4 +1,4 @@
using System;
using Bus;
using System.Collections.Generic;
using System.Linq;
using System.Text;

View File

@ -80,7 +80,7 @@ namespace Bus
private void ButtonAddBus_Click(object sender, EventArgs e)
{
if (_mapBusCollectionGeneric == null)
if (listBoxMaps.SelectedIndex == -1)
{
return;
}
@ -94,11 +94,10 @@ namespace Bus
}
DrawingObjectBus bus = new(form.SelectedBus);
if (_mapBusCollectionGeneric + bus != -1)
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + bus != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapBusCollectionGeneric.ShowSet();
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
@ -109,20 +108,27 @@ namespace Bus
private void ButtonRemoveBus_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)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_mapBusCollectionGeneric - pos != null)
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
{
MessageBox.Show("Объект удален");
pictureBox.Image = _mapBusCollectionGeneric.ShowSet();
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{