diff --git a/Catamaran/Catamaran/BoatDelegate.cs b/Catamaran/Catamaran/BoatDelegate.cs
new file mode 100644
index 0000000..4c1fa91
--- /dev/null
+++ b/Catamaran/Catamaran/BoatDelegate.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Catamaran.Drawings;
+
+namespace Catamaran
+{
+ public delegate void BoatDelegate(DrawingBoat boat);
+
+}
diff --git a/Catamaran/Catamaran/CollectionGenericObjects/ArrayGenericObjects.cs b/Catamaran/Catamaran/CollectionGenericObjects/ArrayGenericObjects.cs
index 71fc9b8..9d3a914 100644
--- a/Catamaran/Catamaran/CollectionGenericObjects/ArrayGenericObjects.cs
+++ b/Catamaran/Catamaran/CollectionGenericObjects/ArrayGenericObjects.cs
@@ -60,7 +60,7 @@ namespace Catamaran.CollectionGenericObjects
public int Insert(T obj, int position)
{
- if (position < Count)
+ if (position < Count || position >= 0)
{
if (_collection[position] == null)
{
diff --git a/Catamaran/Catamaran/Entities/Catamaran.cs b/Catamaran/Catamaran/Entities/Catamaran.cs
index 5ba7261..094c8aa 100644
--- a/Catamaran/Catamaran/Entities/Catamaran.cs
+++ b/Catamaran/Catamaran/Entities/Catamaran.cs
@@ -19,6 +19,11 @@ namespace Catamaran.Entities
public double Step => Speed * 100 / Weight;
+ public void SetAdditionalColor(Color addColor)
+ {
+ AdditionalColor = addColor;
+ }
+
public EntityCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool leftBobber, bool rightBobber, bool sail) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
diff --git a/Catamaran/Catamaran/Entities/EntityBoat.cs b/Catamaran/Catamaran/Entities/EntityBoat.cs
index 8fc2d4d..6c0dacb 100644
--- a/Catamaran/Catamaran/Entities/EntityBoat.cs
+++ b/Catamaran/Catamaran/Entities/EntityBoat.cs
@@ -16,6 +16,11 @@ namespace Catamaran.Entities
public double Step => Speed * 100 / Weight;
+ public void SetBodyColor(Color color)
+ {
+ BodyColor = color;
+ }
+
public EntityBoat(int speed, double weight, Color bodyColor)
{
Speed = speed;
diff --git a/Catamaran/Catamaran/FormBoatColletion.Designer.cs b/Catamaran/Catamaran/FormBoatColletion.Designer.cs
index aa2c822..aed6486 100644
--- a/Catamaran/Catamaran/FormBoatColletion.Designer.cs
+++ b/Catamaran/Catamaran/FormBoatColletion.Designer.cs
@@ -29,6 +29,12 @@
private void InitializeComponent()
{
groupBox1 = new GroupBox();
+ panelCompanyTools = new Panel();
+ AddBoatButton = new Button();
+ UpdateButton = new Button();
+ maskedTextBox = new MaskedTextBox();
+ GoToTestButton = new Button();
+ DeleteButton = new Button();
buttonCompanyCreate = new Button();
panelCollection = new Panel();
buttonCollectionDelete = new Button();
@@ -38,19 +44,12 @@
radioButtonArray = new RadioButton();
textBoxCollectionName = new TextBox();
labelCollectionName = new Label();
- UpdateButton = new Button();
- GoToTestButton = new Button();
- DeleteButton = new Button();
- maskedTextBox = new MaskedTextBox();
- AddCatamaranButton = new Button();
- AddBoatButton = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
- panelCompanyTools = new Panel();
groupBox1.SuspendLayout();
+ panelCompanyTools.SuspendLayout();
panelCollection.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
- panelCompanyTools.SuspendLayout();
SuspendLayout();
//
// groupBox1
@@ -67,6 +66,69 @@
groupBox1.TabStop = false;
groupBox1.Text = "Инструменты";
//
+ // panelCompanyTools
+ //
+ panelCompanyTools.Controls.Add(AddBoatButton);
+ panelCompanyTools.Controls.Add(UpdateButton);
+ panelCompanyTools.Controls.Add(maskedTextBox);
+ panelCompanyTools.Controls.Add(GoToTestButton);
+ panelCompanyTools.Controls.Add(DeleteButton);
+ panelCompanyTools.Dock = DockStyle.Bottom;
+ panelCompanyTools.Enabled = false;
+ panelCompanyTools.Location = new Point(3, 398);
+ panelCompanyTools.Name = "panelCompanyTools";
+ panelCompanyTools.Size = new Size(231, 241);
+ panelCompanyTools.TabIndex = 9;
+ //
+ // AddBoatButton
+ //
+ AddBoatButton.Location = new Point(3, 3);
+ AddBoatButton.Name = "AddBoatButton";
+ AddBoatButton.Size = new Size(222, 32);
+ AddBoatButton.TabIndex = 1;
+ AddBoatButton.Text = "Добавить лодку";
+ AddBoatButton.UseVisualStyleBackColor = true;
+ AddBoatButton.Click += AddBoatButton_Click;
+ //
+ // UpdateButton
+ //
+ UpdateButton.Location = new Point(3, 202);
+ UpdateButton.Name = "UpdateButton";
+ UpdateButton.Size = new Size(222, 38);
+ UpdateButton.TabIndex = 6;
+ UpdateButton.Text = "Обновить";
+ UpdateButton.UseVisualStyleBackColor = true;
+ UpdateButton.Click += UpdateButton_Click;
+ //
+ // maskedTextBox
+ //
+ maskedTextBox.Location = new Point(3, 80);
+ maskedTextBox.Mask = "00";
+ maskedTextBox.Name = "maskedTextBox";
+ maskedTextBox.Size = new Size(222, 27);
+ maskedTextBox.TabIndex = 3;
+ maskedTextBox.ValidatingType = typeof(int);
+ //
+ // GoToTestButton
+ //
+ GoToTestButton.Location = new Point(3, 158);
+ GoToTestButton.Name = "GoToTestButton";
+ GoToTestButton.Size = new Size(222, 38);
+ GoToTestButton.TabIndex = 5;
+ GoToTestButton.Text = "Передать на тесты";
+ GoToTestButton.UseVisualStyleBackColor = true;
+ GoToTestButton.Click += GoToTestButton_Click;
+ //
+ // DeleteButton
+ //
+ DeleteButton.Location = new Point(3, 113);
+ DeleteButton.Name = "DeleteButton";
+ DeleteButton.Size = new Size(222, 38);
+ DeleteButton.TabIndex = 4;
+ DeleteButton.Text = "Удалить лодку";
+ DeleteButton.UseVisualStyleBackColor = true;
+ DeleteButton.Click += DeleteButton_Click;
+ //
// buttonCompanyCreate
//
buttonCompanyCreate.Location = new Point(6, 366);
@@ -157,65 +219,6 @@
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:";
//
- // UpdateButton
- //
- UpdateButton.Location = new Point(3, 202);
- UpdateButton.Name = "UpdateButton";
- UpdateButton.Size = new Size(222, 38);
- UpdateButton.TabIndex = 6;
- UpdateButton.Text = "Обновить";
- UpdateButton.UseVisualStyleBackColor = true;
- UpdateButton.Click += UpdateButton_Click;
- //
- // GoToTestButton
- //
- GoToTestButton.Location = new Point(3, 158);
- GoToTestButton.Name = "GoToTestButton";
- GoToTestButton.Size = new Size(222, 38);
- GoToTestButton.TabIndex = 5;
- GoToTestButton.Text = "Передать на тесты";
- GoToTestButton.UseVisualStyleBackColor = true;
- GoToTestButton.Click += GoToTestButton_Click;
- //
- // DeleteButton
- //
- DeleteButton.Location = new Point(3, 113);
- DeleteButton.Name = "DeleteButton";
- DeleteButton.Size = new Size(222, 38);
- DeleteButton.TabIndex = 4;
- DeleteButton.Text = "Удалить лодку";
- DeleteButton.UseVisualStyleBackColor = true;
- DeleteButton.Click += DeleteButton_Click;
- //
- // maskedTextBox
- //
- maskedTextBox.Location = new Point(3, 80);
- maskedTextBox.Mask = "00";
- maskedTextBox.Name = "maskedTextBox";
- maskedTextBox.Size = new Size(222, 27);
- maskedTextBox.TabIndex = 3;
- maskedTextBox.ValidatingType = typeof(int);
- //
- // AddCatamaranButton
- //
- AddCatamaranButton.Location = new Point(3, 41);
- AddCatamaranButton.Name = "AddCatamaranButton";
- AddCatamaranButton.Size = new Size(222, 33);
- AddCatamaranButton.TabIndex = 2;
- AddCatamaranButton.Text = "Добавить катамаран";
- AddCatamaranButton.UseVisualStyleBackColor = true;
- AddCatamaranButton.Click += AddCatamaranButton_Click;
- //
- // AddBoatButton
- //
- AddBoatButton.Location = new Point(3, 3);
- AddBoatButton.Name = "AddBoatButton";
- AddBoatButton.Size = new Size(222, 32);
- AddBoatButton.TabIndex = 1;
- AddBoatButton.Text = "Добавить лодку";
- AddBoatButton.UseVisualStyleBackColor = true;
- AddBoatButton.Click += AddBoatButton_Click;
- //
// comboBoxSelectorCompany
//
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@@ -238,21 +241,6 @@
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
- // panelCompanyTools
- //
- panelCompanyTools.Controls.Add(AddCatamaranButton);
- panelCompanyTools.Controls.Add(AddBoatButton);
- panelCompanyTools.Controls.Add(UpdateButton);
- panelCompanyTools.Controls.Add(maskedTextBox);
- panelCompanyTools.Controls.Add(GoToTestButton);
- panelCompanyTools.Controls.Add(DeleteButton);
- panelCompanyTools.Dock = DockStyle.Bottom;
- panelCompanyTools.Enabled = false;
- panelCompanyTools.Location = new Point(3, 398);
- panelCompanyTools.Name = "panelCompanyTools";
- panelCompanyTools.Size = new Size(231, 241);
- panelCompanyTools.TabIndex = 9;
- //
// FormBoatColletion
//
AutoScaleDimensions = new SizeF(8F, 20F);
@@ -263,11 +251,11 @@
Name = "FormBoatColletion";
Text = "Коллекция лодок";
groupBox1.ResumeLayout(false);
+ panelCompanyTools.ResumeLayout(false);
+ panelCompanyTools.PerformLayout();
panelCollection.ResumeLayout(false);
panelCollection.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
- panelCompanyTools.ResumeLayout(false);
- panelCompanyTools.PerformLayout();
ResumeLayout(false);
}
@@ -276,7 +264,6 @@
private GroupBox groupBox1;
private ComboBox comboBoxSelectorCompany;
private Button AddBoatButton;
- private Button AddCatamaranButton;
private PictureBox pictureBox;
private MaskedTextBox maskedTextBox;
private Button DeleteButton;
diff --git a/Catamaran/Catamaran/FormBoatColletion.cs b/Catamaran/Catamaran/FormBoatColletion.cs
index 0a87f4d..32502d5 100644
--- a/Catamaran/Catamaran/FormBoatColletion.cs
+++ b/Catamaran/Catamaran/FormBoatColletion.cs
@@ -30,30 +30,27 @@ namespace Catamaran
panelCompanyTools.Enabled = false;
}
- private void CreateObject(string type)
+
+
+ private void AddBoatButton_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
+ FormBoatConfig form = new();
+ form.AddEvent(SetBoat);
+ form.Show();
+ }
- DrawingBoat drawingBoat;
- Random random = new();
-
- switch (type)
+ private void SetBoat(DrawingBoat boat)
+ {
+ if (_company == null || boat == null)
{
- case nameof(DrawingBoat):
- drawingBoat = new DrawingBoat(random.Next(100, 500), random.Next(1000, 3000), GetColor(random));
- break;
- case nameof(DrawingCatamaran):
- drawingBoat = new DrawingCatamaran(random.Next(100, 500), random.Next(1000, 3000), GetColor(random), GetColor(random),
- Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
- break;
- default:
- return;
+ return;
}
- if (_company + drawingBoat >= 0)
+ if (_company + boat >= 0)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@@ -64,17 +61,6 @@ namespace Catamaran
}
}
- private void AddBoatButton_Click(object sender, EventArgs e)
- {
- CreateObject(nameof(DrawingBoat));
- }
-
- private void AddCatamaranButton_Click(object sender, EventArgs e)
- {
- CreateObject(nameof(DrawingCatamaran));
- }
-
-
private static Color GetColor(Random random)
{
diff --git a/Catamaran/Catamaran/FormBoatConfig.Designer.cs b/Catamaran/Catamaran/FormBoatConfig.Designer.cs
new file mode 100644
index 0000000..18393d9
--- /dev/null
+++ b/Catamaran/Catamaran/FormBoatConfig.Designer.cs
@@ -0,0 +1,378 @@
+namespace Catamaran
+{
+ partial class FormBoatConfig
+ {
+ ///
+ /// 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();
+ panelMagenta = new Panel();
+ panelBlack = new Panel();
+ panelGray = new Panel();
+ panelWhite = new Panel();
+ panelYellow = new Panel();
+ panelBlue = new Panel();
+ panelGreen = new Panel();
+ panelRed = new Panel();
+ checkBoxRightBobber = new CheckBox();
+ checkBoxLeftBobber = new CheckBox();
+ checkBoxSail = new CheckBox();
+ numericUpDownWeight = new NumericUpDown();
+ labelWeight = new Label();
+ numericUpDownSpeed = new NumericUpDown();
+ labelSpeed = new Label();
+ labelAdvancedObject = 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(checkBoxRightBobber);
+ groupBoxConfig.Controls.Add(checkBoxLeftBobber);
+ groupBoxConfig.Controls.Add(checkBoxSail);
+ groupBoxConfig.Controls.Add(numericUpDownWeight);
+ groupBoxConfig.Controls.Add(labelWeight);
+ groupBoxConfig.Controls.Add(numericUpDownSpeed);
+ groupBoxConfig.Controls.Add(labelSpeed);
+ groupBoxConfig.Controls.Add(labelAdvancedObject);
+ groupBoxConfig.Controls.Add(labelSimpleObject);
+ groupBoxConfig.Dock = DockStyle.Left;
+ groupBoxConfig.Location = new Point(0, 0);
+ groupBoxConfig.Name = "groupBoxConfig";
+ groupBoxConfig.Size = new Size(599, 271);
+ groupBoxConfig.TabIndex = 0;
+ groupBoxConfig.TabStop = false;
+ groupBoxConfig.Text = "Параметры";
+ //
+ // groupBoxColors
+ //
+ groupBoxColors.Controls.Add(panelMagenta);
+ groupBoxColors.Controls.Add(panelBlack);
+ groupBoxColors.Controls.Add(panelGray);
+ groupBoxColors.Controls.Add(panelWhite);
+ groupBoxColors.Controls.Add(panelYellow);
+ groupBoxColors.Controls.Add(panelBlue);
+ groupBoxColors.Controls.Add(panelGreen);
+ groupBoxColors.Controls.Add(panelRed);
+ groupBoxColors.Location = new Point(257, 26);
+ groupBoxColors.Name = "groupBoxColors";
+ groupBoxColors.Size = new Size(239, 125);
+ groupBoxColors.TabIndex = 9;
+ groupBoxColors.TabStop = false;
+ groupBoxColors.Text = "Цвета";
+ //
+ // panelMagenta
+ //
+ panelMagenta.BackColor = Color.Magenta;
+ panelMagenta.Location = new Point(189, 74);
+ panelMagenta.Name = "panelMagenta";
+ panelMagenta.Size = new Size(38, 39);
+ panelMagenta.TabIndex = 1;
+ panelMagenta.MouseDown += panel_MouseDown;
+ //
+ // panelBlack
+ //
+ panelBlack.BackColor = Color.Black;
+ panelBlack.Location = new Point(130, 74);
+ panelBlack.Name = "panelBlack";
+ panelBlack.Size = new Size(38, 39);
+ panelBlack.TabIndex = 1;
+ panelBlack.MouseDown += panel_MouseDown;
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Gray;
+ panelGray.Location = new Point(70, 74);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(38, 39);
+ panelGray.TabIndex = 1;
+ panelGray.MouseDown += panel_MouseDown;
+ //
+ // panelWhite
+ //
+ panelWhite.BackColor = Color.White;
+ panelWhite.Location = new Point(11, 74);
+ panelWhite.Name = "panelWhite";
+ panelWhite.Size = new Size(38, 39);
+ panelWhite.TabIndex = 1;
+ panelWhite.MouseDown += panel_MouseDown;
+ //
+ // panelYellow
+ //
+ panelYellow.BackColor = Color.Yellow;
+ panelYellow.Location = new Point(189, 22);
+ panelYellow.Name = "panelYellow";
+ panelYellow.Size = new Size(38, 39);
+ panelYellow.TabIndex = 1;
+ panelYellow.MouseDown += panel_MouseDown;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(130, 22);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(38, 39);
+ panelBlue.TabIndex = 1;
+ panelBlue.MouseDown += panel_MouseDown;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.Green;
+ panelGreen.Location = new Point(70, 22);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(38, 39);
+ panelGreen.TabIndex = 1;
+ panelGreen.MouseDown += panel_MouseDown;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(11, 22);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(38, 39);
+ panelRed.TabIndex = 0;
+ panelRed.MouseDown += panel_MouseDown;
+ //
+ // checkBoxRightBobber
+ //
+ checkBoxRightBobber.AutoSize = true;
+ checkBoxRightBobber.Location = new Point(12, 173);
+ checkBoxRightBobber.Name = "checkBoxRightBobber";
+ checkBoxRightBobber.Size = new Size(158, 24);
+ checkBoxRightBobber.TabIndex = 8;
+ checkBoxRightBobber.Text = "Правый поплавок";
+ checkBoxRightBobber.UseVisualStyleBackColor = true;
+ //
+ // checkBoxLeftBobber
+ //
+ checkBoxLeftBobber.AutoSize = true;
+ checkBoxLeftBobber.Location = new Point(12, 143);
+ checkBoxLeftBobber.Name = "checkBoxLeftBobber";
+ checkBoxLeftBobber.Size = new Size(148, 24);
+ checkBoxLeftBobber.TabIndex = 7;
+ checkBoxLeftBobber.Text = "Левый поплавок";
+ checkBoxLeftBobber.UseVisualStyleBackColor = true;
+ //
+ // checkBoxSail
+ //
+ checkBoxSail.AutoSize = true;
+ checkBoxSail.Location = new Point(12, 101);
+ checkBoxSail.Name = "checkBoxSail";
+ checkBoxSail.Size = new Size(73, 24);
+ checkBoxSail.TabIndex = 6;
+ checkBoxSail.Text = "Парус";
+ checkBoxSail.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(94, 61);
+ 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(136, 27);
+ numericUpDownWeight.TabIndex = 5;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelWeight
+ //
+ labelWeight.AutoSize = true;
+ labelWeight.Location = new Point(12, 63);
+ labelWeight.Name = "labelWeight";
+ labelWeight.Size = new Size(36, 20);
+ labelWeight.TabIndex = 4;
+ labelWeight.Text = "Вес:";
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(94, 27);
+ 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(136, 27);
+ numericUpDownSpeed.TabIndex = 3;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelSpeed
+ //
+ labelSpeed.AutoSize = true;
+ labelSpeed.Location = new Point(12, 29);
+ labelSpeed.Name = "labelSpeed";
+ labelSpeed.Size = new Size(76, 20);
+ labelSpeed.TabIndex = 2;
+ labelSpeed.Text = "Скорость:";
+ //
+ // labelAdvancedObject
+ //
+ labelAdvancedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelAdvancedObject.Location = new Point(411, 206);
+ labelAdvancedObject.Name = "labelAdvancedObject";
+ labelAdvancedObject.Size = new Size(148, 33);
+ labelAdvancedObject.TabIndex = 1;
+ labelAdvancedObject.Text = "Продвинутый";
+ labelAdvancedObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelAdvancedObject.MouseDown += labelObject_MouseDown;
+ //
+ // labelSimpleObject
+ //
+ labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
+ labelSimpleObject.Location = new Point(257, 206);
+ labelSimpleObject.Name = "labelSimpleObject";
+ labelSimpleObject.Size = new Size(148, 33);
+ labelSimpleObject.TabIndex = 0;
+ labelSimpleObject.Text = "Простой";
+ labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelSimpleObject.MouseDown += labelObject_MouseDown;
+ //
+ // pictureBoxObject
+ //
+ pictureBoxObject.Location = new Point(14, 63);
+ pictureBoxObject.Name = "pictureBoxObject";
+ pictureBoxObject.Size = new Size(264, 119);
+ pictureBoxObject.TabIndex = 1;
+ pictureBoxObject.TabStop = false;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(619, 210);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(94, 29);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(789, 210);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ 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(605, 12);
+ panelObject.Name = "panelObject";
+ panelObject.Size = new Size(287, 185);
+ panelObject.TabIndex = 4;
+ panelObject.DragDrop += panelObject_DragDrop;
+ panelObject.DragEnter += panelObject_DragEnter;
+ //
+ // labelAdditionalColor
+ //
+ labelAdditionalColor.AllowDrop = true;
+ labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
+ labelAdditionalColor.Location = new Point(169, 9);
+ labelAdditionalColor.Name = "labelAdditionalColor";
+ labelAdditionalColor.Size = new Size(109, 33);
+ labelAdditionalColor.TabIndex = 11;
+ 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(14, 9);
+ labelBodyColor.Name = "labelBodyColor";
+ labelBodyColor.Size = new Size(109, 33);
+ labelBodyColor.TabIndex = 10;
+ labelBodyColor.Text = "Цвет";
+ labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelBodyColor.DragDrop += labelBodyColor_DragDrop;
+ labelBodyColor.DragEnter += labelBodyColor_DragEnter;
+ //
+ // FormBoatConfig
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(920, 271);
+ Controls.Add(panelObject);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonAdd);
+ Controls.Add(groupBoxConfig);
+ Name = "FormBoatConfig";
+ 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 labelAdvancedObject;
+ private NumericUpDown numericUpDownSpeed;
+ private CheckBox checkBoxLeftBobber;
+ private CheckBox checkBoxSail;
+ private NumericUpDown numericUpDownWeight;
+ private Label labelWeight;
+ private GroupBox groupBoxColors;
+ private CheckBox checkBoxRightBobber;
+ private Panel panelYellow;
+ private Panel panelBlue;
+ private Panel panelGreen;
+ private Panel panelRed;
+ private Panel panelMagenta;
+ private Panel panelBlack;
+ private Panel panelGray;
+ private Panel panelWhite;
+ 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/Catamaran/Catamaran/FormBoatConfig.cs b/Catamaran/Catamaran/FormBoatConfig.cs
new file mode 100644
index 0000000..00aa38b
--- /dev/null
+++ b/Catamaran/Catamaran/FormBoatConfig.cs
@@ -0,0 +1,151 @@
+using Catamaran.Drawings;
+using Catamaran.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 Catamaran
+{
+ public partial class FormBoatConfig : Form
+ {
+ private DrawingBoat? _boat = null;
+
+ public event Action? BoatDelegate;
+
+ public FormBoatConfig()
+ {
+ InitializeComponent();
+ panelRed.MouseDown += panel_MouseDown;
+ panelGreen.MouseDown += panel_MouseDown;
+ panelBlue.MouseDown += panel_MouseDown;
+ panelWhite.MouseDown += panel_MouseDown;
+ panelBlack.MouseDown += panel_MouseDown;
+ panelGray.MouseDown += panel_MouseDown;
+ panelMagenta.MouseDown += panel_MouseDown;
+ panelYellow.MouseDown += panel_MouseDown;
+
+ buttonCancel.Click += (events, e) => Close();
+
+ }
+
+ public void AddEvent(Action? boatDelegate)
+ {
+ BoatDelegate += boatDelegate;
+ }
+
+ private void DrawObject()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics g = Graphics.FromImage(bmp);
+ _boat?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
+ _boat?.SetPosition(5, 5);
+ _boat?.DrawTransport(g);
+ pictureBoxObject.Image = bmp;
+ }
+
+ private void labelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ var label = sender as Label;
+ label?.DoDragDrop(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":
+ _boat = new DrawingBoat((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
+ break;
+ case "labelAdvancedObject":
+ _boat = new DrawingCatamaran((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, Color.Black,
+ checkBoxLeftBobber.Checked, checkBoxRightBobber.Checked, checkBoxSail.Checked);
+ break;
+ }
+ DrawObject();
+ }
+
+ private void panel_MouseDown(object? sender, MouseEventArgs e)
+ {
+ var panel = sender as Panel;
+ panel?.DoDragDrop(panel?.BackColor ?? Color.White, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ private void labelAdditionalColor_DragEnter(Object sender, DragEventArgs e)
+ {
+ if (_boat is DrawingCatamaran)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ }
+
+ private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_boat == null)
+ {
+ return;
+ }
+ _boat.EntityBoat?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
+ DrawObject();
+ }
+
+ private void labelAdditionalColor_DragDrop(Object sender, DragEventArgs e)
+ {
+ if (_boat?.EntityBoat is EntityCatamaran _catamaran)
+ {
+ _catamaran.SetAdditionalColor((Color)e.Data?.GetData(typeof(Color)));
+ }
+ DrawObject();
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ if (_boat != null)
+ {
+ BoatDelegate?.Invoke(_boat);
+ Close();
+ }
+ }
+
+ private void panelWhite_Paint(object sender, PaintEventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/Catamaran/Catamaran/FormBoatConfig.resx b/Catamaran/Catamaran/FormBoatConfig.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/Catamaran/Catamaran/FormBoatConfig.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