PIbd-21_SagirovM.M_Liner_Base/Liner/FormLinerCollection.cs
2023-11-24 12:39:11 +04:00

89 lines
2.9 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 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
{
/// <summary>
/// Форма для работы с набором объектов класса DrawingLiner
/// </summary>
public partial class FormLinerCollection : Form
{
/// <summary>
/// Набор объектов
/// </summary>
private readonly LinerGenericCollection<DrawingLiner, DrawingObjectLiner> _liners;
/// <summary>
/// Конструктор
/// </summary>
public FormLinerCollection()
{
InitializeComponent();
_liners = new LinerGenericCollection<DrawingLiner,
DrawingObjectLiner>(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
/// <summary>
/// Добавление объекта в набор
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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("Не удалось добавить объект");
}
}
}
/// <summary>
/// Удаление объекта из набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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("Не удалось удалить объект");
}
}
/// <summary>
/// Обновление рисунка по набору
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonRefreshCollection_Click(object sender, EventArgs e)
{
pictureBoxCollection.Image = _liners.ShowLiners();
}
}
}