From bd7a35bdf7462664d47199687f07d5bc077830f3 Mon Sep 17 00:00:00 2001 From: KirillFirsof <117719052+KirillFirsof@users.noreply.github.com> Date: Thu, 9 Nov 2023 19:09:59 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=82?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D0=BE=20=D0=B2=D1=81=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RPP_FirstLaba_Tractor/FormTractor.cs | 53 +++++++------------ .../FormTractorCollection.cs | 4 ++ .../RPP_FirstLaba_Tractor/SetGeneric.cs | 2 +- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs index f0055aa..4c4dd75 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs @@ -59,31 +59,6 @@ namespace ProjectTractor pictureBoxTractor.Image = bmp; } /// - /// Обработка нажатия кнопки "Создать" - /// - /// - /// - private void ButtonCreateBulldoserTractor_Click(object sender, EventArgs e) - { - Random random = new(); - Color color = Color.FromArgb(random.Next(0, 256), - random.Next(0, 256), random.Next(0, 256)); - //TODO выбор основного цвета - Color dopColor = Color.FromArgb(random.Next(0, 256), - random.Next(0, 256), random.Next(0, 256)); - //TODO выбор дополнительного цвета - _drawningTractor = new DrawningBulldoser(random.Next(100, 300), - random.Next(1000, 3000), - color, - dopColor, - Convert.ToBoolean(random.Next(0, 2)), - Convert.ToBoolean(random.Next(0, 2)), - pictureBoxTractor.Width, - pictureBoxTractor.Height); - _drawningTractor.SetPosition(random.Next(10, 100), random.Next(10, 100)); - Draw(); - } - /// /// Изменение размеров формы /// /// @@ -336,19 +311,30 @@ namespace ProjectTractor private void buttonCreateBulldoserTractor_Click(object sender, EventArgs e) { Random random = new(); + Color color = Color.FromArgb(random.Next(0, 256), + random.Next(0, 256), random.Next(0, 256)); + ColorDialog dialogColor = new(); + if (dialogColor.ShowDialog() == DialogResult.OK) + { + color = dialogColor.Color; + } + Color dopColor = Color.FromArgb(random.Next(0, 256), + random.Next(0, 256), random.Next(0, 256)); + ColorDialog dialogDopColor = new(); + if (dialogDopColor.ShowDialog() == DialogResult.OK) + { + dopColor = dialogDopColor.Color; + } _drawningTractor = new DrawningBulldoser(random.Next(100, 300), random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), - random.Next(0, 256)), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), - random.Next(0, 256)), + color, + dopColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), - pictureBoxTractor.Width, pictureBoxTractor.Height); - _drawningTractor.SetPosition(random.Next(10, 100), random.Next(10, - 100)); + pictureBoxTractor.Width, + pictureBoxTractor.Height); + _drawningTractor.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); - } private void buttonStep_Click(object sender, EventArgs e) @@ -387,6 +373,5 @@ namespace ProjectTractor _strategy = null; } } - } } \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs index 6b3e486..ce60c1b 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs @@ -158,7 +158,11 @@ namespace ProjectTractor this.ClientSize = new System.Drawing.Size(893, 437); this.Controls.Add(this.groupBox); this.Controls.Add(this.pictureBoxCollection); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MinimizeBox = false; this.Name = "FormTractorCollection"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Набор тракторов"; ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit(); this.groupBox.ResumeLayout(false); this.groupBox.PerformLayout(); diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/SetGeneric.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/SetGeneric.cs index 4ce7be5..6ca1fd8 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/SetGeneric.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/SetGeneric.cs @@ -38,7 +38,7 @@ namespace ProjectTractor.Generics } else { - Insert(tractor, 0); + return Insert(tractor, 0); } return true; }