From d2624a12bbf7e5e62af2b7ec44a322eb6c155749 Mon Sep 17 00:00:00 2001 From: malimova Date: Sun, 10 Dec 2023 20:22:26 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D1=91=20=D1=81=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=20=D0=B4=D0=BB=D1=8F=20=D1=83=D1=81=D0=BB?= =?UTF-8?q?=D0=BE=D0=B6=D0=BD=D0=B5=D0=BD=D0=BA=D0=B8=20=D0=B2=D1=80=D0=BE?= =?UTF-8?q?=D0=B4=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AdditionalGeneric.cs | 2 - AirBomber/AirBomber/FormAdditionalGeneric.cs | 66 +++++++++++++++++-- .../AirBomber/FormPlaneCollection.Designer.cs | 13 ++++ AirBomber/AirBomber/FormPlaneCollection.cs | 5 ++ 4 files changed, 80 insertions(+), 6 deletions(-) diff --git a/AirBomber/AirBomber/AdditionalGeneric.cs b/AirBomber/AirBomber/AdditionalGeneric.cs index a6f1201..4b691f5 100644 --- a/AirBomber/AirBomber/AdditionalGeneric.cs +++ b/AirBomber/AirBomber/AdditionalGeneric.cs @@ -89,7 +89,5 @@ namespace AirBomber engine.GetShape() ); } - - } } diff --git a/AirBomber/AirBomber/FormAdditionalGeneric.cs b/AirBomber/AirBomber/FormAdditionalGeneric.cs index 804620b..326f840 100644 --- a/AirBomber/AirBomber/FormAdditionalGeneric.cs +++ b/AirBomber/AirBomber/FormAdditionalGeneric.cs @@ -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 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(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; } } } diff --git a/AirBomber/AirBomber/FormPlaneCollection.Designer.cs b/AirBomber/AirBomber/FormPlaneCollection.Designer.cs index 90f87b5..063c470 100644 --- a/AirBomber/AirBomber/FormPlaneCollection.Designer.cs +++ b/AirBomber/AirBomber/FormPlaneCollection.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormPlaneCollection.cs b/AirBomber/AirBomber/FormPlaneCollection.cs index d473899..d7b25d1 100644 --- a/AirBomber/AirBomber/FormPlaneCollection.cs +++ b/AirBomber/AirBomber/FormPlaneCollection.cs @@ -55,5 +55,10 @@ namespace AirBomber { pictureBoxCollection.Image = _planes.ShowPlanes(); } + private void buttonToFormAddGeneric_Click(object sender, EventArgs e) + { + FormAdditionalGeneric form = new(); + form.ShowDialog(); + } } }