PIbd-23_Vrazhkin_S_A_Electr.../lab1/FormLocomotivCollection.cs

42 lines
1.5 KiB
C#
Raw Permalink Normal View History

2023-10-17 13:49:31 +04:00
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();
}
}