67 lines
2.1 KiB
C#
67 lines
2.1 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;
|
||
|
||
namespace Catamaran
|
||
{
|
||
public partial class FormCatamaranCollection : Form
|
||
{
|
||
|
||
private readonly CatamaransGenericCollection<DrawningCatamaran, DrawningObjectCatamaran> _cats;
|
||
|
||
public FormCatamaranCollection()
|
||
{
|
||
InitializeComponent();
|
||
_cats = new CatamaransGenericCollection<DrawningCatamaran,
|
||
DrawningObjectCatamaran>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||
}
|
||
|
||
private void ButtonAddCat_Click(object sender, EventArgs e)
|
||
{
|
||
FormCatamaran form = new();
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
if (_cats + form.SelectedCatamaran != null)
|
||
{
|
||
MessageBox.Show("Объект добавлен");
|
||
pictureBoxCollection.Image = _cats.ShowCats();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось добавить объект");
|
||
}
|
||
}
|
||
}
|
||
|
||
private void ButtonRemoveCat_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||
if (_cats - pos != null)
|
||
{
|
||
MessageBox.Show("Объект удален");
|
||
pictureBoxCollection.Image = _cats.ShowCats();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось удалить объект");
|
||
}
|
||
}
|
||
|
||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||
{
|
||
pictureBoxCollection.Image = _cats.ShowCats();
|
||
}
|
||
}
|
||
}
|