ISEbd-22 Alimova M.S. Lab Work 03 Hard #3

Closed
malimova wants to merge 11 commits from Lab3 into Lab2
2 changed files with 74 additions and 32 deletions
Showing only changes of commit 69a0414756 - Show all commits

View File

@ -29,11 +29,11 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
pictureBoxCollection = new PictureBox();
buttonAddPlane = new Button();
maskedTextBoxNumber = new MaskedTextBox();
buttonRemovePlane = new Button();
buttonRefreshCollection = new Button();
buttonRemovePlane = new Button();
maskedTextBoxNumber = new MaskedTextBox();
buttonAddPlane = new Button();
pictureBoxCollection = new PictureBox();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
SuspendLayout();
@ -51,23 +51,25 @@
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// pictureBoxCollection
// buttonRefreshCollection
//
pictureBoxCollection.Dock = DockStyle.Left;
pictureBoxCollection.Location = new Point(0, 0);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(752, 668);
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
buttonRefreshCollection.Location = new Point(17, 357);
buttonRefreshCollection.Name = "buttonRefreshCollection";
buttonRefreshCollection.Size = new Size(290, 59);
buttonRefreshCollection.TabIndex = 3;
buttonRefreshCollection.Text = "Обновить коллекцию";
buttonRefreshCollection.UseVisualStyleBackColor = true;
buttonRefreshCollection.Click += buttonRefreshCollection_Click;
//
// buttonAddPlane
// buttonRemovePlane
//
buttonAddPlane.Location = new Point(17, 53);
buttonAddPlane.Name = "buttonAddPlane";
buttonAddPlane.Size = new Size(290, 59);
buttonAddPlane.TabIndex = 0;
buttonAddPlane.Text = "Добавить самолет";
buttonAddPlane.UseVisualStyleBackColor = true;
buttonRemovePlane.Location = new Point(17, 213);
buttonRemovePlane.Name = "buttonRemovePlane";
buttonRemovePlane.Size = new Size(290, 59);
buttonRemovePlane.TabIndex = 2;
buttonRemovePlane.Text = "Удалить самолет";
buttonRemovePlane.UseVisualStyleBackColor = true;
buttonRemovePlane.Click += buttonRemovePlane_Click;
//
// maskedTextBoxNumber
//
@ -78,23 +80,24 @@
maskedTextBoxNumber.TabIndex = 1;
maskedTextBoxNumber.ValidatingType = typeof(int);
//
// buttonRemovePlane
// buttonAddPlane
//
buttonRemovePlane.Location = new Point(17, 213);
buttonRemovePlane.Name = "buttonRemovePlane";
buttonRemovePlane.Size = new Size(290, 59);
buttonRemovePlane.TabIndex = 2;
buttonRemovePlane.Text = "Удалить самолет";
buttonRemovePlane.UseVisualStyleBackColor = true;
buttonAddPlane.Location = new Point(17, 53);
buttonAddPlane.Name = "buttonAddPlane";
buttonAddPlane.Size = new Size(290, 59);
buttonAddPlane.TabIndex = 0;
buttonAddPlane.Text = "Добавить самолет";
buttonAddPlane.UseVisualStyleBackColor = true;
buttonAddPlane.Click += buttonAddPlane_Click;
//
// buttonRefreshCollection
// pictureBoxCollection
//
buttonRefreshCollection.Location = new Point(17, 357);
buttonRefreshCollection.Name = "buttonRefreshCollection";
buttonRefreshCollection.Size = new Size(290, 59);
buttonRefreshCollection.TabIndex = 3;
buttonRefreshCollection.Text = "Обновить коллекцию";
buttonRefreshCollection.UseVisualStyleBackColor = true;
pictureBoxCollection.Dock = DockStyle.Left;
pictureBoxCollection.Location = new Point(0, 0);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(752, 668);
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
// FormPlaneCollection
//

View File

@ -12,9 +12,48 @@ namespace AirBomber
{
public partial class FormPlaneCollection : Form
{
private readonly PlanesGenericCollection<DrawningAirPlane, DrawningObjectAirPlane> _planes;
public FormPlaneCollection()
{
InitializeComponent();
_planes = new PlanesGenericCollection<DrawningAirPlane, DrawningObjectAirPlane>(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
private void buttonAddPlane_Click(object sender, EventArgs e)
{
FormAirBomber form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (_planes + form.SelectedPlane != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _planes.ShowPlanes();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
private void buttonRemovePlane_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
if (_planes - pos != null)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _planes.ShowPlanes();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void buttonRefreshCollection_Click(object sender, EventArgs e)
{
pictureBoxCollection.Image = _planes.ShowPlanes();
}
}
}