71 lines
2.1 KiB
C#
71 lines
2.1 KiB
C#
using RoadTrain.DrawningObjects;
|
||
using RoadTrain.Generics;
|
||
using RoadTrain.MovementStrategy;
|
||
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;
|
||
|
||
namespace RoadTrain
|
||
{
|
||
public partial class FormTrainCollection : Form
|
||
{
|
||
private readonly RoadTrainGenericCollection<DrawningRoadTrain,
|
||
DrawningObjectTrain> _trains;
|
||
public FormTrainCollection()
|
||
{
|
||
InitializeComponent();
|
||
_trains = new RoadTrainGenericCollection<DrawningRoadTrain,
|
||
DrawningObjectTrain>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||
}
|
||
|
||
private void ButtonAddTrain_Click(object sender, EventArgs e)
|
||
{
|
||
FormRoadTrain form = new();
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
if (_trains + form.SelectedTrain != -1)
|
||
{
|
||
MessageBox.Show("Объект добавлен");
|
||
pictureBoxCollection.Image = _trains.ShowTrains();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось добавить объект");
|
||
}
|
||
}
|
||
}
|
||
|
||
private void ButtonRemoveTrain_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
int pos = Convert.ToInt32(InputTextBox.Text);
|
||
if (_trains - pos != null)
|
||
{
|
||
MessageBox.Show("Объект удален");
|
||
pictureBoxCollection.Image = _trains.ShowTrains();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось удалить объект");
|
||
}
|
||
|
||
}
|
||
|
||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||
{
|
||
pictureBoxCollection.Image = _trains.ShowTrains();
|
||
|
||
}
|
||
}
|
||
}
|