From 7372ee4bd3a952caa6f5d070f66fc6ffadaa0a46 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sun, 8 Oct 2023 13:01:38 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=20FormPlaneCollec?= =?UTF-8?q?tion=20=D0=B8=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=B5=D0=B5=20=D0=BB=D0=BE=D0=B3?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormPlaneCollection.Designer.cs | 128 ++++++++++++++++++ .../FormPlaneCollection.cs | 83 ++++++++++++ .../FormPlaneCollection.resx | 120 ++++++++++++++++ 3 files changed, 331 insertions(+) create mode 100644 ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs create mode 100644 ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs create mode 100644 ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.resx diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs new file mode 100644 index 0000000..03ec76e --- /dev/null +++ b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs @@ -0,0 +1,128 @@ +namespace ProjectStormtrooper +{ + partial class FormPlaneCollection + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + groupBoxTools = new GroupBox(); + maskedTextBoxNumber = new MaskedTextBox(); + buttonRefreshCollection = new Button(); + buttonRemovePlane = new Button(); + buttonAddPlane = new Button(); + pictureBoxCollection = new PictureBox(); + groupBoxTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit(); + SuspendLayout(); + // + // groupBoxTools + // + groupBoxTools.Controls.Add(maskedTextBoxNumber); + groupBoxTools.Controls.Add(buttonRefreshCollection); + groupBoxTools.Controls.Add(buttonRemovePlane); + groupBoxTools.Controls.Add(buttonAddPlane); + groupBoxTools.Dock = DockStyle.Right; + groupBoxTools.Location = new Point(787, 0); + groupBoxTools.Name = "groupBoxTools"; + groupBoxTools.Size = new Size(230, 538); + groupBoxTools.TabIndex = 0; + groupBoxTools.TabStop = false; + groupBoxTools.Text = "Инструменты"; + // + // maskedTextBoxNumber + // + maskedTextBoxNumber.Location = new Point(6, 87); + maskedTextBoxNumber.Mask = "00"; + maskedTextBoxNumber.Name = "maskedTextBoxNumber"; + maskedTextBoxNumber.Size = new Size(218, 27); + maskedTextBoxNumber.TabIndex = 4; + maskedTextBoxNumber.TextAlign = HorizontalAlignment.Center; + maskedTextBoxNumber.ValidatingType = typeof(int); + // + // buttonRefreshCollection + // + buttonRefreshCollection.Location = new Point(6, 180); + buttonRefreshCollection.Name = "buttonRefreshCollection"; + buttonRefreshCollection.Size = new Size(218, 29); + buttonRefreshCollection.TabIndex = 3; + buttonRefreshCollection.Text = "Обновить коллекцию"; + buttonRefreshCollection.UseVisualStyleBackColor = true; + buttonRefreshCollection.Click += buttonRefreshCollection_Click; + // + // buttonRemovePlane + // + buttonRemovePlane.Location = new Point(6, 120); + buttonRemovePlane.Name = "buttonRemovePlane"; + buttonRemovePlane.Size = new Size(218, 29); + buttonRemovePlane.TabIndex = 2; + buttonRemovePlane.Text = "Удалить самолет"; + buttonRemovePlane.UseVisualStyleBackColor = true; + buttonRemovePlane.Click += buttonRemovePlane_Click; + // + // buttonAddPlane + // + buttonAddPlane.Location = new Point(6, 26); + buttonAddPlane.Name = "buttonAddPlane"; + buttonAddPlane.Size = new Size(218, 29); + buttonAddPlane.TabIndex = 0; + buttonAddPlane.Text = "Добавить самолет"; + buttonAddPlane.UseVisualStyleBackColor = true; + buttonAddPlane.Click += buttonAddPlane_Click; + // + // pictureBoxCollection + // + pictureBoxCollection.Dock = DockStyle.Fill; + pictureBoxCollection.Location = new Point(0, 0); + pictureBoxCollection.Name = "pictureBoxCollection"; + pictureBoxCollection.Size = new Size(787, 538); + pictureBoxCollection.TabIndex = 1; + pictureBoxCollection.TabStop = false; + // + // FormPlaneCollection + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1017, 538); + Controls.Add(pictureBoxCollection); + Controls.Add(groupBoxTools); + Name = "FormPlaneCollection"; + Text = "Набор самолетов"; + groupBoxTools.ResumeLayout(false); + groupBoxTools.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxTools; + private Button buttonRefreshCollection; + private Button buttonRemovePlane; + private Button buttonAddPlane; + private MaskedTextBox maskedTextBoxNumber; + private PictureBox pictureBoxCollection; + } +} \ No newline at end of file diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs new file mode 100644 index 0000000..baad70d --- /dev/null +++ b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs @@ -0,0 +1,83 @@ +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 ProjectStormtrooper +{ + /// + /// Форма для работы с набором объектов класса DrawningPlane + /// + 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) + { + FormStormtrooper form = new(); + if (form.ShowDialog() == DialogResult.OK) + { + if (_planes + form.SelectedPlane) + { + 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(); + } + } +} diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.resx b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.resx new file mode 100644 index 0000000..a395bff --- /dev/null +++ b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file