From a112213e0aa1464604f8b4e010e0303349158c95 Mon Sep 17 00:00:00 2001 From: MaxKarme <91691525+MaxKarme@users.noreply.github.com> Date: Tue, 1 Nov 2022 17:51:11 +0300 Subject: [PATCH] main commit --- AirFighter/AirFighter/DrawingAirFighter.cs | 5 + .../AirFighter/DrawingModernAirFighter.cs | 8 + .../AirFighter/FormAircraftConfig.Designer.cs | 362 ++++++++++++++++++ AirFighter/AirFighter/FormAircraftConfig.cs | 191 +++++++++ AirFighter/AirFighter/FormAircraftConfig.resx | 60 +++ AirFighter/AirFighter/FormMapWithSetCars.cs | 33 +- 6 files changed, 644 insertions(+), 15 deletions(-) create mode 100644 AirFighter/AirFighter/FormAircraftConfig.Designer.cs create mode 100644 AirFighter/AirFighter/FormAircraftConfig.cs create mode 100644 AirFighter/AirFighter/FormAircraftConfig.resx diff --git a/AirFighter/AirFighter/DrawingAirFighter.cs b/AirFighter/AirFighter/DrawingAirFighter.cs index d78274d..794db25 100644 --- a/AirFighter/AirFighter/DrawingAirFighter.cs +++ b/AirFighter/AirFighter/DrawingAirFighter.cs @@ -30,6 +30,11 @@ namespace AirFighter _airFighterHeight = airFighterHeight; } + public DrawingAirFighter Update(int? speed = null, float? weight = null, Color? bodyColor = null) + { + return new DrawingAirFighter(speed ?? AirFighter.Speed, weight ?? AirFighter.Weight, bodyColor ?? AirFighter.BodyColor); + } + public void SetPosition(int x, int y, int width, int height) { if (width < _airFighterWidth || height < _airFighterHeight) return; diff --git a/AirFighter/AirFighter/DrawingModernAirFighter.cs b/AirFighter/AirFighter/DrawingModernAirFighter.cs index 2fea1df..a848dfc 100644 --- a/AirFighter/AirFighter/DrawingModernAirFighter.cs +++ b/AirFighter/AirFighter/DrawingModernAirFighter.cs @@ -13,6 +13,14 @@ namespace AirFighter { AirFighter = new EntityModernAirFighter(speed, weight, bodyColor, dopColor, dopWings, rockets); } + public DrawingModernAirFighter Update(int? speed = null, float? weight = null, Color? bodyColor = null, + Color? dopColor = null, bool? dopWings = null, bool? rockets = null) + { + EntityModernAirFighter entity = (EntityModernAirFighter)AirFighter; + return new DrawingModernAirFighter(speed ?? entity.Speed, weight ?? entity.Weight, bodyColor ?? entity.BodyColor, + dopColor ?? entity.DopColor, dopWings ?? entity.DopWings, rockets ?? entity.Rockets); + } + public override void DrawTransport(Graphics g) { if (AirFighter is not EntityModernAirFighter modernAirFighter) diff --git a/AirFighter/AirFighter/FormAircraftConfig.Designer.cs b/AirFighter/AirFighter/FormAircraftConfig.Designer.cs new file mode 100644 index 0000000..bde4d19 --- /dev/null +++ b/AirFighter/AirFighter/FormAircraftConfig.Designer.cs @@ -0,0 +1,362 @@ +namespace AirFighter +{ + partial class FormAircraftConfig + { + /// + /// 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.groupBoxConfig = new System.Windows.Forms.GroupBox(); + this.labelModifiedObject = new System.Windows.Forms.Label(); + this.labelSimpleObject = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.panelGray = new System.Windows.Forms.Panel(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.panelWhite = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelRed = new System.Windows.Forms.Panel(); + this.checkBoxRockets = new System.Windows.Forms.CheckBox(); + this.checkBoxDopWings = new System.Windows.Forms.CheckBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.panel8 = new System.Windows.Forms.Panel(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.pictureBoxObject = new System.Windows.Forms.PictureBox(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxConfig.SuspendLayout(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + this.panel8.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); + this.SuspendLayout(); + // + // groupBoxConfig + // + this.groupBoxConfig.Controls.Add(this.labelModifiedObject); + this.groupBoxConfig.Controls.Add(this.labelSimpleObject); + this.groupBoxConfig.Controls.Add(this.groupBox1); + this.groupBoxConfig.Controls.Add(this.checkBoxRockets); + this.groupBoxConfig.Controls.Add(this.checkBoxDopWings); + this.groupBoxConfig.Controls.Add(this.label2); + this.groupBoxConfig.Controls.Add(this.label1); + this.groupBoxConfig.Controls.Add(this.numericUpDownWeight); + this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed); + this.groupBoxConfig.Location = new System.Drawing.Point(12, 23); + this.groupBoxConfig.Name = "groupBoxConfig"; + this.groupBoxConfig.Size = new System.Drawing.Size(581, 307); + this.groupBoxConfig.TabIndex = 0; + this.groupBoxConfig.TabStop = false; + this.groupBoxConfig.Text = "Параметры"; + // + // labelModifiedObject + // + this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelModifiedObject.Location = new System.Drawing.Point(410, 240); + this.labelModifiedObject.Name = "labelModifiedObject"; + this.labelModifiedObject.Size = new System.Drawing.Size(117, 43); + this.labelModifiedObject.TabIndex = 9; + this.labelModifiedObject.Text = "Продвинутый"; + this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + 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(276, 240); + this.labelSimpleObject.Name = "labelSimpleObject"; + this.labelSimpleObject.Size = new System.Drawing.Size(117, 43); + this.labelSimpleObject.TabIndex = 8; + this.labelSimpleObject.Text = "Простой"; + this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.panelGray); + this.groupBox1.Controls.Add(this.panelBlack); + this.groupBox1.Controls.Add(this.panelPurple); + this.groupBox1.Controls.Add(this.panelWhite); + this.groupBox1.Controls.Add(this.panelBlue); + this.groupBox1.Controls.Add(this.panelGreen); + this.groupBox1.Controls.Add(this.panelYellow); + this.groupBox1.Controls.Add(this.panelRed); + this.groupBox1.Location = new System.Drawing.Point(262, 54); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(280, 165); + this.groupBox1.TabIndex = 7; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Цвета"; + // + // panelGray + // + this.panelGray.BackColor = System.Drawing.Color.Gray; + this.panelGray.Location = new System.Drawing.Point(81, 100); + 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(148, 100); + 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(215, 100); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(50, 50); + this.panelPurple.TabIndex = 2; + // + // panelWhite + // + this.panelWhite.BackColor = System.Drawing.Color.White; + this.panelWhite.Location = new System.Drawing.Point(14, 100); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(50, 50); + this.panelWhite.TabIndex = 1; + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(215, 31); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(50, 50); + this.panelBlue.TabIndex = 1; + // + // panelGreen + // + this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); + this.panelGreen.Location = new System.Drawing.Point(148, 31); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(50, 50); + this.panelGreen.TabIndex = 1; + // + // panelYellow + // + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(81, 31); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(50, 50); + this.panelYellow.TabIndex = 1; + // + // panelRed + // + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(14, 31); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(50, 50); + this.panelRed.TabIndex = 0; + // + // checkBoxRockets + // + this.checkBoxRockets.AutoSize = true; + this.checkBoxRockets.Location = new System.Drawing.Point(22, 222); + this.checkBoxRockets.Name = "checkBoxRockets"; + this.checkBoxRockets.Size = new System.Drawing.Size(79, 24); + this.checkBoxRockets.TabIndex = 5; + this.checkBoxRockets.Text = "Ракеты"; + this.checkBoxRockets.UseVisualStyleBackColor = true; + // + // checkBoxDopWings + // + this.checkBoxDopWings.AutoSize = true; + this.checkBoxDopWings.Location = new System.Drawing.Point(22, 182); + this.checkBoxDopWings.Name = "checkBoxDopWings"; + this.checkBoxDopWings.Size = new System.Drawing.Size(207, 24); + this.checkBoxDopWings.TabIndex = 4; + this.checkBoxDopWings.Text = "Дополнительные крылья"; + this.checkBoxDopWings.UseVisualStyleBackColor = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(22, 105); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(36, 20); + this.label2.TabIndex = 3; + this.label2.Text = "Вес:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(22, 56); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(76, 20); + this.label1.TabIndex = 2; + this.label1.Text = "Скорость:"; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(119, 105); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(90, 27); + this.numericUpDownWeight.TabIndex = 1; + this.numericUpDownWeight.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(119, 54); + this.numericUpDownSpeed.Name = "numericUpDownSpeed"; + this.numericUpDownSpeed.Size = new System.Drawing.Size(90, 27); + this.numericUpDownSpeed.TabIndex = 0; + this.numericUpDownSpeed.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // panel8 + // + this.panel8.AllowDrop = true; + this.panel8.Controls.Add(this.label6); + this.panel8.Controls.Add(this.label5); + this.panel8.Controls.Add(this.pictureBoxObject); + this.panel8.Location = new System.Drawing.Point(682, 23); + this.panel8.Name = "panel8"; + this.panel8.Size = new System.Drawing.Size(329, 263); + this.panel8.TabIndex = 1; + this.panel8.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); + this.panel8.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); + // + // label6 + // + this.label6.AllowDrop = true; + this.label6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.label6.Location = new System.Drawing.Point(171, 24); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(143, 43); + this.label6.TabIndex = 11; + this.label6.Text = "Доп. цвет"; + this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.label6.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop); + this.label6.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); + // + // label5 + // + this.label5.AllowDrop = true; + this.label5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.label5.Location = new System.Drawing.Point(13, 24); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(143, 43); + this.label5.TabIndex = 10; + this.label5.Text = "Цвет"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.label5.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop); + this.label5.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); + // + // pictureBoxObject + // + this.pictureBoxObject.Location = new System.Drawing.Point(13, 70); + this.pictureBoxObject.Name = "pictureBoxObject"; + this.pictureBoxObject.Size = new System.Drawing.Size(301, 176); + this.pictureBoxObject.TabIndex = 0; + this.pictureBoxObject.TabStop = false; + // + // buttonOk + // + this.buttonOk.Location = new System.Drawing.Point(695, 308); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.buttonOk.Size = new System.Drawing.Size(110, 31); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "Добавить"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(886, 308); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(110, 31); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // FormAircraftConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1040, 351); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.panel8); + this.Controls.Add(this.groupBoxConfig); + this.Name = "FormAircraftConfig"; + this.Text = "FormAircraftConfig"; + this.groupBoxConfig.ResumeLayout(false); + this.groupBoxConfig.PerformLayout(); + this.groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + this.panel8.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBoxConfig; + private GroupBox groupBox1; + private CheckBox checkBoxRockets; + private CheckBox checkBoxDopWings; + private Label label2; + private Label label1; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelModifiedObject; + private Label labelSimpleObject; + private Panel panelGray; + private Panel panelBlack; + private Panel panelPurple; + private Panel panelWhite; + private Panel panelBlue; + private Panel panelGreen; + private Panel panelYellow; + private Panel panelRed; + private Panel panel8; + private Label label6; + private Label label5; + private PictureBox pictureBoxObject; + private Button buttonOk; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/AirFighter/AirFighter/FormAircraftConfig.cs b/AirFighter/AirFighter/FormAircraftConfig.cs new file mode 100644 index 0000000..b20b712 --- /dev/null +++ b/AirFighter/AirFighter/FormAircraftConfig.cs @@ -0,0 +1,191 @@ +namespace AirFighter +{ + /// + /// Форма создания объекта + /// + public partial class FormAircraftConfig : Form + { + /// + /// Переменная-выбранная машина + /// + DrawingAirFighter _car = null; + + private Action EventAddCar = null; + /// + /// Событие + /// + // private event CarDelegate EventAddCar; + /// + /// Конструктор + /// + public FormAircraftConfig() + { + InitializeComponent(); + panelBlack.MouseDown += PanelColor_MouseDown; + panelPurple.MouseDown += PanelColor_MouseDown; + panelGray.MouseDown += PanelColor_MouseDown; + panelGreen.MouseDown += PanelColor_MouseDown; + panelRed.MouseDown += PanelColor_MouseDown; + panelWhite.MouseDown += PanelColor_MouseDown; + panelYellow.MouseDown += PanelColor_MouseDown; + panelBlue.MouseDown += PanelColor_MouseDown; + // TODO buttonCancel.Click with lambda + + buttonCancel.Click += (s, e) => Close(); + + } + /// + /// Отрисовать машину + /// + + public void AddEvent(Action ev) + { + if(EventAddCar == null) + { + EventAddCar = ev; + return; + } + + EventAddCar += ev; + } + + private void DrawCar() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _car?.SetPosition(5, 5, pictureBoxObject.Width, + pictureBoxObject.Height); + _car?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + /// + /// Добавление события + /// + /// +/* public void AddEvent(CarDelegate ev) + { + if (EventAddCar == null) + { + EventAddCar = new CarDelegate(ev); + } + else + { + EventAddCar += ev; + } + }*/ + /// + /// Передаем информацию при нажатии на Label + /// + /// + /// + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label).DoDragDrop((sender as Label).Name, + DragDropEffects.Move | DragDropEffects.Copy); + } + /// + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// + private void PanelObject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + 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": + _car = new DrawingAirFighter((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _car = new DrawingModernAirFighter((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, Color.Black, + checkBoxDopWings.Checked, checkBoxRockets.Checked); + break; + } + DrawCar(); + } + /// + /// Отправляем цвет с панели + /// + /// + /// + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Control).DoDragDrop((sender as Control).BackColor, + DragDropEffects.Move | DragDropEffects.Copy); + } + /// + private void LabelColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + /// Принимаем основной цвет + /// + /// + /// + private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + { + if (_car == null) return; + Color color = (Color)e.Data.GetData(typeof(Color)); + + if(_car is DrawingModernAirFighter) + { + _car = ((DrawingModernAirFighter)_car).Update(bodyColor: color); + } + else + { + _car = _car.Update(bodyColor: color); + } + DrawCar(); + } + /// + /// Принимаем дополнительный цвет + /// + /// + /// + private void LabelDopColor_DragDrop(object sender, DragEventArgs e) + { + var car = _car as DrawingModernAirFighter; + if (car == null) return; + + Color color = (Color)e.Data.GetData(typeof(Color)); + _car = car.Update(dopColor: color); + DrawCar(); + } + /// + /// Добавление машины + /// + /// + /// + private void ButtonOk_Click(object sender, EventArgs e) + { + EventAddCar?.Invoke(_car); + Close(); + } + + } +} diff --git a/AirFighter/AirFighter/FormAircraftConfig.resx b/AirFighter/AirFighter/FormAircraftConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/AirFighter/AirFighter/FormAircraftConfig.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 diff --git a/AirFighter/AirFighter/FormMapWithSetCars.cs b/AirFighter/AirFighter/FormMapWithSetCars.cs index f7e9144..99eb221 100644 --- a/AirFighter/AirFighter/FormMapWithSetCars.cs +++ b/AirFighter/AirFighter/FormMapWithSetCars.cs @@ -105,28 +105,31 @@ namespace AirFighter } } - - private void ButtonAddCar_Click(object sender, EventArgs e) + private void AircraftAddCallback(DrawingAirFighter aircraft) { if (listBoxMaps.SelectedIndex == -1) { return; } - FormAirFighter form = new(); - if (form.ShowDialog() == DialogResult.OK) + + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObjectAirFighter(aircraft) != -1) { - DrawingObjectAirFighter car = new(form.SelectedAirFighter); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + car != -1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = - _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } + MessageBox.Show("Объект добавлен"); + pictureBox.Image = + _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + + + private void ButtonAddCar_Click(object sender, EventArgs e) + { + FormAircraftConfig form = new(); + form.AddEvent(AircraftAddCallback); + form.Show(); } /// /// Удаление объекта -- 2.25.1