fix conflict bus collection
This commit is contained in:
parent
336e208957
commit
de6d25fed0
@ -20,51 +20,32 @@ namespace ProjectAirbus
|
||||
panelCompanyTools.Enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение цвета
|
||||
/// </summary>
|
||||
/// <param name="random">Генератор случайных чисел</param>
|
||||
/// <returns></returns>
|
||||
private static Color GetColor(Random random)
|
||||
{
|
||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Создание объекта класса-перемещения
|
||||
/// добавить самолет
|
||||
/// </summary>
|
||||
/// <param name="type">Тип создаваемого объекта</param>
|
||||
private void CreateObject(string type)
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_company == null)
|
||||
FormBusConfig form = new();
|
||||
form.Show();
|
||||
form.AddEvent(SetBus);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SetBus(DrawningBus? bus)
|
||||
{
|
||||
if (_company == null || bus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DrawningBus _drawningShip;
|
||||
Random random = new();
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawningBus):
|
||||
_drawningShip = new DrawningBus(random.Next(30, 70), random.Next(100, 500),
|
||||
GetColor(random));
|
||||
break;
|
||||
case nameof(DrawningAirbus):
|
||||
_drawningShip = new DrawningAirbus(random.Next(30, 70), random.Next(100, 500),
|
||||
GetColor(random), GetColor(random),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
}
|
||||
if (_company + _drawningShip != -1)
|
||||
if (_company + bus != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox1.Image = _company.Show();
|
||||
@ -75,19 +56,7 @@ namespace ProjectAirbus
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// добавить самолет
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBus));
|
||||
|
||||
/// <summary>
|
||||
/// добавить аэробус
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddAirbus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirbus));
|
||||
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
@ -267,29 +236,5 @@ namespace ProjectAirbus
|
||||
RerfreshListBoxItems();
|
||||
}
|
||||
|
||||
private void buttonDelBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||||
if (_company - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox1.Image = _company.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user