From 915ad9016278cfa3331daedb11b197899d814365 Mon Sep 17 00:00:00 2001 From: Salikh Date: Tue, 28 Nov 2023 03:03:58 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/FormBomberConfig.Designer.cs | 341 +++++++++++++++++++++++++ AirBomber/FormBomberConfig.cs | 20 ++ AirBomber/FormBomberConfig.resx | 120 +++++++++ 3 files changed, 481 insertions(+) create mode 100644 AirBomber/FormBomberConfig.Designer.cs create mode 100644 AirBomber/FormBomberConfig.cs create mode 100644 AirBomber/FormBomberConfig.resx diff --git a/AirBomber/FormBomberConfig.Designer.cs b/AirBomber/FormBomberConfig.Designer.cs new file mode 100644 index 0000000..eaf97c6 --- /dev/null +++ b/AirBomber/FormBomberConfig.Designer.cs @@ -0,0 +1,341 @@ +namespace AirBomber +{ + partial class FormBomberConfig + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + groupBox1 = new GroupBox(); + weight = new Label(); + speed = new Label(); + SpeedNumericUpDown = new NumericUpDown(); + WeightNumericUpDown = new NumericUpDown(); + bakCheckBox = new CheckBox(); + rocketCheckBox = new CheckBox(); + colorGroupBox = new GroupBox(); + redPanel = new Panel(); + greenPanel = new Panel(); + bluePanel = new Panel(); + yellowPanel = new Panel(); + purplePanel = new Panel(); + blackPanel = new Panel(); + greyPanel = new Panel(); + whitePanel = new Panel(); + easyLabel = new Label(); + hardLabel = new Label(); + PanelColor = new Panel(); + pictureBox1 = new PictureBox(); + labelColor = new Label(); + labelDopColor = new Label(); + AddButton = new Button(); + buttonStop = new Button(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).BeginInit(); + ((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).BeginInit(); + colorGroupBox.SuspendLayout(); + PanelColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + SuspendLayout(); + // + // groupBox1 + // + groupBox1.Controls.Add(hardLabel); + groupBox1.Controls.Add(easyLabel); + groupBox1.Controls.Add(colorGroupBox); + groupBox1.Controls.Add(rocketCheckBox); + groupBox1.Controls.Add(bakCheckBox); + groupBox1.Controls.Add(WeightNumericUpDown); + groupBox1.Controls.Add(SpeedNumericUpDown); + groupBox1.Controls.Add(weight); + groupBox1.Controls.Add(speed); + groupBox1.Location = new Point(12, 12); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(636, 296); + groupBox1.TabIndex = 0; + groupBox1.TabStop = false; + groupBox1.Text = "Параметры"; + // + // weight + // + weight.AutoSize = true; + weight.Location = new Point(15, 84); + weight.Name = "weight"; + weight.Size = new Size(40, 20); + weight.TabIndex = 1; + weight.Text = "Вес: "; + // + // speed + // + speed.AutoSize = true; + speed.Location = new Point(15, 41); + speed.Name = "speed"; + speed.Size = new Size(80, 20); + speed.TabIndex = 0; + speed.Text = "Скорость: "; + // + // SpeedNumericUpDown + // + SpeedNumericUpDown.Location = new Point(113, 34); + SpeedNumericUpDown.Name = "SpeedNumericUpDown"; + SpeedNumericUpDown.Size = new Size(83, 27); + SpeedNumericUpDown.TabIndex = 2; + SpeedNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // WeightNumericUpDown + // + WeightNumericUpDown.Location = new Point(113, 82); + WeightNumericUpDown.Name = "WeightNumericUpDown"; + WeightNumericUpDown.Size = new Size(83, 27); + WeightNumericUpDown.TabIndex = 3; + WeightNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // bakCheckBox + // + bakCheckBox.AutoSize = true; + bakCheckBox.Location = new Point(15, 152); + bakCheckBox.Name = "bakCheckBox"; + bakCheckBox.Size = new Size(199, 24); + bakCheckBox.TabIndex = 4; + bakCheckBox.Text = "Признак наличия баков"; + bakCheckBox.UseVisualStyleBackColor = true; + // + // rocketCheckBox + // + rocketCheckBox.AutoSize = true; + rocketCheckBox.Location = new Point(15, 200); + rocketCheckBox.Name = "rocketCheckBox"; + rocketCheckBox.Size = new Size(196, 24); + rocketCheckBox.TabIndex = 5; + rocketCheckBox.Text = "Признак наличия ракет"; + rocketCheckBox.UseVisualStyleBackColor = true; + // + // colorGroupBox + // + colorGroupBox.Controls.Add(purplePanel); + colorGroupBox.Controls.Add(blackPanel); + colorGroupBox.Controls.Add(greyPanel); + colorGroupBox.Controls.Add(whitePanel); + colorGroupBox.Controls.Add(yellowPanel); + colorGroupBox.Controls.Add(bluePanel); + colorGroupBox.Controls.Add(greenPanel); + colorGroupBox.Controls.Add(redPanel); + colorGroupBox.Location = new Point(248, 34); + colorGroupBox.Name = "colorGroupBox"; + colorGroupBox.Size = new Size(315, 176); + colorGroupBox.TabIndex = 6; + colorGroupBox.TabStop = false; + colorGroupBox.Text = "Цвета"; + // + // redPanel + // + redPanel.BackColor = Color.Red; + redPanel.Location = new Point(18, 37); + redPanel.Name = "redPanel"; + redPanel.Size = new Size(50, 50); + redPanel.TabIndex = 0; + // + // greenPanel + // + greenPanel.BackColor = Color.FromArgb(0, 192, 0); + greenPanel.Location = new Point(97, 37); + greenPanel.Name = "greenPanel"; + greenPanel.Size = new Size(50, 50); + greenPanel.TabIndex = 1; + // + // bluePanel + // + bluePanel.BackColor = Color.Blue; + bluePanel.Location = new Point(174, 37); + bluePanel.Name = "bluePanel"; + bluePanel.Size = new Size(50, 50); + bluePanel.TabIndex = 1; + // + // yellowPanel + // + yellowPanel.BackColor = Color.Yellow; + yellowPanel.Location = new Point(250, 37); + yellowPanel.Name = "yellowPanel"; + yellowPanel.Size = new Size(50, 50); + yellowPanel.TabIndex = 1; + // + // purplePanel + // + purplePanel.BackColor = Color.Purple; + purplePanel.Location = new Point(250, 103); + purplePanel.Name = "purplePanel"; + purplePanel.Size = new Size(50, 50); + purplePanel.TabIndex = 3; + // + // blackPanel + // + blackPanel.BackColor = Color.Black; + blackPanel.Location = new Point(174, 103); + blackPanel.Name = "blackPanel"; + blackPanel.Size = new Size(50, 50); + blackPanel.TabIndex = 4; + // + // greyPanel + // + greyPanel.BackColor = Color.Silver; + greyPanel.Location = new Point(97, 103); + greyPanel.Name = "greyPanel"; + greyPanel.Size = new Size(50, 50); + greyPanel.TabIndex = 5; + // + // whitePanel + // + whitePanel.BackColor = Color.White; + whitePanel.Location = new Point(18, 103); + whitePanel.Name = "whitePanel"; + whitePanel.Size = new Size(50, 50); + whitePanel.TabIndex = 2; + // + // easyLabel + // + easyLabel.BorderStyle = BorderStyle.FixedSingle; + easyLabel.Location = new Point(266, 228); + easyLabel.Name = "easyLabel"; + easyLabel.Size = new Size(116, 47); + easyLabel.TabIndex = 7; + easyLabel.Text = "Простой"; + easyLabel.TextAlign = ContentAlignment.MiddleCenter; + // + // hardLabel + // + hardLabel.BorderStyle = BorderStyle.FixedSingle; + hardLabel.Location = new Point(421, 228); + hardLabel.Name = "hardLabel"; + hardLabel.Size = new Size(127, 47); + hardLabel.TabIndex = 8; + hardLabel.Text = "Продвинутый"; + hardLabel.TextAlign = ContentAlignment.MiddleCenter; + // + // PanelColor + // + PanelColor.AllowDrop = true; + PanelColor.Controls.Add(labelDopColor); + PanelColor.Controls.Add(labelColor); + PanelColor.Controls.Add(pictureBox1); + PanelColor.Location = new Point(654, 12); + PanelColor.Name = "PanelColor"; + PanelColor.Size = new Size(304, 275); + PanelColor.TabIndex = 2; + // + // pictureBox1 + // + pictureBox1.Location = new Point(12, 54); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new Size(284, 209); + pictureBox1.TabIndex = 0; + pictureBox1.TabStop = false; + // + // labelColor + // + labelColor.BorderStyle = BorderStyle.FixedSingle; + labelColor.Location = new Point(12, 12); + labelColor.Name = "labelColor"; + labelColor.Size = new Size(134, 34); + labelColor.TabIndex = 1; + labelColor.Text = "Цвет"; + labelColor.TextAlign = ContentAlignment.MiddleCenter; + // + // labelDopColor + // + labelDopColor.BorderStyle = BorderStyle.FixedSingle; + labelDopColor.Location = new Point(152, 12); + labelDopColor.Name = "labelDopColor"; + labelDopColor.Size = new Size(144, 34); + labelDopColor.TabIndex = 2; + labelDopColor.Text = "Доп. цвет"; + labelDopColor.TextAlign = ContentAlignment.MiddleCenter; + // + // AddButton + // + AddButton.Location = new Point(661, 293); + AddButton.Name = "AddButton"; + AddButton.Size = new Size(139, 36); + AddButton.TabIndex = 3; + AddButton.Text = "Добавить"; + AddButton.UseVisualStyleBackColor = true; + // + // buttonStop + // + buttonStop.Location = new Point(806, 293); + buttonStop.Name = "buttonStop"; + buttonStop.Size = new Size(131, 36); + buttonStop.TabIndex = 4; + buttonStop.Text = "Отмена"; + buttonStop.UseVisualStyleBackColor = true; + // + // FormBomberConfig + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(962, 337); + Controls.Add(buttonStop); + Controls.Add(AddButton); + Controls.Add(PanelColor); + Controls.Add(groupBox1); + Name = "FormBomberConfig"; + Text = "FormBomberConfig"; + groupBox1.ResumeLayout(false); + groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).EndInit(); + ((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).EndInit(); + colorGroupBox.ResumeLayout(false); + PanelColor.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBox1; + private Label weight; + private Label speed; + private GroupBox colorGroupBox; + private Panel purplePanel; + private Panel blackPanel; + private Panel greyPanel; + private Panel whitePanel; + private Panel yellowPanel; + private Panel bluePanel; + private Panel greenPanel; + private Panel redPanel; + private CheckBox rocketCheckBox; + private CheckBox bakCheckBox; + private NumericUpDown WeightNumericUpDown; + private NumericUpDown SpeedNumericUpDown; + private Label hardLabel; + private Label easyLabel; + private Panel PanelColor; + private Label labelDopColor; + private Label labelColor; + private PictureBox pictureBox1; + private Button AddButton; + private Button buttonStop; + } +} \ No newline at end of file diff --git a/AirBomber/FormBomberConfig.cs b/AirBomber/FormBomberConfig.cs new file mode 100644 index 0000000..630a3a4 --- /dev/null +++ b/AirBomber/FormBomberConfig.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AirBomber +{ + public partial class FormBomberConfig : Form + { + public FormBomberConfig() + { + InitializeComponent(); + } + } +} diff --git a/AirBomber/FormBomberConfig.resx b/AirBomber/FormBomberConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/AirBomber/FormBomberConfig.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file -- 2.25.1 From eb8186c60aeb1169e6529ccaf1512bc849616cd8 Mon Sep 17 00:00:00 2001 From: Salikh Date: Tue, 28 Nov 2023 03:36:41 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/EntityAirBomber.cs | 2 +- AirBomber/EntityBomber.cs | 2 +- AirBomber/FormBomberCollection.cs | 34 +-- AirBomber/FormBomberConfig.Designer.cs | 296 +++++++++++++------------ AirBomber/FormBomberConfig.cs | 127 ++++++++++- 5 files changed, 305 insertions(+), 156 deletions(-) diff --git a/AirBomber/EntityAirBomber.cs b/AirBomber/EntityAirBomber.cs index 8f28c76..bc994ba 100644 --- a/AirBomber/EntityAirBomber.cs +++ b/AirBomber/EntityAirBomber.cs @@ -2,7 +2,7 @@ { public class EntityAirBomber : EntityBomber { - public Color DopColor { get; private set; } + public Color DopColor { get; set; } public bool Toplivo { get; private set; } public bool Rocket { get; private set; } diff --git a/AirBomber/EntityBomber.cs b/AirBomber/EntityBomber.cs index c3c3657..9273efc 100644 --- a/AirBomber/EntityBomber.cs +++ b/AirBomber/EntityBomber.cs @@ -10,7 +10,7 @@ namespace AirBomber.Entities { public int Speed { get; private set; } public double Weight { get; private set; } - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } public double Step => (double)Speed * 100 / Weight; public EntityBomber(int speed, double weight, Color bodycolor) diff --git a/AirBomber/FormBomberCollection.cs b/AirBomber/FormBomberCollection.cs index 57eb04f..9fce61b 100644 --- a/AirBomber/FormBomberCollection.cs +++ b/AirBomber/FormBomberCollection.cs @@ -64,24 +64,28 @@ namespace AirBomber { return; } - var obj = _bomber[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; - if (obj == null) + var formBomberConfig = new FormBomberConfig(); + + formBomberConfig.AddEvent(bomber => { - return; - } - FormAirBomber form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - if (obj + form.SelectedBomber != 1) + if (listBoxStorages.SelectedIndex != -1) { - MessageBox.Show("Объект добавлен"); - PicBoxBomberCollection.Image = obj.ShowBomber(); + var obj = _bomber[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]; + if (obj != null) + { + if (obj + bomber != 1) + { + MessageBox.Show("Объект добавлен"); + PicBoxBomberCollection.Image = obj.ShowBomber(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + }); + formBomberConfig.Show(); } private void ButtonRemoveBomber_Click(object sender, EventArgs e) diff --git a/AirBomber/FormBomberConfig.Designer.cs b/AirBomber/FormBomberConfig.Designer.cs index eaf97c6..a3f3706 100644 --- a/AirBomber/FormBomberConfig.Designer.cs +++ b/AirBomber/FormBomberConfig.Designer.cs @@ -29,35 +29,35 @@ private void InitializeComponent() { groupBox1 = new GroupBox(); - weight = new Label(); - speed = new Label(); - SpeedNumericUpDown = new NumericUpDown(); - WeightNumericUpDown = new NumericUpDown(); - bakCheckBox = new CheckBox(); - rocketCheckBox = new CheckBox(); + hardLabel = new Label(); + easyLabel = new Label(); colorGroupBox = new GroupBox(); - redPanel = new Panel(); - greenPanel = new Panel(); - bluePanel = new Panel(); - yellowPanel = new Panel(); purplePanel = new Panel(); blackPanel = new Panel(); greyPanel = new Panel(); whitePanel = new Panel(); - easyLabel = new Label(); - hardLabel = new Label(); + yellowPanel = new Panel(); + bluePanel = new Panel(); + greenPanel = new Panel(); + redPanel = new Panel(); + rocketCheckBox = new CheckBox(); + bakCheckBox = new CheckBox(); + WeightNumericUpDown = new NumericUpDown(); + SpeedNumericUpDown = new NumericUpDown(); + weight = new Label(); + speed = new Label(); PanelColor = new Panel(); - pictureBox1 = new PictureBox(); - labelColor = new Label(); labelDopColor = new Label(); + labelColor = new Label(); + pictureBoxConfig = new PictureBox(); AddButton = new Button(); buttonStop = new Button(); groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).BeginInit(); - ((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).BeginInit(); colorGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).BeginInit(); + ((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).BeginInit(); PanelColor.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxConfig).BeginInit(); SuspendLayout(); // // groupBox1 @@ -78,59 +78,27 @@ groupBox1.TabStop = false; groupBox1.Text = "Параметры"; // - // weight + // hardLabel // - weight.AutoSize = true; - weight.Location = new Point(15, 84); - weight.Name = "weight"; - weight.Size = new Size(40, 20); - weight.TabIndex = 1; - weight.Text = "Вес: "; + hardLabel.BorderStyle = BorderStyle.FixedSingle; + hardLabel.Location = new Point(421, 228); + hardLabel.Name = "hardLabel"; + hardLabel.Size = new Size(127, 47); + hardLabel.TabIndex = 8; + hardLabel.Text = "Продвинутый"; + hardLabel.TextAlign = ContentAlignment.MiddleCenter; + hardLabel.MouseDown += LableObject_MouseDown; // - // speed + // easyLabel // - speed.AutoSize = true; - speed.Location = new Point(15, 41); - speed.Name = "speed"; - speed.Size = new Size(80, 20); - speed.TabIndex = 0; - speed.Text = "Скорость: "; - // - // SpeedNumericUpDown - // - SpeedNumericUpDown.Location = new Point(113, 34); - SpeedNumericUpDown.Name = "SpeedNumericUpDown"; - SpeedNumericUpDown.Size = new Size(83, 27); - SpeedNumericUpDown.TabIndex = 2; - SpeedNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 }); - // - // WeightNumericUpDown - // - WeightNumericUpDown.Location = new Point(113, 82); - WeightNumericUpDown.Name = "WeightNumericUpDown"; - WeightNumericUpDown.Size = new Size(83, 27); - WeightNumericUpDown.TabIndex = 3; - WeightNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 }); - // - // bakCheckBox - // - bakCheckBox.AutoSize = true; - bakCheckBox.Location = new Point(15, 152); - bakCheckBox.Name = "bakCheckBox"; - bakCheckBox.Size = new Size(199, 24); - bakCheckBox.TabIndex = 4; - bakCheckBox.Text = "Признак наличия баков"; - bakCheckBox.UseVisualStyleBackColor = true; - // - // rocketCheckBox - // - rocketCheckBox.AutoSize = true; - rocketCheckBox.Location = new Point(15, 200); - rocketCheckBox.Name = "rocketCheckBox"; - rocketCheckBox.Size = new Size(196, 24); - rocketCheckBox.TabIndex = 5; - rocketCheckBox.Text = "Признак наличия ракет"; - rocketCheckBox.UseVisualStyleBackColor = true; + easyLabel.BorderStyle = BorderStyle.FixedSingle; + easyLabel.Location = new Point(266, 228); + easyLabel.Name = "easyLabel"; + easyLabel.Size = new Size(116, 47); + easyLabel.TabIndex = 7; + easyLabel.Text = "Простой"; + easyLabel.TextAlign = ContentAlignment.MiddleCenter; + easyLabel.MouseDown += LableObject_MouseDown; // // colorGroupBox // @@ -149,38 +117,6 @@ colorGroupBox.TabStop = false; colorGroupBox.Text = "Цвета"; // - // redPanel - // - redPanel.BackColor = Color.Red; - redPanel.Location = new Point(18, 37); - redPanel.Name = "redPanel"; - redPanel.Size = new Size(50, 50); - redPanel.TabIndex = 0; - // - // greenPanel - // - greenPanel.BackColor = Color.FromArgb(0, 192, 0); - greenPanel.Location = new Point(97, 37); - greenPanel.Name = "greenPanel"; - greenPanel.Size = new Size(50, 50); - greenPanel.TabIndex = 1; - // - // bluePanel - // - bluePanel.BackColor = Color.Blue; - bluePanel.Location = new Point(174, 37); - bluePanel.Name = "bluePanel"; - bluePanel.Size = new Size(50, 50); - bluePanel.TabIndex = 1; - // - // yellowPanel - // - yellowPanel.BackColor = Color.Yellow; - yellowPanel.Location = new Point(250, 37); - yellowPanel.Name = "yellowPanel"; - yellowPanel.Size = new Size(50, 50); - yellowPanel.TabIndex = 1; - // // purplePanel // purplePanel.BackColor = Color.Purple; @@ -188,6 +124,7 @@ purplePanel.Name = "purplePanel"; purplePanel.Size = new Size(50, 50); purplePanel.TabIndex = 3; + purplePanel.MouseClick += PanelColor_MouseDown; // // blackPanel // @@ -196,6 +133,7 @@ blackPanel.Name = "blackPanel"; blackPanel.Size = new Size(50, 50); blackPanel.TabIndex = 4; + blackPanel.MouseClick += PanelColor_MouseDown; // // greyPanel // @@ -204,6 +142,7 @@ greyPanel.Name = "greyPanel"; greyPanel.Size = new Size(50, 50); greyPanel.TabIndex = 5; + greyPanel.MouseClick += PanelColor_MouseDown; // // whitePanel // @@ -212,55 +151,111 @@ whitePanel.Name = "whitePanel"; whitePanel.Size = new Size(50, 50); whitePanel.TabIndex = 2; + whitePanel.MouseClick += PanelColor_MouseDown; // - // easyLabel + // yellowPanel // - easyLabel.BorderStyle = BorderStyle.FixedSingle; - easyLabel.Location = new Point(266, 228); - easyLabel.Name = "easyLabel"; - easyLabel.Size = new Size(116, 47); - easyLabel.TabIndex = 7; - easyLabel.Text = "Простой"; - easyLabel.TextAlign = ContentAlignment.MiddleCenter; + yellowPanel.BackColor = Color.Yellow; + yellowPanel.Location = new Point(250, 37); + yellowPanel.Name = "yellowPanel"; + yellowPanel.Size = new Size(50, 50); + yellowPanel.TabIndex = 1; + yellowPanel.MouseClick += PanelColor_MouseDown; // - // hardLabel + // bluePanel // - hardLabel.BorderStyle = BorderStyle.FixedSingle; - hardLabel.Location = new Point(421, 228); - hardLabel.Name = "hardLabel"; - hardLabel.Size = new Size(127, 47); - hardLabel.TabIndex = 8; - hardLabel.Text = "Продвинутый"; - hardLabel.TextAlign = ContentAlignment.MiddleCenter; + bluePanel.BackColor = Color.Blue; + bluePanel.Location = new Point(174, 37); + bluePanel.Name = "bluePanel"; + bluePanel.Size = new Size(50, 50); + bluePanel.TabIndex = 1; + bluePanel.MouseClick += PanelColor_MouseDown; + // + // greenPanel + // + greenPanel.BackColor = Color.FromArgb(0, 192, 0); + greenPanel.Location = new Point(97, 37); + greenPanel.Name = "greenPanel"; + greenPanel.Size = new Size(50, 50); + greenPanel.TabIndex = 1; + greenPanel.MouseClick += PanelColor_MouseDown; + // + // redPanel + // + redPanel.BackColor = Color.Red; + redPanel.Location = new Point(18, 37); + redPanel.Name = "redPanel"; + redPanel.Size = new Size(50, 50); + redPanel.TabIndex = 0; + redPanel.MouseClick += PanelColor_MouseDown; + // + // rocketCheckBox + // + rocketCheckBox.AutoSize = true; + rocketCheckBox.Location = new Point(15, 200); + rocketCheckBox.Name = "rocketCheckBox"; + rocketCheckBox.Size = new Size(196, 24); + rocketCheckBox.TabIndex = 5; + rocketCheckBox.Text = "Признак наличия ракет"; + rocketCheckBox.UseVisualStyleBackColor = true; + // + // bakCheckBox + // + bakCheckBox.AutoSize = true; + bakCheckBox.Location = new Point(15, 152); + bakCheckBox.Name = "bakCheckBox"; + bakCheckBox.Size = new Size(199, 24); + bakCheckBox.TabIndex = 4; + bakCheckBox.Text = "Признак наличия баков"; + bakCheckBox.UseVisualStyleBackColor = true; + // + // WeightNumericUpDown + // + WeightNumericUpDown.Location = new Point(113, 82); + WeightNumericUpDown.Name = "WeightNumericUpDown"; + WeightNumericUpDown.Size = new Size(83, 27); + WeightNumericUpDown.TabIndex = 3; + WeightNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // SpeedNumericUpDown + // + SpeedNumericUpDown.Location = new Point(113, 34); + SpeedNumericUpDown.Name = "SpeedNumericUpDown"; + SpeedNumericUpDown.Size = new Size(83, 27); + SpeedNumericUpDown.TabIndex = 2; + SpeedNumericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // weight + // + weight.AutoSize = true; + weight.Location = new Point(15, 84); + weight.Name = "weight"; + weight.Size = new Size(40, 20); + weight.TabIndex = 1; + weight.Text = "Вес: "; + // + // speed + // + speed.AutoSize = true; + speed.Location = new Point(15, 41); + speed.Name = "speed"; + speed.Size = new Size(80, 20); + speed.TabIndex = 0; + speed.Text = "Скорость: "; // // PanelColor // PanelColor.AllowDrop = true; PanelColor.Controls.Add(labelDopColor); PanelColor.Controls.Add(labelColor); - PanelColor.Controls.Add(pictureBox1); + PanelColor.Controls.Add(pictureBoxConfig); PanelColor.Location = new Point(654, 12); PanelColor.Name = "PanelColor"; PanelColor.Size = new Size(304, 275); PanelColor.TabIndex = 2; - // - // pictureBox1 - // - pictureBox1.Location = new Point(12, 54); - pictureBox1.Name = "pictureBox1"; - pictureBox1.Size = new Size(284, 209); - pictureBox1.TabIndex = 0; - pictureBox1.TabStop = false; - // - // labelColor - // - labelColor.BorderStyle = BorderStyle.FixedSingle; - labelColor.Location = new Point(12, 12); - labelColor.Name = "labelColor"; - labelColor.Size = new Size(134, 34); - labelColor.TabIndex = 1; - labelColor.Text = "Цвет"; - labelColor.TextAlign = ContentAlignment.MiddleCenter; + PanelColor.DragDrop += PanelObject_DragDrop; + PanelColor.DragEnter += PanelObject_DragEnter; + PanelColor.MouseDown += PanelColor_MouseDown; // // labelDopColor // @@ -271,6 +266,30 @@ labelDopColor.TabIndex = 2; labelDopColor.Text = "Доп. цвет"; labelDopColor.TextAlign = ContentAlignment.MiddleCenter; + labelDopColor.DragDrop += labelAddBoxColor_DragDrop; + labelDopColor.DragEnter += LabelColor_DragEnter; + labelDopColor.MouseDown += LableObject_MouseDown; + // + // labelColor + // + labelColor.BorderStyle = BorderStyle.FixedSingle; + labelColor.Location = new Point(12, 12); + labelColor.Name = "labelColor"; + labelColor.Size = new Size(134, 34); + labelColor.TabIndex = 1; + labelColor.Text = "Цвет"; + labelColor.TextAlign = ContentAlignment.MiddleCenter; + labelColor.DragDrop += LabelBaseColor_DragDrop; + labelColor.DragEnter += LabelColor_DragEnter; + labelColor.MouseDown += LableObject_MouseDown; + // + // pictureBoxConfig + // + pictureBoxConfig.Location = new Point(12, 54); + pictureBoxConfig.Name = "pictureBoxConfig"; + pictureBoxConfig.Size = new Size(284, 209); + pictureBoxConfig.TabIndex = 0; + pictureBoxConfig.TabStop = false; // // AddButton // @@ -280,6 +299,7 @@ AddButton.TabIndex = 3; AddButton.Text = "Добавить"; AddButton.UseVisualStyleBackColor = true; + AddButton.Click += AddButton_Click; // // buttonStop // @@ -303,11 +323,11 @@ Text = "FormBomberConfig"; groupBox1.ResumeLayout(false); groupBox1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).EndInit(); - ((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).EndInit(); colorGroupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)WeightNumericUpDown).EndInit(); + ((System.ComponentModel.ISupportInitialize)SpeedNumericUpDown).EndInit(); PanelColor.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxConfig).EndInit(); ResumeLayout(false); } @@ -334,7 +354,7 @@ private Panel PanelColor; private Label labelDopColor; private Label labelColor; - private PictureBox pictureBox1; + private PictureBox pictureBoxConfig; private Button AddButton; private Button buttonStop; } diff --git a/AirBomber/FormBomberConfig.cs b/AirBomber/FormBomberConfig.cs index 630a3a4..7449c99 100644 --- a/AirBomber/FormBomberConfig.cs +++ b/AirBomber/FormBomberConfig.cs @@ -1,4 +1,6 @@ -using System; +using AirBomber.DrawningObjects; +using AirBomber.Entities; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +14,132 @@ namespace AirBomber { public partial class FormBomberConfig : Form { + private event Action? EventAddBomber; + DrawningBomber? _bomber = null; + public FormBomberConfig() { InitializeComponent(); + redPanel.MouseDown += PanelColor_MouseDown; + greenPanel.MouseDown += PanelColor_MouseDown; + bluePanel.MouseDown += PanelColor_MouseDown; + yellowPanel.MouseDown += PanelColor_MouseDown; + whitePanel.MouseDown += PanelColor_MouseDown; + greyPanel.MouseDown += PanelColor_MouseDown; + blackPanel.MouseDown += PanelColor_MouseDown; + purplePanel.MouseDown += PanelColor_MouseDown; + buttonStop.Click += (sender, e) => Close(); + } + + private void DrawBomber() + { + Bitmap bmp = new(pictureBoxConfig.Width, pictureBoxConfig.Height); + Graphics gr = Graphics.FromImage(bmp); + _bomber?.SetPosition(5, 5); + _bomber?.DrawBomber(gr); + pictureBoxConfig.Image = bmp; + } + + public void AddEvent(Action ev) + { + if (EventAddBomber == null) + { + EventAddBomber = new Action(ev); + } + else + { + EventAddBomber += ev; + } + } + + private void LableObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void PanelObject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void PanelObject_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text).ToString()) + { + case "easyLabel": + _bomber = new DrawningBomber((int)SpeedNumericUpDown.Value, + (int)WeightNumericUpDown.Value, Color.White, pictureBoxConfig.Width, + pictureBoxConfig.Height); + break; + case "hardLabel": + _bomber = new DrawningAirBomber((int)SpeedNumericUpDown.Value, + (int)WeightNumericUpDown.Value, Color.Red, Color.Black, + rocketCheckBox.Checked, bakCheckBox.Checked, pictureBoxConfig.Width, + pictureBoxConfig.Height); + break; + } + DrawBomber(); + } + + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void AddButton_Click(object sender, EventArgs e) + { + EventAddBomber?.Invoke(_bomber); + Close(); + } + + private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + { + if (_bomber != null) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + _bomber.EntityBomber.BodyColor = (Color)e.Data.GetData(typeof(Color)); + } + DrawBomber(); + } + } + + private void LabelColor_DragEnter(object sender, DragEventArgs e) + { + if (_bomber != null && _bomber.EntityBomber is EntityAirBomber entityAirBomber) + { + labelDopColor.AllowDrop = true; + } + else + labelDopColor.AllowDrop = false; + + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void labelAddBoxColor_DragDrop(object sender, DragEventArgs e) + { + if (_bomber != null && _bomber.EntityBomber is EntityAirBomber entityAirBomber) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + entityAirBomber.DopColor = (Color)e.Data.GetData(typeof(Color)); + } + DrawBomber(); + } } } } -- 2.25.1 From 3ac1a746a06a3399c43419ee30f3176d3101fa54 Mon Sep 17 00:00:00 2001 From: Salikh Date: Tue, 28 Nov 2023 03:43:46 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/FormBomberConfig.Designer.cs | 2 ++ AirBomber/FormBomberConfig.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AirBomber/FormBomberConfig.Designer.cs b/AirBomber/FormBomberConfig.Designer.cs index a3f3706..717a11a 100644 --- a/AirBomber/FormBomberConfig.Designer.cs +++ b/AirBomber/FormBomberConfig.Designer.cs @@ -259,6 +259,7 @@ // // labelDopColor // + labelDopColor.AllowDrop = true; labelDopColor.BorderStyle = BorderStyle.FixedSingle; labelDopColor.Location = new Point(152, 12); labelDopColor.Name = "labelDopColor"; @@ -272,6 +273,7 @@ // // labelColor // + labelColor.AllowDrop = true; labelColor.BorderStyle = BorderStyle.FixedSingle; labelColor.Location = new Point(12, 12); labelColor.Name = "labelColor"; diff --git a/AirBomber/FormBomberConfig.cs b/AirBomber/FormBomberConfig.cs index 7449c99..745668a 100644 --- a/AirBomber/FormBomberConfig.cs +++ b/AirBomber/FormBomberConfig.cs @@ -81,7 +81,7 @@ namespace AirBomber case "hardLabel": _bomber = new DrawningAirBomber((int)SpeedNumericUpDown.Value, (int)WeightNumericUpDown.Value, Color.Red, Color.Black, - rocketCheckBox.Checked, bakCheckBox.Checked, pictureBoxConfig.Width, + bakCheckBox.Checked, rocketCheckBox.Checked, pictureBoxConfig.Width, pictureBoxConfig.Height); break; } -- 2.25.1 From e396498be156c454bb51afee51377827ab07108f Mon Sep 17 00:00:00 2001 From: Salikh Date: Tue, 28 Nov 2023 18:42:06 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/DrawningAirBomber.cs | 7 +++++++ AirBomber/DrawningBomber.cs | 4 ++++ AirBomber/EntityAirBomber.cs | 6 +++++- AirBomber/EntityBomber.cs | 4 ++++ AirBomber/FormBomberConfig.cs | 20 ++++++++------------ 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/AirBomber/DrawningAirBomber.cs b/AirBomber/DrawningAirBomber.cs index 937c5af..74b3379 100644 --- a/AirBomber/DrawningAirBomber.cs +++ b/AirBomber/DrawningAirBomber.cs @@ -65,5 +65,12 @@ namespace AirBomber.DrawningObjects } base.DrawBomber(g); } + public void setAddColor(Color color) + { + if (EntityBomber is EntityAirBomber airbomber) + { + airbomber.setAddColor(color); + } + } } } diff --git a/AirBomber/DrawningBomber.cs b/AirBomber/DrawningBomber.cs index fadb038..e7c551f 100644 --- a/AirBomber/DrawningBomber.cs +++ b/AirBomber/DrawningBomber.cs @@ -162,5 +162,9 @@ namespace AirBomber.DrawningObjects wing_2.CloseFigure(); g.DrawPath(Pens.Black, wing_2); } + public void setColor(Color color) + { + EntityBomber.setColor(color); + } } } diff --git a/AirBomber/EntityAirBomber.cs b/AirBomber/EntityAirBomber.cs index bc994ba..9c7cfd5 100644 --- a/AirBomber/EntityAirBomber.cs +++ b/AirBomber/EntityAirBomber.cs @@ -2,7 +2,7 @@ { public class EntityAirBomber : EntityBomber { - public Color DopColor { get; set; } + public Color DopColor { get; private set; } public bool Toplivo { get; private set; } public bool Rocket { get; private set; } @@ -12,5 +12,9 @@ Toplivo = toplivo; Rocket = ropcket; } + public void setAddColor(Color color) + { + DopColor = color; + } } } diff --git a/AirBomber/EntityBomber.cs b/AirBomber/EntityBomber.cs index 9273efc..35434f1 100644 --- a/AirBomber/EntityBomber.cs +++ b/AirBomber/EntityBomber.cs @@ -19,5 +19,9 @@ namespace AirBomber.Entities Weight = weight; BodyColor = bodycolor; } + public void setColor(Color color) + { + BodyColor = color; + } } } diff --git a/AirBomber/FormBomberConfig.cs b/AirBomber/FormBomberConfig.cs index 745668a..4ba33f8 100644 --- a/AirBomber/FormBomberConfig.cs +++ b/AirBomber/FormBomberConfig.cs @@ -101,14 +101,12 @@ namespace AirBomber private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { - if (_bomber != null) + if (_bomber is DrawningBomber entityAirBomber) { - if (e.Data.GetDataPresent(typeof(Color))) - { - _bomber.EntityBomber.BodyColor = (Color)e.Data.GetData(typeof(Color)); - } - DrawBomber(); + labelColor.BackColor = (Color)e.Data.GetData(typeof(Color)); + _bomber.setColor((Color)e.Data.GetData(typeof(Color))); } + DrawBomber(); } private void LabelColor_DragEnter(object sender, DragEventArgs e) @@ -132,14 +130,12 @@ namespace AirBomber private void labelAddBoxColor_DragDrop(object sender, DragEventArgs e) { - if (_bomber != null && _bomber.EntityBomber is EntityAirBomber entityAirBomber) + if (_bomber is DrawningAirBomber entityAirBomber) { - if (e.Data.GetDataPresent(typeof(Color))) - { - entityAirBomber.DopColor = (Color)e.Data.GetData(typeof(Color)); - } - DrawBomber(); + labelDopColor.BackColor = (Color)e.Data.GetData(typeof(Color)); + entityAirBomber.setAddColor((Color)e.Data.GetData(typeof(Color))); } + DrawBomber(); } } } -- 2.25.1 From 54c2da98b6c11350f7d20e17432bd8af29001ded Mon Sep 17 00:00:00 2001 From: Salikh Date: Wed, 29 Nov 2023 19:49:43 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/SetGeneric.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/AirBomber/SetGeneric.cs b/AirBomber/SetGeneric.cs index 1a592a7..57ee127 100644 --- a/AirBomber/SetGeneric.cs +++ b/AirBomber/SetGeneric.cs @@ -69,10 +69,8 @@ namespace ProjectBomber.Generics public bool Remove(int position) { /// Проверка позиции - if (position < 0 || position >= _places.Count) - return false; - /// Удаление объекта из массива, присвоив элементу массива значение null - _places[position] = null; + if ((position < 0) || (position > _maxCount)) return false; + _places.RemoveAt(position); return true; } /// -- 2.25.1