PIbd-23-Kondratev-N.D.-Gaso.../GasolineTanker/ProjectGasolineTanker/FormTruckCollection.cs
2024-10-03 00:40:53 +03:00

86 lines
2.5 KiB
C#
Raw Permalink 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.

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 ProjectGasolineTanker.Drawings;
using ProjectGasolineTanker.Generic;
using ProjectGasolineTanker.MovementStratg;
namespace ProjectGasolineTanker
{
public partial class FormTruckCollection : Form
{
private readonly TruckGenericCollection<DrawingTruck, DrawingObjectTruck> _truck;
public FormTruckCollection()
{
InitializeComponent();
_truck = new TruckGenericCollection<DrawingTruck, DrawingObjectTruck>(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
private void ButtonAddTruck_Click(object sender, EventArgs e)
{
FormGasolineTanker form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (_truck + form.SelectedTruck != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _truck.ShowTruck();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
private void ButtonRemoveTruck_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = 0;
try
{
pos = Convert.ToInt32(maskedTextBoxNumber.Text) ;
}
catch
{
MessageBox.Show("Ошибка ввода данных");
return;
}
if (_truck - (_truck.ReturnLength() - pos))
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _truck.ShowTruck();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void ButtonRefreshCollection_Click(object sender, EventArgs
e)
{
pictureBoxCollection.Image = _truck.ShowTruck();
}
}
}