From 3835f12fd0b9077d4eab9f1af45215450cd7119e Mon Sep 17 00:00:00 2001 From: malimova Date: Sun, 12 Nov 2023 16:58:21 +0400 Subject: [PATCH 1/4] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20Lab5?= =?UTF-8?q?.=20=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D1=8B=20FormPlaneConfig,=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=8D=D0=BB?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirBomber/FormPlaneConfig.Designer.cs | 39 ++++++ AirBomber/AirBomber/FormPlaneConfig.cs | 20 +++ AirBomber/AirBomber/FormPlaneConfig.resx | 120 ++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 AirBomber/AirBomber/FormPlaneConfig.Designer.cs create mode 100644 AirBomber/AirBomber/FormPlaneConfig.cs create mode 100644 AirBomber/AirBomber/FormPlaneConfig.resx diff --git a/AirBomber/AirBomber/FormPlaneConfig.Designer.cs b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs new file mode 100644 index 0000000..e9bc764 --- /dev/null +++ b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs @@ -0,0 +1,39 @@ +namespace AirBomber +{ + partial class FormPlaneConfig + { + /// + /// 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() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "FormPlaneConfig"; + } + + #endregion + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormPlaneConfig.cs b/AirBomber/AirBomber/FormPlaneConfig.cs new file mode 100644 index 0000000..bbfb1fd --- /dev/null +++ b/AirBomber/AirBomber/FormPlaneConfig.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 FormPlaneConfig : Form + { + public FormPlaneConfig() + { + InitializeComponent(); + } + } +} diff --git a/AirBomber/AirBomber/FormPlaneConfig.resx b/AirBomber/AirBomber/FormPlaneConfig.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/AirBomber/AirBomber/FormPlaneConfig.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 2b1fbcbf939eaac04691bfb38ac321d672ada21c Mon Sep 17 00:00:00 2001 From: malimova Date: Sun, 12 Nov 2023 18:58:47 +0400 Subject: [PATCH 2/4] =?UTF-8?q?*=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B=20FormPlaneConfig,=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirBomber/FormPlaneConfig.Designer.cs | 316 +++++++++++++++++- AirBomber/AirBomber/FormPlaneConfig.cs | 5 + AirBomber/AirBomber/FormPlaneConfig.resx | 62 +--- 3 files changed, 318 insertions(+), 65 deletions(-) diff --git a/AirBomber/AirBomber/FormPlaneConfig.Designer.cs b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs index e9bc764..6b6522b 100644 --- a/AirBomber/AirBomber/FormPlaneConfig.Designer.cs +++ b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs @@ -28,12 +28,320 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "FormPlaneConfig"; + groupBoxParameters = new GroupBox(); + labelModifiedObject = new Label(); + labelSimpleObject = new Label(); + groupBoxColors = new GroupBox(); + panelPurple = new Panel(); + panelBlack = new Panel(); + panelGrey = new Panel(); + panelWhite = new Panel(); + panelYellow = new Panel(); + panelBlue = new Panel(); + panelGreen = new Panel(); + panelRed = new Panel(); + checkBoxFuelTanks = new CheckBox(); + checkBoxBombs = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + numericUpDownSpeed = new NumericUpDown(); + labelWeight = new Label(); + labelSpeed = new Label(); + pictureBoxObject = new PictureBox(); + panelObject = new Panel(); + labelColor = new Label(); + labelAddColor = new Label(); + buttonOk = new Button(); + buttonCancel = new Button(); + groupBoxParameters.SuspendLayout(); + groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + panelObject.SuspendLayout(); + SuspendLayout(); + // + // groupBoxParameters + // + groupBoxParameters.Controls.Add(labelModifiedObject); + groupBoxParameters.Controls.Add(labelSimpleObject); + groupBoxParameters.Controls.Add(groupBoxColors); + groupBoxParameters.Controls.Add(checkBoxFuelTanks); + groupBoxParameters.Controls.Add(checkBoxBombs); + groupBoxParameters.Controls.Add(numericUpDownWeight); + groupBoxParameters.Controls.Add(numericUpDownSpeed); + groupBoxParameters.Controls.Add(labelWeight); + groupBoxParameters.Controls.Add(labelSpeed); + groupBoxParameters.Location = new Point(12, 12); + groupBoxParameters.Name = "groupBoxParameters"; + groupBoxParameters.Size = new Size(733, 340); + groupBoxParameters.TabIndex = 0; + groupBoxParameters.TabStop = false; + groupBoxParameters.Text = "Параметры"; + // + // labelModifiedObject + // + labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; + labelModifiedObject.Location = new Point(563, 259); + labelModifiedObject.Name = "labelModifiedObject"; + labelModifiedObject.Size = new Size(150, 48); + labelModifiedObject.TabIndex = 8; + labelModifiedObject.Text = "Продвинутый"; + labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + // + // labelSimpleObject + // + labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; + labelSimpleObject.Location = new Point(389, 259); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(150, 48); + labelSimpleObject.TabIndex = 7; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.MouseDown += labelSimpleObject_MouseDown; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelPurple); + groupBoxColors.Controls.Add(panelBlack); + groupBoxColors.Controls.Add(panelGrey); + groupBoxColors.Controls.Add(panelWhite); + groupBoxColors.Controls.Add(panelYellow); + groupBoxColors.Controls.Add(panelBlue); + groupBoxColors.Controls.Add(panelGreen); + groupBoxColors.Controls.Add(panelRed); + groupBoxColors.Location = new Point(389, 20); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Size = new Size(324, 194); + groupBoxColors.TabIndex = 6; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "Цвета"; + // + // panelPurple + // + panelPurple.BackColor = Color.Purple; + panelPurple.Location = new Point(243, 113); + panelPurple.Name = "panelPurple"; + panelPurple.Size = new Size(54, 54); + panelPurple.TabIndex = 1; + // + // panelBlack + // + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(169, 113); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(54, 54); + panelBlack.TabIndex = 1; + // + // panelGrey + // + panelGrey.BackColor = Color.Gray; + panelGrey.Location = new Point(96, 113); + panelGrey.Name = "panelGrey"; + panelGrey.Size = new Size(54, 54); + panelGrey.TabIndex = 1; + // + // panelWhite + // + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(22, 113); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(54, 54); + panelWhite.TabIndex = 1; + // + // panelYellow + // + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(243, 43); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(54, 54); + panelYellow.TabIndex = 1; + // + // panelBlue + // + panelBlue.BackColor = Color.Blue; + panelBlue.Location = new Point(169, 43); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(54, 54); + panelBlue.TabIndex = 1; + // + // panelGreen + // + panelGreen.BackColor = Color.FromArgb(0, 192, 0); + panelGreen.Location = new Point(96, 43); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(54, 54); + panelGreen.TabIndex = 1; + // + // panelRed + // + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(22, 43); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(54, 54); + panelRed.TabIndex = 0; + // + // checkBoxFuelTanks + // + checkBoxFuelTanks.AutoSize = true; + checkBoxFuelTanks.Location = new Point(30, 225); + checkBoxFuelTanks.Name = "checkBoxFuelTanks"; + checkBoxFuelTanks.Size = new Size(327, 29); + checkBoxFuelTanks.TabIndex = 5; + checkBoxFuelTanks.Text = "Признак наличия топливных баков"; + checkBoxFuelTanks.UseVisualStyleBackColor = true; + // + // checkBoxBombs + // + checkBoxBombs.AutoSize = true; + checkBoxBombs.Location = new Point(30, 158); + checkBoxBombs.Name = "checkBoxBombs"; + checkBoxBombs.Size = new Size(229, 29); + checkBoxBombs.TabIndex = 4; + checkBoxBombs.Text = "Признак наличия бомб"; + checkBoxBombs.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(146, 94); + numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDownWeight.Name = "numericUpDownWeight"; + numericUpDownWeight.Size = new Size(180, 31); + numericUpDownWeight.TabIndex = 3; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(146, 52); + numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDownSpeed.Name = "numericUpDownSpeed"; + numericUpDownSpeed.Size = new Size(180, 31); + numericUpDownSpeed.TabIndex = 2; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelWeight + // + labelWeight.AutoSize = true; + labelWeight.Location = new Point(30, 100); + labelWeight.Name = "labelWeight"; + labelWeight.Size = new Size(39, 25); + labelWeight.TabIndex = 1; + labelWeight.Text = "Вес"; + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(30, 54); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(89, 25); + labelSpeed.TabIndex = 0; + labelSpeed.Text = "Скорость"; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(32, 61); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(358, 175); + pictureBoxObject.TabIndex = 1; + pictureBoxObject.TabStop = false; + // + // panelObject + // + panelObject.AllowDrop = true; + panelObject.Controls.Add(labelAddColor); + panelObject.Controls.Add(labelColor); + panelObject.Controls.Add(pictureBoxObject); + panelObject.Location = new Point(776, 23); + panelObject.Name = "panelObject"; + panelObject.Size = new Size(418, 253); + panelObject.TabIndex = 2; + // + // labelColor + // + labelColor.BorderStyle = BorderStyle.FixedSingle; + labelColor.Location = new Point(32, 9); + labelColor.Name = "labelColor"; + labelColor.Size = new Size(165, 49); + labelColor.TabIndex = 2; + labelColor.Text = "Цвет"; + labelColor.TextAlign = ContentAlignment.MiddleCenter; + // + // labelAddColor + // + labelAddColor.BorderStyle = BorderStyle.FixedSingle; + labelAddColor.Location = new Point(225, 9); + labelAddColor.Name = "labelAddColor"; + labelAddColor.Size = new Size(165, 49); + labelAddColor.TabIndex = 3; + labelAddColor.Text = "Доп. цвет"; + labelAddColor.TextAlign = ContentAlignment.MiddleCenter; + // + // buttonOk + // + buttonOk.Location = new Point(783, 291); + buttonOk.Name = "buttonOk"; + buttonOk.Size = new Size(190, 51); + buttonOk.TabIndex = 3; + buttonOk.Text = "Добавить"; + buttonOk.UseVisualStyleBackColor = true; + // + // buttonCancel + // + buttonCancel.Location = new Point(992, 291); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(190, 51); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // FormPlaneConfig + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1222, 364); + Controls.Add(buttonCancel); + Controls.Add(buttonOk); + Controls.Add(panelObject); + Controls.Add(groupBoxParameters); + Name = "FormPlaneConfig"; + Text = "Создание объекта"; + groupBoxParameters.ResumeLayout(false); + groupBoxParameters.PerformLayout(); + groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit(); + panelObject.ResumeLayout(false); + ResumeLayout(false); } #endregion + + private GroupBox groupBoxParameters; + private CheckBox checkBox3; + private CheckBox checkBoxFuelTanks; + private CheckBox checkBoxBombs; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelWeight; + private Label labelSpeed; + private Label labelModifiedObject; + private Label labelSimpleObject; + private GroupBox groupBoxColors; + private Panel panelPurple; + private Panel panelBlack; + private Panel panelGrey; + private Panel panelWhite; + private Panel panelYellow; + private Panel panelBlue; + private Panel panelGreen; + private Panel panelRed; + private PictureBox pictureBoxObject; + private Panel panelObject; + private Label labelAddColor; + private Label labelColor; + private Button buttonOk; + private Button buttonCancel; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormPlaneConfig.cs b/AirBomber/AirBomber/FormPlaneConfig.cs index bbfb1fd..dcdda34 100644 --- a/AirBomber/AirBomber/FormPlaneConfig.cs +++ b/AirBomber/AirBomber/FormPlaneConfig.cs @@ -16,5 +16,10 @@ namespace AirBomber { InitializeComponent(); } + + private void labelSimpleObject_MouseDown(object sender, MouseEventArgs e) + { + + } } } diff --git a/AirBomber/AirBomber/FormPlaneConfig.resx b/AirBomber/AirBomber/FormPlaneConfig.resx index 1af7de1..f298a7b 100644 --- a/AirBomber/AirBomber/FormPlaneConfig.resx +++ b/AirBomber/AirBomber/FormPlaneConfig.resx @@ -1,64 +1,4 @@ - - - + -- 2.25.1 From ede63a0ae5b02e3897759ce1bb59b7288f714f19 Mon Sep 17 00:00:00 2001 From: malimova Date: Mon, 13 Nov 2023 00:26:52 +0400 Subject: [PATCH 3/4] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=20=D0=BC?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=B8=D1=85=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81?= =?UTF-8?q?=D0=BE=D0=B2,=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= =?UTF-8?q?,=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20AirPlaneDelegate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AirPlaneDelegate.cs | 10 ++ AirBomber/AirBomber/DrawningAirBomber.cs | 28 ++-- AirBomber/AirBomber/DrawningAirPlane.cs | 7 +- AirBomber/AirBomber/EntityAirBomber.cs | 7 +- AirBomber/AirBomber/EntityAirPlane.cs | 4 + AirBomber/AirBomber/FormPlaneCollection.cs | 48 ++++--- .../AirBomber/FormPlaneConfig.Designer.cs | 79 ++++++++--- AirBomber/AirBomber/FormPlaneConfig.cs | 134 +++++++++++++++++- 8 files changed, 254 insertions(+), 63 deletions(-) create mode 100644 AirBomber/AirBomber/AirPlaneDelegate.cs diff --git a/AirBomber/AirBomber/AirPlaneDelegate.cs b/AirBomber/AirBomber/AirPlaneDelegate.cs new file mode 100644 index 0000000..e912336 --- /dev/null +++ b/AirBomber/AirBomber/AirPlaneDelegate.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + public delegate void AirPlaneDelegate(DrawningAirPlane plane); +} diff --git a/AirBomber/AirBomber/DrawningAirBomber.cs b/AirBomber/AirBomber/DrawningAirBomber.cs index 05612cf..003679d 100644 --- a/AirBomber/AirBomber/DrawningAirBomber.cs +++ b/AirBomber/AirBomber/DrawningAirBomber.cs @@ -39,18 +39,24 @@ namespace AirBomber Pen pen = new(Color.Black); Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor); base.DrawPlane(g); - // обвесы - g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 15, 29); - g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29); - g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 70, 15, 29); - g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29); - g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 50, 15, 15); - g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15); + // bombs + if(airBomber.Bombs) + { + g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 15, 29); + g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29); + g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 70, 15, 29); + g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29); + g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 50, 15, 15); + g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15); + } // fueltanks - g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15); - g.DrawRectangle(pen, _startPosX + 63, _startPosY + 34, 20, 15); - g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 70, 20, 15); - g.DrawRectangle(pen, _startPosX + 63, _startPosY + 70, 20, 15); + if (airBomber.FuelTanks) + { + g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15); + g.DrawRectangle(pen, _startPosX + 63, _startPosY + 34, 20, 15); + g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 70, 20, 15); + g.DrawRectangle(pen, _startPosX + 63, _startPosY + 70, 20, 15); + } } } } diff --git a/AirBomber/AirBomber/DrawningAirPlane.cs b/AirBomber/AirBomber/DrawningAirPlane.cs index 4308f24..56a60f7 100644 --- a/AirBomber/AirBomber/DrawningAirPlane.cs +++ b/AirBomber/AirBomber/DrawningAirPlane.cs @@ -16,11 +16,11 @@ namespace AirBomber /// /// Ширина окна /// - private int _pictureWidth; + public int _pictureWidth; /// /// Высота окна /// - private int _pictureHeight; + public int _pictureHeight; /// /// Левая координата прорисовки самолета /// @@ -272,7 +272,6 @@ namespace AirBomber /// /// Получение объекта IMoveableObject из объекта DrawningAirPlane /// - public IMoveableObject GetMoveableObject => new - DrawningObjectAirPlane(this); + public IMoveableObject GetMoveableObject => new DrawningObjectAirPlane(this); } } diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index 2197b86..f8b76af 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -13,12 +13,15 @@ namespace AirBomber public bool Bombs { get; private set; } public Color BombsColor { get; private set; } public bool FuelTanks { get; private set; } - public EntityAirBomber(int speed, double weight, Color bodyColor, Color - additionalColor, bool bombs, bool fuelTanks) : base(speed, weight, bodyColor) + public EntityAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks) : base(speed, weight, bodyColor) { AdditionalColor = additionalColor; Bombs = bombs; FuelTanks = fuelTanks; } + public void SetAdditionalColor(Color color) + { + AdditionalColor = color; + } } } diff --git a/AirBomber/AirBomber/EntityAirPlane.cs b/AirBomber/AirBomber/EntityAirPlane.cs index a8341c9..418142f 100644 --- a/AirBomber/AirBomber/EntityAirPlane.cs +++ b/AirBomber/AirBomber/EntityAirPlane.cs @@ -37,5 +37,9 @@ namespace AirBomber Weight = weight; BodyColor = bodyColor; } + public void SetBodyColor(Color color) + { + BodyColor = color; + } } } diff --git a/AirBomber/AirBomber/FormPlaneCollection.cs b/AirBomber/AirBomber/FormPlaneCollection.cs index 49ce1c9..2d5b92a 100644 --- a/AirBomber/AirBomber/FormPlaneCollection.cs +++ b/AirBomber/AirBomber/FormPlaneCollection.cs @@ -58,28 +58,10 @@ namespace AirBomber /// private void buttonAddPlane_Click(object sender, EventArgs e) { - if (listBoxStorages.SelectedIndex == -1) - { - return; - } - var obj = _storage[listBoxStorages.SelectedItem.ToString()?? string.Empty]; - if (obj == null) - { - return; - } - FormAirBomber form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - if (obj + form.SelectedPlane > -1) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowPlanes(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + var formPlaneConfig = new FormPlaneConfig(); + // TODO DONE + formPlaneConfig.AddEvent(AddPlane); + formPlaneConfig.Show(); } /// /// Удаление объекта из набора @@ -158,5 +140,27 @@ namespace AirBomber ReloadObjects(); } } + private void AddPlane(DrawningAirPlane plane) + { + plane._pictureWidth = pictureBoxCollection.Width; + plane._pictureHeight = pictureBoxCollection.Height; + + if (listBoxStorages.SelectedIndex == -1) return; + + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + if (obj + plane > -1) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowPlanes(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } } } diff --git a/AirBomber/AirBomber/FormPlaneConfig.Designer.cs b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs index 6b6522b..70e2b0c 100644 --- a/AirBomber/AirBomber/FormPlaneConfig.Designer.cs +++ b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs @@ -34,7 +34,7 @@ groupBoxColors = new GroupBox(); panelPurple = new Panel(); panelBlack = new Panel(); - panelGrey = new Panel(); + panelGray = new Panel(); panelWhite = new Panel(); panelYellow = new Panel(); panelBlue = new Panel(); @@ -48,8 +48,8 @@ labelSpeed = new Label(); pictureBoxObject = new PictureBox(); panelObject = new Panel(); - labelColor = new Label(); labelAddColor = new Label(); + labelColor = new Label(); buttonOk = new Button(); buttonCancel = new Button(); groupBoxParameters.SuspendLayout(); @@ -87,6 +87,7 @@ labelModifiedObject.TabIndex = 8; labelModifiedObject.Text = "Продвинутый"; labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + labelModifiedObject.MouseDown += labelObject_MouseDown; // // labelSimpleObject // @@ -97,13 +98,13 @@ labelSimpleObject.TabIndex = 7; labelSimpleObject.Text = "Простой"; labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; - labelSimpleObject.MouseDown += labelSimpleObject_MouseDown; + labelSimpleObject.MouseDown += labelObject_MouseDown; // // groupBoxColors // groupBoxColors.Controls.Add(panelPurple); groupBoxColors.Controls.Add(panelBlack); - groupBoxColors.Controls.Add(panelGrey); + groupBoxColors.Controls.Add(panelGray); groupBoxColors.Controls.Add(panelWhite); groupBoxColors.Controls.Add(panelYellow); groupBoxColors.Controls.Add(panelBlue); @@ -115,6 +116,8 @@ groupBoxColors.TabIndex = 6; groupBoxColors.TabStop = false; groupBoxColors.Text = "Цвета"; + groupBoxColors.DragDrop += PanelObject_DragDrop; + groupBoxColors.DragEnter += PanelObject_DragEnter; // // panelPurple // @@ -123,6 +126,9 @@ panelPurple.Name = "panelPurple"; panelPurple.Size = new Size(54, 54); panelPurple.TabIndex = 1; + panelPurple.DragDrop += PanelObject_DragDrop; + panelPurple.DragEnter += PanelObject_DragEnter; + panelPurple.MouseDown += panelColor_MouseDown; // // panelBlack // @@ -131,14 +137,20 @@ panelBlack.Name = "panelBlack"; panelBlack.Size = new Size(54, 54); panelBlack.TabIndex = 1; + panelBlack.DragDrop += PanelObject_DragDrop; + panelBlack.DragEnter += PanelObject_DragEnter; + panelBlack.MouseDown += panelColor_MouseDown; // - // panelGrey + // panelGray // - panelGrey.BackColor = Color.Gray; - panelGrey.Location = new Point(96, 113); - panelGrey.Name = "panelGrey"; - panelGrey.Size = new Size(54, 54); - panelGrey.TabIndex = 1; + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(96, 113); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(54, 54); + panelGray.TabIndex = 1; + panelGray.DragDrop += PanelObject_DragDrop; + panelGray.DragEnter += PanelObject_DragEnter; + panelGray.MouseDown += panelColor_MouseDown; // // panelWhite // @@ -147,6 +159,9 @@ panelWhite.Name = "panelWhite"; panelWhite.Size = new Size(54, 54); panelWhite.TabIndex = 1; + panelWhite.DragDrop += PanelObject_DragDrop; + panelWhite.DragEnter += PanelObject_DragEnter; + panelWhite.MouseDown += panelColor_MouseDown; // // panelYellow // @@ -155,6 +170,9 @@ panelYellow.Name = "panelYellow"; panelYellow.Size = new Size(54, 54); panelYellow.TabIndex = 1; + panelYellow.DragDrop += PanelObject_DragDrop; + panelYellow.DragEnter += PanelObject_DragEnter; + panelYellow.MouseDown += panelColor_MouseDown; // // panelBlue // @@ -163,6 +181,9 @@ panelBlue.Name = "panelBlue"; panelBlue.Size = new Size(54, 54); panelBlue.TabIndex = 1; + panelBlue.DragDrop += PanelObject_DragDrop; + panelBlue.DragEnter += PanelObject_DragEnter; + panelBlue.MouseDown += panelColor_MouseDown; // // panelGreen // @@ -171,6 +192,9 @@ panelGreen.Name = "panelGreen"; panelGreen.Size = new Size(54, 54); panelGreen.TabIndex = 1; + panelGreen.DragDrop += PanelObject_DragDrop; + panelGreen.DragEnter += PanelObject_DragEnter; + panelGreen.MouseDown += panelColor_MouseDown; // // panelRed // @@ -179,6 +203,9 @@ panelRed.Name = "panelRed"; panelRed.Size = new Size(54, 54); panelRed.TabIndex = 0; + panelRed.DragDrop += PanelObject_DragDrop; + panelRed.DragEnter += PanelObject_DragEnter; + panelRed.MouseDown += panelColor_MouseDown; // // checkBoxFuelTanks // @@ -256,19 +283,12 @@ panelObject.Name = "panelObject"; panelObject.Size = new Size(418, 253); panelObject.TabIndex = 2; - // - // labelColor - // - labelColor.BorderStyle = BorderStyle.FixedSingle; - labelColor.Location = new Point(32, 9); - labelColor.Name = "labelColor"; - labelColor.Size = new Size(165, 49); - labelColor.TabIndex = 2; - labelColor.Text = "Цвет"; - labelColor.TextAlign = ContentAlignment.MiddleCenter; + panelObject.DragDrop += PanelObject_DragDrop; + panelObject.DragEnter += PanelObject_DragEnter; // // labelAddColor // + labelAddColor.AllowDrop = true; labelAddColor.BorderStyle = BorderStyle.FixedSingle; labelAddColor.Location = new Point(225, 9); labelAddColor.Name = "labelAddColor"; @@ -276,6 +296,21 @@ labelAddColor.TabIndex = 3; labelAddColor.Text = "Доп. цвет"; labelAddColor.TextAlign = ContentAlignment.MiddleCenter; + labelAddColor.DragDrop += labelColor_dragDrop; + labelAddColor.DragEnter += labelColor_dragEnter; + // + // labelColor + // + labelColor.AllowDrop = true; + labelColor.BorderStyle = BorderStyle.FixedSingle; + labelColor.Location = new Point(32, 9); + labelColor.Name = "labelColor"; + labelColor.Size = new Size(165, 49); + labelColor.TabIndex = 2; + labelColor.Text = "Цвет"; + labelColor.TextAlign = ContentAlignment.MiddleCenter; + labelColor.DragDrop += labelColor_dragDrop; + labelColor.DragEnter += labelColor_dragEnter; // // buttonOk // @@ -285,6 +320,7 @@ buttonOk.TabIndex = 3; buttonOk.Text = "Добавить"; buttonOk.UseVisualStyleBackColor = true; + buttonOk.Click += buttonOk_Click; // // buttonCancel // @@ -319,7 +355,6 @@ #endregion private GroupBox groupBoxParameters; - private CheckBox checkBox3; private CheckBox checkBoxFuelTanks; private CheckBox checkBoxBombs; private NumericUpDown numericUpDownWeight; @@ -331,7 +366,7 @@ private GroupBox groupBoxColors; private Panel panelPurple; private Panel panelBlack; - private Panel panelGrey; + private Panel panelGray; private Panel panelWhite; private Panel panelYellow; private Panel panelBlue; diff --git a/AirBomber/AirBomber/FormPlaneConfig.cs b/AirBomber/AirBomber/FormPlaneConfig.cs index dcdda34..b00e861 100644 --- a/AirBomber/AirBomber/FormPlaneConfig.cs +++ b/AirBomber/AirBomber/FormPlaneConfig.cs @@ -12,14 +12,144 @@ namespace AirBomber { public partial class FormPlaneConfig : Form { + /// + /// Переменная-выбранная машина + /// + DrawningAirPlane? _plane = null; + /// + /// Делегат для передачи объекта-автомобиля + /// + /// + private event AirPlaneDelegate? EventAddPlane; + /// + /// Конструктор + /// + /// + /// Конструктор + /// public FormPlaneConfig() { InitializeComponent(); + panelBlack.MouseDown += panelColor_MouseDown; + panelPurple.MouseDown += panelColor_MouseDown; + panelGray.MouseDown += panelColor_MouseDown; + panelGreen.MouseDown += panelColor_MouseDown; + panelRed.MouseDown += panelColor_MouseDown; + panelWhite.MouseDown += panelColor_MouseDown; + panelYellow.MouseDown += panelColor_MouseDown; + panelBlue.MouseDown += panelColor_MouseDown; + // TODO buttonCancel.Click with lambda DONE + buttonCancel.Click += (s, e) => Close(); + } + private void DrawPlane() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _plane?.SetPosition(5, 5); + _plane?.DrawPlane(gr); + pictureBoxObject.Image = bmp; + } + /// + /// Добавление события + /// + /// Привязанный метод + public void AddEvent(AirPlaneDelegate ev) + { + if (EventAddPlane == null) + { + EventAddPlane = ev; + } + else + { + EventAddPlane += ev; + } + } + /// + /// Передаем информацию при нажатии на Label + /// + /// + /// + private void labelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); } - private void labelSimpleObject_MouseDown(object sender, MouseEventArgs e) + /// + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// + 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 "labelSimpleObject": + _plane = new DrawningAirPlane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, pictureBoxObject.Height); + break; + case "labelModifiedObject": + _plane = new DrawningAirBomber((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBombs.Checked, checkBoxFuelTanks.Checked, pictureBoxObject.Width, pictureBoxObject.Height); + break; + } + DrawPlane(); + } + // TODO Реализовать логику смены цветов DONE + public void panelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + private void labelColor_dragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(typeof(Color)) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + private void labelColor_dragDrop(object sender, DragEventArgs e) + { + if (_plane == null) + return; + switch (((Label)sender).Name) + { + case "labelColor": + _plane?.EntityAirPlane?.SetBodyColor((Color)e.Data.GetData(typeof(Color))); + break; + case "labelAddColor": + if (!(_plane is DrawningAirBomber)) + return; + (_plane.EntityAirPlane as EntityAirBomber)?.SetAdditionalColor(color: (Color)e.Data.GetData(typeof(Color))); + break; + } + DrawPlane(); + } + /// + /// Добавление самолета + /// + /// + /// + private void buttonOk_Click(object sender, EventArgs e) + { + EventAddPlane?.Invoke(_plane); + Close(); } } } -- 2.25.1 From 32ff4df6d89f9e1f643200e3bb59b932703c33fa Mon Sep 17 00:00:00 2001 From: malimova Date: Mon, 13 Nov 2023 12:40:58 +0400 Subject: [PATCH 4/4] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20Delegate,=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=BC?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=BE=20=D0=BD=D0=B5=D0=B3=D0=BE=20Action.?= =?UTF-8?q?=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA.=20=D0=A1=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B0=20Lab5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AirPlaneDelegate.cs | 10 ----- AirBomber/AirBomber/FormPlaneCollection.cs | 45 ++++++++++--------- .../AirBomber/FormPlaneConfig.Designer.cs | 16 ------- AirBomber/AirBomber/FormPlaneConfig.cs | 6 +-- 4 files changed, 26 insertions(+), 51 deletions(-) delete mode 100644 AirBomber/AirBomber/AirPlaneDelegate.cs diff --git a/AirBomber/AirBomber/AirPlaneDelegate.cs b/AirBomber/AirBomber/AirPlaneDelegate.cs deleted file mode 100644 index e912336..0000000 --- a/AirBomber/AirBomber/AirPlaneDelegate.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AirBomber -{ - public delegate void AirPlaneDelegate(DrawningAirPlane plane); -} diff --git a/AirBomber/AirBomber/FormPlaneCollection.cs b/AirBomber/AirBomber/FormPlaneCollection.cs index 2d5b92a..6ed5627 100644 --- a/AirBomber/AirBomber/FormPlaneCollection.cs +++ b/AirBomber/AirBomber/FormPlaneCollection.cs @@ -63,6 +63,28 @@ namespace AirBomber formPlaneConfig.AddEvent(AddPlane); formPlaneConfig.Show(); } + private void AddPlane(DrawningAirPlane plane) + { + plane._pictureWidth = pictureBoxCollection.Width; + plane._pictureHeight = pictureBoxCollection.Height; + + if (listBoxStorages.SelectedIndex == -1) return; + + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + if (obj + plane > -1) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowPlanes(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } /// /// Удаление объекта из набора /// @@ -140,27 +162,6 @@ namespace AirBomber ReloadObjects(); } } - private void AddPlane(DrawningAirPlane plane) - { - plane._pictureWidth = pictureBoxCollection.Width; - plane._pictureHeight = pictureBoxCollection.Height; - - if (listBoxStorages.SelectedIndex == -1) return; - - var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; - if (obj == null) - { - return; - } - if (obj + plane > -1) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowPlanes(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + } } diff --git a/AirBomber/AirBomber/FormPlaneConfig.Designer.cs b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs index 70e2b0c..dbf6319 100644 --- a/AirBomber/AirBomber/FormPlaneConfig.Designer.cs +++ b/AirBomber/AirBomber/FormPlaneConfig.Designer.cs @@ -126,8 +126,6 @@ panelPurple.Name = "panelPurple"; panelPurple.Size = new Size(54, 54); panelPurple.TabIndex = 1; - panelPurple.DragDrop += PanelObject_DragDrop; - panelPurple.DragEnter += PanelObject_DragEnter; panelPurple.MouseDown += panelColor_MouseDown; // // panelBlack @@ -137,8 +135,6 @@ panelBlack.Name = "panelBlack"; panelBlack.Size = new Size(54, 54); panelBlack.TabIndex = 1; - panelBlack.DragDrop += PanelObject_DragDrop; - panelBlack.DragEnter += PanelObject_DragEnter; panelBlack.MouseDown += panelColor_MouseDown; // // panelGray @@ -148,8 +144,6 @@ panelGray.Name = "panelGray"; panelGray.Size = new Size(54, 54); panelGray.TabIndex = 1; - panelGray.DragDrop += PanelObject_DragDrop; - panelGray.DragEnter += PanelObject_DragEnter; panelGray.MouseDown += panelColor_MouseDown; // // panelWhite @@ -159,8 +153,6 @@ panelWhite.Name = "panelWhite"; panelWhite.Size = new Size(54, 54); panelWhite.TabIndex = 1; - panelWhite.DragDrop += PanelObject_DragDrop; - panelWhite.DragEnter += PanelObject_DragEnter; panelWhite.MouseDown += panelColor_MouseDown; // // panelYellow @@ -170,8 +162,6 @@ panelYellow.Name = "panelYellow"; panelYellow.Size = new Size(54, 54); panelYellow.TabIndex = 1; - panelYellow.DragDrop += PanelObject_DragDrop; - panelYellow.DragEnter += PanelObject_DragEnter; panelYellow.MouseDown += panelColor_MouseDown; // // panelBlue @@ -181,8 +171,6 @@ panelBlue.Name = "panelBlue"; panelBlue.Size = new Size(54, 54); panelBlue.TabIndex = 1; - panelBlue.DragDrop += PanelObject_DragDrop; - panelBlue.DragEnter += PanelObject_DragEnter; panelBlue.MouseDown += panelColor_MouseDown; // // panelGreen @@ -192,8 +180,6 @@ panelGreen.Name = "panelGreen"; panelGreen.Size = new Size(54, 54); panelGreen.TabIndex = 1; - panelGreen.DragDrop += PanelObject_DragDrop; - panelGreen.DragEnter += PanelObject_DragEnter; panelGreen.MouseDown += panelColor_MouseDown; // // panelRed @@ -203,8 +189,6 @@ panelRed.Name = "panelRed"; panelRed.Size = new Size(54, 54); panelRed.TabIndex = 0; - panelRed.DragDrop += PanelObject_DragDrop; - panelRed.DragEnter += PanelObject_DragEnter; panelRed.MouseDown += panelColor_MouseDown; // // checkBoxFuelTanks diff --git a/AirBomber/AirBomber/FormPlaneConfig.cs b/AirBomber/AirBomber/FormPlaneConfig.cs index b00e861..b41872a 100644 --- a/AirBomber/AirBomber/FormPlaneConfig.cs +++ b/AirBomber/AirBomber/FormPlaneConfig.cs @@ -19,8 +19,8 @@ namespace AirBomber /// /// Делегат для передачи объекта-автомобиля /// - /// - private event AirPlaneDelegate? EventAddPlane; + /// + private event Action? EventAddPlane; /// /// Конструктор /// @@ -53,7 +53,7 @@ namespace AirBomber /// Добавление события /// /// Привязанный метод - public void AddEvent(AirPlaneDelegate ev) + public void AddEvent(Action ev) { if (EventAddPlane == null) { -- 2.25.1