75 lines
2.3 KiB
C#
75 lines
2.3 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
using DoubleDeckerbus.DrawingObjects;
|
||
using DoubleDeckerbus;
|
||
using DoubleDeckerbus.MovementStrategy;
|
||
|
||
namespace DoubleDeckerbus
|
||
{
|
||
public partial class FormBusCollection : Form
|
||
{
|
||
private readonly BusGenericCollection<DrawingBus, DrawingObjectBus> _bus;
|
||
public FormBusCollection()
|
||
{
|
||
InitializeComponent();
|
||
_bus = new BusGenericCollection<DrawingBus, DrawingObjectBus>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||
|
||
}
|
||
private void ButtonAddBus_Click(object sender, EventArgs e)
|
||
{
|
||
FormDoubleDeckerbus form = new();
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
if (_bus + form.SelectedBus != -1)
|
||
{
|
||
MessageBox.Show("Объект добавлен");
|
||
pictureBoxCollection.Image = _bus.ShowBus();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось добавить объект");
|
||
}
|
||
}
|
||
}
|
||
private void ButtonRemoveBus_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
int pos = 0;
|
||
try
|
||
{
|
||
pos = Convert.ToInt32(maskedTextBoxNumber.Text) ;
|
||
|
||
}
|
||
catch
|
||
{
|
||
MessageBox.Show("Ошибка ввода данных");
|
||
return;
|
||
}
|
||
if (_bus - (_bus.ReturnLength() - pos))
|
||
{
|
||
MessageBox.Show("Объект удален");
|
||
pictureBoxCollection.Image = _bus.ShowBus();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось удалить объект");
|
||
}
|
||
}
|
||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||
{
|
||
pictureBoxCollection.Image = _bus.ShowBus();
|
||
}
|
||
}
|
||
}
|