Всё сделано для усложненки вроде

This commit is contained in:
malimova 2023-12-10 20:22:26 +04:00
parent 294c75c51c
commit d2624a12bb
4 changed files with 80 additions and 6 deletions

View File

@ -89,7 +89,5 @@ namespace AirBomber
engine.GetShape()
);
}
}
}

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
namespace AirBomber
{
@ -14,16 +15,73 @@ namespace AirBomber
{
private DrawningAirPlane _drawningAirPlane;
private AdditionalGeneric<EntityAirPlane, IDrawningEngines> additionalGeneric;
private readonly int _pictureWidth = 200;
private readonly int _pictureHeight = 200;
private readonly int _pictureWidth = 400;
private readonly int _pictureHeight = 400;
Random random = new Random();
public FormAdditionalGeneric()
{
InitializeComponent();
}
private void Draw()
{
if (_drawningAirPlane == null)
{
return;
}
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningAirPlane.DrawPlane(gr);
pictureBoxObject.Image = bmp;
}
private void buttonCreate_Click(object sender, EventArgs e)
{
_drawningAirPlane = additionalGeneric.CreateDrawObject();
int size = random.Next(1, 10);
additionalGeneric = new AdditionalGeneric<EntityAirPlane, IDrawningEngines>(size, _pictureWidth, _pictureHeight);
for (int i = 0; i < size; i++)
{
EntityAirPlane plane = CreateRandomPlane();
IDrawningEngines engines = CreateRandomEngines();
additionalGeneric.Add(plane);
additionalGeneric.Add(engines);
_drawningAirPlane = additionalGeneric.CreateDrawObject();
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
}
public EntityAirPlane CreateRandomPlane()
{
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
EntityAirPlane plane;
switch (random.Next(0, 2))
{
case 1:
plane = new EntityAirBomber(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(2)), Convert.ToBoolean(random.Next(2)));
break;
default:
plane = new EntityAirPlane(random.Next(100, 300), random.Next(1000, 3000), color);
break;
}
return plane;
}
public IDrawningEngines CreateRandomEngines()
{
IDrawningEngines engines;
switch (random.Next(3))
{
case 1:
engines = new DrawningEnginesTriangle();
break;
case 2:
engines = new DrawningEnginesCircle();
break;
default:
engines = new DrawningEnginesRectangle();
break;
}
engines.SetAmount((random.Next(1, 4) * 2));
return engines;
}
}
}

View File

@ -34,12 +34,14 @@
maskedTextBoxNumber = new MaskedTextBox();
buttonAddPlane = new Button();
pictureBoxCollection = new PictureBox();
buttonToFormAddGeneric = new Button();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(buttonToFormAddGeneric);
groupBoxTools.Controls.Add(buttonRefreshCollection);
groupBoxTools.Controls.Add(buttonRemovePlane);
groupBoxTools.Controls.Add(maskedTextBoxNumber);
@ -99,6 +101,16 @@
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
// buttonToFormAddGeneric
//
buttonToFormAddGeneric.Location = new Point(17, 545);
buttonToFormAddGeneric.Name = "buttonToFormAddGeneric";
buttonToFormAddGeneric.Size = new Size(290, 61);
buttonToFormAddGeneric.TabIndex = 4;
buttonToFormAddGeneric.Text = "Перейти к генерации объектов";
buttonToFormAddGeneric.UseVisualStyleBackColor = true;
buttonToFormAddGeneric.Click += buttonToFormAddGeneric_Click;
//
// FormPlaneCollection
//
AutoScaleDimensions = new SizeF(10F, 25F);
@ -122,5 +134,6 @@
private MaskedTextBox maskedTextBoxNumber;
private Button buttonAddPlane;
private PictureBox pictureBoxCollection;
private Button buttonToFormAddGeneric;
}
}

View File

@ -55,5 +55,10 @@ namespace AirBomber
{
pictureBoxCollection.Image = _planes.ShowPlanes();
}
private void buttonToFormAddGeneric_Click(object sender, EventArgs e)
{
FormAdditionalGeneric form = new();
form.ShowDialog();
}
}
}