72 lines
2.1 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 Lab.DrawningObjects;
using Lab.Generics;
using Lab.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 Lab
{
public partial class CollectionsFrame : Form
{
private readonly CarsGenericCollection<DrawTanker, DrawingObjectTanker> _cars;
public CollectionsFrame()
{
InitializeComponent();
_cars = new CarsGenericCollection<DrawTanker, DrawingObjectTanker>(DrawTank.Width, DrawTank.Height);
}
private void ButtonAddTank_Click(object sender, EventArgs e)
{
Frame form = new Frame();
if (form.ShowDialog() == DialogResult.OK)
{
if (_cars + form.SelectedCar != -1)
{
MessageBox.Show("Объект добавлен");
DrawTank.Image = _cars.ShowCars();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
private void ButtonRemoveCar_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = -1;
try
{
pos = Convert.ToInt32(InputNum.Text);
}
catch (Exception ex) { }
if (_cars - pos)
{
MessageBox.Show("Объект удален");
DrawTank.Image = _cars.ShowCars();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
{
DrawTank.Image = _cars.ShowCars();
}
}
}