From 350c0b31eae5db806b164df6a37fc0cedc565de1 Mon Sep 17 00:00:00 2001 From: YourDax Date: Tue, 14 Nov 2023 00:01:05 +0400 Subject: [PATCH 1/4] 80% --- .../AdvancedDrawingAntiAirCraftGun.cs | 10 +- .../BaseDrawingAntiAirCraftGun.cs | 10 +- .../Enitites/EntityAdvancedAntiAircraftGun.cs | 2 +- .../Enitites/EntityAntiAirCraftGun.cs | 8 +- .../FormAntiAirCraftGunCollection.cs | 11 +- .../FormAntiAirCraftGunConfig.Designer.cs | 389 ++++++++++++++++++ .../FormAntiAirCraftGunConfig.cs | 153 +++++++ .../FormAntiAirCraftGunConfig.resx | 60 +++ 8 files changed, 631 insertions(+), 12 deletions(-) create mode 100644 AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs create mode 100644 AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs create mode 100644 AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.resx diff --git a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/AdvancedDrawingAntiAirCraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/AdvancedDrawingAntiAirCraftGun.cs index 8d28d7e..4df9646 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/AdvancedDrawingAntiAirCraftGun.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/AdvancedDrawingAntiAirCraftGun.cs @@ -16,9 +16,15 @@ namespace AntiAircraftGun.DrawingObjects public AdvancedDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, Color dopColor, bool rocket,bool radar, int width, int height) : base(speed, weight, bodyColor, additionalColor, width, height) { - AntiAirСraftGun = new EntityAdvancedAntiAirCraftGun(speed, weight, bodyColor, additionalColor, dopColor, rocket,radar); + if (AntiAirСraftGun!=null) + { + AntiAirСraftGun = new EntityAdvancedAntiAirCraftGun(speed, weight, bodyColor, additionalColor, dopColor, rocket, radar); + } + } + public void ChangeAddColor(Color col) + { + ((EntityAdvancedAntiAirCraftGun)AntiAirСraftGun).AdditionalColor = col; } - public override void DrawTransport(Graphics g) { if (AntiAirСraftGun is not EntityAdvancedAntiAirCraftGun advancedGun) diff --git a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs index 9dc56d4..bde380e 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs @@ -25,7 +25,7 @@ namespace AntiAircraftGun.DrawingObjects AntiAirСraftGun = new EntityAntiAirCraftGun(speed, weight, bodyColor, additionalColor); } - protected BaseDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height, int carWidth, int carHeight) + public BaseDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height, int carWidth, int carHeight) { _pictureWidth = width; _pictureHeight = height; @@ -46,6 +46,14 @@ namespace AntiAircraftGun.DrawingObjects } } + public void ChangeColor(Color col) + { + if (AntiAirСraftGun == null) + return; + AntiAirСraftGun.BodyColor = col; + } + + /// /// Координата X объекта /// diff --git a/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAdvancedAntiAircraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAdvancedAntiAircraftGun.cs index 31daa0d..be36030 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAdvancedAntiAircraftGun.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAdvancedAntiAircraftGun.cs @@ -9,7 +9,7 @@ namespace AntiAircraftGun.Enitites public class EntityAdvancedAntiAirCraftGun : EntityAntiAirCraftGun { - public Color DopColor { get; private set; } + public Color DopColor { get; set; } public bool Rocket { get; private set; } diff --git a/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAntiAirCraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAntiAirCraftGun.cs index ce0e940..4d348fe 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAntiAirCraftGun.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAntiAirCraftGun.cs @@ -11,19 +11,19 @@ namespace AntiAircraftGun.Enitites /// /// Скорость /// - public int Speed { get; private set; } + public int Speed { get; set; } /// /// Вес /// - public double Weight { get; private set; } + public double Weight { get; set; } /// /// Основной цвет /// - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } /// /// Шаг перемещения автомобиля /// - public Color AdditionalColor { get; private set; } + public Color AdditionalColor { get; set; } /// /// Шаг перемещения автомобиля /// diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs index e70e4a7..bfd13b0 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs @@ -90,6 +90,7 @@ namespace AntiAircraftGun ReloadObjects(); } } + private void ButtonAddZenit_Click(object sender, EventArgs e) { if (listBoxStorages.SelectedIndex == -1) @@ -103,12 +104,14 @@ namespace AntiAircraftGun MessageBox.Show("Выбранный набор не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - FormAntiAirCraftGun form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - if (obj + form.SelectedZenit) + FormMonorailConfig form = new(); + form.Show(); + Action? monorailDelegate = new((m) => { + bool q = (obj + m); + if (q) { MessageBox.Show("Объект добавлен"); + m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height); pictureBoxCollection.Image = obj.ShowZenits(); } else diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs new file mode 100644 index 0000000..bab80f2 --- /dev/null +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs @@ -0,0 +1,389 @@ +namespace AntiAircraftGun +{ + partial class FormAntiAirCraftGunConfig + { + /// + /// 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.panel1 = new System.Windows.Forms.Panel(); + this.groupBoxParameters = new System.Windows.Forms.GroupBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.checkBoxRadar = new System.Windows.Forms.CheckBox(); + this.checkBoxRocket = new System.Windows.Forms.CheckBox(); + this.groupBoxColor = new System.Windows.Forms.GroupBox(); + this.panelRed = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelWhite = new System.Windows.Forms.Panel(); + this.panelGray = new System.Windows.Forms.Panel(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.labelBase = new System.Windows.Forms.Label(); + this.labelAdvanced = new System.Windows.Forms.Label(); + this.pictureBoxObject = new System.Windows.Forms.PictureBox(); + this.labelColor = new System.Windows.Forms.Label(); + this.labelAdditionalColor = new System.Windows.Forms.Label(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.allowPanel = new System.Windows.Forms.Panel(); + this.panel1.SuspendLayout(); + this.groupBoxParameters.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + this.groupBoxColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); + this.allowPanel.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.groupBoxParameters); + this.panel1.Location = new System.Drawing.Point(7, 9); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(574, 306); + this.panel1.TabIndex = 0; + // + // groupBoxParameters + // + this.groupBoxParameters.Controls.Add(this.labelAdvanced); + this.groupBoxParameters.Controls.Add(this.labelBase); + this.groupBoxParameters.Controls.Add(this.groupBoxColor); + this.groupBoxParameters.Controls.Add(this.checkBoxRocket); + this.groupBoxParameters.Controls.Add(this.checkBoxRadar); + this.groupBoxParameters.Controls.Add(this.numericUpDownWeight); + this.groupBoxParameters.Controls.Add(this.numericUpDownSpeed); + this.groupBoxParameters.Controls.Add(this.label2); + this.groupBoxParameters.Controls.Add(this.label1); + this.groupBoxParameters.Location = new System.Drawing.Point(5, 3); + this.groupBoxParameters.Name = "groupBoxParameters"; + this.groupBoxParameters.Size = new System.Drawing.Size(566, 300); + this.groupBoxParameters.TabIndex = 0; + this.groupBoxParameters.TabStop = false; + this.groupBoxParameters.Text = "Параметры"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(44, 38); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(59, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Скорость"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(44, 84); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(26, 15); + this.label2.TabIndex = 1; + this.label2.Text = "Вес"; + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(128, 36); + 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(120, 23); + this.numericUpDownSpeed.TabIndex = 2; + this.numericUpDownSpeed.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(128, 82); + 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(120, 23); + this.numericUpDownWeight.TabIndex = 3; + this.numericUpDownWeight.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // checkBoxRadar + // + this.checkBoxRadar.AutoSize = true; + this.checkBoxRadar.Location = new System.Drawing.Point(41, 189); + this.checkBoxRadar.Name = "checkBoxRadar"; + this.checkBoxRadar.Size = new System.Drawing.Size(164, 19); + this.checkBoxRadar.TabIndex = 4; + this.checkBoxRadar.Text = "Признак наличия радара"; + this.checkBoxRadar.UseVisualStyleBackColor = true; + // + // checkBoxRocket + // + this.checkBoxRocket.AutoSize = true; + this.checkBoxRocket.Location = new System.Drawing.Point(41, 229); + this.checkBoxRocket.Name = "checkBoxRocket"; + this.checkBoxRocket.Size = new System.Drawing.Size(165, 19); + this.checkBoxRocket.TabIndex = 5; + this.checkBoxRocket.Text = "Признак наличия ракеты"; + this.checkBoxRocket.UseVisualStyleBackColor = true; + // + // groupBoxColor + // + this.groupBoxColor.Controls.Add(this.panelPurple); + this.groupBoxColor.Controls.Add(this.panelBlack); + this.groupBoxColor.Controls.Add(this.panelGray); + this.groupBoxColor.Controls.Add(this.panelWhite); + this.groupBoxColor.Controls.Add(this.panelYellow); + this.groupBoxColor.Controls.Add(this.panelBlue); + this.groupBoxColor.Controls.Add(this.panelGreen); + this.groupBoxColor.Controls.Add(this.panelRed); + this.groupBoxColor.Location = new System.Drawing.Point(287, 36); + this.groupBoxColor.Name = "groupBoxColor"; + this.groupBoxColor.Size = new System.Drawing.Size(273, 151); + this.groupBoxColor.TabIndex = 6; + this.groupBoxColor.TabStop = false; + this.groupBoxColor.Text = "Цвета"; + // + // panelRed + // + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(28, 27); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(50, 50); + this.panelRed.TabIndex = 0; + // + // panelGreen + // + this.panelGreen.BackColor = System.Drawing.Color.Green; + this.panelGreen.Location = new System.Drawing.Point(84, 27); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(50, 50); + this.panelGreen.TabIndex = 1; + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(140, 27); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(50, 50); + this.panelBlue.TabIndex = 2; + // + // panelYellow + // + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(196, 27); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(50, 50); + this.panelYellow.TabIndex = 2; + // + // panelWhite + // + this.panelWhite.BackColor = System.Drawing.Color.White; + this.panelWhite.Location = new System.Drawing.Point(28, 83); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(50, 50); + this.panelWhite.TabIndex = 2; + // + // panelGray + // + this.panelGray.BackColor = System.Drawing.Color.Gray; + this.panelGray.Location = new System.Drawing.Point(84, 83); + this.panelGray.Name = "panelGray"; + this.panelGray.Size = new System.Drawing.Size(50, 50); + this.panelGray.TabIndex = 2; + // + // panelBlack + // + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(140, 83); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(50, 50); + this.panelBlack.TabIndex = 2; + // + // panelPurple + // + this.panelPurple.BackColor = System.Drawing.Color.Purple; + this.panelPurple.Location = new System.Drawing.Point(196, 83); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(50, 50); + this.panelPurple.TabIndex = 2; + // + // labelBase + // + this.labelBase.Anchor = System.Windows.Forms.AnchorStyles.None; + this.labelBase.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelBase.Location = new System.Drawing.Point(315, 217); + this.labelBase.Name = "labelBase"; + this.labelBase.Size = new System.Drawing.Size(88, 40); + this.labelBase.TabIndex = 7; + this.labelBase.Text = "Простой"; + this.labelBase.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // labelAdvanced + // + this.labelAdvanced.Anchor = System.Windows.Forms.AnchorStyles.None; + this.labelAdvanced.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelAdvanced.Location = new System.Drawing.Point(427, 217); + this.labelAdvanced.Name = "labelAdvanced"; + this.labelAdvanced.Size = new System.Drawing.Size(88, 40); + this.labelAdvanced.TabIndex = 8; + this.labelAdvanced.Text = "Продвинутый"; + this.labelAdvanced.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // pictureBoxObject + // + this.pictureBoxObject.Location = new System.Drawing.Point(41, 85); + this.pictureBoxObject.Name = "pictureBoxObject"; + this.pictureBoxObject.Size = new System.Drawing.Size(227, 141); + this.pictureBoxObject.TabIndex = 1; + this.pictureBoxObject.TabStop = false; + // + // labelColor + // + this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelColor.Location = new System.Drawing.Point(20, 24); + this.labelColor.Name = "labelColor"; + this.labelColor.Size = new System.Drawing.Size(120, 32); + this.labelColor.TabIndex = 2; + this.labelColor.Text = "Цвет"; + this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragDrop); + this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter); + // + // labelAdditionalColor + // + this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelAdditionalColor.Location = new System.Drawing.Point(169, 24); + this.labelAdditionalColor.Name = "labelAdditionalColor"; + this.labelAdditionalColor.Size = new System.Drawing.Size(120, 32); + this.labelAdditionalColor.TabIndex = 3; + this.labelAdditionalColor.Text = "Доп.Цвет"; + this.labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.addColorLabel_DragDrop); + this.labelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(587, 278); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(164, 37); + this.buttonAdd.TabIndex = 4; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(757, 278); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(152, 37); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // allowPanel + // + this.allowPanel.Controls.Add(this.labelAdditionalColor); + this.allowPanel.Controls.Add(this.labelColor); + this.allowPanel.Controls.Add(this.pictureBoxObject); + this.allowPanel.Location = new System.Drawing.Point(589, 9); + this.allowPanel.Name = "allowPanel"; + this.allowPanel.Size = new System.Drawing.Size(316, 263); + this.allowPanel.TabIndex = 6; + this.allowPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.allowPanel_DragDrop); + this.allowPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.allowPanel_DragEnter); + // + // FormAntiAirCraftGunConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(912, 327); + this.Controls.Add(this.allowPanel); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.panel1); + this.Name = "FormAntiAirCraftGunConfig"; + this.Text = "FormAntiAirCraftGunConfig"; + this.panel1.ResumeLayout(false); + this.groupBoxParameters.ResumeLayout(false); + this.groupBoxParameters.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + this.groupBoxColor.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); + this.allowPanel.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel1; + private GroupBox groupBoxParameters; + private Label labelAdvanced; + private Label labelBase; + private GroupBox groupBoxColor; + 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 checkBoxRocket; + private CheckBox checkBoxRadar; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label label2; + private Label label1; + private PictureBox pictureBoxObject; + private Label labelColor; + private Label labelAdditionalColor; + private Button buttonAdd; + private Button buttonCancel; + private Panel allowPanel; + } +} \ No newline at end of file diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs new file mode 100644 index 0000000..c80b092 --- /dev/null +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs @@ -0,0 +1,153 @@ +using AntiAircraftGun.DrawingObjects; +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 AntiAircraftGun +{ + public partial class FormAntiAirCraftGunConfig : Form + { + /// + /// Делегат для передачи объекта-автомобиля + /// + + public delegate void CarDelegate(BaseDrawingAntiAirCraftGun zenit); + /// + /// Переменная-выбранная машина + /// + BaseDrawingAntiAirCraftGun? _zenit = null; + /// + /// Событие + /// + private event CarDelegate? EventAddZenit; + + /// + /// Конструктор + /// + public FormAntiAirCraftGunConfig() + { + InitializeComponent(); + panelBlack.MouseDown += PanelColor_MouseDown; + panelGreen.MouseDown += PanelColor_MouseDown; + panelRed.MouseDown += PanelColor_MouseDown; + panelBlue.MouseDown += PanelColor_MouseDown; + panelGreen.MouseDown += PanelColor_MouseDown; + panelYellow.MouseDown += PanelColor_MouseDown; + panelPurple.MouseDown += PanelColor_MouseDown; + panelWhite.MouseDown += PanelColor_MouseDown; + + buttonCancel.Click += (s, e) => Close(); + } + + public void DrawAntiAirCraftGun() + { + Bitmap bmp = new Bitmap(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _zenit?.SetPosition(5, 5); + _zenit?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + public void AddEvent(CarDelegate ev) + { + if (EventAddZenit == null) + { + EventAddZenit = ev; + } + else + { + EventAddZenit += ev; + } + } + + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,DragDropEffects.Move | DragDropEffects.Copy); + + } + + private void allowPanel_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text).ToString()) + { + case "labelBase": + _zenit = new BaseDrawingAntiAirCraftGun((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, Color.Black, pictureBoxObject.Width, + pictureBoxObject.Height); + break; + case "labelAdvanced": + _zenit = new AdvancedDrawingAntiAirCraftGun((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, Color.Black ,Color.Silver, checkBoxRadar.Checked, + checkBoxRocket.Checked, pictureBoxObject.Width,pictureBoxObject.Height); + break; + } + labelColor.BackColor = Color.Empty; + labelAdditionalColor.BackColor = Color.Empty; + DrawAntiAirCraftGun(); + + } + + private void allowPanel_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + + } + + private void addButton_Click(object sender, EventArgs e) + { + EventAddZenit?.Invoke(_zenit); + Close(); + } + + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); + } + + + private void colorLabel_DragDrop(object sender, DragEventArgs e) + { + if (_zenit == null) + return; + labelColor.BackColor = (Color)e.Data.GetData(typeof(Color)); + _zenit.ChangeColor(labelColor.BackColor); + DrawAntiAirCraftGun(); + } + + private void colorLabel_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void addColorLabel_DragDrop(object sender, DragEventArgs e) + { + if ((_zenit == null) || (_zenit is AdvancedDrawingAntiAirCraftGun == false)) + return; + labelAdditionalColor.BackColor = (Color)e.Data.GetData(typeof(Color)); + ((AdvancedDrawingAntiAirCraftGun)_zenit).ChangeAddColor(labelAdditionalColor.BackColor); + DrawAntiAirCraftGun(); + } + + + } +} + diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.resx b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.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 -- 2.25.1 From 1377cdaa77992e03829b03822a4f88ae9e025aa6 Mon Sep 17 00:00:00 2001 From: YourDax Date: Tue, 14 Nov 2023 02:43:14 +0400 Subject: [PATCH 2/4] Done --- .../AdvancedDrawingAntiAirCraftGun.cs | 5 +- .../BaseDrawingAntiAirCraftGun.cs | 12 +- .../Enitites/EntityAntiAirCraftGun.cs | 4 +- .../FormAntiAirCraftGunCollection.cs | 11 +- .../FormAntiAirCraftGunConfig.Designer.cs | 348 +++++++++--------- .../FormAntiAirCraftGunConfig.cs | 112 +++--- 6 files changed, 269 insertions(+), 223 deletions(-) diff --git a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/AdvancedDrawingAntiAirCraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/AdvancedDrawingAntiAirCraftGun.cs index 4df9646..19dc938 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/AdvancedDrawingAntiAirCraftGun.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/AdvancedDrawingAntiAirCraftGun.cs @@ -23,7 +23,10 @@ namespace AntiAircraftGun.DrawingObjects } public void ChangeAddColor(Color col) { - ((EntityAdvancedAntiAirCraftGun)AntiAirСraftGun).AdditionalColor = col; + if (AntiAirСraftGun!=null) + { + ((EntityAdvancedAntiAirCraftGun)AntiAirСraftGun).DopColor = col; + } } public override void DrawTransport(Graphics g) { diff --git a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs index bde380e..8af2932 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs @@ -11,8 +11,8 @@ namespace AntiAircraftGun.DrawingObjects public class BaseDrawingAntiAirCraftGun { public EntityAntiAirCraftGun? AntiAirСraftGun { get; protected set; } - private readonly int _pictureWidth; - private readonly int _pictureHeight; + private int _pictureWidth; + private int _pictureHeight; protected int _startPosX; protected int _startPosY; protected int _zenitWidth = 110; @@ -20,6 +20,8 @@ namespace AntiAircraftGun.DrawingObjects public BaseDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height) { + if (width <= _zenitWidth || height <= _zenitHeight) + return; _pictureWidth = width; _pictureHeight = height; AntiAirСraftGun = new EntityAntiAirCraftGun(speed, weight, bodyColor, additionalColor); @@ -52,8 +54,12 @@ namespace AntiAircraftGun.DrawingObjects return; AntiAirСraftGun.BodyColor = col; } + public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight) + { + _pictureHeight = pictureBoxHeight; + _pictureWidth = pictureBoxWidth; + } - /// /// Координата X объекта /// diff --git a/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAntiAirCraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAntiAirCraftGun.cs index 4d348fe..e84a64a 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAntiAirCraftGun.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/Enitites/EntityAntiAirCraftGun.cs @@ -11,11 +11,11 @@ namespace AntiAircraftGun.Enitites /// /// Скорость /// - public int Speed { get; set; } + public int Speed { get; private set; } /// /// Вес /// - public double Weight { get; set; } + public double Weight { get; private set; } /// /// Основной цвет /// diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs index bfd13b0..6c664d7 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs @@ -90,7 +90,7 @@ namespace AntiAircraftGun ReloadObjects(); } } - + private void ButtonAddZenit_Click(object sender, EventArgs e) { if (listBoxStorages.SelectedIndex == -1) @@ -104,9 +104,9 @@ namespace AntiAircraftGun MessageBox.Show("Выбранный набор не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - FormMonorailConfig form = new(); + FormAntiAirCraftGunConfig form = new(); form.Show(); - Action? monorailDelegate = new((m) => { + CarDelegate carDelegate = new CarDelegate((m) => { bool q = (obj + m); if (q) { @@ -118,7 +118,10 @@ namespace AntiAircraftGun { MessageBox.Show("Не удалось добавить объект"); } - } + }); + + form.AddEvent(carDelegate); + } private void ButtonDeleteZenit_Click(object sender, EventArgs e) diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs index bab80f2..50c1b86 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs @@ -30,23 +30,23 @@ { this.panel1 = new System.Windows.Forms.Panel(); this.groupBoxParameters = new System.Windows.Forms.GroupBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); - this.checkBoxRadar = new System.Windows.Forms.CheckBox(); - this.checkBoxRocket = new System.Windows.Forms.CheckBox(); - this.groupBoxColor = new System.Windows.Forms.GroupBox(); - this.panelRed = new System.Windows.Forms.Panel(); - this.panelGreen = new System.Windows.Forms.Panel(); - this.panelBlue = new System.Windows.Forms.Panel(); - this.panelYellow = new System.Windows.Forms.Panel(); - this.panelWhite = new System.Windows.Forms.Panel(); - this.panelGray = new System.Windows.Forms.Panel(); - this.panelBlack = new System.Windows.Forms.Panel(); - this.panelPurple = new System.Windows.Forms.Panel(); - this.labelBase = new System.Windows.Forms.Label(); this.labelAdvanced = new System.Windows.Forms.Label(); + this.labelBase = new System.Windows.Forms.Label(); + this.groupBoxColor = 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.checkBoxRocket = 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.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); this.pictureBoxObject = new System.Windows.Forms.PictureBox(); this.labelColor = new System.Windows.Forms.Label(); this.labelAdditionalColor = new System.Windows.Forms.Label(); @@ -55,9 +55,9 @@ this.allowPanel = new System.Windows.Forms.Panel(); this.panel1.SuspendLayout(); this.groupBoxParameters.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); this.groupBoxColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); this.allowPanel.SuspendLayout(); this.SuspendLayout(); @@ -88,45 +88,130 @@ this.groupBoxParameters.TabStop = false; this.groupBoxParameters.Text = "Параметры"; // - // label1 + // labelAdvanced // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(44, 38); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(59, 15); - this.label1.TabIndex = 0; - this.label1.Text = "Скорость"; + this.labelAdvanced.Anchor = System.Windows.Forms.AnchorStyles.None; + this.labelAdvanced.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelAdvanced.Location = new System.Drawing.Point(427, 217); + this.labelAdvanced.Name = "labelAdvanced"; + this.labelAdvanced.Size = new System.Drawing.Size(88, 40); + this.labelAdvanced.TabIndex = 8; + this.labelAdvanced.Text = "Продвинутый"; + this.labelAdvanced.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelAdvanced.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); // - // label2 + // labelBase // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(44, 84); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(26, 15); - this.label2.TabIndex = 1; - this.label2.Text = "Вес"; + this.labelBase.Anchor = System.Windows.Forms.AnchorStyles.None; + this.labelBase.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelBase.Location = new System.Drawing.Point(315, 217); + this.labelBase.Name = "labelBase"; + this.labelBase.Size = new System.Drawing.Size(88, 40); + this.labelBase.TabIndex = 7; + this.labelBase.Text = "Простой"; + this.labelBase.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelBase.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); // - // numericUpDownSpeed + // groupBoxColor // - this.numericUpDownSpeed.Location = new System.Drawing.Point(128, 36); - 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(120, 23); - this.numericUpDownSpeed.TabIndex = 2; - this.numericUpDownSpeed.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); + this.groupBoxColor.Controls.Add(this.panelPurple); + this.groupBoxColor.Controls.Add(this.panelBlack); + this.groupBoxColor.Controls.Add(this.panelGray); + this.groupBoxColor.Controls.Add(this.panelWhite); + this.groupBoxColor.Controls.Add(this.panelYellow); + this.groupBoxColor.Controls.Add(this.panelBlue); + this.groupBoxColor.Controls.Add(this.panelGreen); + this.groupBoxColor.Controls.Add(this.panelRed); + this.groupBoxColor.Location = new System.Drawing.Point(287, 36); + this.groupBoxColor.Name = "groupBoxColor"; + this.groupBoxColor.Size = new System.Drawing.Size(273, 151); + this.groupBoxColor.TabIndex = 6; + this.groupBoxColor.TabStop = false; + this.groupBoxColor.Text = "Цвета"; + // + // panelPurple + // + this.panelPurple.BackColor = System.Drawing.Color.Purple; + this.panelPurple.Location = new System.Drawing.Point(196, 83); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(50, 50); + this.panelPurple.TabIndex = 2; + // + // panelBlack + // + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(140, 83); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(50, 50); + this.panelBlack.TabIndex = 2; + // + // panelGray + // + this.panelGray.BackColor = System.Drawing.Color.Gray; + this.panelGray.Location = new System.Drawing.Point(84, 83); + this.panelGray.Name = "panelGray"; + this.panelGray.Size = new System.Drawing.Size(50, 50); + this.panelGray.TabIndex = 2; + // + // panelWhite + // + this.panelWhite.BackColor = System.Drawing.Color.White; + this.panelWhite.Location = new System.Drawing.Point(28, 83); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(50, 50); + this.panelWhite.TabIndex = 2; + // + // panelYellow + // + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(196, 27); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(50, 50); + this.panelYellow.TabIndex = 2; + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(140, 27); + 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(84, 27); + 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(28, 27); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(50, 50); + this.panelRed.TabIndex = 0; + // + // checkBoxRocket + // + this.checkBoxRocket.AutoSize = true; + this.checkBoxRocket.Location = new System.Drawing.Point(41, 229); + this.checkBoxRocket.Name = "checkBoxRocket"; + this.checkBoxRocket.Size = new System.Drawing.Size(165, 19); + this.checkBoxRocket.TabIndex = 5; + this.checkBoxRocket.Text = "Признак наличия ракеты"; + this.checkBoxRocket.UseVisualStyleBackColor = true; + // + // checkBoxRadar + // + this.checkBoxRadar.AutoSize = true; + this.checkBoxRadar.Location = new System.Drawing.Point(41, 189); + 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 // @@ -150,128 +235,45 @@ 0, 0}); // - // checkBoxRadar + // numericUpDownSpeed // - this.checkBoxRadar.AutoSize = true; - this.checkBoxRadar.Location = new System.Drawing.Point(41, 189); - this.checkBoxRadar.Name = "checkBoxRadar"; - this.checkBoxRadar.Size = new System.Drawing.Size(164, 19); - this.checkBoxRadar.TabIndex = 4; - this.checkBoxRadar.Text = "Признак наличия радара"; - this.checkBoxRadar.UseVisualStyleBackColor = true; + this.numericUpDownSpeed.Location = new System.Drawing.Point(128, 36); + 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(120, 23); + this.numericUpDownSpeed.TabIndex = 2; + this.numericUpDownSpeed.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); // - // checkBoxRocket + // label2 // - this.checkBoxRocket.AutoSize = true; - this.checkBoxRocket.Location = new System.Drawing.Point(41, 229); - this.checkBoxRocket.Name = "checkBoxRocket"; - this.checkBoxRocket.Size = new System.Drawing.Size(165, 19); - this.checkBoxRocket.TabIndex = 5; - this.checkBoxRocket.Text = "Признак наличия ракеты"; - this.checkBoxRocket.UseVisualStyleBackColor = true; + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(44, 84); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(26, 15); + this.label2.TabIndex = 1; + this.label2.Text = "Вес"; // - // groupBoxColor + // label1 // - this.groupBoxColor.Controls.Add(this.panelPurple); - this.groupBoxColor.Controls.Add(this.panelBlack); - this.groupBoxColor.Controls.Add(this.panelGray); - this.groupBoxColor.Controls.Add(this.panelWhite); - this.groupBoxColor.Controls.Add(this.panelYellow); - this.groupBoxColor.Controls.Add(this.panelBlue); - this.groupBoxColor.Controls.Add(this.panelGreen); - this.groupBoxColor.Controls.Add(this.panelRed); - this.groupBoxColor.Location = new System.Drawing.Point(287, 36); - this.groupBoxColor.Name = "groupBoxColor"; - this.groupBoxColor.Size = new System.Drawing.Size(273, 151); - this.groupBoxColor.TabIndex = 6; - this.groupBoxColor.TabStop = false; - this.groupBoxColor.Text = "Цвета"; - // - // panelRed - // - this.panelRed.BackColor = System.Drawing.Color.Red; - this.panelRed.Location = new System.Drawing.Point(28, 27); - this.panelRed.Name = "panelRed"; - this.panelRed.Size = new System.Drawing.Size(50, 50); - this.panelRed.TabIndex = 0; - // - // panelGreen - // - this.panelGreen.BackColor = System.Drawing.Color.Green; - this.panelGreen.Location = new System.Drawing.Point(84, 27); - this.panelGreen.Name = "panelGreen"; - this.panelGreen.Size = new System.Drawing.Size(50, 50); - this.panelGreen.TabIndex = 1; - // - // panelBlue - // - this.panelBlue.BackColor = System.Drawing.Color.Blue; - this.panelBlue.Location = new System.Drawing.Point(140, 27); - this.panelBlue.Name = "panelBlue"; - this.panelBlue.Size = new System.Drawing.Size(50, 50); - this.panelBlue.TabIndex = 2; - // - // panelYellow - // - this.panelYellow.BackColor = System.Drawing.Color.Yellow; - this.panelYellow.Location = new System.Drawing.Point(196, 27); - this.panelYellow.Name = "panelYellow"; - this.panelYellow.Size = new System.Drawing.Size(50, 50); - this.panelYellow.TabIndex = 2; - // - // panelWhite - // - this.panelWhite.BackColor = System.Drawing.Color.White; - this.panelWhite.Location = new System.Drawing.Point(28, 83); - this.panelWhite.Name = "panelWhite"; - this.panelWhite.Size = new System.Drawing.Size(50, 50); - this.panelWhite.TabIndex = 2; - // - // panelGray - // - this.panelGray.BackColor = System.Drawing.Color.Gray; - this.panelGray.Location = new System.Drawing.Point(84, 83); - this.panelGray.Name = "panelGray"; - this.panelGray.Size = new System.Drawing.Size(50, 50); - this.panelGray.TabIndex = 2; - // - // panelBlack - // - this.panelBlack.BackColor = System.Drawing.Color.Black; - this.panelBlack.Location = new System.Drawing.Point(140, 83); - this.panelBlack.Name = "panelBlack"; - this.panelBlack.Size = new System.Drawing.Size(50, 50); - this.panelBlack.TabIndex = 2; - // - // panelPurple - // - this.panelPurple.BackColor = System.Drawing.Color.Purple; - this.panelPurple.Location = new System.Drawing.Point(196, 83); - this.panelPurple.Name = "panelPurple"; - this.panelPurple.Size = new System.Drawing.Size(50, 50); - this.panelPurple.TabIndex = 2; - // - // labelBase - // - this.labelBase.Anchor = System.Windows.Forms.AnchorStyles.None; - this.labelBase.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelBase.Location = new System.Drawing.Point(315, 217); - this.labelBase.Name = "labelBase"; - this.labelBase.Size = new System.Drawing.Size(88, 40); - this.labelBase.TabIndex = 7; - this.labelBase.Text = "Простой"; - this.labelBase.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // labelAdvanced - // - this.labelAdvanced.Anchor = System.Windows.Forms.AnchorStyles.None; - this.labelAdvanced.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelAdvanced.Location = new System.Drawing.Point(427, 217); - this.labelAdvanced.Name = "labelAdvanced"; - this.labelAdvanced.Size = new System.Drawing.Size(88, 40); - this.labelAdvanced.TabIndex = 8; - this.labelAdvanced.Text = "Продвинутый"; - this.labelAdvanced.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(44, 38); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(59, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Скорость"; // // pictureBoxObject // @@ -283,6 +285,7 @@ // // labelColor // + this.labelColor.AllowDrop = true; this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelColor.Location = new System.Drawing.Point(20, 24); this.labelColor.Name = "labelColor"; @@ -295,6 +298,7 @@ // // labelAdditionalColor // + this.labelAdditionalColor.AllowDrop = true; this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelAdditionalColor.Location = new System.Drawing.Point(169, 24); this.labelAdditionalColor.Name = "labelAdditionalColor"; @@ -313,6 +317,7 @@ this.buttonAdd.TabIndex = 4; this.buttonAdd.Text = "Добавить"; this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.addButton_Click); // // buttonCancel // @@ -325,6 +330,7 @@ // // allowPanel // + this.allowPanel.AllowDrop = true; this.allowPanel.Controls.Add(this.labelAdditionalColor); this.allowPanel.Controls.Add(this.labelColor); this.allowPanel.Controls.Add(this.pictureBoxObject); @@ -349,9 +355,9 @@ this.panel1.ResumeLayout(false); this.groupBoxParameters.ResumeLayout(false); this.groupBoxParameters.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); this.groupBoxColor.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); this.allowPanel.ResumeLayout(false); this.ResumeLayout(false); diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs index c80b092..add32df 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs @@ -11,48 +11,57 @@ using System.Windows.Forms; namespace AntiAircraftGun { + /// + /// Делегат для передачи объекта-зенитной установки + /// + public delegate void CarDelegate(BaseDrawingAntiAirCraftGun zenit); + public partial class FormAntiAirCraftGunConfig : Form { /// - /// Делегат для передачи объекта-автомобиля - /// - - public delegate void CarDelegate(BaseDrawingAntiAirCraftGun zenit); - /// - /// Переменная-выбранная машина + /// Выбранная зенитная установка /// BaseDrawingAntiAirCraftGun? _zenit = null; + /// - /// Событие + /// Событие для добавления зенитной установки /// private event CarDelegate? EventAddZenit; /// - /// Конструктор + /// Конструктор формы /// public FormAntiAirCraftGunConfig() { InitializeComponent(); + + // Назначение обработчика события для панелей цвета и кнопки отмены panelBlack.MouseDown += PanelColor_MouseDown; - panelGreen.MouseDown += PanelColor_MouseDown; + panelGray.MouseDown += PanelColor_MouseDown; panelRed.MouseDown += PanelColor_MouseDown; panelBlue.MouseDown += PanelColor_MouseDown; panelGreen.MouseDown += PanelColor_MouseDown; panelYellow.MouseDown += PanelColor_MouseDown; panelPurple.MouseDown += PanelColor_MouseDown; panelWhite.MouseDown += PanelColor_MouseDown; - buttonCancel.Click += (s, e) => Close(); } + /// + /// Отрисовка зенитной установки на PictureBox + /// public void DrawAntiAirCraftGun() { Bitmap bmp = new Bitmap(pictureBoxObject.Width, pictureBoxObject.Height); Graphics gr = Graphics.FromImage(bmp); - _zenit?.SetPosition(5, 5); + _zenit?.SetPosition(15, 15); _zenit?.DrawTransport(gr); pictureBoxObject.Image = bmp; } + + /// + /// Добавление обработчика события для добавления зенитной установки + /// public void AddEvent(CarDelegate ev) { if (EventAddZenit == null) @@ -65,33 +74,17 @@ namespace AntiAircraftGun } } - private void PanelColor_MouseDown(object sender, MouseEventArgs e) + /// + /// Обработчик события MouseDown для LabelObject + /// + private void LabelObject_MouseDown(object sender, MouseEventArgs e) { - (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,DragDropEffects.Move | DragDropEffects.Copy); - - } - - private void allowPanel_DragDrop(object sender, DragEventArgs e) - { - switch (e.Data?.GetData(DataFormats.Text).ToString()) - { - case "labelBase": - _zenit = new BaseDrawingAntiAirCraftGun((int)numericUpDownSpeed.Value, - (int)numericUpDownWeight.Value, Color.White, Color.Black, pictureBoxObject.Width, - pictureBoxObject.Height); - break; - case "labelAdvanced": - _zenit = new AdvancedDrawingAntiAirCraftGun((int)numericUpDownSpeed.Value, - (int)numericUpDownWeight.Value, Color.White, Color.Black ,Color.Silver, checkBoxRadar.Checked, - checkBoxRocket.Checked, pictureBoxObject.Width,pictureBoxObject.Height); - break; - } - labelColor.BackColor = Color.Empty; - labelAdditionalColor.BackColor = Color.Empty; - DrawAntiAirCraftGun(); - + (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); } + /// + /// Обработчик события DragEnter для allowPanel + /// private void allowPanel_DragEnter(object sender, DragEventArgs e) { if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) @@ -102,21 +95,53 @@ namespace AntiAircraftGun { e.Effect = DragDropEffects.None; } - } + /// + /// Обработчик события DragDrop для allowPanel + /// + private void allowPanel_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text).ToString()) + { + case "labelBase": + _zenit = new BaseDrawingAntiAirCraftGun((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, Color.Gray, pictureBoxObject.Width, + pictureBoxObject.Height); + break; + case "labelAdvanced": + _zenit = new AdvancedDrawingAntiAirCraftGun((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, Color.Gray, Color.Silver, + checkBoxRadar.Checked, checkBoxRocket.Checked, pictureBoxObject.Width, + pictureBoxObject.Height); + break; + } + labelColor.BackColor = Color.Empty; + labelAdditionalColor.BackColor = Color.Empty; + DrawAntiAirCraftGun(); + } + + /// + /// Обработчик события Click для addButton + /// private void addButton_Click(object sender, EventArgs e) { EventAddZenit?.Invoke(_zenit); Close(); } - private void LabelObject_MouseDown(object sender, MouseEventArgs e) + /// + /// Обработчик события MouseDown для панелей цвета + /// + private void PanelColor_MouseDown(object sender, MouseEventArgs e) { - (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, + DragDropEffects.Move | DragDropEffects.Copy); } - + /// + /// Обработчик события DragDrop для colorLabel + /// private void colorLabel_DragDrop(object sender, DragEventArgs e) { if (_zenit == null) @@ -126,6 +151,9 @@ namespace AntiAircraftGun DrawAntiAirCraftGun(); } + /// + /// Обработчик события DragEnter для colorLabel + /// private void colorLabel_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(Color))) @@ -138,6 +166,9 @@ namespace AntiAircraftGun } } + /// + /// Обработчик события DragDrop для addColorLabel + /// private void addColorLabel_DragDrop(object sender, DragEventArgs e) { if ((_zenit == null) || (_zenit is AdvancedDrawingAntiAirCraftGun == false)) @@ -146,8 +177,5 @@ namespace AntiAircraftGun ((AdvancedDrawingAntiAirCraftGun)_zenit).ChangeAddColor(labelAdditionalColor.BackColor); DrawAntiAirCraftGun(); } - - } } - -- 2.25.1 From c63daba830afd8eae5996a0cd684a3960dd036c7 Mon Sep 17 00:00:00 2001 From: YourDax Date: Tue, 14 Nov 2023 02:48:52 +0400 Subject: [PATCH 3/4] fix --- .../DrawingObjects/BaseDrawingAntiAirCraftGun.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs index 8af2932..26b4fc2 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/DrawingObjects/BaseDrawingAntiAirCraftGun.cs @@ -27,7 +27,7 @@ namespace AntiAircraftGun.DrawingObjects AntiAirСraftGun = new EntityAntiAirCraftGun(speed, weight, bodyColor, additionalColor); } - public BaseDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height, int carWidth, int carHeight) + protected BaseDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height, int carWidth, int carHeight) { _pictureWidth = width; _pictureHeight = height; -- 2.25.1 From 9b21f4a1ef2c14ede6e31da698507ff5edd9f101 Mon Sep 17 00:00:00 2001 From: YourDax Date: Tue, 14 Nov 2023 12:31:11 +0400 Subject: [PATCH 4/4] fix --- .../FormAntiAirCraftGunCollection.cs | 7 +- .../FormAntiAirCraftGunConfig.Designer.cs | 485 +++++++++--------- .../FormAntiAirCraftGunConfig.cs | 15 +- .../FormAntiAirCraftGunConfig.resx | 62 ++- 4 files changed, 298 insertions(+), 271 deletions(-) diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs index 6c664d7..724e5ca 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunCollection.cs @@ -106,7 +106,7 @@ namespace AntiAircraftGun } FormAntiAirCraftGunConfig form = new(); form.Show(); - CarDelegate carDelegate = new CarDelegate((m) => { + Action? zenitDelegate = new((m) => { bool q = (obj + m); if (q) { @@ -119,11 +119,8 @@ namespace AntiAircraftGun MessageBox.Show("Не удалось добавить объект"); } }); - - form.AddEvent(carDelegate); - + form.AddEvent(zenitDelegate); } - private void ButtonDeleteZenit_Click(object sender, EventArgs e) { if (listBoxStorages.SelectedIndex == -1) diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs index 50c1b86..83f0bd9 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs @@ -28,340 +28,313 @@ /// private void InitializeComponent() { - this.panel1 = new System.Windows.Forms.Panel(); - this.groupBoxParameters = new System.Windows.Forms.GroupBox(); - this.labelAdvanced = new System.Windows.Forms.Label(); - this.labelBase = new System.Windows.Forms.Label(); - this.groupBoxColor = 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.checkBoxRocket = 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.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.pictureBoxObject = new System.Windows.Forms.PictureBox(); - this.labelColor = new System.Windows.Forms.Label(); - this.labelAdditionalColor = new System.Windows.Forms.Label(); - this.buttonAdd = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.allowPanel = new System.Windows.Forms.Panel(); - this.panel1.SuspendLayout(); - this.groupBoxParameters.SuspendLayout(); - this.groupBoxColor.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); - this.allowPanel.SuspendLayout(); - this.SuspendLayout(); + panel1 = new Panel(); + groupBoxParameters = new GroupBox(); + labelAdvanced = new Label(); + labelBase = new Label(); + groupBoxColor = new GroupBox(); + panelPurple = new Panel(); + panelBlack = new Panel(); + panelGray = new Panel(); + panelWhite = new Panel(); + panelYellow = new Panel(); + panelBlue = new Panel(); + panelGreen = new Panel(); + panelRed = new Panel(); + checkBoxRocket = new CheckBox(); + checkBoxRadar = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + numericUpDownSpeed = new NumericUpDown(); + label2 = new Label(); + label1 = new Label(); + pictureBoxObject = new PictureBox(); + labelColor = new Label(); + labelAdditionalColor = new Label(); + buttonAdd = new Button(); + buttonCancel = new Button(); + allowPanel = new Panel(); + panel1.SuspendLayout(); + groupBoxParameters.SuspendLayout(); + groupBoxColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + allowPanel.SuspendLayout(); + SuspendLayout(); // // panel1 // - this.panel1.Controls.Add(this.groupBoxParameters); - this.panel1.Location = new System.Drawing.Point(7, 9); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(574, 306); - this.panel1.TabIndex = 0; + panel1.Controls.Add(groupBoxParameters); + panel1.Location = new Point(7, 9); + panel1.Name = "panel1"; + panel1.Size = new Size(574, 306); + panel1.TabIndex = 0; // // groupBoxParameters // - this.groupBoxParameters.Controls.Add(this.labelAdvanced); - this.groupBoxParameters.Controls.Add(this.labelBase); - this.groupBoxParameters.Controls.Add(this.groupBoxColor); - this.groupBoxParameters.Controls.Add(this.checkBoxRocket); - this.groupBoxParameters.Controls.Add(this.checkBoxRadar); - this.groupBoxParameters.Controls.Add(this.numericUpDownWeight); - this.groupBoxParameters.Controls.Add(this.numericUpDownSpeed); - this.groupBoxParameters.Controls.Add(this.label2); - this.groupBoxParameters.Controls.Add(this.label1); - this.groupBoxParameters.Location = new System.Drawing.Point(5, 3); - this.groupBoxParameters.Name = "groupBoxParameters"; - this.groupBoxParameters.Size = new System.Drawing.Size(566, 300); - this.groupBoxParameters.TabIndex = 0; - this.groupBoxParameters.TabStop = false; - this.groupBoxParameters.Text = "Параметры"; + groupBoxParameters.Controls.Add(labelAdvanced); + groupBoxParameters.Controls.Add(labelBase); + groupBoxParameters.Controls.Add(groupBoxColor); + groupBoxParameters.Controls.Add(checkBoxRocket); + groupBoxParameters.Controls.Add(checkBoxRadar); + groupBoxParameters.Controls.Add(numericUpDownWeight); + groupBoxParameters.Controls.Add(numericUpDownSpeed); + groupBoxParameters.Controls.Add(label2); + groupBoxParameters.Controls.Add(label1); + groupBoxParameters.Location = new Point(5, 3); + groupBoxParameters.Name = "groupBoxParameters"; + groupBoxParameters.Size = new Size(566, 300); + groupBoxParameters.TabIndex = 0; + groupBoxParameters.TabStop = false; + groupBoxParameters.Text = "Параметры"; // // labelAdvanced // - this.labelAdvanced.Anchor = System.Windows.Forms.AnchorStyles.None; - this.labelAdvanced.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelAdvanced.Location = new System.Drawing.Point(427, 217); - this.labelAdvanced.Name = "labelAdvanced"; - this.labelAdvanced.Size = new System.Drawing.Size(88, 40); - this.labelAdvanced.TabIndex = 8; - this.labelAdvanced.Text = "Продвинутый"; - this.labelAdvanced.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelAdvanced.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); + labelAdvanced.Anchor = AnchorStyles.None; + labelAdvanced.BorderStyle = BorderStyle.FixedSingle; + labelAdvanced.Location = new Point(427, 217); + labelAdvanced.Name = "labelAdvanced"; + labelAdvanced.Size = new Size(88, 40); + labelAdvanced.TabIndex = 8; + labelAdvanced.Text = "Продвинутый"; + labelAdvanced.TextAlign = ContentAlignment.MiddleCenter; // // labelBase // - this.labelBase.Anchor = System.Windows.Forms.AnchorStyles.None; - this.labelBase.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelBase.Location = new System.Drawing.Point(315, 217); - this.labelBase.Name = "labelBase"; - this.labelBase.Size = new System.Drawing.Size(88, 40); - this.labelBase.TabIndex = 7; - this.labelBase.Text = "Простой"; - this.labelBase.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelBase.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); + labelBase.Anchor = AnchorStyles.None; + labelBase.BorderStyle = BorderStyle.FixedSingle; + labelBase.Location = new Point(315, 217); + labelBase.Name = "labelBase"; + labelBase.Size = new Size(88, 40); + labelBase.TabIndex = 7; + labelBase.Text = "Простой"; + labelBase.TextAlign = ContentAlignment.MiddleCenter; // // groupBoxColor // - this.groupBoxColor.Controls.Add(this.panelPurple); - this.groupBoxColor.Controls.Add(this.panelBlack); - this.groupBoxColor.Controls.Add(this.panelGray); - this.groupBoxColor.Controls.Add(this.panelWhite); - this.groupBoxColor.Controls.Add(this.panelYellow); - this.groupBoxColor.Controls.Add(this.panelBlue); - this.groupBoxColor.Controls.Add(this.panelGreen); - this.groupBoxColor.Controls.Add(this.panelRed); - this.groupBoxColor.Location = new System.Drawing.Point(287, 36); - this.groupBoxColor.Name = "groupBoxColor"; - this.groupBoxColor.Size = new System.Drawing.Size(273, 151); - this.groupBoxColor.TabIndex = 6; - this.groupBoxColor.TabStop = false; - this.groupBoxColor.Text = "Цвета"; + groupBoxColor.Controls.Add(panelPurple); + groupBoxColor.Controls.Add(panelBlack); + groupBoxColor.Controls.Add(panelGray); + groupBoxColor.Controls.Add(panelWhite); + groupBoxColor.Controls.Add(panelYellow); + groupBoxColor.Controls.Add(panelBlue); + groupBoxColor.Controls.Add(panelGreen); + groupBoxColor.Controls.Add(panelRed); + groupBoxColor.Location = new Point(287, 36); + groupBoxColor.Name = "groupBoxColor"; + groupBoxColor.Size = new Size(273, 151); + groupBoxColor.TabIndex = 6; + groupBoxColor.TabStop = false; + groupBoxColor.Text = "Цвета"; // // panelPurple // - this.panelPurple.BackColor = System.Drawing.Color.Purple; - this.panelPurple.Location = new System.Drawing.Point(196, 83); - this.panelPurple.Name = "panelPurple"; - this.panelPurple.Size = new System.Drawing.Size(50, 50); - this.panelPurple.TabIndex = 2; + panelPurple.BackColor = Color.Purple; + panelPurple.Location = new Point(196, 83); + panelPurple.Name = "panelPurple"; + panelPurple.Size = new Size(50, 50); + panelPurple.TabIndex = 2; // // panelBlack // - this.panelBlack.BackColor = System.Drawing.Color.Black; - this.panelBlack.Location = new System.Drawing.Point(140, 83); - this.panelBlack.Name = "panelBlack"; - this.panelBlack.Size = new System.Drawing.Size(50, 50); - this.panelBlack.TabIndex = 2; + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(140, 83); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(50, 50); + panelBlack.TabIndex = 2; // // panelGray // - this.panelGray.BackColor = System.Drawing.Color.Gray; - this.panelGray.Location = new System.Drawing.Point(84, 83); - this.panelGray.Name = "panelGray"; - this.panelGray.Size = new System.Drawing.Size(50, 50); - this.panelGray.TabIndex = 2; + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(84, 83); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(50, 50); + panelGray.TabIndex = 2; // // panelWhite // - this.panelWhite.BackColor = System.Drawing.Color.White; - this.panelWhite.Location = new System.Drawing.Point(28, 83); - this.panelWhite.Name = "panelWhite"; - this.panelWhite.Size = new System.Drawing.Size(50, 50); - this.panelWhite.TabIndex = 2; + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(28, 83); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(50, 50); + panelWhite.TabIndex = 2; // // panelYellow // - this.panelYellow.BackColor = System.Drawing.Color.Yellow; - this.panelYellow.Location = new System.Drawing.Point(196, 27); - this.panelYellow.Name = "panelYellow"; - this.panelYellow.Size = new System.Drawing.Size(50, 50); - this.panelYellow.TabIndex = 2; + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(196, 27); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(50, 50); + panelYellow.TabIndex = 2; // // panelBlue // - this.panelBlue.BackColor = System.Drawing.Color.Blue; - this.panelBlue.Location = new System.Drawing.Point(140, 27); - this.panelBlue.Name = "panelBlue"; - this.panelBlue.Size = new System.Drawing.Size(50, 50); - this.panelBlue.TabIndex = 2; + panelBlue.BackColor = Color.Blue; + panelBlue.Location = new Point(140, 27); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(50, 50); + panelBlue.TabIndex = 2; // // panelGreen // - this.panelGreen.BackColor = System.Drawing.Color.Green; - this.panelGreen.Location = new System.Drawing.Point(84, 27); - this.panelGreen.Name = "panelGreen"; - this.panelGreen.Size = new System.Drawing.Size(50, 50); - this.panelGreen.TabIndex = 1; + panelGreen.BackColor = Color.Green; + panelGreen.Location = new Point(84, 27); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(50, 50); + panelGreen.TabIndex = 1; // // panelRed // - this.panelRed.BackColor = System.Drawing.Color.Red; - this.panelRed.Location = new System.Drawing.Point(28, 27); - this.panelRed.Name = "panelRed"; - this.panelRed.Size = new System.Drawing.Size(50, 50); - this.panelRed.TabIndex = 0; + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(28, 27); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(50, 50); + panelRed.TabIndex = 0; // // checkBoxRocket // - this.checkBoxRocket.AutoSize = true; - this.checkBoxRocket.Location = new System.Drawing.Point(41, 229); - this.checkBoxRocket.Name = "checkBoxRocket"; - this.checkBoxRocket.Size = new System.Drawing.Size(165, 19); - this.checkBoxRocket.TabIndex = 5; - this.checkBoxRocket.Text = "Признак наличия ракеты"; - this.checkBoxRocket.UseVisualStyleBackColor = true; + checkBoxRocket.AutoSize = true; + checkBoxRocket.Location = new Point(41, 229); + checkBoxRocket.Name = "checkBoxRocket"; + checkBoxRocket.Size = new Size(165, 19); + checkBoxRocket.TabIndex = 5; + checkBoxRocket.Text = "Признак наличия ракеты"; + checkBoxRocket.UseVisualStyleBackColor = true; // // checkBoxRadar // - this.checkBoxRadar.AutoSize = true; - this.checkBoxRadar.Location = new System.Drawing.Point(41, 189); - this.checkBoxRadar.Name = "checkBoxRadar"; - this.checkBoxRadar.Size = new System.Drawing.Size(164, 19); - this.checkBoxRadar.TabIndex = 4; - this.checkBoxRadar.Text = "Признак наличия радара"; - this.checkBoxRadar.UseVisualStyleBackColor = true; + checkBoxRadar.AutoSize = true; + checkBoxRadar.Location = new Point(41, 189); + checkBoxRadar.Name = "checkBoxRadar"; + checkBoxRadar.Size = new Size(164, 19); + checkBoxRadar.TabIndex = 4; + checkBoxRadar.Text = "Признак наличия радара"; + checkBoxRadar.UseVisualStyleBackColor = true; // // numericUpDownWeight // - this.numericUpDownWeight.Location = new System.Drawing.Point(128, 82); - 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(120, 23); - this.numericUpDownWeight.TabIndex = 3; - this.numericUpDownWeight.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); + numericUpDownWeight.Location = new Point(128, 82); + 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(120, 23); + numericUpDownWeight.TabIndex = 3; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); // // numericUpDownSpeed // - this.numericUpDownSpeed.Location = new System.Drawing.Point(128, 36); - 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(120, 23); - this.numericUpDownSpeed.TabIndex = 2; - this.numericUpDownSpeed.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); + numericUpDownSpeed.Location = new Point(128, 36); + 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(120, 23); + numericUpDownSpeed.TabIndex = 2; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); // // label2 // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(44, 84); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(26, 15); - this.label2.TabIndex = 1; - this.label2.Text = "Вес"; + label2.AutoSize = true; + label2.Location = new Point(44, 84); + label2.Name = "label2"; + label2.Size = new Size(26, 15); + label2.TabIndex = 1; + label2.Text = "Вес"; // // label1 // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(44, 38); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(59, 15); - this.label1.TabIndex = 0; - this.label1.Text = "Скорость"; + label1.AutoSize = true; + label1.Location = new Point(44, 38); + label1.Name = "label1"; + label1.Size = new Size(59, 15); + label1.TabIndex = 0; + label1.Text = "Скорость"; // // pictureBoxObject // - this.pictureBoxObject.Location = new System.Drawing.Point(41, 85); - this.pictureBoxObject.Name = "pictureBoxObject"; - this.pictureBoxObject.Size = new System.Drawing.Size(227, 141); - this.pictureBoxObject.TabIndex = 1; - this.pictureBoxObject.TabStop = false; + pictureBoxObject.Location = new Point(41, 85); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(227, 141); + pictureBoxObject.TabIndex = 1; + pictureBoxObject.TabStop = false; // // labelColor // - this.labelColor.AllowDrop = true; - this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelColor.Location = new System.Drawing.Point(20, 24); - this.labelColor.Name = "labelColor"; - this.labelColor.Size = new System.Drawing.Size(120, 32); - this.labelColor.TabIndex = 2; - this.labelColor.Text = "Цвет"; - this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragDrop); - this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter); + labelColor.AllowDrop = true; + labelColor.BorderStyle = BorderStyle.FixedSingle; + labelColor.Location = new Point(20, 24); + labelColor.Name = "labelColor"; + labelColor.Size = new Size(120, 32); + labelColor.TabIndex = 2; + labelColor.Text = "Цвет"; + labelColor.TextAlign = ContentAlignment.MiddleCenter; + labelColor.DragDrop += colorLabel_DragDrop; + labelColor.DragEnter += colorLabel_DragEnter; // // labelAdditionalColor // - this.labelAdditionalColor.AllowDrop = true; - this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelAdditionalColor.Location = new System.Drawing.Point(169, 24); - this.labelAdditionalColor.Name = "labelAdditionalColor"; - this.labelAdditionalColor.Size = new System.Drawing.Size(120, 32); - this.labelAdditionalColor.TabIndex = 3; - this.labelAdditionalColor.Text = "Доп.Цвет"; - this.labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.addColorLabel_DragDrop); - this.labelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter); + labelAdditionalColor.AllowDrop = true; + labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; + labelAdditionalColor.Location = new Point(169, 24); + labelAdditionalColor.Name = "labelAdditionalColor"; + labelAdditionalColor.Size = new Size(120, 32); + labelAdditionalColor.TabIndex = 3; + labelAdditionalColor.Text = "Доп.Цвет"; + labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; + labelAdditionalColor.DragDrop += addColorLabel_DragDrop; + labelAdditionalColor.DragEnter += colorLabel_DragEnter; // // buttonAdd // - this.buttonAdd.Location = new System.Drawing.Point(587, 278); - this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(164, 37); - this.buttonAdd.TabIndex = 4; - this.buttonAdd.Text = "Добавить"; - this.buttonAdd.UseVisualStyleBackColor = true; - this.buttonAdd.Click += new System.EventHandler(this.addButton_Click); + buttonAdd.Location = new Point(587, 278); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(164, 37); + buttonAdd.TabIndex = 4; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += addButton_Click; // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(757, 278); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(152, 37); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Location = new Point(757, 278); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(152, 37); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; // // allowPanel // - this.allowPanel.AllowDrop = true; - this.allowPanel.Controls.Add(this.labelAdditionalColor); - this.allowPanel.Controls.Add(this.labelColor); - this.allowPanel.Controls.Add(this.pictureBoxObject); - this.allowPanel.Location = new System.Drawing.Point(589, 9); - this.allowPanel.Name = "allowPanel"; - this.allowPanel.Size = new System.Drawing.Size(316, 263); - this.allowPanel.TabIndex = 6; - this.allowPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.allowPanel_DragDrop); - this.allowPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.allowPanel_DragEnter); + allowPanel.AllowDrop = true; + allowPanel.Controls.Add(labelAdditionalColor); + allowPanel.Controls.Add(labelColor); + allowPanel.Controls.Add(pictureBoxObject); + allowPanel.Location = new Point(589, 9); + allowPanel.Name = "allowPanel"; + allowPanel.Size = new Size(316, 263); + allowPanel.TabIndex = 6; + allowPanel.DragDrop += allowPanel_DragDrop; + allowPanel.DragEnter += allowPanel_DragEnter; // // FormAntiAirCraftGunConfig // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(912, 327); - this.Controls.Add(this.allowPanel); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonAdd); - this.Controls.Add(this.panel1); - this.Name = "FormAntiAirCraftGunConfig"; - this.Text = "FormAntiAirCraftGunConfig"; - this.panel1.ResumeLayout(false); - this.groupBoxParameters.ResumeLayout(false); - this.groupBoxParameters.PerformLayout(); - this.groupBoxColor.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); - this.allowPanel.ResumeLayout(false); - this.ResumeLayout(false); - + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(912, 327); + Controls.Add(allowPanel); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(panel1); + Name = "FormAntiAirCraftGunConfig"; + Text = "FormAntiAirCraftGunConfig"; + panel1.ResumeLayout(false); + groupBoxParameters.ResumeLayout(false); + groupBoxParameters.PerformLayout(); + groupBoxColor.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit(); + allowPanel.ResumeLayout(false); + ResumeLayout(false); } #endregion diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs index add32df..a551a5f 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs @@ -11,10 +11,7 @@ using System.Windows.Forms; namespace AntiAircraftGun { - /// - /// Делегат для передачи объекта-зенитной установки - /// - public delegate void CarDelegate(BaseDrawingAntiAirCraftGun zenit); + public partial class FormAntiAirCraftGunConfig : Form { @@ -26,7 +23,7 @@ namespace AntiAircraftGun /// /// Событие для добавления зенитной установки /// - private event CarDelegate? EventAddZenit; + private event Action? EventAddZenit; /// /// Конструктор формы @@ -35,7 +32,6 @@ namespace AntiAircraftGun { InitializeComponent(); - // Назначение обработчика события для панелей цвета и кнопки отмены panelBlack.MouseDown += PanelColor_MouseDown; panelGray.MouseDown += PanelColor_MouseDown; panelRed.MouseDown += PanelColor_MouseDown; @@ -44,6 +40,8 @@ namespace AntiAircraftGun panelYellow.MouseDown += PanelColor_MouseDown; panelPurple.MouseDown += PanelColor_MouseDown; panelWhite.MouseDown += PanelColor_MouseDown; + labelBase.MouseDown += LabelObject_MouseDown; + labelAdvanced.MouseDown += LabelObject_MouseDown; buttonCancel.Click += (s, e) => Close(); } @@ -62,7 +60,7 @@ namespace AntiAircraftGun /// /// Добавление обработчика события для добавления зенитной установки /// - public void AddEvent(CarDelegate ev) + public void AddEvent(Action ev) { if (EventAddZenit == null) { @@ -135,8 +133,7 @@ namespace AntiAircraftGun /// private void PanelColor_MouseDown(object sender, MouseEventArgs e) { - (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, - DragDropEffects.Move | DragDropEffects.Copy); + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,DragDropEffects.Move | DragDropEffects.Copy); } /// diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.resx b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.resx index f298a7b..af32865 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.resx +++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.resx @@ -1,4 +1,64 @@ - + + + -- 2.25.1