From 69a0414756ff35a60810b56f683e989f9b233103 Mon Sep 17 00:00:00 2001 From: malimova Date: Sun, 10 Dec 2023 14:44:55 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=BF=D0=B8=D1=81=D0=B0?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D1=8B-=D0=BA=D0=BE=D0=BB=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirBomber/FormPlaneCollection.Designer.cs | 67 ++++++++++--------- AirBomber/AirBomber/FormPlaneCollection.cs | 39 +++++++++++ 2 files changed, 74 insertions(+), 32 deletions(-) diff --git a/AirBomber/AirBomber/FormPlaneCollection.Designer.cs b/AirBomber/AirBomber/FormPlaneCollection.Designer.cs index 7f7ef81..90f87b5 100644 --- a/AirBomber/AirBomber/FormPlaneCollection.Designer.cs +++ b/AirBomber/AirBomber/FormPlaneCollection.Designer.cs @@ -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 // diff --git a/AirBomber/AirBomber/FormPlaneCollection.cs b/AirBomber/AirBomber/FormPlaneCollection.cs index 28a9d7e..d473899 100644 --- a/AirBomber/AirBomber/FormPlaneCollection.cs +++ b/AirBomber/AirBomber/FormPlaneCollection.cs @@ -12,9 +12,48 @@ namespace AirBomber { public partial class FormPlaneCollection : Form { + private readonly PlanesGenericCollection _planes; public FormPlaneCollection() { InitializeComponent(); + _planes = new PlanesGenericCollection(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(); } } }