78 lines
2.4 KiB
C#
78 lines
2.4 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 DumpTruck.Generics;
|
||
using DumpTruck.DrawingObjects;
|
||
using DumpTruck.MovementStrategy;
|
||
|
||
namespace DumpTruck
|
||
{
|
||
/// <summary>
|
||
/// Форма для работы с набором объектов класса DrawingTruck
|
||
/// </summary>
|
||
public partial class FormTruckCollection : Form
|
||
{
|
||
/// <summary>
|
||
/// Набор объектов
|
||
/// </summary>
|
||
private readonly TrucksGenericCollection<DrawingTruck, DrawningObjectTruck> _trucks;
|
||
/// <summary>
|
||
/// Конструктор
|
||
/// </summary>
|
||
public FormTruckCollection()
|
||
{
|
||
InitializeComponent();
|
||
_trucks = new TrucksGenericCollection<DrawingTruck, DrawningObjectTruck>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||
}
|
||
|
||
private void buttonAddTruck_Click(object sender, EventArgs e)
|
||
{
|
||
FormDumpTruck form = new();
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
if (_trucks + form.SelectedTruck != -1)
|
||
{
|
||
MessageBox.Show("Объект добавлен");
|
||
pictureBoxCollection.Image = _trucks.ShowTrucks();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось добавить объект");
|
||
}
|
||
}
|
||
}
|
||
|
||
private void buttonRemoveTruck_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||
if (_trucks - pos)
|
||
{
|
||
MessageBox.Show("Объект удален");
|
||
pictureBoxCollection.Image = _trucks.ShowTrucks();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось удалить объект");
|
||
}
|
||
}
|
||
|
||
private void buttonRefreshCollection_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
pictureBoxCollection.Image = _trucks.ShowTrucks();
|
||
}
|
||
}
|
||
|
||
}
|