diff --git a/SelfPropelledArtilleryUnit/DrawingAdvancedArtillery.cs b/SelfPropelledArtilleryUnit/DrawingAdvancedArtillery.cs
index ae60223..3a43065 100644
--- a/SelfPropelledArtilleryUnit/DrawingAdvancedArtillery.cs
+++ b/SelfPropelledArtilleryUnit/DrawingAdvancedArtillery.cs
@@ -38,5 +38,15 @@ namespace Artilleries
base.DrawTransport(g);
}
+
+ public override void SetBodyColor(Color color)
+ {
+ Artillery = new EntityAdvancedArtillery(Artillery.Speed, Artillery.Weight, color, (Artillery as EntityAdvancedArtillery).DopColor, (Artillery as EntityAdvancedArtillery).Weapon, (Artillery as EntityAdvancedArtillery).SalvoBattery);
+ }
+
+ public void SetDopColor(Color color)
+ {
+ Artillery = new EntityAdvancedArtillery(Artillery.Speed, Artillery.Weight, Artillery.BodyColor, color, (Artillery as EntityAdvancedArtillery).Weapon, (Artillery as EntityAdvancedArtillery).SalvoBattery);
+ }
}
}
diff --git a/SelfPropelledArtilleryUnit/DrawingArtillery.cs b/SelfPropelledArtilleryUnit/DrawingArtillery.cs
index 52f941c..5ea083d 100644
--- a/SelfPropelledArtilleryUnit/DrawingArtillery.cs
+++ b/SelfPropelledArtilleryUnit/DrawingArtillery.cs
@@ -124,6 +124,11 @@ namespace Artilleries
}
}
+ public virtual void SetBodyColor(Color color)
+ {
+ Artillery = new EntityArtillery(Artillery.Speed, Artillery.Weight, color);
+ }
+
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return (_startPosX, _startPosX + _artilleryWidth - 1, _startPosY, _startPosY + _artilleryHeight - 1);
diff --git a/SelfPropelledArtilleryUnit/FormArtilleryConfig.Designer.cs b/SelfPropelledArtilleryUnit/FormArtilleryConfig.Designer.cs
new file mode 100644
index 0000000..dc85963
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/FormArtilleryConfig.Designer.cs
@@ -0,0 +1,381 @@
+namespace Artilleries
+{
+ partial class FormArtilleryConfig
+ {
+ ///
+ /// 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.groupBoxSettings = new System.Windows.Forms.GroupBox();
+ this.labelAdvancedObject = new System.Windows.Forms.Label();
+ this.labelSimpleObject = new System.Windows.Forms.Label();
+ this.groupBoxColors = 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.checkBoxSalvoBattery = new System.Windows.Forms.CheckBox();
+ this.checkBoxWeapon = new System.Windows.Forms.CheckBox();
+ this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
+ this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
+ this.labelWeight = new System.Windows.Forms.Label();
+ this.labelSpeed = new System.Windows.Forms.Label();
+ this.panelObject = new System.Windows.Forms.Panel();
+ this.pictureBoxObject = new System.Windows.Forms.PictureBox();
+ this.labelDopColor = new System.Windows.Forms.Label();
+ this.labelBaseColor = new System.Windows.Forms.Label();
+ this.buttonOk = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.groupBoxSettings.SuspendLayout();
+ this.groupBoxColors.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
+ this.panelObject.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBoxSettings
+ //
+ this.groupBoxSettings.Controls.Add(this.labelAdvancedObject);
+ this.groupBoxSettings.Controls.Add(this.labelSimpleObject);
+ this.groupBoxSettings.Controls.Add(this.groupBoxColors);
+ this.groupBoxSettings.Controls.Add(this.checkBoxSalvoBattery);
+ this.groupBoxSettings.Controls.Add(this.checkBoxWeapon);
+ this.groupBoxSettings.Controls.Add(this.numericUpDownWeight);
+ this.groupBoxSettings.Controls.Add(this.numericUpDownSpeed);
+ this.groupBoxSettings.Controls.Add(this.labelWeight);
+ this.groupBoxSettings.Controls.Add(this.labelSpeed);
+ this.groupBoxSettings.Location = new System.Drawing.Point(12, 12);
+ this.groupBoxSettings.Name = "groupBoxSettings";
+ this.groupBoxSettings.Size = new System.Drawing.Size(538, 244);
+ this.groupBoxSettings.TabIndex = 0;
+ this.groupBoxSettings.TabStop = false;
+ this.groupBoxSettings.Text = "Параметры";
+ //
+ // labelAdvancedObject
+ //
+ this.labelAdvancedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelAdvancedObject.Location = new System.Drawing.Point(414, 187);
+ this.labelAdvancedObject.Name = "labelAdvancedObject";
+ this.labelAdvancedObject.Size = new System.Drawing.Size(100, 38);
+ this.labelAdvancedObject.TabIndex = 8;
+ this.labelAdvancedObject.Text = "Продвинутый";
+ this.labelAdvancedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelAdvancedObject.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(305, 187);
+ this.labelSimpleObject.Name = "labelSimpleObject";
+ this.labelSimpleObject.Size = new System.Drawing.Size(100, 38);
+ this.labelSimpleObject.TabIndex = 7;
+ this.labelSimpleObject.Text = "Простой";
+ this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelObject_MouseDown);
+ //
+ // groupBoxColors
+ //
+ this.groupBoxColors.Controls.Add(this.panelPurple);
+ this.groupBoxColors.Controls.Add(this.panelBlack);
+ this.groupBoxColors.Controls.Add(this.panelGray);
+ this.groupBoxColors.Controls.Add(this.panelWhite);
+ this.groupBoxColors.Controls.Add(this.panelYellow);
+ this.groupBoxColors.Controls.Add(this.panelBlue);
+ this.groupBoxColors.Controls.Add(this.panelGreen);
+ this.groupBoxColors.Controls.Add(this.panelRed);
+ this.groupBoxColors.Location = new System.Drawing.Point(289, 39);
+ this.groupBoxColors.Name = "groupBoxColors";
+ this.groupBoxColors.Size = new System.Drawing.Size(243, 126);
+ this.groupBoxColors.TabIndex = 6;
+ this.groupBoxColors.TabStop = false;
+ this.groupBoxColors.Text = "Цвета";
+ //
+ // panelPurple
+ //
+ this.panelPurple.BackColor = System.Drawing.Color.Purple;
+ this.panelPurple.Location = new System.Drawing.Point(181, 74);
+ this.panelPurple.Name = "panelPurple";
+ this.panelPurple.Size = new System.Drawing.Size(39, 39);
+ this.panelPurple.TabIndex = 1;
+ //
+ // panelBlack
+ //
+ this.panelBlack.BackColor = System.Drawing.Color.Black;
+ this.panelBlack.Location = new System.Drawing.Point(125, 74);
+ this.panelBlack.Name = "panelBlack";
+ this.panelBlack.Size = new System.Drawing.Size(39, 39);
+ this.panelBlack.TabIndex = 1;
+ //
+ // panelGray
+ //
+ this.panelGray.BackColor = System.Drawing.Color.Gray;
+ this.panelGray.Location = new System.Drawing.Point(70, 74);
+ this.panelGray.Name = "panelGray";
+ this.panelGray.Size = new System.Drawing.Size(39, 39);
+ this.panelGray.TabIndex = 1;
+ //
+ // panelWhite
+ //
+ this.panelWhite.BackColor = System.Drawing.Color.White;
+ this.panelWhite.Location = new System.Drawing.Point(16, 74);
+ this.panelWhite.Name = "panelWhite";
+ this.panelWhite.Size = new System.Drawing.Size(39, 39);
+ this.panelWhite.TabIndex = 1;
+ //
+ // panelYellow
+ //
+ this.panelYellow.BackColor = System.Drawing.Color.Yellow;
+ this.panelYellow.Location = new System.Drawing.Point(181, 22);
+ this.panelYellow.Name = "panelYellow";
+ this.panelYellow.Size = new System.Drawing.Size(39, 39);
+ this.panelYellow.TabIndex = 1;
+ //
+ // panelBlue
+ //
+ this.panelBlue.BackColor = System.Drawing.Color.Blue;
+ this.panelBlue.Location = new System.Drawing.Point(125, 22);
+ this.panelBlue.Name = "panelBlue";
+ this.panelBlue.Size = new System.Drawing.Size(39, 39);
+ this.panelBlue.TabIndex = 1;
+ //
+ // panelGreen
+ //
+ this.panelGreen.BackColor = System.Drawing.Color.Green;
+ this.panelGreen.Location = new System.Drawing.Point(70, 22);
+ this.panelGreen.Name = "panelGreen";
+ this.panelGreen.Size = new System.Drawing.Size(39, 39);
+ this.panelGreen.TabIndex = 1;
+ //
+ // panelRed
+ //
+ this.panelRed.BackColor = System.Drawing.Color.Red;
+ this.panelRed.Location = new System.Drawing.Point(16, 22);
+ this.panelRed.Name = "panelRed";
+ this.panelRed.Size = new System.Drawing.Size(39, 39);
+ this.panelRed.TabIndex = 0;
+ //
+ // checkBoxSalvoBattery
+ //
+ this.checkBoxSalvoBattery.AutoSize = true;
+ this.checkBoxSalvoBattery.Location = new System.Drawing.Point(22, 169);
+ this.checkBoxSalvoBattery.Name = "checkBoxSalvoBattery";
+ this.checkBoxSalvoBattery.Size = new System.Drawing.Size(225, 19);
+ this.checkBoxSalvoBattery.TabIndex = 5;
+ this.checkBoxSalvoBattery.Text = "Признак наличия залповой батареи";
+ this.checkBoxSalvoBattery.UseVisualStyleBackColor = true;
+ //
+ // checkBoxWeapon
+ //
+ this.checkBoxWeapon.AutoSize = true;
+ this.checkBoxWeapon.Location = new System.Drawing.Point(22, 133);
+ this.checkBoxWeapon.Name = "checkBoxWeapon";
+ this.checkBoxWeapon.Size = new System.Drawing.Size(165, 19);
+ this.checkBoxWeapon.TabIndex = 4;
+ this.checkBoxWeapon.Text = "Признак наличия орудия";
+ this.checkBoxWeapon.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ this.numericUpDownWeight.Location = new System.Drawing.Point(88, 83);
+ 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});
+ //
+ // numericUpDownSpeed
+ //
+ this.numericUpDownSpeed.Location = new System.Drawing.Point(88, 39);
+ 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});
+ //
+ // labelWeight
+ //
+ this.labelWeight.AutoSize = true;
+ this.labelWeight.Location = new System.Drawing.Point(20, 85);
+ this.labelWeight.Name = "labelWeight";
+ this.labelWeight.Size = new System.Drawing.Size(29, 15);
+ this.labelWeight.TabIndex = 1;
+ this.labelWeight.Text = "Вес:";
+ //
+ // labelSpeed
+ //
+ this.labelSpeed.AutoSize = true;
+ this.labelSpeed.Location = new System.Drawing.Point(20, 41);
+ this.labelSpeed.Name = "labelSpeed";
+ this.labelSpeed.Size = new System.Drawing.Size(62, 15);
+ this.labelSpeed.TabIndex = 0;
+ this.labelSpeed.Text = "Скорость:";
+ //
+ // panelObject
+ //
+ this.panelObject.AllowDrop = true;
+ this.panelObject.Controls.Add(this.pictureBoxObject);
+ this.panelObject.Controls.Add(this.labelDopColor);
+ this.panelObject.Controls.Add(this.labelBaseColor);
+ this.panelObject.Location = new System.Drawing.Point(556, 12);
+ this.panelObject.Name = "panelObject";
+ this.panelObject.Size = new System.Drawing.Size(293, 205);
+ this.panelObject.TabIndex = 1;
+ this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
+ this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelObject_DragEnter);
+ //
+ // pictureBoxObject
+ //
+ this.pictureBoxObject.Location = new System.Drawing.Point(29, 61);
+ this.pictureBoxObject.Name = "pictureBoxObject";
+ this.pictureBoxObject.Size = new System.Drawing.Size(236, 127);
+ this.pictureBoxObject.TabIndex = 11;
+ this.pictureBoxObject.TabStop = false;
+ //
+ // labelDopColor
+ //
+ this.labelDopColor.AllowDrop = true;
+ this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelDopColor.Location = new System.Drawing.Point(165, 18);
+ this.labelDopColor.Name = "labelDopColor";
+ this.labelDopColor.Size = new System.Drawing.Size(100, 38);
+ this.labelDopColor.TabIndex = 10;
+ this.labelDopColor.Text = "Доп. цвет";
+ this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelDopColor_DragDrop);
+ this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
+ //
+ // labelBaseColor
+ //
+ this.labelBaseColor.AllowDrop = true;
+ this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelBaseColor.Location = new System.Drawing.Point(29, 18);
+ this.labelBaseColor.Name = "labelBaseColor";
+ this.labelBaseColor.Size = new System.Drawing.Size(100, 38);
+ this.labelBaseColor.TabIndex = 9;
+ this.labelBaseColor.Text = "Цвет";
+ this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelBaseColor_DragDrop);
+ this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
+ //
+ // buttonOk
+ //
+ this.buttonOk.Location = new System.Drawing.Point(585, 223);
+ this.buttonOk.Name = "buttonOk";
+ this.buttonOk.Size = new System.Drawing.Size(100, 33);
+ 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(721, 223);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(100, 33);
+ this.buttonCancel.TabIndex = 3;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // FormArtilleryConfig
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(861, 268);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonOk);
+ this.Controls.Add(this.panelObject);
+ this.Controls.Add(this.groupBoxSettings);
+ this.Name = "FormArtilleryConfig";
+ this.Text = "FormArtilleryConfig";
+ this.groupBoxSettings.ResumeLayout(false);
+ this.groupBoxSettings.PerformLayout();
+ this.groupBoxColors.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
+ this.panelObject.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBoxSettings;
+ private CheckBox checkBoxWeapon;
+ private NumericUpDown numericUpDownWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private Label labelWeight;
+ private Label labelSpeed;
+ private CheckBox checkBoxSalvoBattery;
+ private Label labelAdvancedObject;
+ private Label labelSimpleObject;
+ private GroupBox groupBoxColors;
+ 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 Panel panelObject;
+ private PictureBox pictureBoxObject;
+ private Label labelDopColor;
+ private Label labelBaseColor;
+ private Button buttonOk;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/FormArtilleryConfig.cs b/SelfPropelledArtilleryUnit/FormArtilleryConfig.cs
new file mode 100644
index 0000000..071033a
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/FormArtilleryConfig.cs
@@ -0,0 +1,122 @@
+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 Artilleries
+{
+ public partial class FormArtilleryConfig : Form
+ {
+ DrawingArtillery _artillery = null;
+ private event Action EventAddArtillery;
+
+ public FormArtilleryConfig()
+ {
+ InitializeComponent();
+ panelBlack.MouseDown += panelColor_MouseDown;
+ panelPurple.MouseDown += panelColor_MouseDown;
+ panelGray.MouseDown += panelColor_MouseDown;
+ panelGreen.MouseDown += panelColor_MouseDown;
+ panelRed.MouseDown += panelColor_MouseDown;
+ panelWhite.MouseDown += panelColor_MouseDown;
+ panelYellow.MouseDown += panelColor_MouseDown;
+ panelBlue.MouseDown += panelColor_MouseDown;
+ buttonCancel.Click += (sender, e) => Close();
+ }
+
+ private void DrawArtillery()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _artillery?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
+ _artillery?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+
+ 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":
+ _artillery = new DrawingArtillery((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
+ break;
+ case "labelAdvancedObject":
+ _artillery = new DrawingAdvancedArtillery((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxWeapon.Checked, checkBoxSalvoBattery.Checked);
+ break;
+ }
+ DrawArtillery();
+ }
+
+ 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)
+ {
+ _artillery.SetBodyColor((Color) e.Data.GetData(typeof(Color)));
+ DrawArtillery();
+ }
+
+ private void labelDopColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_artillery is DrawingAdvancedArtillery artillery)
+ {
+ artillery.SetDopColor((Color)e.Data.GetData(typeof(Color)));
+ }
+ DrawArtillery();
+ }
+
+ public void AddEvent(Action ev)
+ {
+ if (EventAddArtillery == null)
+ {
+ EventAddArtillery = new Action(ev);
+ }
+ else
+ {
+ EventAddArtillery += ev;
+ }
+ }
+
+ private void buttonOk_Click(object sender, EventArgs e)
+ {
+ EventAddArtillery?.Invoke(_artillery);
+ Close();
+ }
+ }
+}
diff --git a/SelfPropelledArtilleryUnit/FormArtilleryConfig.resx b/SelfPropelledArtilleryUnit/FormArtilleryConfig.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/FormArtilleryConfig.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/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.cs b/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.cs
index a2696c8..f5bdf3a 100644
--- a/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.cs
+++ b/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.cs
@@ -88,24 +88,23 @@ namespace Artilleries
private void buttonAddArtillery_Click(object sender, EventArgs e)
{
- if (listBoxMaps.SelectedIndex == -1)
- {
- return;
- }
- FormArtillery form = new();
- if (form.ShowDialog() == DialogResult.OK)
- {
- DrawingObjectArtillery artillery = new(form.SelectedArtillery);
- if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + artillery != -1)
+ var formArtilleryConfig = new FormArtilleryConfig();
+ formArtilleryConfig.AddEvent((artillery) => {
+ if (listBoxMaps.SelectedIndex == -1)
+ {
+ return;
+ }
+
+ if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] + new DrawingObjectArtillery(artillery) != -1)
{
MessageBox.Show("Объект добавлен");
- pictureBoxArtilleries.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
- }
- else
+ } else
{
MessageBox.Show("Не удалось добавить объект");
}
- }
+ pictureBoxArtilleries.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty].ShowSet();
+ });
+ formArtilleryConfig.Show();
}
private void buttonRemoveArtillery_Click(object sender, EventArgs e)