PIbd-23_Vrazhkin_S_A_Electr.../lab1/FormLocomotivCollection.cs
2023-10-17 13:49:31 +04:00

42 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
}
}