From 76a9f320c4d103d672af7ddb0c78756d640fb663 Mon Sep 17 00:00:00 2001 From: Alenka Date: Sun, 3 Dec 2023 23:03:06 +0400 Subject: [PATCH] Done --- Cruiser/Cruiser/DrawningAdvancedCruiser.cs | 31 ++++++++++------ Cruiser/Cruiser/EntityAdvancedCruiser.cs | 2 +- Cruiser/Cruiser/FormCruiserConfig.Designer.cs | 22 ++++++------ Cruiser/Cruiser/FormCruiserConfig.cs | 36 ++----------------- 4 files changed, 34 insertions(+), 57 deletions(-) diff --git a/Cruiser/Cruiser/DrawningAdvancedCruiser.cs b/Cruiser/Cruiser/DrawningAdvancedCruiser.cs index d5a35b8..3997a2f 100644 --- a/Cruiser/Cruiser/DrawningAdvancedCruiser.cs +++ b/Cruiser/Cruiser/DrawningAdvancedCruiser.cs @@ -26,24 +26,33 @@ namespace Cruiser.DrawningObjects { return; } - Pen pen = new Pen(Color.Black); Brush addBrush = new SolidBrush(cruiser.AdditionalColor); - Brush brush = new SolidBrush(cruiser.BodyColor); base.DrawTransport(g); if (cruiser.HelicopterPad) { - Brush brYellow = new SolidBrush(Color.Yellow); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20, - 20); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, - 20); + + Point[] trianglePoints1 = + { + new Point(_startPosX + 20, _startPosY + 5), + new Point(_startPosX + 40, _startPosY + 25), + new Point(_startPosX + 60, _startPosY + 5) + }; + + Point[] trianglePoints2 = + { + new Point(_startPosX + 20, _startPosY + 55), + new Point(_startPosX + 40, _startPosY + 35), + new Point(_startPosX + 60, _startPosY + 55) + }; + + g.FillPolygon(addBrush, trianglePoints1); + g.FillPolygon(addBrush, trianglePoints2); } if (cruiser.Coating) { - g.FillEllipse(Brushes.Green, _startPosX + 90, _startPosY + 20, 20, 20); + g.FillEllipse(addBrush, _startPosX + 90, _startPosY + 20, 20, 20); - } - + } } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/Cruiser/Cruiser/EntityAdvancedCruiser.cs b/Cruiser/Cruiser/EntityAdvancedCruiser.cs index f1a7326..dbf25ff 100644 --- a/Cruiser/Cruiser/EntityAdvancedCruiser.cs +++ b/Cruiser/Cruiser/EntityAdvancedCruiser.cs @@ -11,7 +11,7 @@ namespace Cruiser.Entities { public class EntityAdvancedCruiser : EntityCruiser { - public Color AdditionalColor { get; set; } + public Color AdditionalColor { get; private set; } public bool HelicopterPad { get; private set; } public bool Coating { get; private set; } public EntityAdvancedCruiser(int speed, double weight, Color bodyColor, Color diff --git a/Cruiser/Cruiser/FormCruiserConfig.Designer.cs b/Cruiser/Cruiser/FormCruiserConfig.Designer.cs index e837d99..a85fc69 100644 --- a/Cruiser/Cruiser/FormCruiserConfig.Designer.cs +++ b/Cruiser/Cruiser/FormCruiserConfig.Designer.cs @@ -81,16 +81,15 @@ this.groupBoxCruiser.TabStop = false; this.groupBoxCruiser.Text = "Параметры"; // - // checkBox2 + // checkBoxMissileSilos // this.checkBoxMissileSilos.AutoSize = true; this.checkBoxMissileSilos.Location = new System.Drawing.Point(33, 277); - this.checkBoxMissileSilos.Name = "checkBox2"; + this.checkBoxMissileSilos.Name = "checkBoxMissileSilos"; this.checkBoxMissileSilos.Size = new System.Drawing.Size(232, 29); this.checkBoxMissileSilos.TabIndex = 12; this.checkBoxMissileSilos.Text = "Наличие ракетных шахт"; this.checkBoxMissileSilos.UseVisualStyleBackColor = true; - this.checkBoxMissileSilos.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged); // // buttonCancel // @@ -104,7 +103,7 @@ // buttonAdd // this.buttonAdd.Location = new System.Drawing.Point(838, 321); - this.buttonAdd.Name = "button1"; + this.buttonAdd.Name = "buttonAdd"; this.buttonAdd.Size = new System.Drawing.Size(136, 38); this.buttonAdd.TabIndex = 10; this.buttonAdd.Text = "Добавить"; @@ -134,7 +133,7 @@ this.label_addit_color.TabIndex = 10; this.label_addit_color.Text = "Доп.цвет"; this.label_addit_color.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.label_addit_color.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragDrop); + this.label_addit_color.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelColor_DragDrop); this.label_addit_color.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter); // // label_color @@ -293,7 +292,7 @@ 0, 0}); // - // numericUpDown1 + // numericUpDownSpeed // this.numericUpDownSpeed.Location = new System.Drawing.Point(128, 75); this.numericUpDownSpeed.Maximum = new decimal(new int[] { @@ -306,7 +305,7 @@ 0, 0, 0}); - this.numericUpDownSpeed.Name = "numericUpDown1"; + this.numericUpDownSpeed.Name = "numericUpDownSpeed"; this.numericUpDownSpeed.Size = new System.Drawing.Size(74, 31); this.numericUpDownSpeed.TabIndex = 2; this.numericUpDownSpeed.Value = new decimal(new int[] { @@ -319,7 +318,7 @@ // this.labelWeight.AutoSize = true; this.labelWeight.Location = new System.Drawing.Point(33, 145); - this.labelWeight.Name = "label2"; + this.labelWeight.Name = "labelWeight"; this.labelWeight.Size = new System.Drawing.Size(43, 25); this.labelWeight.TabIndex = 1; this.labelWeight.Text = "Вес:"; @@ -328,20 +327,19 @@ // this.labelSpeed.AutoSize = true; this.labelSpeed.Location = new System.Drawing.Point(33, 75); - this.labelSpeed.Name = "label1"; + this.labelSpeed.Name = "labelSpeed"; this.labelSpeed.Size = new System.Drawing.Size(93, 25); this.labelSpeed.TabIndex = 0; this.labelSpeed.Text = "Скорость:"; // - // Form2 + // FormCruiserConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1279, 552); this.Controls.Add(this.groupBoxCruiser); - this.Name = "Form2"; + this.Name = "FormCruiserConfig"; this.Text = "Создание объекта"; - this.Load += new System.EventHandler(this.Form2_Load); this.groupBoxCruiser.ResumeLayout(false); this.groupBoxCruiser.PerformLayout(); this.panelOrchid.ResumeLayout(false); diff --git a/Cruiser/Cruiser/FormCruiserConfig.cs b/Cruiser/Cruiser/FormCruiserConfig.cs index ad8901d..c6d06c7 100644 --- a/Cruiser/Cruiser/FormCruiserConfig.cs +++ b/Cruiser/Cruiser/FormCruiserConfig.cs @@ -17,8 +17,6 @@ namespace Cruiser { DrawningCruiser? _cruiser = null; public event Action? EventAddCruiser; - - public FormCruiserConfig() { InitializeComponent(); @@ -30,8 +28,6 @@ namespace Cruiser panelViolet.MouseDown += PanelColor_MouseDown; panelPurple.MouseDown += PanelColor_MouseDown; panelOrchid.MouseDown += PanelColor_MouseDown; - labelBasic.MouseDown += LabelObject_MouseDown; - labelAdvanced.MouseDown += LabelObject_MouseDown; buttonCancel.Click += (s, e) => Close(); } @@ -89,21 +85,18 @@ namespace Cruiser label_addit_color.BackColor = Color.Empty; DrawCruiser(); } - private void PanelColor_MouseDown(object? sender, MouseEventArgs e) { (sender as Control)?.DoDragDrop((sender as Control)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); } - private void ButtonAdd_Click(object sender, EventArgs e) { EventAddCruiser?.Invoke(_cruiser); Close(); } - private void labelColor_DragDrop(object sender, DragEventArgs e) { - if (_cruiser == null) + if (_cruiser?.EntityCruiser == null) return; switch (((Label)sender).Name) { @@ -116,9 +109,8 @@ namespace Cruiser (_cruiser.EntityCruiser as EntityAdvancedCruiser)?.setAdditionalColor(color: (Color)e.Data.GetData(typeof(Color))); break; } - DrawCruiser(); + DrawCruiser(); } - private void labelColor_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(Color))) @@ -130,27 +122,5 @@ namespace Cruiser e.Effect = DragDropEffects.None; } } - private void labelAddColor_DragDrop(object sender, DragEventArgs e) - { - if ((_cruiser?.EntityCruiser == null) || (_cruiser is DrawningAdvancedCruiser == false)) - return; - Color additionalColor = (Color)e.Data.GetData(typeof(Color)); - _cruiser = new DrawningAdvancedCruiser((int)numericUpDownSpeed.Value, - (int)numericUpDownWeight.Value, _cruiser.EntityCruiser.BodyColor, additionalColor, checkBoxHelicopterPad.Checked, - checkBoxHelicopterPad.Checked, pictureBoxCruiser.Height, pictureBoxCruiser.Width); - DrawCruiser(); - } - private void Form2_Load(object sender, EventArgs e) - { - - } - - private void checkBox2_CheckedChanged(object sender, EventArgs e) - { - - } } - - - } - +} \ No newline at end of file