From 181f8dac1ef1405d969a87a00d7de2b7d586bbe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B0=D0=B1=D0=B5=D0=B5=D0=B2=20=D0=90=D0=BB=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Wed, 29 Nov 2023 19:01:49 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=205=20=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawningObjects/DrawningAircraftGun.cs | 4 +- .../Entities/EntityAircraftGun.cs | 4 + .../Entities/EntityAntiAircraftGun.cs | 4 + .../FormAircraftGunCollection.cs | 39 +- .../FormAircraftGunConfig.Designer.cs | 400 ++++++++++++++++++ .../AntiAircraftGun/FormAircraftGunConfig.cs | 135 ++++++ .../FormAircraftGunConfig.resx | 60 +++ 7 files changed, 631 insertions(+), 15 deletions(-) create mode 100644 AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.Designer.cs create mode 100644 AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.cs create mode 100644 AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.resx diff --git a/AntiAircraftGun/AntiAircraftGun/DrawningObjects/DrawningAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/DrawningObjects/DrawningAircraftGun.cs index c17189d..31970ae 100644 --- a/AntiAircraftGun/AntiAircraftGun/DrawningObjects/DrawningAircraftGun.cs +++ b/AntiAircraftGun/AntiAircraftGun/DrawningObjects/DrawningAircraftGun.cs @@ -15,10 +15,10 @@ namespace AntiAircraftGun.DrawningObjects public EntityAircraftGun? EntityAircraftGun { get; protected set; } // Ширина окна - private int pictureWidth; + public int pictureWidth; // Высота окна - private int pictureHeight; + public int pictureHeight; // Левая координата прорисовки зенитки protected int startPosX; diff --git a/AntiAircraftGun/AntiAircraftGun/Entities/EntityAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/Entities/EntityAircraftGun.cs index 619eba4..d1caa8c 100644 --- a/AntiAircraftGun/AntiAircraftGun/Entities/EntityAircraftGun.cs +++ b/AntiAircraftGun/AntiAircraftGun/Entities/EntityAircraftGun.cs @@ -9,6 +9,10 @@ namespace AntiAircraftGun.Entities // Класс-сущность "Зенитка" public class EntityAircraftGun { + public void Bodycolor(Color color) + { + BodyColor = color; + } // Скорость public int Speed { get; private set; } diff --git a/AntiAircraftGun/AntiAircraftGun/Entities/EntityAntiAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/Entities/EntityAntiAircraftGun.cs index 15cc1fc..5db8b76 100644 --- a/AntiAircraftGun/AntiAircraftGun/Entities/EntityAntiAircraftGun.cs +++ b/AntiAircraftGun/AntiAircraftGun/Entities/EntityAntiAircraftGun.cs @@ -9,6 +9,10 @@ namespace AntiAircraftGun.Entities // Класс-сущность "Стреляющая зенитка" public class EntityAntiAircraftGun : EntityAircraftGun { + public void Additionalcolor(Color color) + { + AdditionalColor = color; + } // Доп. цвет public Color AdditionalColor { get; private set; } // Признак наличия люка diff --git a/AntiAircraftGun/AntiAircraftGun/FormAircraftGunCollection.cs b/AntiAircraftGun/AntiAircraftGun/FormAircraftGunCollection.cs index 66a8bb9..17a0694 100644 --- a/AntiAircraftGun/AntiAircraftGun/FormAircraftGunCollection.cs +++ b/AntiAircraftGun/AntiAircraftGun/FormAircraftGunCollection.cs @@ -85,6 +85,29 @@ namespace AntiAircraftGun } } + private void AddAircraftGun(DrawningAircraftGun aircraftGun) + { + aircraftGun.pictureWidth = pictureBoxCollection.Width; + aircraftGun.pictureHeight = pictureBoxCollection.Height; + if (listBoxStorages.SelectedIndex == -1) + { + return; + } + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + if (obj + aircraftGun) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowAntiAircraftGuns(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } // Добавление объекта в набор private void ButtonAddAircraftGun_Click(object sender, EventArgs e) { @@ -97,19 +120,9 @@ namespace AntiAircraftGun { return; } - FormAntiAircraftGun form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - if (obj + form.SelectedAircraftGun) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowAntiAircraftGuns(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + FormAircraftGunConfig form = new FormAircraftGunConfig(); + form.Show(); + form.AddEvent(AddAircraftGun); } // Удаление набора diff --git a/AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.Designer.cs b/AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.Designer.cs new file mode 100644 index 0000000..67276fc --- /dev/null +++ b/AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.Designer.cs @@ -0,0 +1,400 @@ +namespace AntiAircraftGun +{ + partial class FormAircraftGunConfig + { + /// + /// 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.groupBox1 = new System.Windows.Forms.GroupBox(); + this.labelModifiedObject = new System.Windows.Forms.Label(); + this.labelSimpleObject = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.panelGray = new System.Windows.Forms.Panel(); + this.panelWhite = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelRed = new System.Windows.Forms.Panel(); + this.checkBoxGuns = new System.Windows.Forms.CheckBox(); + this.checkBoxLuke = new System.Windows.Forms.CheckBox(); + this.checkBoxRadar = new System.Windows.Forms.CheckBox(); + this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.labelWeight = new System.Windows.Forms.Label(); + this.labelSpeed = new System.Windows.Forms.Label(); + this.pictureBoxObject = new System.Windows.Forms.PictureBox(); + this.panel9 = new System.Windows.Forms.Panel(); + this.LabelAdditionalColor = new System.Windows.Forms.Label(); + this.LabelColor = new System.Windows.Forms.Label(); + this.ButtonOk = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); + this.panel9.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.labelModifiedObject); + this.groupBox1.Controls.Add(this.labelSimpleObject); + this.groupBox1.Controls.Add(this.groupBox2); + this.groupBox1.Controls.Add(this.checkBoxGuns); + this.groupBox1.Controls.Add(this.checkBoxLuke); + this.groupBox1.Controls.Add(this.checkBoxRadar); + this.groupBox1.Controls.Add(this.numericUpDownWeight); + this.groupBox1.Controls.Add(this.numericUpDownSpeed); + this.groupBox1.Controls.Add(this.labelWeight); + this.groupBox1.Controls.Add(this.labelSpeed); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(538, 264); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Параметры"; + // + // labelModifiedObject + // + this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelModifiedObject.Location = new System.Drawing.Point(380, 202); + this.labelModifiedObject.Name = "labelModifiedObject"; + this.labelModifiedObject.Size = new System.Drawing.Size(114, 42); + this.labelModifiedObject.TabIndex = 9; + this.labelModifiedObject.Text = "Продвинутый"; + this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelModifiedObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); + this.labelModifiedObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); + this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); + // + // labelSimpleObject + // + this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelSimpleObject.Location = new System.Drawing.Point(238, 202); + this.labelSimpleObject.Name = "labelSimpleObject"; + this.labelSimpleObject.Size = new System.Drawing.Size(114, 42); + this.labelSimpleObject.TabIndex = 8; + this.labelSimpleObject.Text = "Простой"; + this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelSimpleObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); + this.labelSimpleObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); + this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.panelPurple); + this.groupBox2.Controls.Add(this.panelBlack); + this.groupBox2.Controls.Add(this.panelGray); + this.groupBox2.Controls.Add(this.panelWhite); + this.groupBox2.Controls.Add(this.panelYellow); + this.groupBox2.Controls.Add(this.panelBlue); + this.groupBox2.Controls.Add(this.panelGreen); + this.groupBox2.Controls.Add(this.panelRed); + this.groupBox2.Location = new System.Drawing.Point(217, 28); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(302, 149); + this.groupBox2.TabIndex = 7; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Цвета"; + // + // panelPurple + // + this.panelPurple.BackColor = System.Drawing.Color.Purple; + this.panelPurple.Location = new System.Drawing.Point(235, 89); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(50, 50); + this.panelPurple.TabIndex = 7; + // + // panelBlack + // + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(163, 89); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(50, 50); + this.panelBlack.TabIndex = 6; + // + // panelGray + // + this.panelGray.BackColor = System.Drawing.Color.Gray; + this.panelGray.Location = new System.Drawing.Point(91, 89); + this.panelGray.Name = "panelGray"; + this.panelGray.Size = new System.Drawing.Size(50, 50); + this.panelGray.TabIndex = 5; + // + // panelWhite + // + this.panelWhite.BackColor = System.Drawing.Color.White; + this.panelWhite.Location = new System.Drawing.Point(21, 89); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(50, 50); + this.panelWhite.TabIndex = 4; + // + // panelYellow + // + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(235, 22); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(50, 50); + this.panelYellow.TabIndex = 3; + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(163, 22); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(50, 50); + this.panelBlue.TabIndex = 2; + // + // panelGreen + // + this.panelGreen.BackColor = System.Drawing.Color.Green; + this.panelGreen.Location = new System.Drawing.Point(91, 22); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(50, 50); + this.panelGreen.TabIndex = 1; + // + // panelRed + // + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(21, 22); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(50, 50); + this.panelRed.TabIndex = 0; + // + // checkBoxGuns + // + this.checkBoxGuns.AutoSize = true; + this.checkBoxGuns.Location = new System.Drawing.Point(16, 202); + this.checkBoxGuns.Name = "checkBoxGuns"; + this.checkBoxGuns.Size = new System.Drawing.Size(166, 19); + this.checkBoxGuns.TabIndex = 6; + this.checkBoxGuns.Text = "Признак наличия орудий"; + this.checkBoxGuns.UseVisualStyleBackColor = true; + // + // checkBoxLuke + // + this.checkBoxLuke.AutoSize = true; + this.checkBoxLuke.Location = new System.Drawing.Point(16, 160); + this.checkBoxLuke.Name = "checkBoxLuke"; + this.checkBoxLuke.Size = new System.Drawing.Size(162, 19); + this.checkBoxLuke.TabIndex = 5; + this.checkBoxLuke.Text = "Признак наличия лючка"; + this.checkBoxLuke.UseVisualStyleBackColor = true; + // + // checkBoxRadar + // + this.checkBoxRadar.AutoSize = true; + this.checkBoxRadar.Location = new System.Drawing.Point(16, 119); + this.checkBoxRadar.Name = "checkBoxRadar"; + this.checkBoxRadar.Size = new System.Drawing.Size(164, 19); + this.checkBoxRadar.TabIndex = 4; + this.checkBoxRadar.Text = "Признак наличия радара"; + this.checkBoxRadar.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(84, 75); + this.numericUpDownWeight.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownWeight.Minimum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(75, 23); + this.numericUpDownWeight.TabIndex = 3; + this.numericUpDownWeight.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(84, 28); + this.numericUpDownSpeed.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownSpeed.Minimum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownSpeed.Name = "numericUpDownSpeed"; + this.numericUpDownSpeed.Size = new System.Drawing.Size(75, 23); + this.numericUpDownSpeed.TabIndex = 2; + this.numericUpDownSpeed.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelWeight + // + this.labelWeight.AutoSize = true; + this.labelWeight.Location = new System.Drawing.Point(16, 77); + this.labelWeight.Name = "labelWeight"; + this.labelWeight.Size = new System.Drawing.Size(29, 15); + this.labelWeight.TabIndex = 1; + this.labelWeight.Text = "Вес:"; + // + // labelSpeed + // + this.labelSpeed.AutoSize = true; + this.labelSpeed.Location = new System.Drawing.Point(16, 30); + this.labelSpeed.Name = "labelSpeed"; + this.labelSpeed.Size = new System.Drawing.Size(62, 15); + this.labelSpeed.TabIndex = 0; + this.labelSpeed.Text = "Скорость:"; + // + // pictureBoxObject + // + this.pictureBoxObject.Location = new System.Drawing.Point(19, 58); + this.pictureBoxObject.Name = "pictureBoxObject"; + this.pictureBoxObject.Size = new System.Drawing.Size(278, 154); + this.pictureBoxObject.TabIndex = 1; + this.pictureBoxObject.TabStop = false; + // + // panel9 + // + this.panel9.AllowDrop = true; + this.panel9.Controls.Add(this.LabelAdditionalColor); + this.panel9.Controls.Add(this.LabelColor); + this.panel9.Controls.Add(this.pictureBoxObject); + this.panel9.Location = new System.Drawing.Point(566, 21); + this.panel9.Name = "panel9"; + this.panel9.Size = new System.Drawing.Size(311, 222); + this.panel9.TabIndex = 2; + this.panel9.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); + this.panel9.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); + // + // LabelAdditionalColor + // + this.LabelAdditionalColor.AllowDrop = true; + this.LabelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.LabelAdditionalColor.Location = new System.Drawing.Point(172, 19); + this.LabelAdditionalColor.Name = "LabelAdditionalColor"; + this.LabelAdditionalColor.Size = new System.Drawing.Size(125, 36); + this.LabelAdditionalColor.TabIndex = 3; + this.LabelAdditionalColor.Text = "Доп. цвет"; + this.LabelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.LabelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop); + this.LabelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); + this.LabelAdditionalColor.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // LabelColor + // + this.LabelColor.AllowDrop = true; + this.LabelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.LabelColor.Location = new System.Drawing.Point(19, 19); + this.LabelColor.Name = "LabelColor"; + this.LabelColor.Size = new System.Drawing.Size(125, 36); + this.LabelColor.TabIndex = 2; + this.LabelColor.Text = "Цвет"; + this.LabelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.LabelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop); + this.LabelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); + this.LabelColor.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // ButtonOk + // + this.ButtonOk.Location = new System.Drawing.Point(585, 248); + this.ButtonOk.Name = "ButtonOk"; + this.ButtonOk.Size = new System.Drawing.Size(125, 32); + this.ButtonOk.TabIndex = 3; + this.ButtonOk.Text = "Добавить"; + this.ButtonOk.UseVisualStyleBackColor = true; + this.ButtonOk.Click += new System.EventHandler(this.ButtonOk_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(738, 248); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(125, 32); + this.ButtonCancel.TabIndex = 3; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + // + // FormAircraftGunConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(901, 288); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.panel9); + this.Controls.Add(this.ButtonOk); + this.Controls.Add(this.groupBox1); + this.Name = "FormAircraftGunConfig"; + this.Text = "Создание объекта"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); + this.panel9.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBox1; + private Label labelModifiedObject; + private Label labelSimpleObject; + private GroupBox groupBox2; + private Panel panelPurple; + private Panel panelBlack; + private Panel panelGray; + private Panel panelWhite; + private Panel panelYellow; + private Panel panelBlue; + private Panel panelGreen; + private Panel panelRed; + private CheckBox checkBoxGuns; + private CheckBox checkBoxLuke; + private CheckBox checkBoxRadar; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelWeight; + private Label labelSpeed; + private PictureBox pictureBoxObject; + private Panel panel9; + private Label LabelAdditionalColor; + private Label LabelColor; + private Button ButtonOk; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.cs b/AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.cs new file mode 100644 index 0000000..55a443b --- /dev/null +++ b/AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.cs @@ -0,0 +1,135 @@ +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; +using AntiAircraftGun.DrawningObjects; +using AntiAircraftGun.Entities; + +namespace AntiAircraftGun +{ + public partial class FormAircraftGunConfig : Form + { + // Переменная выбранная зенитка + DrawningAircraftGun? _aircraftGun = null; + // Событие + private event Action? EventAddAircraftGun; + + public FormAircraftGunConfig() + { + 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; + ButtonCancel.Click += (sender, e) => Close(); + } + + private void DrawAircraftGun() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _aircraftGun?.SetPosition(5, 5); + _aircraftGun?.DrawZenitka(gr); + pictureBoxObject.Image = bmp; + } + + public void AddEvent(Action ev) + { + if (EventAddAircraftGun == null) + { + EventAddAircraftGun = ev; + } + else + { + EventAddAircraftGun += ev; + } + } + + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, 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 "labelSimpleObject": + _aircraftGun = new DrawningAircraftGun((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, + pictureBoxObject.Width, pictureBoxObject.Height); + break; + case "labelModifiedObject": + _aircraftGun = new DrawingAntiAircraftGun((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, + checkBoxLuke.Checked, checkBoxGuns.Checked, checkBoxRadar.Checked, pictureBoxObject.Width, pictureBoxObject.Height); + break; + } + DrawAircraftGun(); + } + + private void ButtonOk_Click(object sender, EventArgs e) + { + EventAddAircraftGun?.Invoke(_aircraftGun); + Close(); + } + + private void LabelColor_DragDrop(object sender, DragEventArgs e) + { + if (_aircraftGun == null) + { + return; + } + switch (((Label)sender).Name) + { + case "LabelColor": + _aircraftGun.EntityAircraftGun.Bodycolor((Color)e.Data.GetData(typeof(Color))); + break; + case "LabelAdditionalColor": + if (_aircraftGun == null) + { + return; + } + (_aircraftGun.EntityAircraftGun as EntityAntiAircraftGun).Additionalcolor((Color)e.Data.GetData(typeof(Color))); + break; + } + DrawAircraftGun(); + } + + private void LabelColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(typeof(Color)) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + } +} diff --git a/AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.resx b/AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/AntiAircraftGun/AntiAircraftGun/FormAircraftGunConfig.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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