diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/DrawningUsta.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/DrawningUsta.cs
index 679c4e5..8f5ecf9 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/DrawningUsta.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/DrawningUsta.cs
@@ -19,7 +19,7 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
///
/// Класс-сущность
///
- public EntityUsta? EntityUsta { get; protected set; }
+ public EntityUsta? EntityUsta { get; set; }
///
/// Ширина окна
///
@@ -85,6 +85,8 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
_ustaHeight = ustaHeight;
EntityUsta = new EntityUsta(speed, weight, bodyColor);
}
+
+
///
/// Установка позиции
///
@@ -93,7 +95,7 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
public void SetPosition(int x, int y)
{
// TODO: Изменение x, y, если при установке объект выходит за границы
- if (x < 0 || y < 0)
+ if (x < 0 || y < 0 || x + _ustaWidth > _pictureWidth || y + _ustaHeight > _pictureHeight)
{
x = 10;
y = 10;
@@ -149,7 +151,7 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
{
//влево
DirectionType.Left => _startPosX - EntityUsta.Step > 0,
- //вверх
+ //вверх
DirectionType.Up => _startPosY - EntityUsta.Step > 7,
// вправо
DirectionType.Right => _startPosX + EntityUsta.Step + _ustaWidth < _pictureWidth,// TODO: Продумать логику
@@ -249,6 +251,10 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
g.FillEllipse(pen3, _startPosX + 10, _startPosY + 52, 26, 26);
g.FillEllipse(pen3, _startPosX + 105, _startPosY + 52, 26, 26);
}
+
+
}
+
+
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntityUsta.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntityUsta.cs
index 64f9da5..3e2a21f 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntityUsta.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntityUsta.cs
@@ -22,7 +22,7 @@ namespace SelfPropelledArtilleryUnit.Entities
///
/// Основной цвет
///
- public Color BodyColor { get; private set; }
+ public Color BodyColor { get; set; }
///
/// Шаг перемещения установки
///
@@ -39,6 +39,7 @@ namespace SelfPropelledArtilleryUnit.Entities
Weight = weight;
BodyColor = bodyColor;
}
+
}
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntityUstaBat.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntityUstaBat.cs
index 3b466d9..3c4bc0d 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntityUstaBat.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntityUstaBat.cs
@@ -10,7 +10,7 @@ namespace SelfPropelledArtilleryUnit.Entities
///
/// Дополнительный цвет (для опциональных элементов)
///
- public Color AdditionalColor { get; private set; }
+ public Color AdditionalColor { get; set; }
///
/// Признак (опция) наличия батареи
///
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnit.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnit.cs
index 1ae64a4..27f6e50 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnit.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnit.cs
@@ -33,7 +33,7 @@ namespace SelfPropelledArtilleryUnit
}
///
- ///
+ ///
///
private void Draw()
{
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitCollection.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitCollection.cs
index 624d48e..0143e21 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitCollection.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitCollection.cs
@@ -105,26 +105,33 @@ namespace SelfPropelledArtilleryUnit
{
return;
}
- var obj = _storage[listBoxStorage.SelectedItem.ToString() ??
- string.Empty];
- if (obj == null)
+
+ var formSelfPropelledArtilleryUnitConfig = new FormSelfPropelledArtilleryUnitConfig();
+
+ formSelfPropelledArtilleryUnitConfig.AddEvent(usta =>
{
- return;
- }
- FormSelfPropelledArtilleryUnit form = new();
- if (form.ShowDialog() == DialogResult.OK)
- {
- if (obj + form.SelectedUsta > -1)
+ if (listBoxStorage.SelectedIndex != -1)
{
- MessageBox.Show("Объект добавлен");
- pictureBoxCollection.Image = obj.ShowUsta();
+ var obj = _storage[listBoxStorage.SelectedItem?.ToString() ?? string.Empty];
+ if (obj != null)
+ {
+ if (obj + usta != 1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollection.Image = obj.ShowUsta();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
}
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
- }
+ });
+
+ formSelfPropelledArtilleryUnitConfig.Show();
}
+
+
///
/// Удаление объекта из набора
///
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitConfig.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitConfig.Designer.cs
new file mode 100644
index 0000000..67f2f24
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitConfig.Designer.cs
@@ -0,0 +1,383 @@
+namespace SelfPropelledArtilleryUnit
+{
+ partial class FormSelfPropelledArtilleryUnitConfig
+ {
+ ///
+ /// 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()
+ {
+ groupBox1 = new GroupBox();
+ labelModifiedObject = new Label();
+ labelSimpleObject = new Label();
+ groupBox2 = new GroupBox();
+ panelPurple = new Panel();
+ panelYellow = new Panel();
+ panelBlack = new Panel();
+ panelBlue = new Panel();
+ panelGray = new Panel();
+ panelGreen = new Panel();
+ panelWhite = new Panel();
+ panelRed = new Panel();
+ checkBoxBodyKit = new CheckBox();
+ checkBoxPushka = new CheckBox();
+ numericUpDownWeight = new NumericUpDown();
+ numericUpDownSpeed = new NumericUpDown();
+ label2 = new Label();
+ label1 = new Label();
+ panelColor = new Panel();
+ labelDopColor = new Label();
+ labelBaseColor = new Label();
+ pictureBoxObject = new PictureBox();
+ ButtonOk = new Button();
+ buttonCancel = new Button();
+ groupBox1.SuspendLayout();
+ groupBox2.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
+ panelColor.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
+ SuspendLayout();
+ //
+ // groupBox1
+ //
+ groupBox1.Controls.Add(labelModifiedObject);
+ groupBox1.Controls.Add(labelSimpleObject);
+ groupBox1.Controls.Add(groupBox2);
+ groupBox1.Controls.Add(checkBoxBodyKit);
+ groupBox1.Controls.Add(checkBoxPushka);
+ groupBox1.Controls.Add(numericUpDownWeight);
+ groupBox1.Controls.Add(numericUpDownSpeed);
+ groupBox1.Controls.Add(label2);
+ groupBox1.Controls.Add(label1);
+ groupBox1.Location = new Point(14, 16);
+ groupBox1.Margin = new Padding(3, 4, 3, 4);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Padding = new Padding(3, 4, 3, 4);
+ groupBox1.Size = new Size(519, 304);
+ groupBox1.TabIndex = 0;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Параметры";
+ //
+ // labelModifiedObject
+ //
+ labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelModifiedObject.Location = new Point(358, 195);
+ labelModifiedObject.Name = "labelModifiedObject";
+ labelModifiedObject.Size = new Size(99, 35);
+ labelModifiedObject.TabIndex = 8;
+ labelModifiedObject.Text = "Продвинутый";
+ labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelModifiedObject.MouseDown += LabelObject_MouseDown;
+ //
+ // labelSimpleObject
+ //
+ labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
+ labelSimpleObject.Location = new Point(246, 195);
+ labelSimpleObject.Name = "labelSimpleObject";
+ labelSimpleObject.Size = new Size(99, 35);
+ labelSimpleObject.TabIndex = 7;
+ labelSimpleObject.Text = "Простой";
+ labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelSimpleObject.MouseDown += LabelObject_MouseDown;
+ //
+ // groupBox2
+ //
+ groupBox2.Controls.Add(panelPurple);
+ groupBox2.Controls.Add(panelYellow);
+ groupBox2.Controls.Add(panelBlack);
+ groupBox2.Controls.Add(panelBlue);
+ groupBox2.Controls.Add(panelGray);
+ groupBox2.Controls.Add(panelGreen);
+ groupBox2.Controls.Add(panelWhite);
+ groupBox2.Controls.Add(panelRed);
+ groupBox2.Location = new Point(246, 43);
+ groupBox2.Margin = new Padding(3, 4, 3, 4);
+ groupBox2.Name = "groupBox2";
+ groupBox2.Padding = new Padding(3, 4, 3, 4);
+ groupBox2.Size = new Size(211, 141);
+ groupBox2.TabIndex = 6;
+ groupBox2.TabStop = false;
+ groupBox2.Text = "Цвета";
+ //
+ // panelPurple
+ //
+ panelPurple.BackColor = Color.FromArgb(192, 0, 192);
+ panelPurple.Location = new Point(159, 84);
+ panelPurple.Margin = new Padding(3, 4, 3, 4);
+ panelPurple.Name = "panelPurple";
+ panelPurple.Size = new Size(40, 40);
+ panelPurple.TabIndex = 7;
+ panelPurple.MouseDown += panelColor_MouseDown;
+ //
+ // panelYellow
+ //
+ panelYellow.BackColor = Color.Yellow;
+ panelYellow.Location = new Point(159, 29);
+ panelYellow.Margin = new Padding(3, 4, 3, 4);
+ panelYellow.Name = "panelYellow";
+ panelYellow.Size = new Size(40, 40);
+ panelYellow.TabIndex = 3;
+ panelYellow.MouseDown += panelColor_MouseDown;
+ //
+ // panelBlack
+ //
+ panelBlack.BackColor = Color.Black;
+ panelBlack.Location = new Point(112, 84);
+ panelBlack.Margin = new Padding(3, 4, 3, 4);
+ panelBlack.Name = "panelBlack";
+ panelBlack.Size = new Size(40, 40);
+ panelBlack.TabIndex = 6;
+ panelBlack.MouseDown += panelColor_MouseDown;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(112, 29);
+ panelBlue.Margin = new Padding(3, 4, 3, 4);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(40, 40);
+ panelBlue.TabIndex = 2;
+ panelBlue.MouseDown += panelColor_MouseDown;
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Gray;
+ panelGray.Location = new Point(65, 84);
+ panelGray.Margin = new Padding(3, 4, 3, 4);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(40, 40);
+ panelGray.TabIndex = 5;
+ panelGray.MouseDown += panelColor_MouseDown;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.FromArgb(0, 192, 0);
+ panelGreen.Location = new Point(65, 29);
+ panelGreen.Margin = new Padding(3, 4, 3, 4);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(40, 40);
+ panelGreen.TabIndex = 1;
+ panelGreen.MouseDown += panelColor_MouseDown;
+ //
+ // panelWhite
+ //
+ panelWhite.BackColor = Color.White;
+ panelWhite.Location = new Point(18, 84);
+ panelWhite.Margin = new Padding(3, 4, 3, 4);
+ panelWhite.Name = "panelWhite";
+ panelWhite.Size = new Size(40, 40);
+ panelWhite.TabIndex = 4;
+ panelWhite.MouseDown += panelColor_MouseDown;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(18, 29);
+ panelRed.Margin = new Padding(3, 4, 3, 4);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(40, 40);
+ panelRed.TabIndex = 0;
+ panelRed.MouseDown += panelColor_MouseDown;
+ //
+ // checkBoxBodyKit
+ //
+ checkBoxBodyKit.AutoSize = true;
+ checkBoxBodyKit.Location = new Point(11, 205);
+ checkBoxBodyKit.Margin = new Padding(3, 4, 3, 4);
+ checkBoxBodyKit.Name = "checkBoxBodyKit";
+ checkBoxBodyKit.Size = new Size(215, 24);
+ checkBoxBodyKit.TabIndex = 5;
+ checkBoxBodyKit.Text = "Признак наличия батареи";
+ checkBoxBodyKit.UseVisualStyleBackColor = true;
+ //
+ // checkBoxPushka
+ //
+ checkBoxPushka.AutoSize = true;
+ checkBoxPushka.Location = new Point(11, 159);
+ checkBoxPushka.Margin = new Padding(3, 4, 3, 4);
+ checkBoxPushka.Name = "checkBoxPushka";
+ checkBoxPushka.Size = new Size(202, 24);
+ checkBoxPushka.TabIndex = 4;
+ checkBoxPushka.Text = "Признак наличия пушки";
+ checkBoxPushka.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(87, 80);
+ numericUpDownWeight.Margin = new Padding(3, 4, 3, 4);
+ numericUpDownWeight.Name = "numericUpDownWeight";
+ numericUpDownWeight.Size = new Size(83, 27);
+ numericUpDownWeight.TabIndex = 3;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(87, 41);
+ numericUpDownSpeed.Margin = new Padding(3, 4, 3, 4);
+ numericUpDownSpeed.Name = "numericUpDownSpeed";
+ numericUpDownSpeed.Size = new Size(83, 27);
+ numericUpDownSpeed.TabIndex = 2;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(11, 83);
+ label2.Name = "label2";
+ label2.Size = new Size(36, 20);
+ label2.TabIndex = 1;
+ label2.Text = "Вес:";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(11, 44);
+ label1.Name = "label1";
+ label1.Size = new Size(76, 20);
+ label1.TabIndex = 0;
+ label1.Text = "Скорость:";
+ //
+ // panelColor
+ //
+ panelColor.AllowDrop = true;
+ panelColor.Controls.Add(labelDopColor);
+ panelColor.Controls.Add(labelBaseColor);
+ panelColor.Controls.Add(pictureBoxObject);
+ panelColor.Location = new Point(539, 16);
+ panelColor.Margin = new Padding(3, 4, 3, 4);
+ panelColor.Name = "panelColor";
+ panelColor.Size = new Size(315, 245);
+ panelColor.TabIndex = 1;
+ panelColor.DragDrop += PanelObject_DragDrop;
+ panelColor.DragEnter += PanelObject_DragEnter;
+ //
+ // labelDopColor
+ //
+ labelDopColor.AllowDrop = true;
+ labelDopColor.BorderStyle = BorderStyle.FixedSingle;
+ labelDopColor.Location = new Point(187, 13);
+ labelDopColor.Name = "labelDopColor";
+ labelDopColor.Size = new Size(114, 38);
+ labelDopColor.TabIndex = 2;
+ labelDopColor.Text = "Доп. цвет";
+ labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelDopColor.DragDrop += LabelDopColor_DragDrop;
+ labelDopColor.DragEnter += LabelColor_DragEnter;
+ labelDopColor.MouseDown += LabelObject_MouseDown;
+ //
+ // labelBaseColor
+ //
+ labelBaseColor.AllowDrop = true;
+ labelBaseColor.BorderStyle = BorderStyle.FixedSingle;
+ labelBaseColor.Location = new Point(14, 13);
+ labelBaseColor.Name = "labelBaseColor";
+ labelBaseColor.Size = new Size(114, 38);
+ labelBaseColor.TabIndex = 2;
+ labelBaseColor.Text = "Цвет";
+ labelBaseColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelBaseColor.DragDrop += LabelBaseColor_DragDrop;
+ labelBaseColor.DragEnter += LabelColor_DragEnter;
+ labelBaseColor.MouseDown += LabelObject_MouseDown;
+ //
+ // pictureBoxObject
+ //
+ pictureBoxObject.Location = new Point(14, 61);
+ pictureBoxObject.Margin = new Padding(3, 4, 3, 4);
+ pictureBoxObject.Name = "pictureBoxObject";
+ pictureBoxObject.Size = new Size(288, 169);
+ pictureBoxObject.TabIndex = 0;
+ pictureBoxObject.TabStop = false;
+ //
+ // ButtonOk
+ //
+ ButtonOk.Location = new Point(553, 277);
+ ButtonOk.Margin = new Padding(3, 4, 3, 4);
+ ButtonOk.Name = "ButtonOk";
+ ButtonOk.Size = new Size(114, 43);
+ ButtonOk.TabIndex = 2;
+ ButtonOk.Text = "Добавить";
+ ButtonOk.UseVisualStyleBackColor = true;
+ ButtonOk.Click += ButtonOk_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(727, 277);
+ buttonCancel.Margin = new Padding(3, 4, 3, 4);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(114, 43);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // FormSelfPropelledArtilleryUnitConfig
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(914, 336);
+ Controls.Add(buttonCancel);
+ Controls.Add(ButtonOk);
+ Controls.Add(panelColor);
+ Controls.Add(groupBox1);
+ Margin = new Padding(3, 4, 3, 4);
+ Name = "FormSelfPropelledArtilleryUnitConfig";
+ Text = "FormSelfPropelledArtilleryUnitConfig";
+ groupBox1.ResumeLayout(false);
+ groupBox1.PerformLayout();
+ groupBox2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
+ panelColor.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBox1;
+ private NumericUpDown numericUpDownWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private Label label2;
+ private Label label1;
+ private GroupBox groupBox2;
+ private CheckBox checkBoxBodyKit;
+ private CheckBox checkBoxPushka;
+ private Panel panelPurple;
+ private Panel panelYellow;
+ private Panel panelBlack;
+ private Panel panelBlue;
+ private Panel panelGray;
+ private Panel panelGreen;
+ private Panel panelWhite;
+ private Panel panelRed;
+ private Label labelSimpleObject;
+ private Label labelModifiedObject;
+ private Panel panelColor;
+ 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/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitConfig.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitConfig.cs
new file mode 100644
index 0000000..2754219
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitConfig.cs
@@ -0,0 +1,180 @@
+
+using SelfPropelledArtilleryUnit.Drawnings;
+using SelfPropelledArtilleryUnit.Entities;
+using SelfPropelledArtilleryUnit;
+using SelfPropelledArtilleryUnit.DrawningObjects;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
+
+namespace SelfPropelledArtilleryUnit
+{
+ ///
+ /// Форма создания объекта
+ ///
+ public partial class FormSelfPropelledArtilleryUnitConfig : Form
+ {
+ ///
+ /// Переменная-выбранная установка
+ ///
+ DrawningUsta? _usta = null;
+ ///
+ /// Событие
+ ///
+ private event Action EventAddUsta;
+ ///
+ /// Конструктор
+ ///
+ public FormSelfPropelledArtilleryUnitConfig()
+ {
+ 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 += (sender, e) => Close();
+ }
+ ///
+ /// Отрисовать установку
+ ///
+ private void DrawUsta()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _usta?.SetPosition(5, 5);
+ _usta?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+ ///
+ /// Добавление события
+ ///
+ /// Привязанный метод
+ public void AddEvent(Action ev)
+ {
+ if (EventAddUsta == null)
+ {
+ EventAddUsta = new Action(ev);
+ }
+ else
+ {
+ EventAddUsta += 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) ?? false)
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ ///
+ /// Действия при приеме перетаскиваемой информации
+ ///
+ ///
+ ///
+ private void PanelObject_DragDrop(object sender, DragEventArgs e)
+ {
+ switch (e.Data?.GetData(DataFormats.Text).ToString())
+ {
+ case "labelSimpleObject":
+ _usta = new DrawningUsta((int)numericUpDownSpeed.Value,
+ (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
+ pictureBoxObject.Height);
+ break;
+ case "labelModifiedObject":
+ _usta = new DrawningUstaBat((int)numericUpDownSpeed.Value,
+ (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBodyKit.Checked,
+ checkBoxPushka.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
+ break;
+ }
+ DrawUsta();
+ }
+
+ ///
+ /// Отправляем цвет с панели
+ ///
+ ///
+ ///
+ private void panelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+ // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
+ private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_usta != null)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ _usta.EntityUsta.BodyColor = (Color)e.Data.GetData(typeof(Color));
+
+ }
+ DrawUsta();
+ }
+ }
+
+ private void LabelColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (_usta != null && _usta.EntityUsta is EntityUstaBat entityustabat)
+ {
+ labelDopColor.AllowDrop = true;
+ }
+ else
+ labelDopColor.AllowDrop = false;
+
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_usta != null && _usta.EntityUsta is EntityUstaBat entityustabat)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ entityustabat.AdditionalColor = (Color)e.Data.GetData(typeof(Color));
+
+ }
+ DrawUsta();
+ }
+ }
+ ///
+ /// Добавление установки
+ ///
+ ///
+ ///
+ private void ButtonOk_Click(object sender, EventArgs e)
+ {
+ EventAddUsta?.Invoke(_usta);
+ Close();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitConfig.resx b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitConfig.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSelfPropelledArtilleryUnitConfig.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file