Compare commits

..

3 Commits

4 changed files with 77 additions and 35 deletions

View File

@ -41,7 +41,7 @@
} }
_drawningAirPlane = new DrawningAirBomber(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, _drawningAirPlane = new DrawningAirBomber(random.Next(100, 300), random.Next(1000, 3000), color, dopColor,
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height); Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height, random.Next(1, 4) * 2, random.Next(0, 4));
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); _drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw(); Draw();
@ -55,7 +55,7 @@
{ {
color = dialog.Color; color = dialog.Color;
} }
_drawningAirPlane = new DrawningAirPlane(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxAirBomber.Width, pictureBoxAirBomber.Height); _drawningAirPlane = new DrawningAirPlane(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxAirBomber.Width, pictureBoxAirBomber.Height, random.Next(1, 4) * 2, random.Next(0, 4));
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); _drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw(); Draw();

View File

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

View File

@ -12,9 +12,48 @@ namespace AirBomber
{ {
public partial class FormPlaneCollection : Form public partial class FormPlaneCollection : Form
{ {
private readonly PlanesGenericCollection<DrawningAirPlane, DrawningObjectAirPlane> _planes;
public FormPlaneCollection() public FormPlaneCollection()
{ {
InitializeComponent(); 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();
} }
} }
} }

View File

@ -11,7 +11,7 @@
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new FormAirBomber()); Application.Run(new FormPlaneCollection());
} }
} }
} }