From f1d9f1de88f9b8a7fc28b8adb527305a2cd86d59 Mon Sep 17 00:00:00 2001
From: GokaPek <109132407+GokaPek@users.noreply.github.com>
Date: Tue, 7 Nov 2023 12:22:58 +0400
Subject: [PATCH 1/6] =?UTF-8?q?=D0=9E=D1=81=D0=BD=D0=BE=D0=B2=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../FormSPAUCollection.cs | 4 +
.../FormSPAUConfig.Designer.cs | 333 ++++++++++++++++++
.../FormSPAUConfig.cs | 130 +++++++
.../FormSPAUConfig.resx | 120 +++++++
.../SPAUDelegate.cs | 15 +
5 files changed, 602 insertions(+)
create mode 100644 SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
create mode 100644 SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
create mode 100644 SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.resx
create mode 100644 SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs
index beac829..4b6a84d 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs
@@ -106,6 +106,10 @@ namespace SelfPropelledArtilleryUnit
///
private void ButtonAddSPAU_Click(object sender, EventArgs e)
{
+ var formSPAUConfig = new FormSPAUConfig();
+ // TODO Call method AddEvent from formCarConfig
+ formSPAUConfig.Show();
+
if (listBoxStorages.SelectedIndex == -1)
{
return;
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
new file mode 100644
index 0000000..f32a7d4
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
@@ -0,0 +1,333 @@
+namespace SelfPropelledArtilleryUnit
+{
+ partial class FormSPAUConfig
+ {
+ ///
+ /// 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()
+ {
+ groupBox_param = new GroupBox();
+ checkBox_zalp = new CheckBox();
+ label_weight = new Label();
+ groupBox_colors = new GroupBox();
+ panelGray = new Panel();
+ panelCian = new Panel();
+ panelPurple = new Panel();
+ panelBlack = new Panel();
+ panelBlue = new Panel();
+ panelGreen = new Panel();
+ panelYellow = new Panel();
+ panelRed = new Panel();
+ numericUpDownWeight = new NumericUpDown();
+ numericUpDownSpeed = new NumericUpDown();
+ label_speed = new Label();
+ label_orig = new Label();
+ label_child = new Label();
+ pictureBox = new PictureBox();
+ Panel = new Panel();
+ button_close = new Button();
+ button_add = new Button();
+ label_addit_color = new Label();
+ label_color = new Label();
+ groupBox_param.SuspendLayout();
+ groupBox_colors.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
+ Panel.SuspendLayout();
+ SuspendLayout();
+ //
+ // groupBox_param
+ //
+ groupBox_param.Controls.Add(checkBox_zalp);
+ groupBox_param.Controls.Add(label_weight);
+ groupBox_param.Controls.Add(groupBox_colors);
+ groupBox_param.Controls.Add(numericUpDownWeight);
+ groupBox_param.Controls.Add(numericUpDownSpeed);
+ groupBox_param.Controls.Add(label_speed);
+ groupBox_param.Location = new Point(600, 12);
+ groupBox_param.Name = "groupBox_param";
+ groupBox_param.Size = new Size(188, 401);
+ groupBox_param.TabIndex = 0;
+ groupBox_param.TabStop = false;
+ groupBox_param.Text = "Параметры";
+ //
+ // checkBox_zalp
+ //
+ checkBox_zalp.AutoSize = true;
+ checkBox_zalp.Location = new Point(6, 154);
+ checkBox_zalp.Name = "checkBox_zalp";
+ checkBox_zalp.Size = new Size(170, 24);
+ checkBox_zalp.TabIndex = 5;
+ checkBox_zalp.Text = "Залповая установка";
+ checkBox_zalp.UseVisualStyleBackColor = true;
+ //
+ // label_weight
+ //
+ label_weight.AutoSize = true;
+ label_weight.Location = new Point(6, 86);
+ label_weight.Name = "label_weight";
+ label_weight.Size = new Size(33, 20);
+ label_weight.TabIndex = 3;
+ label_weight.Text = "Вес";
+ //
+ // groupBox_colors
+ //
+ groupBox_colors.Controls.Add(panelGray);
+ groupBox_colors.Controls.Add(panelCian);
+ groupBox_colors.Controls.Add(panelPurple);
+ groupBox_colors.Controls.Add(panelBlack);
+ groupBox_colors.Controls.Add(panelBlue);
+ groupBox_colors.Controls.Add(panelGreen);
+ groupBox_colors.Controls.Add(panelYellow);
+ groupBox_colors.Controls.Add(panelRed);
+ groupBox_colors.Location = new Point(10, 184);
+ groupBox_colors.Name = "groupBox_colors";
+ groupBox_colors.Size = new Size(166, 203);
+ groupBox_colors.TabIndex = 1;
+ groupBox_colors.TabStop = false;
+ groupBox_colors.Text = "Цвета";
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Silver;
+ panelGray.Location = new Point(91, 163);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(60, 25);
+ panelGray.TabIndex = 7;
+ //
+ // panelCian
+ //
+ panelCian.BackColor = Color.Cyan;
+ panelCian.Location = new Point(9, 163);
+ panelCian.Name = "panelCian";
+ panelCian.Size = new Size(60, 25);
+ panelCian.TabIndex = 6;
+ //
+ // panelPurple
+ //
+ panelPurple.BackColor = Color.FromArgb(192, 0, 192);
+ panelPurple.Location = new Point(91, 123);
+ panelPurple.Name = "panelPurple";
+ panelPurple.Size = new Size(60, 25);
+ panelPurple.TabIndex = 5;
+ //
+ // panelBlack
+ //
+ panelBlack.BackColor = Color.Black;
+ panelBlack.Location = new Point(9, 123);
+ panelBlack.Name = "panelBlack";
+ panelBlack.Size = new Size(60, 25);
+ panelBlack.TabIndex = 4;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(91, 79);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(60, 25);
+ panelBlue.TabIndex = 3;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.Lime;
+ panelGreen.Location = new Point(9, 79);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(60, 25);
+ panelGreen.TabIndex = 2;
+ //
+ // panelYellow
+ //
+ panelYellow.BackColor = Color.Yellow;
+ panelYellow.Location = new Point(91, 36);
+ panelYellow.Name = "panelYellow";
+ panelYellow.Size = new Size(60, 25);
+ panelYellow.TabIndex = 1;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(8, 38);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(60, 25);
+ panelRed.TabIndex = 0;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(6, 109);
+ 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(52, 27);
+ numericUpDownWeight.TabIndex = 2;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(6, 56);
+ 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(56, 27);
+ numericUpDownSpeed.TabIndex = 1;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // label_speed
+ //
+ label_speed.AutoSize = true;
+ label_speed.Location = new Point(6, 33);
+ label_speed.Name = "label_speed";
+ label_speed.Size = new Size(73, 20);
+ label_speed.TabIndex = 0;
+ label_speed.Text = "Скорость";
+ //
+ // label_orig
+ //
+ label_orig.BorderStyle = BorderStyle.FixedSingle;
+ label_orig.Location = new Point(606, 416);
+ label_orig.Name = "label_orig";
+ label_orig.Size = new Size(81, 29);
+ label_orig.TabIndex = 2;
+ label_orig.Text = "Простой";
+ label_orig.MouseDown += LabelOrig_MouseDown;
+ //
+ // label_child
+ //
+ label_child.BorderStyle = BorderStyle.FixedSingle;
+ label_child.Location = new Point(711, 416);
+ label_child.Name = "label_child";
+ label_child.Size = new Size(77, 29);
+ label_child.TabIndex = 3;
+ label_child.Text = "Потомок";
+ //
+ // pictureBox
+ //
+ pictureBox.Location = new Point(3, 68);
+ pictureBox.Name = "pictureBox";
+ pictureBox.Size = new Size(588, 377);
+ pictureBox.TabIndex = 4;
+ pictureBox.TabStop = false;
+ //
+ // Panel
+ //
+ Panel.AllowDrop = true;
+ Panel.Controls.Add(button_close);
+ Panel.Controls.Add(button_add);
+ Panel.Controls.Add(label_addit_color);
+ Panel.Controls.Add(label_color);
+ Panel.Controls.Add(pictureBox);
+ Panel.Dock = DockStyle.Left;
+ Panel.Location = new Point(0, 0);
+ Panel.Name = "Panel";
+ Panel.Size = new Size(600, 450);
+ Panel.TabIndex = 5;
+ Panel.DragDrop += panel_dragDrop;
+ Panel.DragEnter += panel_dragEnter;
+ //
+ // button_close
+ //
+ button_close.Location = new Point(488, 21);
+ button_close.Name = "button_close";
+ button_close.Size = new Size(80, 29);
+ button_close.TabIndex = 8;
+ button_close.Text = "Отмена";
+ button_close.UseVisualStyleBackColor = true;
+ //
+ // button_add
+ //
+ button_add.Location = new Point(387, 21);
+ button_add.Name = "button_add";
+ button_add.Size = new Size(95, 29);
+ button_add.TabIndex = 7;
+ button_add.Text = "Добавить";
+ button_add.UseVisualStyleBackColor = true;
+ button_add.Click += button_add_Click;
+ //
+ // label_addit_color
+ //
+ label_addit_color.BorderStyle = BorderStyle.FixedSingle;
+ label_addit_color.Location = new Point(145, 21);
+ label_addit_color.Name = "label_addit_color";
+ label_addit_color.Size = new Size(173, 29);
+ label_addit_color.TabIndex = 6;
+ label_addit_color.Text = "Дополнительный цвет";
+ //
+ // label_color
+ //
+ label_color.BorderStyle = BorderStyle.FixedSingle;
+ label_color.Location = new Point(12, 21);
+ label_color.Name = "label_color";
+ label_color.Size = new Size(127, 29);
+ label_color.TabIndex = 5;
+ label_color.Text = "Основной цвет";
+ //
+ // FormSPAUConfig
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(Panel);
+ Controls.Add(label_child);
+ Controls.Add(label_orig);
+ Controls.Add(groupBox_param);
+ Name = "FormSPAUConfig";
+ Text = "FormSPAUConfig";
+ groupBox_param.ResumeLayout(false);
+ groupBox_param.PerformLayout();
+ groupBox_colors.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ Panel.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBox_param;
+ private Label label_weight;
+ private NumericUpDown numericUpDownWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private Label label_speed;
+ private CheckBox checkBox_zalp;
+ private GroupBox groupBox_colors;
+ private Panel panelGreen;
+ private Panel panelYellow;
+ private Panel panelRed;
+ private Panel panelGray;
+ private Panel panelCian;
+ private Panel panelPurple;
+ private Panel panelBlack;
+ private Panel panelBlue;
+ private Label label_orig;
+ private Label label_child;
+ private PictureBox pictureBox;
+ private Panel Panel;
+ private Label label_addit_color;
+ private Label label_color;
+ private Button button_close;
+ private Button button_add;
+ }
+}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
new file mode 100644
index 0000000..c894bcd
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
@@ -0,0 +1,130 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using SelfPropelledArtilleryUnit.DrawningObjects;
+using SelfPropelledArtilleryUnit.SPAUs;
+
+namespace SelfPropelledArtilleryUnit
+{
+ public partial class FormSPAUConfig : Form
+ {
+ ///
+ /// Переменная-выбранная машина
+ ///
+ DrawningSPAU? _sPAU = null;
+ ///
+ /// Событие
+ ///
+ private event SPAUDelegate? EventAddSPAU;
+ ///
+ /// Конструктор
+ ///
+ public FormSPAUConfig()
+ {
+
+ InitializeComponent();
+ panelBlack.MouseDown += PanelColor_MouseDown;
+ panelPurple.MouseDown += PanelColor_MouseDown;
+ panelGray.MouseDown += PanelColor_MouseDown;
+ panelGreen.MouseDown += PanelColor_MouseDown;
+ panelRed.MouseDown += PanelColor_MouseDown;
+ panelCian.MouseDown += PanelColor_MouseDown;
+ panelYellow.MouseDown += PanelColor_MouseDown;
+ panelBlue.MouseDown += PanelColor_MouseDown;
+ // TODO buttonCancel.Click with lambda
+ }
+
+ ///
+ /// Отрисовать машину
+ ///
+ private void DrawSPAU()
+ {
+ Bitmap bmp = new(pictureBox.Width, pictureBox.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _sPAU?.SetPosition(5, 5);
+ _sPAU?.DrawTransport(gr);
+ pictureBox.Image = bmp;
+ }
+
+ ///
+ /// Добавление события
+ ///
+ /// Привязанный метод
+ public void AddEvent(SPAUDelegate ev)
+ {
+ if (EventAddSPAU == null)
+ {
+ EventAddSPAU = ev;
+ }
+ else
+ {
+ EventAddSPAU += ev;
+ }
+ }
+
+ ///
+ /// Передаем информацию при нажатии на Label
+ ///
+ ///
+ ///
+ private void LabelOrig_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ ///
+ /// Проверка получаемой информации (ее типа на соответствие требуемому)
+ ///
+ ///
+ ///
+ private void panel_dragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ ///
+ /// Действия при приеме перетаскиваемой информации
+ ///
+ ///
+ ///
+ private void panel_dragDrop(object sender, DragEventArgs e)
+ {
+ switch (e.Data?.GetData(DataFormats.Text).ToString())
+ {
+ case "labelOriginalObject":
+ _sPAU = new DrawningSPAU((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBox.Width, pictureBox.Height);
+ break;
+ case "labelModifiedObject":
+ _sPAU = new DrawningSPAUchild((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBox_zalp.Checked, pictureBox.Width, pictureBox.Height);
+ break;
+ }
+ DrawSPAU();
+ }
+
+ // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
+ ///
+ /// Добавление машины
+ ///
+ ///
+ ///
+
+ private void button_add_Click(object sender, EventArgs e)
+ {
+ EventAddSPAU?.Invoke(_sPAU);
+ Close();
+ }
+ }
+}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.resx b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.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
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs
new file mode 100644
index 0000000..bdedea1
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SelfPropelledArtilleryUnit.DrawningObjects;
+
+namespace SelfPropelledArtilleryUnit.SPAUs
+{
+ ///
+ /// Делегат для передачи объекта-автомобиля
+ ///
+ ///
+ public delegate void SPAUDelegate(DrawningSPAU sPAU);
+}
--
2.25.1
From 667598f1d34df5ec468c2b0e0f3283c7dec11ddf Mon Sep 17 00:00:00 2001
From: GokaPek <109132407+GokaPek@users.noreply.github.com>
Date: Tue, 7 Nov 2023 13:44:40 +0400
Subject: [PATCH 2/6] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?=
=?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?=
=?UTF-8?q?=D1=8F=D1=82=D1=8C=20=D0=BF=D0=BE=D1=82=D0=BE=D0=BC=D0=BE=D0=BA?=
=?UTF-8?q?=20=D0=B8=20=D1=80=D0=BE=D0=B4=D0=B8=D1=82=D0=B5=D0=BB=D1=8C?=
=?UTF-8?q?=D1=81=D0=BA=D0=B8=D0=B9=20=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80?=
=?UTF-8?q?=D0=BC=D1=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../FormSPAUConfig.Designer.cs | 43 ++++++++++---------
.../FormSPAUConfig.cs | 27 ++++++++----
2 files changed, 40 insertions(+), 30 deletions(-)
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
index f32a7d4..1e1a4bc 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
@@ -43,8 +43,8 @@
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
label_speed = new Label();
- label_orig = new Label();
- label_child = new Label();
+ labelOriginalObject = new Label();
+ labelModifiedObject = new Label();
pictureBox = new PictureBox();
Panel = new Panel();
button_close = new Button();
@@ -203,24 +203,25 @@
label_speed.TabIndex = 0;
label_speed.Text = "Скорость";
//
- // label_orig
+ // labelOriginalObject
//
- label_orig.BorderStyle = BorderStyle.FixedSingle;
- label_orig.Location = new Point(606, 416);
- label_orig.Name = "label_orig";
- label_orig.Size = new Size(81, 29);
- label_orig.TabIndex = 2;
- label_orig.Text = "Простой";
- label_orig.MouseDown += LabelOrig_MouseDown;
+ labelOriginalObject.BorderStyle = BorderStyle.FixedSingle;
+ labelOriginalObject.Location = new Point(606, 416);
+ labelOriginalObject.Name = "labelOriginalObject";
+ labelOriginalObject.Size = new Size(81, 29);
+ labelOriginalObject.TabIndex = 2;
+ labelOriginalObject.Text = "Простой";
+ labelOriginalObject.MouseDown += Label_MouseDown;
//
- // label_child
+ // labelModifiedObject
//
- label_child.BorderStyle = BorderStyle.FixedSingle;
- label_child.Location = new Point(711, 416);
- label_child.Name = "label_child";
- label_child.Size = new Size(77, 29);
- label_child.TabIndex = 3;
- label_child.Text = "Потомок";
+ labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelModifiedObject.Location = new Point(711, 416);
+ labelModifiedObject.Name = "labelModifiedObject";
+ labelModifiedObject.Size = new Size(77, 29);
+ labelModifiedObject.TabIndex = 3;
+ labelModifiedObject.Text = "Потомок";
+ labelModifiedObject.MouseDown += Label_MouseDown;
//
// pictureBox
//
@@ -289,8 +290,8 @@
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(Panel);
- Controls.Add(label_child);
- Controls.Add(label_orig);
+ Controls.Add(labelModifiedObject);
+ Controls.Add(labelOriginalObject);
Controls.Add(groupBox_param);
Name = "FormSPAUConfig";
Text = "FormSPAUConfig";
@@ -321,8 +322,8 @@
private Panel panelPurple;
private Panel panelBlack;
private Panel panelBlue;
- private Label label_orig;
- private Label label_child;
+ private Label labelOriginalObject;
+ private Label labelModifiedObject;
private PictureBox pictureBox;
private Panel Panel;
private Label label_addit_color;
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
index c894bcd..0004b2e 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using System.Xml.Linq;
using SelfPropelledArtilleryUnit.DrawningObjects;
using SelfPropelledArtilleryUnit.SPAUs;
@@ -29,17 +30,25 @@ namespace SelfPropelledArtilleryUnit
{
InitializeComponent();
- panelBlack.MouseDown += PanelColor_MouseDown;
- panelPurple.MouseDown += PanelColor_MouseDown;
- panelGray.MouseDown += PanelColor_MouseDown;
- panelGreen.MouseDown += PanelColor_MouseDown;
- panelRed.MouseDown += PanelColor_MouseDown;
- panelCian.MouseDown += PanelColor_MouseDown;
- panelYellow.MouseDown += PanelColor_MouseDown;
- panelBlue.MouseDown += PanelColor_MouseDown;
+ panelBlack.MouseDown += panelColor_MouseDown;
+ panelPurple.MouseDown += panelColor_MouseDown;
+ panelGray.MouseDown += panelColor_MouseDown;
+ panelGreen.MouseDown += panelColor_MouseDown;
+ panelRed.MouseDown += panelColor_MouseDown;
+ panelCian.MouseDown += panelColor_MouseDown;
+ panelYellow.MouseDown += panelColor_MouseDown;
+ panelBlue.MouseDown += panelColor_MouseDown;
// TODO buttonCancel.Click with lambda
+
+ button_close.Click += (s, e) => Close();
}
+ public void panelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+
///
/// Отрисовать машину
///
@@ -73,7 +82,7 @@ namespace SelfPropelledArtilleryUnit
///
///
///
- private void LabelOrig_MouseDown(object sender, MouseEventArgs e)
+ private void Label_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
}
--
2.25.1
From dcd33b6133d1f856a090dafb2ad330d0e11dff40 Mon Sep 17 00:00:00 2001
From: GokaPek <109132407+GokaPek@users.noreply.github.com>
Date: Tue, 7 Nov 2023 15:49:39 +0400
Subject: [PATCH 3/6] =?UTF-8?q?=D0=9A=D0=BE=D1=81=D1=8F=D0=BA=20=D1=81=20?=
=?UTF-8?q?=D1=86=D0=B2=D0=B5=D1=82=D0=B0=D0=BC=D0=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../SelfPropelledArtilleryUnit/EntitySPAU.cs | 4 ++
.../EntitySPAUchild.cs | 4 ++
.../FormSPAUCollection.cs | 43 +++++++++++--------
.../FormSPAUConfig.Designer.cs | 4 ++
.../FormSPAUConfig.cs | 41 +++++++++++++++---
5 files changed, 73 insertions(+), 23 deletions(-)
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAU.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAU.cs
index 2ac7543..3259a2c 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAU.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAU.cs
@@ -30,5 +30,9 @@
Weight = weight;
BodyColor = bodyColor;
}
+ public void setBodyColor(Color color)
+ {
+ BodyColor = color;
+ }
}
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAUchild.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAUchild.cs
index 25dfa58..617bd08 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAUchild.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAUchild.cs
@@ -23,5 +23,9 @@ namespace SelfPropelledArtilleryUnit.Entities
AdditionalColor = additionalColor;
BodyKit = bodyKit;
}
+ public void setAdditionalColor(Color color)
+ {
+ AdditionalColor = color;
+ }
}
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs
index 4b6a84d..d5753a7 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUCollection.cs
@@ -23,7 +23,6 @@ namespace SelfPropelledArtilleryUnit
///
/// Набор объектов
///
- //private readonly SPAUGenericCollection _SPAUs;
private readonly SPAUGenericStorage _storage;
///
/// Конструктор
@@ -106,9 +105,6 @@ namespace SelfPropelledArtilleryUnit
///
private void ButtonAddSPAU_Click(object sender, EventArgs e)
{
- var formSPAUConfig = new FormSPAUConfig();
- // TODO Call method AddEvent from formCarConfig
- formSPAUConfig.Show();
if (listBoxStorages.SelectedIndex == -1)
{
@@ -119,20 +115,33 @@ namespace SelfPropelledArtilleryUnit
{
return;
}
- FormSPAU form = new();
- if (form.ShowDialog() == DialogResult.OK)
- {
- int addedIndex = obj + form.SelectedSPAU;
- if (addedIndex != -1 && addedIndex <= countPlaces)
- {
- MessageBox.Show("Объект добавлен");
- pictureBoxCollection.Image = obj.ShowSPAUs();
- }
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
+ var formSPAUConfig = new FormSPAUConfig();
+ formSPAUConfig.AddEvent(AddSPAU);
+ formSPAUConfig.Show();
+ }
+
+ private void AddSPAU(DrawningSPAU sPAU)
+ {
+ if (listBoxStorages.SelectedIndex == -1)
+ {
+ return;
+ }
+ var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
+ if (obj == null)
+ {
+ return;
+ }
+
+ int addedIndex = obj + sPAU;
+ if (addedIndex != -1 && addedIndex <= countPlaces)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollection.Image = obj.ShowSPAUs();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
}
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
index 1e1a4bc..1cca28b 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
@@ -274,6 +274,8 @@
label_addit_color.Size = new Size(173, 29);
label_addit_color.TabIndex = 6;
label_addit_color.Text = "Дополнительный цвет";
+ label_addit_color.DragDrop += labelColor_dragDrop;
+ label_addit_color.DragEnter += labelColor_dragEnter;
//
// label_color
//
@@ -283,6 +285,8 @@
label_color.Size = new Size(127, 29);
label_color.TabIndex = 5;
label_color.Text = "Основной цвет";
+ label_color.DragDrop += labelColor_dragDrop;
+ label_color.DragEnter += labelColor_dragEnter;
//
// FormSPAUConfig
//
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
index 0004b2e..6a0a567 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using SelfPropelledArtilleryUnit.DrawningObjects;
+using SelfPropelledArtilleryUnit.Entities;
using SelfPropelledArtilleryUnit.SPAUs;
namespace SelfPropelledArtilleryUnit
@@ -38,15 +39,10 @@ namespace SelfPropelledArtilleryUnit
panelCian.MouseDown += panelColor_MouseDown;
panelYellow.MouseDown += panelColor_MouseDown;
panelBlue.MouseDown += panelColor_MouseDown;
- // TODO buttonCancel.Click with lambda
button_close.Click += (s, e) => Close();
}
- public void panelColor_MouseDown(object sender, MouseEventArgs e)
- {
- (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
- }
///
@@ -123,7 +119,40 @@ namespace SelfPropelledArtilleryUnit
DrawSPAU();
}
- // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
+ public void panelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void labelColor_dragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ private void labelColor_dragDrop(object sender, DragEventArgs e)
+ {
+ if (_sPAU != null)
+ return;
+ switch (((Label)sender).Name)
+ {
+ case "label_color":
+ _sPAU.EntitySPAU.setBodyColor((Color)e.Data.GetData(typeof(Color)));
+ break;
+ case "label_addit_color":
+ if (!(_sPAU is DrawningSPAUchild))
+ return;
+ (_sPAU.EntitySPAU as EntitySPAUchild).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
+ break;
+ }
+ DrawSPAU();
+ }
+
///
/// Добавление машины
///
--
2.25.1
From 735998ad4f1360170c5862a35ac165dcac052be6 Mon Sep 17 00:00:00 2001
From: GokaPek <109132407+GokaPek@users.noreply.github.com>
Date: Tue, 7 Nov 2023 17:05:48 +0400
Subject: [PATCH 4/6] =?UTF-8?q?=D0=9A=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80?=
=?UTF-8?q?=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE=D0=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../FormSPAUConfig.Designer.cs | 84 ++++++++++++-------
.../FormSPAUConfig.cs | 12 +--
2 files changed, 61 insertions(+), 35 deletions(-)
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
index 1cca28b..d7b90d0 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
@@ -49,14 +49,18 @@
Panel = new Panel();
button_close = new Button();
button_add = new Button();
- label_addit_color = new Label();
label_color = new Label();
+ panel_color = new Panel();
+ panel_addit_color = new Panel();
+ label1 = new Label();
groupBox_param.SuspendLayout();
groupBox_colors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
Panel.SuspendLayout();
+ panel_color.SuspendLayout();
+ panel_addit_color.SuspendLayout();
SuspendLayout();
//
// groupBox_param
@@ -225,31 +229,26 @@
//
// pictureBox
//
- pictureBox.Location = new Point(3, 68);
+ pictureBox.Location = new Point(3, 22);
pictureBox.Name = "pictureBox";
- pictureBox.Size = new Size(588, 377);
+ pictureBox.Size = new Size(588, 365);
pictureBox.TabIndex = 4;
pictureBox.TabStop = false;
//
// Panel
//
Panel.AllowDrop = true;
- Panel.Controls.Add(button_close);
- Panel.Controls.Add(button_add);
- Panel.Controls.Add(label_addit_color);
- Panel.Controls.Add(label_color);
Panel.Controls.Add(pictureBox);
- Panel.Dock = DockStyle.Left;
- Panel.Location = new Point(0, 0);
+ Panel.Location = new Point(0, 58);
Panel.Name = "Panel";
- Panel.Size = new Size(600, 450);
+ Panel.Size = new Size(600, 392);
Panel.TabIndex = 5;
Panel.DragDrop += panel_dragDrop;
Panel.DragEnter += panel_dragEnter;
//
// button_close
//
- button_close.Location = new Point(488, 21);
+ button_close.Location = new Point(511, 12);
button_close.Name = "button_close";
button_close.Size = new Size(80, 29);
button_close.TabIndex = 8;
@@ -258,7 +257,7 @@
//
// button_add
//
- button_add.Location = new Point(387, 21);
+ button_add.Location = new Point(410, 12);
button_add.Name = "button_add";
button_add.Size = new Size(95, 29);
button_add.TabIndex = 7;
@@ -266,34 +265,56 @@
button_add.UseVisualStyleBackColor = true;
button_add.Click += button_add_Click;
//
- // label_addit_color
- //
- label_addit_color.BorderStyle = BorderStyle.FixedSingle;
- label_addit_color.Location = new Point(145, 21);
- label_addit_color.Name = "label_addit_color";
- label_addit_color.Size = new Size(173, 29);
- label_addit_color.TabIndex = 6;
- label_addit_color.Text = "Дополнительный цвет";
- label_addit_color.DragDrop += labelColor_dragDrop;
- label_addit_color.DragEnter += labelColor_dragEnter;
- //
// label_color
//
label_color.BorderStyle = BorderStyle.FixedSingle;
- label_color.Location = new Point(12, 21);
+ label_color.Location = new Point(5, 7);
label_color.Name = "label_color";
- label_color.Size = new Size(127, 29);
+ label_color.Size = new Size(171, 46);
label_color.TabIndex = 5;
label_color.Text = "Основной цвет";
- label_color.DragDrop += labelColor_dragDrop;
- label_color.DragEnter += labelColor_dragEnter;
+ //
+ // panel_color
+ //
+ panel_color.AllowDrop = true;
+ panel_color.Controls.Add(label_color);
+ panel_color.Location = new Point(0, 2);
+ panel_color.Name = "panel_color";
+ panel_color.Size = new Size(179, 53);
+ panel_color.TabIndex = 6;
+ panel_color.DragDrop += labelColor_dragDrop;
+ panel_color.DragEnter += labelColor_dragEnter;
+ //
+ // panel_addit_color
+ //
+ panel_addit_color.AllowDrop = true;
+ panel_addit_color.Controls.Add(label1);
+ panel_addit_color.Location = new Point(188, 2);
+ panel_addit_color.Name = "panel_addit_color";
+ panel_addit_color.Size = new Size(179, 53);
+ panel_addit_color.TabIndex = 7;
+ panel_addit_color.DragDrop += labelColor_dragDrop;
+ panel_addit_color.DragEnter += labelColor_dragEnter;
+ //
+ // label1
+ //
+ label1.BorderStyle = BorderStyle.FixedSingle;
+ label1.Location = new Point(3, 7);
+ label1.Name = "label1";
+ label1.Size = new Size(173, 46);
+ label1.TabIndex = 6;
+ label1.Text = "Дополнительный цвет";
//
// FormSPAUConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
+ Controls.Add(panel_addit_color);
+ Controls.Add(panel_color);
+ Controls.Add(button_close);
Controls.Add(Panel);
+ Controls.Add(button_add);
Controls.Add(labelModifiedObject);
Controls.Add(labelOriginalObject);
Controls.Add(groupBox_param);
@@ -306,6 +327,8 @@
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
Panel.ResumeLayout(false);
+ panel_color.ResumeLayout(false);
+ panel_addit_color.ResumeLayout(false);
ResumeLayout(false);
}
@@ -330,9 +353,12 @@
private Label labelModifiedObject;
private PictureBox pictureBox;
private Panel Panel;
- private Label label_addit_color;
- private Label label_color;
private Button button_close;
private Button button_add;
+ private Label label_color;
+ private Label label_addit_color;
+ private Panel panel_color;
+ private Panel panel_addit_color;
+ private Label label1;
}
}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
index 6a0a567..f28ae91 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
@@ -137,17 +137,17 @@ namespace SelfPropelledArtilleryUnit
}
private void labelColor_dragDrop(object sender, DragEventArgs e)
{
- if (_sPAU != null)
+ if (_sPAU == null)
return;
- switch (((Label)sender).Name)
+ switch (((Panel)sender).Name)
{
- case "label_color":
- _sPAU.EntitySPAU.setBodyColor((Color)e.Data.GetData(typeof(Color)));
+ case "panel_color":
+ _sPAU?.EntitySPAU?.setBodyColor((Color)e.Data.GetData(typeof(Color)));
break;
- case "label_addit_color":
+ case "panel_addit_color":
if (!(_sPAU is DrawningSPAUchild))
return;
- (_sPAU.EntitySPAU as EntitySPAUchild).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
+ (_sPAU.EntitySPAU as EntitySPAUchild)?.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
break;
}
DrawSPAU();
--
2.25.1
From 57d002abc8795050633ee5982b4de83df9dff638 Mon Sep 17 00:00:00 2001
From: GokaPek <109132407+GokaPek@users.noreply.github.com>
Date: Wed, 8 Nov 2023 09:56:27 +0400
Subject: [PATCH 5/6] Finak
---
.../DrawningSPAUchild.cs | 9 ++++++--
.../EntitySPAUchild.cs | 8 ++++++-
.../SelfPropelledArtilleryUnit/FormSPAU.cs | 2 +-
.../FormSPAUConfig.Designer.cs | 23 +++++++++++++++----
.../FormSPAUConfig.cs | 8 +++----
.../SPAUDelegate.cs | 2 +-
6 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/DrawningSPAUchild.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/DrawningSPAUchild.cs
index 4ae1dad..a567363 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/DrawningSPAUchild.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/DrawningSPAUchild.cs
@@ -11,11 +11,11 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
{
/// Дополнительный цвет
/// Признак наличия залповой установки
- public DrawningSPAUchild(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, int width, int height) : base(speed, weight, bodyColor, width, height)
+ public DrawningSPAUchild(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool ballon, int width, int height) : base(speed, weight, bodyColor, width, height)
{
if (EntitySPAU != null)
{
- EntitySPAU = new EntitySPAUchild(speed, weight, bodyColor, additionalColor, bodyKit);
+ EntitySPAU = new EntitySPAUchild(speed, weight, bodyColor, additionalColor, bodyKit, ballon);
}
}
public override void DrawTransport(Graphics g)
@@ -33,6 +33,11 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
g.FillRectangle(additionalBrush, _startPosX + 15, _startPosY + 20, 20, 40);
g.DrawLine(penBlack, _startPosX + 5, _startPosY + 20, _startPosX + 15, _startPosY + 25);
}
+ if (entitySPAUchild.Ballon)
+ {
+ //баллон
+ g.FillRectangle(additionalBrush, _startPosX + 110, _startPosY + 35, 30, 20);
+ }
base.DrawTransport(g);
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAUchild.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAUchild.cs
index 617bd08..4dcd6b6 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAUchild.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/EntitySPAUchild.cs
@@ -16,12 +16,18 @@ namespace SelfPropelledArtilleryUnit.Entities
/// Признак (опция) наличия залповой установки
///
public bool BodyKit { get; private set; }
+ ///
+ /// Признак (опция) наличия баллона
+ ///
+ public bool Ballon { get; private set; }
/// Дополнительный цвет
/// Признак наличия залповой установки
- public EntitySPAUchild(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit) : base(speed, weight, bodyColor)
+ public EntitySPAUchild(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool ballon) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
BodyKit = bodyKit;
+ Ballon = ballon;
+
}
public void setAdditionalColor(Color color)
{
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAU.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAU.cs
index e011b97..b46c7b5 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAU.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAU.cs
@@ -67,7 +67,7 @@ namespace SelfPropelledArtilleryUnit
}
_drawningSPAU = new DrawningSPAUchild(random.Next(100, 300),
random.Next(1000, 3000), color,
- dopColor, true,
+ dopColor, true, true,
pictureBoxSPAU.Width, pictureBoxSPAU.Height);
_drawningSPAU.SetPosition(random.Next(10, 100), random.Next(10,
100));
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
index d7b90d0..d438521 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
@@ -29,6 +29,7 @@
private void InitializeComponent()
{
groupBox_param = new GroupBox();
+ сheckBox_ballon = new CheckBox();
checkBox_zalp = new CheckBox();
label_weight = new Label();
groupBox_colors = new GroupBox();
@@ -65,6 +66,7 @@
//
// groupBox_param
//
+ groupBox_param.Controls.Add(сheckBox_ballon);
groupBox_param.Controls.Add(checkBox_zalp);
groupBox_param.Controls.Add(label_weight);
groupBox_param.Controls.Add(groupBox_colors);
@@ -78,10 +80,20 @@
groupBox_param.TabStop = false;
groupBox_param.Text = "Параметры";
//
+ // сheckBox_ballon
+ //
+ сheckBox_ballon.AutoSize = true;
+ сheckBox_ballon.Location = new Point(6, 162);
+ сheckBox_ballon.Name = "сheckBox_ballon";
+ сheckBox_ballon.Size = new Size(82, 24);
+ сheckBox_ballon.TabIndex = 7;
+ сheckBox_ballon.Text = "Баллон";
+ сheckBox_ballon.UseVisualStyleBackColor = true;
+ //
// checkBox_zalp
//
checkBox_zalp.AutoSize = true;
- checkBox_zalp.Location = new Point(6, 154);
+ checkBox_zalp.Location = new Point(6, 132);
checkBox_zalp.Name = "checkBox_zalp";
checkBox_zalp.Size = new Size(170, 24);
checkBox_zalp.TabIndex = 5;
@@ -91,7 +103,7 @@
// label_weight
//
label_weight.AutoSize = true;
- label_weight.Location = new Point(6, 86);
+ label_weight.Location = new Point(111, 76);
label_weight.Name = "label_weight";
label_weight.Size = new Size(33, 20);
label_weight.TabIndex = 3;
@@ -180,7 +192,7 @@
//
// numericUpDownWeight
//
- numericUpDownWeight.Location = new Point(6, 109);
+ numericUpDownWeight.Location = new Point(120, 99);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
@@ -190,7 +202,7 @@
//
// numericUpDownSpeed
//
- numericUpDownSpeed.Location = new Point(6, 56);
+ numericUpDownSpeed.Location = new Point(120, 46);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
@@ -201,7 +213,7 @@
// label_speed
//
label_speed.AutoSize = true;
- label_speed.Location = new Point(6, 33);
+ label_speed.Location = new Point(109, 23);
label_speed.Name = "label_speed";
label_speed.Size = new Size(73, 20);
label_speed.TabIndex = 0;
@@ -360,5 +372,6 @@
private Panel panel_color;
private Panel panel_addit_color;
private Label label1;
+ private CheckBox сheckBox_ballon;
}
}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
index f28ae91..7070bbe 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
@@ -23,7 +23,7 @@ namespace SelfPropelledArtilleryUnit
///
/// Событие
///
- private event SPAUDelegate? EventAddSPAU;
+ public event Action? EventAddSPAU;
///
/// Конструктор
///
@@ -61,7 +61,7 @@ namespace SelfPropelledArtilleryUnit
/// Добавление события
///
/// Привязанный метод
- public void AddEvent(SPAUDelegate ev)
+ public void AddEvent(Action ev)
{
if (EventAddSPAU == null)
{
@@ -113,7 +113,7 @@ namespace SelfPropelledArtilleryUnit
_sPAU = new DrawningSPAU((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBox.Width, pictureBox.Height);
break;
case "labelModifiedObject":
- _sPAU = new DrawningSPAUchild((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBox_zalp.Checked, pictureBox.Width, pictureBox.Height);
+ _sPAU = new DrawningSPAUchild((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBox_zalp.Checked, сheckBox_ballon.Checked, pictureBox.Width, pictureBox.Height);
break;
}
DrawSPAU();
@@ -147,7 +147,7 @@ namespace SelfPropelledArtilleryUnit
case "panel_addit_color":
if (!(_sPAU is DrawningSPAUchild))
return;
- (_sPAU.EntitySPAU as EntitySPAUchild)?.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
+ (_sPAU.EntitySPAU as EntitySPAUchild)?.setAdditionalColor(color: (Color)e.Data.GetData(typeof(Color)));
break;
}
DrawSPAU();
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs
index bdedea1..c19d0f3 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs
@@ -11,5 +11,5 @@ namespace SelfPropelledArtilleryUnit.SPAUs
/// Делегат для передачи объекта-автомобиля
///
///
- public delegate void SPAUDelegate(DrawningSPAU sPAU);
+ //public delegate void SPAUDelegate(DrawningSPAU sPAU);
}
--
2.25.1
From 71b4b13eeaa38e492e114843458da35625bff9be Mon Sep 17 00:00:00 2001
From: GokaPek <109132407+GokaPek@users.noreply.github.com>
Date: Wed, 8 Nov 2023 10:59:49 +0400
Subject: [PATCH 6/6] =?UTF-8?q?=D0=A4=D0=B8=D0=BD=D0=B0=D0=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../FormSPAUConfig.Designer.cs | 47 +++++++------------
.../FormSPAUConfig.cs | 7 ++-
.../SPAUDelegate.cs | 15 ------
3 files changed, 21 insertions(+), 48 deletions(-)
delete mode 100644 SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
index d438521..2dfe2ff 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.Designer.cs
@@ -52,8 +52,7 @@
button_add = new Button();
label_color = new Label();
panel_color = new Panel();
- panel_addit_color = new Panel();
- label1 = new Label();
+ label_addit_color = new Label();
groupBox_param.SuspendLayout();
groupBox_colors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
@@ -61,7 +60,6 @@
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
Panel.SuspendLayout();
panel_color.SuspendLayout();
- panel_addit_color.SuspendLayout();
SuspendLayout();
//
// groupBox_param
@@ -279,50 +277,43 @@
//
// label_color
//
+ label_color.AllowDrop = true;
label_color.BorderStyle = BorderStyle.FixedSingle;
- label_color.Location = new Point(5, 7);
+ label_color.Location = new Point(3, 6);
label_color.Name = "label_color";
label_color.Size = new Size(171, 46);
label_color.TabIndex = 5;
label_color.Text = "Основной цвет";
+ label_color.DragDrop += labelColor_dragDrop;
+ label_color.DragEnter += labelColor_dragEnter;
//
// panel_color
//
panel_color.AllowDrop = true;
+ panel_color.Controls.Add(label_addit_color);
panel_color.Controls.Add(label_color);
- panel_color.Location = new Point(0, 2);
+ panel_color.Location = new Point(0, 3);
panel_color.Name = "panel_color";
- panel_color.Size = new Size(179, 53);
+ panel_color.Size = new Size(362, 52);
panel_color.TabIndex = 6;
- panel_color.DragDrop += labelColor_dragDrop;
- panel_color.DragEnter += labelColor_dragEnter;
//
- // panel_addit_color
+ // label_addit_color
//
- panel_addit_color.AllowDrop = true;
- panel_addit_color.Controls.Add(label1);
- panel_addit_color.Location = new Point(188, 2);
- panel_addit_color.Name = "panel_addit_color";
- panel_addit_color.Size = new Size(179, 53);
- panel_addit_color.TabIndex = 7;
- panel_addit_color.DragDrop += labelColor_dragDrop;
- panel_addit_color.DragEnter += labelColor_dragEnter;
- //
- // label1
- //
- label1.BorderStyle = BorderStyle.FixedSingle;
- label1.Location = new Point(3, 7);
- label1.Name = "label1";
- label1.Size = new Size(173, 46);
- label1.TabIndex = 6;
- label1.Text = "Дополнительный цвет";
+ label_addit_color.AllowDrop = true;
+ label_addit_color.BorderStyle = BorderStyle.FixedSingle;
+ label_addit_color.Location = new Point(180, 6);
+ label_addit_color.Name = "label_addit_color";
+ label_addit_color.Size = new Size(173, 46);
+ label_addit_color.TabIndex = 6;
+ label_addit_color.Text = "Дополнительный цвет";
+ label_addit_color.DragDrop += labelColor_dragDrop;
+ label_addit_color.DragEnter += labelColor_dragEnter;
//
// FormSPAUConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
- Controls.Add(panel_addit_color);
Controls.Add(panel_color);
Controls.Add(button_close);
Controls.Add(Panel);
@@ -340,7 +331,6 @@
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
Panel.ResumeLayout(false);
panel_color.ResumeLayout(false);
- panel_addit_color.ResumeLayout(false);
ResumeLayout(false);
}
@@ -370,7 +360,6 @@
private Label label_color;
private Label label_addit_color;
private Panel panel_color;
- private Panel panel_addit_color;
private Label label1;
private CheckBox сheckBox_ballon;
}
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
index 7070bbe..bd58e5c 100644
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
+++ b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/FormSPAUConfig.cs
@@ -10,7 +10,6 @@ using System.Windows.Forms;
using System.Xml.Linq;
using SelfPropelledArtilleryUnit.DrawningObjects;
using SelfPropelledArtilleryUnit.Entities;
-using SelfPropelledArtilleryUnit.SPAUs;
namespace SelfPropelledArtilleryUnit
{
@@ -139,12 +138,12 @@ namespace SelfPropelledArtilleryUnit
{
if (_sPAU == null)
return;
- switch (((Panel)sender).Name)
+ switch (((Label)sender).Name)
{
- case "panel_color":
+ case "label_color":
_sPAU?.EntitySPAU?.setBodyColor((Color)e.Data.GetData(typeof(Color)));
break;
- case "panel_addit_color":
+ case "label_addit_color":
if (!(_sPAU is DrawningSPAUchild))
return;
(_sPAU.EntitySPAU as EntitySPAUchild)?.setAdditionalColor(color: (Color)e.Data.GetData(typeof(Color)));
diff --git a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs b/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs
deleted file mode 100644
index c19d0f3..0000000
--- a/SelfPropelledArtilleryUnit/SelfPropelledArtilleryUnit/SPAUDelegate.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using SelfPropelledArtilleryUnit.DrawningObjects;
-
-namespace SelfPropelledArtilleryUnit.SPAUs
-{
- ///
- /// Делегат для передачи объекта-автомобиля
- ///
- ///
- //public delegate void SPAUDelegate(DrawningSPAU sPAU);
-}
--
2.25.1