using Liner.Drawing; using Liner.Generics; using Liner.MovingStrategies; 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 Liner { /// /// Форма для работы с набором объектов класса DrawingLiner /// public partial class FormLinerCollection : Form { /// /// Набор объектов /// private readonly LinerGenericCollection _liners; /// /// Конструктор /// public FormLinerCollection() { InitializeComponent(); _liners = new LinerGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height); } /// /// Добавление объекта в набор /// /// /// private void buttonAddLiner_Click(object sender, EventArgs e) { MainScreen form = new(); if (form.ShowDialog() == DialogResult.OK) { if (_liners + form.SelectedLiner != -1) { MessageBox.Show("Объект добавлен"); pictureBoxCollection.Image = _liners.ShowLiners(); } else { MessageBox.Show("Не удалось добавить объект"); } } } /// /// Удаление объекта из набора /// /// /// private void buttonRemoveLiner_Click(object sender, EventArgs e) { if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } int pos = Convert.ToInt32(textBoxNumber.Text); if (_liners - pos) { MessageBox.Show("Объект удален"); pictureBoxCollection.Image = _liners.ShowLiners(); } else { MessageBox.Show("Не удалось удалить объект"); } } /// /// Обновление рисунка по набору /// /// /// private void buttonRefreshCollection_Click(object sender, EventArgs e) { pictureBoxCollection.Image = _liners.ShowLiners(); } } }