42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
namespace ElectricLocomotive;
|
||
|
||
public partial class FormLocomotivCollection : Form {
|
||
private readonly LocosGenericCollection<DrawingLocomotiv, DrawingObjectLocomotiv> _locos;
|
||
public FormLocomotivCollection() {
|
||
InitializeComponent();
|
||
_locos = new(collectionPictureBox.Width, collectionPictureBox.Height);
|
||
}
|
||
|
||
private void addLocomotiv_Click(object sender, EventArgs e) {
|
||
FormLocomotiv form = new();
|
||
if (form.ShowDialog() == DialogResult.OK) {
|
||
if (_locos + form.SelectedLocomotiv != null) {
|
||
MessageBox.Show("Объект добавлен");
|
||
collectionPictureBox.Image = _locos.ShowLocos();
|
||
}
|
||
else {
|
||
MessageBox.Show("Не удалось добавить объект");
|
||
}
|
||
}
|
||
}
|
||
|
||
private void deleteLoco_Click(object sender, EventArgs e) {
|
||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) {
|
||
return;
|
||
}
|
||
int pos = Convert.ToInt32(input.Text);
|
||
if (_locos - pos != null) {
|
||
MessageBox.Show("Объект удален");
|
||
collectionPictureBox.Image = _locos.ShowLocos();
|
||
}
|
||
else {
|
||
MessageBox.Show("Не удалось удалить объект");
|
||
}
|
||
}
|
||
|
||
private void refreshCollection_Click(object sender, EventArgs e) {
|
||
collectionPictureBox.Image = _locos.ShowLocos();
|
||
|
||
}
|
||
|
||
} |