diff --git a/ProjectBattleship/ProjectBattleship/CollectionGenericObjects/AbstractCompany.cs b/ProjectBattleship/ProjectBattleship/CollectionGenericObjects/AbstractCompany.cs
index ade4314..b93c54a 100644
--- a/ProjectBattleship/ProjectBattleship/CollectionGenericObjects/AbstractCompany.cs
+++ b/ProjectBattleship/ProjectBattleship/CollectionGenericObjects/AbstractCompany.cs
@@ -71,7 +71,7 @@ public abstract class AbstractCompany
/// Компания
/// Номер удаляемого объекта
///
- public static DrawingShip operator -(AbstractCompany company, int position)
+ public static DrawingShip? operator -(AbstractCompany company, int position)
{
return company._collection?.Remove(position);
}
diff --git a/ProjectBattleship/ProjectBattleship/Entities/EntityBattleship.cs b/ProjectBattleship/ProjectBattleship/Entities/EntityBattleship.cs
index 08f515b..c87c5e0 100644
--- a/ProjectBattleship/ProjectBattleship/Entities/EntityBattleship.cs
+++ b/ProjectBattleship/ProjectBattleship/Entities/EntityBattleship.cs
@@ -11,4 +11,8 @@ public class EntityBattleship : EntityShip
Turret = turret;
RocketLauncher = rocketLauncher;
}
+ public void ChangeAddColor(Color? addColor)
+ {
+ AdditionalColor = addColor ?? AdditionalColor;
+ }
}
\ No newline at end of file
diff --git a/ProjectBattleship/ProjectBattleship/Entities/EntityShip.cs b/ProjectBattleship/ProjectBattleship/Entities/EntityShip.cs
index 8bbd131..9097330 100644
--- a/ProjectBattleship/ProjectBattleship/Entities/EntityShip.cs
+++ b/ProjectBattleship/ProjectBattleship/Entities/EntityShip.cs
@@ -11,4 +11,8 @@ public class EntityShip
Weight = weight;
BodyColor = bodyColor;
}
+ public void ChangeColor(Color? color)
+ {
+ BodyColor = color ?? BodyColor;
+ }
}
\ No newline at end of file
diff --git a/ProjectBattleship/ProjectBattleship/FormShipCollection.Designer.cs b/ProjectBattleship/ProjectBattleship/FormShipCollection.Designer.cs
index 61fff26..d98eb94 100644
--- a/ProjectBattleship/ProjectBattleship/FormShipCollection.Designer.cs
+++ b/ProjectBattleship/ProjectBattleship/FormShipCollection.Designer.cs
@@ -29,6 +29,12 @@
private void InitializeComponent()
{
Tools = new GroupBox();
+ panelCompanyTools = new Panel();
+ buttonAddShip = new Button();
+ buttonRefresh = new Button();
+ maskedTextBox = new MaskedTextBox();
+ buttonGoToTest = new Button();
+ buttonDelShip = new Button();
buttonCreateCompany = new Button();
panelStorage = new Panel();
buttonCollectionDel = new Button();
@@ -38,19 +44,12 @@
radioButtonMassive = new RadioButton();
textBoxCollectionName = new TextBox();
labelCollectionName = new Label();
- buttonRefresh = new Button();
- buttonGoToTest = new Button();
- buttonDelShip = new Button();
- maskedTextBox = new MaskedTextBox();
- buttonAddBettleship = new Button();
- buttonAddShip = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
- panelCompanyTools = new Panel();
Tools.SuspendLayout();
+ panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
- panelCompanyTools.SuspendLayout();
SuspendLayout();
//
// Tools
@@ -67,6 +66,73 @@
Tools.TabStop = false;
Tools.Text = "Инструменты";
//
+ // panelCompanyTools
+ //
+ panelCompanyTools.Controls.Add(buttonAddShip);
+ panelCompanyTools.Controls.Add(buttonRefresh);
+ panelCompanyTools.Controls.Add(maskedTextBox);
+ panelCompanyTools.Controls.Add(buttonGoToTest);
+ panelCompanyTools.Controls.Add(buttonDelShip);
+ panelCompanyTools.Enabled = false;
+ panelCompanyTools.Location = new Point(0, 686);
+ panelCompanyTools.Name = "panelCompanyTools";
+ panelCompanyTools.Size = new Size(488, 569);
+ panelCompanyTools.TabIndex = 8;
+ //
+ // buttonAddShip
+ //
+ buttonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddShip.Location = new Point(9, 3);
+ buttonAddShip.Name = "buttonAddShip";
+ buttonAddShip.Size = new Size(473, 90);
+ buttonAddShip.TabIndex = 1;
+ buttonAddShip.Text = "Добавить корабль";
+ buttonAddShip.UseVisualStyleBackColor = true;
+ buttonAddShip.Click += ButtonAddShip_Click;
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(16, 432);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(466, 90);
+ buttonRefresh.TabIndex = 6;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
+ //
+ // maskedTextBox
+ //
+ maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ maskedTextBox.Location = new Point(12, 195);
+ maskedTextBox.Mask = "00";
+ maskedTextBox.Name = "maskedTextBox";
+ maskedTextBox.Size = new Size(470, 39);
+ maskedTextBox.TabIndex = 3;
+ maskedTextBox.ValidatingType = typeof(int);
+ //
+ // buttonGoToTest
+ //
+ buttonGoToTest.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonGoToTest.Location = new Point(16, 336);
+ buttonGoToTest.Name = "buttonGoToTest";
+ buttonGoToTest.Size = new Size(466, 90);
+ buttonGoToTest.TabIndex = 5;
+ buttonGoToTest.Text = "Передать на тест";
+ buttonGoToTest.UseVisualStyleBackColor = true;
+ buttonGoToTest.Click += ButtonGoToTest_Click;
+ //
+ // buttonDelShip
+ //
+ buttonDelShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonDelShip.Location = new Point(12, 240);
+ buttonDelShip.Name = "buttonDelShip";
+ buttonDelShip.Size = new Size(473, 90);
+ buttonDelShip.TabIndex = 4;
+ buttonDelShip.Text = "Удалить корабль";
+ buttonDelShip.UseVisualStyleBackColor = true;
+ buttonDelShip.Click += ButtonDelShip_Click;
+ //
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(9, 612);
@@ -159,71 +225,6 @@
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:";
//
- // buttonRefresh
- //
- buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonRefresh.Location = new Point(16, 432);
- buttonRefresh.Name = "buttonRefresh";
- buttonRefresh.Size = new Size(466, 90);
- buttonRefresh.TabIndex = 6;
- buttonRefresh.Text = "Обновить";
- buttonRefresh.UseVisualStyleBackColor = true;
- buttonRefresh.Click += ButtonRefresh_Click;
- //
- // buttonGoToTest
- //
- buttonGoToTest.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonGoToTest.Location = new Point(16, 336);
- buttonGoToTest.Name = "buttonGoToTest";
- buttonGoToTest.Size = new Size(466, 90);
- buttonGoToTest.TabIndex = 5;
- buttonGoToTest.Text = "Передать на тест";
- buttonGoToTest.UseVisualStyleBackColor = true;
- buttonGoToTest.Click += ButtonGoToTest_Click;
- //
- // buttonDelShip
- //
- buttonDelShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonDelShip.Location = new Point(12, 240);
- buttonDelShip.Name = "buttonDelShip";
- buttonDelShip.Size = new Size(473, 90);
- buttonDelShip.TabIndex = 4;
- buttonDelShip.Text = "Удалить корабль";
- buttonDelShip.UseVisualStyleBackColor = true;
- buttonDelShip.Click += ButtonDelShip_Click;
- //
- // maskedTextBox
- //
- maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- maskedTextBox.Location = new Point(12, 195);
- maskedTextBox.Mask = "00";
- maskedTextBox.Name = "maskedTextBox";
- maskedTextBox.Size = new Size(470, 39);
- maskedTextBox.TabIndex = 3;
- maskedTextBox.ValidatingType = typeof(int);
- //
- // buttonAddBettleship
- //
- buttonAddBettleship.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddBettleship.Location = new Point(9, 99);
- buttonAddBettleship.Name = "buttonAddBettleship";
- buttonAddBettleship.Size = new Size(473, 90);
- buttonAddBettleship.TabIndex = 2;
- buttonAddBettleship.Text = "Добавить боевой корабль";
- buttonAddBettleship.UseVisualStyleBackColor = true;
- buttonAddBettleship.Click += ButtonAddBattleship_Click;
- //
- // buttonAddShip
- //
- buttonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddShip.Location = new Point(9, 3);
- buttonAddShip.Name = "buttonAddShip";
- buttonAddShip.Size = new Size(473, 90);
- buttonAddShip.TabIndex = 1;
- buttonAddShip.Text = "Добавить корабль";
- buttonAddShip.UseVisualStyleBackColor = true;
- buttonAddShip.Click += ButtonAddShip_Click_1;
- //
// comboBoxSelectorCompany
//
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@@ -245,20 +246,6 @@
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
- // panelCompanyTools
- //
- panelCompanyTools.Controls.Add(buttonAddShip);
- panelCompanyTools.Controls.Add(buttonAddBettleship);
- panelCompanyTools.Controls.Add(buttonRefresh);
- panelCompanyTools.Controls.Add(maskedTextBox);
- panelCompanyTools.Controls.Add(buttonGoToTest);
- panelCompanyTools.Controls.Add(buttonDelShip);
- panelCompanyTools.Enabled = false;
- panelCompanyTools.Location = new Point(0, 686);
- panelCompanyTools.Name = "panelCompanyTools";
- panelCompanyTools.Size = new Size(488, 569);
- panelCompanyTools.TabIndex = 8;
- //
// FormShipCollection
//
AutoScaleDimensions = new SizeF(13F, 32F);
@@ -269,18 +256,17 @@
Name = "FormShipCollection";
Text = "Коллекция кораблей";
Tools.ResumeLayout(false);
+ panelCompanyTools.ResumeLayout(false);
+ panelCompanyTools.PerformLayout();
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
- panelCompanyTools.ResumeLayout(false);
- panelCompanyTools.PerformLayout();
ResumeLayout(false);
}
#endregion
private GroupBox Tools;
- private Button buttonAddBettleship;
private Button buttonAddShip;
private ComboBox comboBoxSelectorCompany;
private Button buttonDelShip;
diff --git a/ProjectBattleship/ProjectBattleship/FormShipCollection.cs b/ProjectBattleship/ProjectBattleship/FormShipCollection.cs
index 55481c3..a1e51f0 100644
--- a/ProjectBattleship/ProjectBattleship/FormShipCollection.cs
+++ b/ProjectBattleship/ProjectBattleship/FormShipCollection.cs
@@ -21,7 +21,6 @@ public partial class FormShipCollection : Form
/// Компания
///
private AbstractCompany? _company = null;
-
///
/// Конструктор
///
@@ -40,59 +39,10 @@ public partial class FormShipCollection : Form
panelCompanyTools.Enabled = false;
}
///
- /// Создание объекта класса-перемещения
+ /// Кнопка удаления корабля
///
- /// Тип создаваемого объекта
- private void CreateObject(string type)
- {
- if (_company == null)
- {
- return;
- }
-
- Random random = new();
- DrawingShip drawningShip;
- switch (type)
- {
- case nameof(DrawingShip):
- drawningShip = new DrawingShip(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
- break;
- case nameof(DrawingBattleship):
- drawningShip = new DrawingBattleship(random.Next(100, 300), random.Next(1000, 3000),
- GetColor(random), GetColor(random),
- Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
- break;
- default:
- return;
- }
-
- if (_company + drawningShip != -1)
- {
- MessageBox.Show("Объект добавлен");
- pictureBox.Image = _company.Show();
- }
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
- }
-
- ///
- /// Получение цвета
- ///
- /// Генератор случайных чисел
- ///
- private static Color GetColor(Random random)
- {
- Color color = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
- ColorDialog dialog = new();
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- color = dialog.Color;
- }
- return color;
- }
-
+ ///
+ ///
private void ButtonDelShip_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
@@ -116,7 +66,11 @@ public partial class FormShipCollection : Form
MessageBox.Show("Не удалось удалить объект");
}
}
-
+ ///
+ /// Кнопка отправки на тест
+ ///
+ ///
+ ///
private void ButtonGoToTest_Click(object sender, EventArgs e)
{
if (_company == null)
@@ -148,7 +102,11 @@ public partial class FormShipCollection : Form
form.ShowDialog();
}
-
+ ///
+ /// Кнопка обновить
+ ///
+ ///
+ ///
private void ButtonRefresh_Click(object sender, EventArgs e)
{
if (_company == null)
@@ -158,9 +116,34 @@ public partial class FormShipCollection : Form
pictureBox.Image = _company.Show();
}
- private void ButtonAddBattleship_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingBattleship));
-
- private void ButtonAddShip_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawingShip));
+ ///
+ /// Кнопка добавления корабля
+ ///
+ ///
+ ///
+ private void ButtonAddShip_Click(object sender, EventArgs e)
+ {
+ FormShipConfig form = new();
+ form.AddEvent(SetShip);
+ form.Show();
+ }
+ ///
+ /// Метод установки корабля в компанию
+ ///
+ private void SetShip(DrawingShip? ship)
+ {
+ if (_company == null)
+ return;
+ if (_company + ship != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
///
/// Добавление коллекции
///
@@ -217,7 +200,6 @@ public partial class FormShipCollection : Form
listBoxCollection.Items.Add(colName);
}
}
-
}
///
/// Создание компании
diff --git a/ProjectBattleship/ProjectBattleship/FormShipConfig.Designer.cs b/ProjectBattleship/ProjectBattleship/FormShipConfig.Designer.cs
new file mode 100644
index 0000000..d38017d
--- /dev/null
+++ b/ProjectBattleship/ProjectBattleship/FormShipConfig.Designer.cs
@@ -0,0 +1,357 @@
+namespace Battleship
+{
+ partial class FormShipConfig
+ {
+ ///
+ /// 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()
+ {
+ groupBoxConfig = new GroupBox();
+ groupBoxColors = new GroupBox();
+ panelGray = new Panel();
+ panelOrange = new Panel();
+ panelPink = new Panel();
+ panelPurple = new Panel();
+ panelBlue = new Panel();
+ panelWhite = new Panel();
+ panelGreen = new Panel();
+ panelRed = new Panel();
+ checkBoxRockets = new CheckBox();
+ checkBoxWeapon = new CheckBox();
+ numericUpDownWeight = new NumericUpDown();
+ labelWeight = new Label();
+ numericUpDownSpeed = new NumericUpDown();
+ labelSpeed = new Label();
+ labelModifiedObject = new Label();
+ labelSimpleObject = new Label();
+ pictureBoxObject = new PictureBox();
+ buttonAdd = new Button();
+ buttonCancel = new Button();
+ panelObject = new Panel();
+ labelAdditionalColor = new Label();
+ labelBodyColor = new Label();
+ groupBoxConfig.SuspendLayout();
+ groupBoxColors.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
+ panelObject.SuspendLayout();
+ SuspendLayout();
+ //
+ // groupBoxConfig
+ //
+ groupBoxConfig.Controls.Add(groupBoxColors);
+ groupBoxConfig.Controls.Add(checkBoxRockets);
+ groupBoxConfig.Controls.Add(checkBoxWeapon);
+ groupBoxConfig.Controls.Add(numericUpDownWeight);
+ groupBoxConfig.Controls.Add(labelWeight);
+ groupBoxConfig.Controls.Add(numericUpDownSpeed);
+ groupBoxConfig.Controls.Add(labelSpeed);
+ groupBoxConfig.Controls.Add(labelModifiedObject);
+ groupBoxConfig.Controls.Add(labelSimpleObject);
+ groupBoxConfig.Dock = DockStyle.Left;
+ groupBoxConfig.Location = new Point(0, 0);
+ groupBoxConfig.Name = "groupBoxConfig";
+ groupBoxConfig.Size = new Size(996, 436);
+ groupBoxConfig.TabIndex = 0;
+ groupBoxConfig.TabStop = false;
+ groupBoxConfig.Text = "Параметры";
+ //
+ // groupBoxColors
+ //
+ groupBoxColors.Controls.Add(panelGray);
+ groupBoxColors.Controls.Add(panelOrange);
+ groupBoxColors.Controls.Add(panelPink);
+ groupBoxColors.Controls.Add(panelPurple);
+ groupBoxColors.Controls.Add(panelBlue);
+ groupBoxColors.Controls.Add(panelWhite);
+ groupBoxColors.Controls.Add(panelGreen);
+ groupBoxColors.Controls.Add(panelRed);
+ groupBoxColors.Location = new Point(499, 52);
+ groupBoxColors.Name = "groupBoxColors";
+ groupBoxColors.Size = new Size(471, 249);
+ groupBoxColors.TabIndex = 8;
+ groupBoxColors.TabStop = false;
+ groupBoxColors.Text = "Цвета";
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Gray;
+ panelGray.Location = new Point(359, 135);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(76, 71);
+ panelGray.TabIndex = 3;
+ //
+ // panelOrange
+ //
+ panelOrange.BackColor = Color.Orange;
+ panelOrange.Location = new Point(359, 38);
+ panelOrange.Name = "panelOrange";
+ panelOrange.Size = new Size(76, 71);
+ panelOrange.TabIndex = 1;
+ //
+ // panelPink
+ //
+ panelPink.BackColor = Color.HotPink;
+ panelPink.Location = new Point(254, 135);
+ panelPink.Name = "panelPink";
+ panelPink.Size = new Size(76, 71);
+ panelPink.TabIndex = 4;
+ //
+ // panelPurple
+ //
+ panelPurple.BackColor = Color.Purple;
+ panelPurple.Location = new Point(148, 135);
+ panelPurple.Name = "panelPurple";
+ panelPurple.Size = new Size(76, 71);
+ panelPurple.TabIndex = 5;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(254, 38);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(76, 71);
+ panelBlue.TabIndex = 1;
+ //
+ // panelWhite
+ //
+ panelWhite.BackColor = Color.White;
+ panelWhite.Location = new Point(44, 135);
+ panelWhite.Name = "panelWhite";
+ panelWhite.Size = new Size(76, 71);
+ panelWhite.TabIndex = 2;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.Green;
+ panelGreen.Location = new Point(148, 38);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(76, 71);
+ panelGreen.TabIndex = 1;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(44, 38);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(76, 71);
+ panelRed.TabIndex = 0;
+ //
+ // checkBoxRockets
+ //
+ checkBoxRockets.AutoSize = true;
+ checkBoxRockets.Location = new Point(12, 265);
+ checkBoxRockets.Name = "checkBoxRockets";
+ checkBoxRockets.Size = new Size(374, 36);
+ checkBoxRockets.TabIndex = 7;
+ checkBoxRockets.Text = "Наличие рокетных установок";
+ checkBoxRockets.UseVisualStyleBackColor = true;
+ //
+ // checkBoxWeapon
+ //
+ checkBoxWeapon.AutoSize = true;
+ checkBoxWeapon.Location = new Point(12, 207);
+ checkBoxWeapon.Name = "checkBoxWeapon";
+ checkBoxWeapon.Size = new Size(343, 36);
+ checkBoxWeapon.TabIndex = 6;
+ checkBoxWeapon.Text = "Наличие оруженой башни";
+ checkBoxWeapon.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(150, 124);
+ 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(240, 39);
+ numericUpDownWeight.TabIndex = 5;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelWeight
+ //
+ labelWeight.AutoSize = true;
+ labelWeight.Location = new Point(12, 124);
+ labelWeight.Name = "labelWeight";
+ labelWeight.Size = new Size(57, 32);
+ labelWeight.TabIndex = 4;
+ labelWeight.Text = "Вес:";
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(150, 52);
+ 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(240, 39);
+ numericUpDownSpeed.TabIndex = 3;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelSpeed
+ //
+ labelSpeed.AutoSize = true;
+ labelSpeed.Location = new Point(12, 52);
+ labelSpeed.Name = "labelSpeed";
+ labelSpeed.Size = new Size(121, 32);
+ labelSpeed.TabIndex = 2;
+ labelSpeed.Text = "Скорость:";
+ //
+ // labelModifiedObject
+ //
+ labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelModifiedObject.Location = new Point(757, 326);
+ labelModifiedObject.Name = "labelModifiedObject";
+ labelModifiedObject.Size = new Size(169, 65);
+ labelModifiedObject.TabIndex = 1;
+ labelModifiedObject.Text = "Продвинутый";
+ labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelModifiedObject.MouseDown += LabelObject_MouseDown;
+ //
+ // labelSimpleObject
+ //
+ labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
+ labelSimpleObject.Location = new Point(499, 326);
+ labelSimpleObject.Name = "labelSimpleObject";
+ labelSimpleObject.Size = new Size(169, 65);
+ labelSimpleObject.TabIndex = 0;
+ labelSimpleObject.Text = "Простой";
+ labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelSimpleObject.MouseDown += LabelObject_MouseDown;
+ //
+ // pictureBoxObject
+ //
+ pictureBoxObject.Location = new Point(41, 97);
+ pictureBoxObject.Name = "pictureBoxObject";
+ pictureBoxObject.Size = new Size(379, 249);
+ pictureBoxObject.TabIndex = 1;
+ pictureBoxObject.TabStop = false;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(1028, 378);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(150, 46);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(1327, 378);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(150, 46);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // panelObject
+ //
+ panelObject.AllowDrop = true;
+ panelObject.Controls.Add(labelAdditionalColor);
+ panelObject.Controls.Add(labelBodyColor);
+ panelObject.Controls.Add(pictureBoxObject);
+ panelObject.Location = new Point(1028, 12);
+ panelObject.Name = "panelObject";
+ panelObject.Size = new Size(449, 360);
+ panelObject.TabIndex = 4;
+ panelObject.DragDrop += PanelObject_DragDrop;
+ panelObject.DragEnter += PanelObject_DragEnter;
+ //
+ // labelAdditionalColor
+ //
+ labelAdditionalColor.AllowDrop = true;
+ labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
+ labelAdditionalColor.Location = new Point(251, 26);
+ labelAdditionalColor.Name = "labelAdditionalColor";
+ labelAdditionalColor.Size = new Size(169, 65);
+ labelAdditionalColor.TabIndex = 10;
+ labelAdditionalColor.Text = "Доп. цвет";
+ labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
+ labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter;
+ //
+ // labelBodyColor
+ //
+ labelBodyColor.AllowDrop = true;
+ labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
+ labelBodyColor.Location = new Point(41, 26);
+ labelBodyColor.Name = "labelBodyColor";
+ labelBodyColor.Size = new Size(169, 65);
+ labelBodyColor.TabIndex = 9;
+ labelBodyColor.Text = "Цвет";
+ labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelBodyColor.DragDrop += LabelBodyColor_DragDrop;
+ labelBodyColor.DragEnter += LabelBodyColor_DragEnter;
+ //
+ // FormShipConfig
+ //
+ AutoScaleDimensions = new SizeF(13F, 32F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1501, 436);
+ Controls.Add(panelObject);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonAdd);
+ Controls.Add(groupBoxConfig);
+ Name = "FormShipConfig";
+ Text = "Создание объекта";
+ groupBoxConfig.ResumeLayout(false);
+ groupBoxConfig.PerformLayout();
+ groupBoxColors.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
+ panelObject.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxConfig;
+ private Label labelSimpleObject;
+ private Label labelSpeed;
+ private Label labelModifiedObject;
+ private CheckBox checkBoxRockets;
+ private CheckBox checkBoxWeapon;
+ private NumericUpDown numericUpDownWeight;
+ private Label labelWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private GroupBox groupBoxColors;
+ private Panel panelGray;
+ private Panel panelOrange;
+ private Panel panelPink;
+ private Panel panelPurple;
+ private Panel panelBlue;
+ private Panel panelWhite;
+ private Panel panelGreen;
+ private Panel panelRed;
+ private PictureBox pictureBoxObject;
+ private Button buttonAdd;
+ private Button buttonCancel;
+ private Panel panelObject;
+ private Label labelAdditionalColor;
+ private Label labelBodyColor;
+ }
+}
\ No newline at end of file
diff --git a/ProjectBattleship/ProjectBattleship/FormShipConfig.cs b/ProjectBattleship/ProjectBattleship/FormShipConfig.cs
new file mode 100644
index 0000000..8f9cce8
--- /dev/null
+++ b/ProjectBattleship/ProjectBattleship/FormShipConfig.cs
@@ -0,0 +1,155 @@
+using ProjectBattleship.Drawnings;
+using ProjectBattleship.Entities;
+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 Battleship;
+///
+/// Форма конфигурации объекта
+///
+public partial class FormShipConfig : Form
+{
+ ///
+ /// Объект-прорисовка
+ ///
+ private DrawingShip? _ship;
+ ///
+ /// Событие для передачи объекта
+ ///
+ private event Action EventAddShip;
+ ///
+ /// Конструктор
+ /// labelModifiedObject
+ public FormShipConfig()
+ {
+ InitializeComponent();
+ panelRed.MouseDown += Panel_MouseDown;
+ panelGreen.MouseDown += Panel_MouseDown;
+ panelBlue.MouseDown += Panel_MouseDown;
+ panelPink.MouseDown += Panel_MouseDown;
+ panelWhite.MouseDown += Panel_MouseDown;
+ panelGray.MouseDown += Panel_MouseDown;
+ panelOrange.MouseDown += Panel_MouseDown;
+ panelPurple.MouseDown += Panel_MouseDown;
+ buttonCancel.Click += (s, e) => Close();
+ }
+ ///
+ /// Привязка внешнего метода к событию
+ ///
+ public void AddEvent(Action action)
+ {
+ EventAddShip += action;
+ }
+ //
+ /// Прорисовка объекта
+ ///
+ private void DrawObject()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _ship?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
+ _ship?.SetPosition(15, 15);
+ _ship?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+ ///
+ /// Передача данных по нажатию Label
+ ///
+ ///
+ ///
+ private void LabelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, 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":
+ _ship = new DrawingShip((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
+ break;
+ case "labelModifiedObject":
+ _ship = new DrawingBattleship((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
+ Color.Black, checkBoxWeapon.Checked, checkBoxRockets.Checked);
+ break;
+ }
+ DrawObject();
+ }
+ ///
+ /// Передаем информацию при нажатии на Panel
+ ///
+ ///
+ ///
+ private void Panel_MouseDown(object? sender, MouseEventArgs e)
+ {
+ (sender as Control)?.DoDragDrop((sender as Control)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+ ///
+ /// Проверка полчаемой в LabelBodyColor информации
+ ///
+ ///
+ ///
+ private void LabelBodyColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)) && _ship != null)
+ e.Effect = DragDropEffects.Copy;
+ else
+ e.Effect = DragDropEffects.None;
+ }
+ ///
+ /// Проверка полчаемой в LabelAdditionalColor информации
+ ///
+ ///
+ ///
+ private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)) && _ship != null && _ship is DrawingBattleship)
+ e.Effect = DragDropEffects.Copy;
+ else
+ e.Effect = DragDropEffects.None;
+ }
+ private void LabelBodyColor_DragDrop(object sender, DragEventArgs e)
+ {
+ var color = (Color)e?.Data?.GetData(typeof(Color));
+ _ship?.EntityShip?.ChangeColor(color);
+ DrawObject();
+ }
+ private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
+ {
+ var color = (Color)e?.Data?.GetData(typeof(Color));
+ if (_ship is DrawingBattleship)
+ {
+ ((EntityBattleship?)_ship.EntityShip)?.ChangeAddColor(color);
+ DrawObject();
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ EventAddShip?.Invoke(_ship);
+ Close();
+ }
+}
diff --git a/ProjectBattleship/ProjectBattleship/FormShipConfig.resx b/ProjectBattleship/ProjectBattleship/FormShipConfig.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectBattleship/ProjectBattleship/FormShipConfig.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