diff --git a/SailBoat/SailBoat/Entities/EntityBoat.cs b/SailBoat/SailBoat/Entities/EntityBoat.cs
index c062152..52b4cc6 100644
--- a/SailBoat/SailBoat/Entities/EntityBoat.cs
+++ b/SailBoat/SailBoat/Entities/EntityBoat.cs
@@ -9,6 +9,11 @@ namespace SailBoat.Entities
public class EntityBoat
{
+ public void SetBodyColor(Color color)
+ {
+ BodyColor = color;
+ }
+
public int Speed { get; private set; }
public double Weight { get; private set; }
diff --git a/SailBoat/SailBoat/Entities/EntitySailBoat.cs b/SailBoat/SailBoat/Entities/EntitySailBoat.cs
index 08318c9..217f3cf 100644
--- a/SailBoat/SailBoat/Entities/EntitySailBoat.cs
+++ b/SailBoat/SailBoat/Entities/EntitySailBoat.cs
@@ -8,6 +8,10 @@ namespace SailBoat.Entities
{
public class EntitySailBoat : EntityBoat
{
+ public void setAdditionalColor(Color color)
+ {
+ AdditionalColor = color;
+ }
public Color AdditionalColor { get; private set; }
public bool Sail { get; private set; }
diff --git a/SailBoat/SailBoat/FormBoatCollection.Designer.cs b/SailBoat/SailBoat/FormBoatCollection.Designer.cs
index c60ac48..40bdad9 100644
--- a/SailBoat/SailBoat/FormBoatCollection.Designer.cs
+++ b/SailBoat/SailBoat/FormBoatCollection.Designer.cs
@@ -29,10 +29,10 @@
private void InitializeComponent()
{
tools = new GroupBox();
- groupBox1 = new GroupBox();
+ sets = new GroupBox();
+ ButtonDelObject = new Button();
listBoxStorages = new ListBox();
- buttonDelObject = new Button();
- buttonAddObject = new Button();
+ ButtonAddObject = new Button();
textBoxStorageName = new TextBox();
maskedTextBoxNumber = new MaskedTextBox();
buttonRefreshCollection = new Button();
@@ -40,13 +40,13 @@
buttonAddBoat = new Button();
pictureBoxCollection = new PictureBox();
tools.SuspendLayout();
- groupBox1.SuspendLayout();
+ sets.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
SuspendLayout();
//
// tools
//
- tools.Controls.Add(groupBox1);
+ tools.Controls.Add(sets);
tools.Controls.Add(maskedTextBoxNumber);
tools.Controls.Add(buttonRefreshCollection);
tools.Controls.Add(buttonRemoveBoat);
@@ -59,59 +59,59 @@
tools.TabStop = false;
tools.Text = "Инструменты";
//
- // groupBox1
+ // sets
//
- groupBox1.Controls.Add(listBoxStorages);
- groupBox1.Controls.Add(buttonDelObject);
- groupBox1.Controls.Add(buttonAddObject);
- groupBox1.Controls.Add(textBoxStorageName);
- groupBox1.Location = new Point(6, 22);
- groupBox1.Name = "groupBox1";
- groupBox1.Size = new Size(188, 288);
- groupBox1.TabIndex = 5;
- groupBox1.TabStop = false;
- groupBox1.Text = "Наборы";
+ sets.Controls.Add(ButtonDelObject);
+ sets.Controls.Add(listBoxStorages);
+ sets.Controls.Add(ButtonAddObject);
+ sets.Controls.Add(textBoxStorageName);
+ sets.Location = new Point(6, 22);
+ sets.Name = "sets";
+ sets.Size = new Size(188, 264);
+ sets.TabIndex = 5;
+ sets.TabStop = false;
+ sets.Text = "Наборы";
+ //
+ // ButtonDelObject
+ //
+ ButtonDelObject.Location = new Point(6, 215);
+ ButtonDelObject.Name = "ButtonDelObject";
+ ButtonDelObject.Size = new Size(176, 41);
+ ButtonDelObject.TabIndex = 3;
+ ButtonDelObject.Text = "Удалить набор";
+ ButtonDelObject.UseVisualStyleBackColor = true;
+ ButtonDelObject.Click += ButtonDelObject_Click;
//
// listBoxStorages
//
listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 15;
- listBoxStorages.Location = new Point(11, 95);
+ listBoxStorages.Location = new Point(6, 100);
listBoxStorages.Name = "listBoxStorages";
- listBoxStorages.Size = new Size(171, 139);
- listBoxStorages.TabIndex = 3;
+ listBoxStorages.Size = new Size(176, 109);
+ listBoxStorages.TabIndex = 2;
listBoxStorages.SelectedIndexChanged += listBoxStorages_SelectedIndexChanged;
//
- // buttonDelObject
+ // ButtonAddObject
//
- buttonDelObject.Location = new Point(6, 246);
- buttonDelObject.Name = "buttonDelObject";
- buttonDelObject.Size = new Size(176, 36);
- buttonDelObject.TabIndex = 2;
- buttonDelObject.Text = "Удалить набор";
- buttonDelObject.UseVisualStyleBackColor = true;
- buttonDelObject.Click += buttonDelObject_Click;
- //
- // buttonAddObject
- //
- buttonAddObject.Location = new Point(6, 51);
- buttonAddObject.Name = "buttonAddObject";
- buttonAddObject.Size = new Size(176, 36);
- buttonAddObject.TabIndex = 1;
- buttonAddObject.Text = "Добавить набор";
- buttonAddObject.UseVisualStyleBackColor = true;
- buttonAddObject.Click += buttonAddObject_Click;
+ ButtonAddObject.Location = new Point(6, 53);
+ ButtonAddObject.Name = "ButtonAddObject";
+ ButtonAddObject.Size = new Size(176, 41);
+ ButtonAddObject.TabIndex = 1;
+ ButtonAddObject.Text = "Добавить набор";
+ ButtonAddObject.UseVisualStyleBackColor = true;
+ ButtonAddObject.Click += ButtonAddObject_Click;
//
// textBoxStorageName
//
- textBoxStorageName.Location = new Point(6, 22);
+ textBoxStorageName.Location = new Point(6, 23);
textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(176, 23);
textBoxStorageName.TabIndex = 0;
//
// maskedTextBoxNumber
//
- maskedTextBoxNumber.Location = new Point(45, 433);
+ maskedTextBoxNumber.Location = new Point(45, 454);
maskedTextBoxNumber.Mask = "00000";
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(112, 23);
@@ -120,7 +120,7 @@
//
// buttonRefreshCollection
//
- buttonRefreshCollection.Location = new Point(6, 563);
+ buttonRefreshCollection.Location = new Point(6, 561);
buttonRefreshCollection.Name = "buttonRefreshCollection";
buttonRefreshCollection.Size = new Size(188, 39);
buttonRefreshCollection.TabIndex = 3;
@@ -167,8 +167,8 @@
Text = "Набор лодок";
tools.ResumeLayout(false);
tools.PerformLayout();
- groupBox1.ResumeLayout(false);
- groupBox1.PerformLayout();
+ sets.ResumeLayout(false);
+ sets.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
ResumeLayout(false);
}
@@ -181,10 +181,10 @@
private Button buttonRefreshCollection;
private PictureBox pictureBoxCollection;
private MaskedTextBox maskedTextBoxNumber;
- private GroupBox groupBox1;
+ private GroupBox sets;
+ private Button ButtonDelObject;
private ListBox listBoxStorages;
- private Button buttonDelObject;
- private Button buttonAddObject;
+ private Button ButtonAddObject;
private TextBox textBoxStorageName;
}
}
\ No newline at end of file
diff --git a/SailBoat/SailBoat/FormBoatCollection.cs b/SailBoat/SailBoat/FormBoatCollection.cs
index 744242f..fae8dd5 100644
--- a/SailBoat/SailBoat/FormBoatCollection.cs
+++ b/SailBoat/SailBoat/FormBoatCollection.cs
@@ -26,24 +26,24 @@ namespace SailBoat
private void ReloadObjects()
{
int index = listBoxStorages.SelectedIndex;
+
listBoxStorages.Items.Clear();
for (int i = 0; i < _storage.Keys.Count; i++)
{
listBoxStorages.Items.Add(_storage.Keys[i]);
}
- if (listBoxStorages.Items.Count > 0 && (index == -1 || index
- >= listBoxStorages.Items.Count))
+
+ if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
{
listBoxStorages.SelectedIndex = 0;
}
- else if (listBoxStorages.Items.Count > 0 && index > -1 &&
- index < listBoxStorages.Items.Count)
+ else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
{
listBoxStorages.SelectedIndex = index;
}
}
- private void buttonAddObject_Click(object sender, EventArgs e)
+ private void ButtonAddObject_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxStorageName.Text))
{
@@ -52,74 +52,67 @@ namespace SailBoat
}
_storage.AddSet(textBoxStorageName.Text);
ReloadObjects();
-
}
-
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBoats();
-
}
- private void buttonDelObject_Click(object sender, EventArgs e)
+ private void ButtonDelObject_Click(object sender, EventArgs e)
{
- if (listBoxStorages.SelectedIndex == -1)
+ if(listBoxStorages.SelectedIndex == -1)
{
return;
}
- if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ if(MessageBox.Show($"Удалить объект{listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
ReloadObjects();
}
+ }
+ private void AddBoat(DrawningBoat boat)
+ {
+ if (listBoxStorages.SelectedIndex == -1) return;
+ var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
+ if (obj == null) return;
+
+ if (obj + boat)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollection.Image = obj.ShowBoats();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
}
private void buttonAddBoat_Click(object sender, EventArgs e)
{
- if (listBoxStorages.SelectedIndex == -1)
- {
- return;
- }
+ if (listBoxStorages.SelectedIndex == -1) return;
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
- if (obj == null)
- {
- return;
- }
- FormSailBoat form = new();
- if (form.ShowDialog() == DialogResult.OK)
- {
- if (obj + form.SelectedBoat)
- {
- MessageBox.Show("Объект добавлен");
- pictureBoxCollection.Image = obj.ShowBoats();
- }
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
- }
+ if (obj == null) return;
+ FormBoatConfig form = new FormBoatConfig();
+ form.Show();
+ form.AddEvent(AddBoat);
}
private void buttonRemoveBoat_Click(object sender, EventArgs e)
{
- if (listBoxStorages.SelectedIndex == -1)
- {
- return;
- }
+ if (listBoxStorages.SelectedIndex == -1) return;
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
- if (obj == null)
- {
- return;
- }
+ if (obj == null) return;
+
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
+ if (maskedTextBoxNumber.Text == "") { return; }
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
- if (obj - pos != null)
+ if (obj - pos)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = obj.ShowBoats();
@@ -128,21 +121,16 @@ namespace SailBoat
{
MessageBox.Show("Не удалось удалить объект");
}
-
}
private void buttonRefreshCollection_Click(object sender, EventArgs e)
{
- if (listBoxStorages.SelectedIndex == -1)
- {
- return;
- }
+ if (listBoxStorages.SelectedIndex == -1) return;
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
- if (obj == null)
- {
- return;
- }
+ if (obj == null) return;
pictureBoxCollection.Image = obj.ShowBoats();
}
+
+
}
}
diff --git a/SailBoat/SailBoat/FormBoatConfig.Designer.cs b/SailBoat/SailBoat/FormBoatConfig.Designer.cs
new file mode 100644
index 0000000..c44d43e
--- /dev/null
+++ b/SailBoat/SailBoat/FormBoatConfig.Designer.cs
@@ -0,0 +1,366 @@
+namespace SailBoat
+{
+ 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()
+ {
+ groupBox1 = new GroupBox();
+ labelModifiedObject = new Label();
+ labelSimpleObject = new Label();
+ groupBox2 = new GroupBox();
+ panelPink = new Panel();
+ panelBlack = new Panel();
+ panelGray = new Panel();
+ panelWhite = new Panel();
+ panelYellow = new Panel();
+ panelBlue = new Panel();
+ panelGreen = new Panel();
+ panelRed = new Panel();
+ checkBoxSail = new CheckBox();
+ checkBoxRainforce = new CheckBox();
+ numericUpDownWeight = new NumericUpDown();
+ numericUpDownSpeed = new NumericUpDown();
+ label2 = new Label();
+ label1 = new Label();
+ pictureBoxObject = new PictureBox();
+ panelObject = new Panel();
+ labelAdditionalColor = new Label();
+ labelColor = new Label();
+ buttonOk = new Button();
+ buttonCancel = new Button();
+ groupBox1.SuspendLayout();
+ groupBox2.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
+ panelObject.SuspendLayout();
+ SuspendLayout();
+ //
+ // groupBox1
+ //
+ groupBox1.Controls.Add(labelModifiedObject);
+ groupBox1.Controls.Add(labelSimpleObject);
+ groupBox1.Controls.Add(groupBox2);
+ groupBox1.Controls.Add(checkBoxSail);
+ groupBox1.Controls.Add(checkBoxRainforce);
+ groupBox1.Controls.Add(numericUpDownWeight);
+ groupBox1.Controls.Add(numericUpDownSpeed);
+ groupBox1.Controls.Add(label2);
+ groupBox1.Controls.Add(label1);
+ groupBox1.Location = new Point(12, 12);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Size = new Size(525, 241);
+ groupBox1.TabIndex = 0;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Праметры";
+ //
+ // labelModifiedObject
+ //
+ labelModifiedObject.AutoEllipsis = true;
+ labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelModifiedObject.Location = new Point(385, 185);
+ labelModifiedObject.Name = "labelModifiedObject";
+ labelModifiedObject.Size = new Size(96, 42);
+ labelModifiedObject.TabIndex = 8;
+ labelModifiedObject.Text = "Продвинутый";
+ labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelModifiedObject.MouseDown += LabelObject_MouseDown;
+ //
+ // labelSimpleObject
+ //
+ labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
+ labelSimpleObject.Location = new Point(263, 185);
+ labelSimpleObject.Name = "labelSimpleObject";
+ labelSimpleObject.Size = new Size(96, 42);
+ labelSimpleObject.TabIndex = 7;
+ labelSimpleObject.Text = "Простой";
+ labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelSimpleObject.MouseDown += LabelObject_MouseDown;
+ //
+ // groupBox2
+ //
+ groupBox2.Controls.Add(panelPink);
+ groupBox2.Controls.Add(panelBlack);
+ groupBox2.Controls.Add(panelGray);
+ groupBox2.Controls.Add(panelWhite);
+ groupBox2.Controls.Add(panelYellow);
+ groupBox2.Controls.Add(panelBlue);
+ groupBox2.Controls.Add(panelGreen);
+ groupBox2.Controls.Add(panelRed);
+ groupBox2.Location = new Point(248, 22);
+ groupBox2.Name = "groupBox2";
+ groupBox2.Size = new Size(250, 150);
+ groupBox2.TabIndex = 6;
+ groupBox2.TabStop = false;
+ groupBox2.Text = "Цвета";
+ //
+ // panelPink
+ //
+ panelPink.BackColor = Color.Fuchsia;
+ panelPink.Location = new Point(183, 82);
+ panelPink.Name = "panelPink";
+ panelPink.Size = new Size(50, 50);
+ panelPink.TabIndex = 1;
+ panelPink.MouseDown += PanelColor_MouseDown;
+ //
+ // panelBlack
+ //
+ panelBlack.BackColor = Color.Black;
+ panelBlack.Location = new Point(127, 82);
+ panelBlack.Name = "panelBlack";
+ panelBlack.Size = new Size(50, 50);
+ panelBlack.TabIndex = 1;
+ panelBlack.MouseDown += PanelColor_MouseDown;
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Silver;
+ panelGray.Location = new Point(71, 82);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(50, 50);
+ panelGray.TabIndex = 1;
+ panelGray.MouseDown += PanelColor_MouseDown;
+ //
+ // panelWhite
+ //
+ panelWhite.BackColor = Color.White;
+ panelWhite.Location = new Point(15, 82);
+ panelWhite.Name = "panelWhite";
+ panelWhite.Size = new Size(50, 50);
+ panelWhite.TabIndex = 1;
+ panelWhite.MouseDown += PanelColor_MouseDown;
+ //
+ // panelYellow
+ //
+ panelYellow.BackColor = Color.Yellow;
+ panelYellow.Location = new Point(183, 22);
+ panelYellow.Name = "panelYellow";
+ panelYellow.Size = new Size(50, 50);
+ panelYellow.TabIndex = 1;
+ panelYellow.MouseDown += PanelColor_MouseDown;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(127, 22);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(50, 50);
+ panelBlue.TabIndex = 1;
+ panelBlue.MouseDown += PanelColor_MouseDown;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.FromArgb(0, 192, 0);
+ panelGreen.Location = new Point(71, 22);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(50, 50);
+ panelGreen.TabIndex = 1;
+ panelGreen.MouseDown += PanelColor_MouseDown;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(15, 22);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(50, 50);
+ panelRed.TabIndex = 0;
+ panelRed.MouseDown += PanelColor_MouseDown;
+ //
+ // checkBoxSail
+ //
+ checkBoxSail.AutoSize = true;
+ checkBoxSail.Location = new Point(6, 114);
+ checkBoxSail.Name = "checkBoxSail";
+ checkBoxSail.Size = new Size(60, 19);
+ checkBoxSail.TabIndex = 5;
+ checkBoxSail.Text = "Парус";
+ checkBoxSail.UseVisualStyleBackColor = true;
+ //
+ // checkBoxRainforce
+ //
+ checkBoxRainforce.AutoSize = true;
+ checkBoxRainforce.Location = new Point(6, 153);
+ checkBoxRainforce.Name = "checkBoxRainforce";
+ checkBoxRainforce.Size = new Size(239, 19);
+ checkBoxRainforce.TabIndex = 4;
+ checkBoxRainforce.Text = "Признак наличия усиленного корпуса";
+ checkBoxRainforce.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(74, 71);
+ 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(65, 23);
+ numericUpDownWeight.TabIndex = 3;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(74, 30);
+ 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(65, 23);
+ numericUpDownSpeed.TabIndex = 2;
+ numericUpDownSpeed.UseWaitCursor = true;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(6, 73);
+ label2.Name = "label2";
+ label2.Size = new Size(29, 15);
+ label2.TabIndex = 1;
+ label2.Text = "Вес:";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(6, 32);
+ label1.Name = "label1";
+ label1.Size = new Size(62, 15);
+ label1.TabIndex = 0;
+ label1.Text = "Скорость:";
+ //
+ // pictureBoxObject
+ //
+ pictureBoxObject.Location = new Point(26, 58);
+ pictureBoxObject.Name = "pictureBoxObject";
+ pictureBoxObject.Size = new Size(345, 139);
+ pictureBoxObject.TabIndex = 1;
+ pictureBoxObject.TabStop = false;
+ //
+ // panelObject
+ //
+ panelObject.AllowDrop = true;
+ panelObject.Controls.Add(labelAdditionalColor);
+ panelObject.Controls.Add(pictureBoxObject);
+ panelObject.Controls.Add(labelColor);
+ panelObject.Location = new Point(543, 12);
+ panelObject.Name = "panelObject";
+ panelObject.Size = new Size(395, 207);
+ panelObject.TabIndex = 2;
+ panelObject.DragDrop += panelObject_DragDrop;
+ panelObject.DragEnter += panelObject_DragEnter;
+ //
+ // labelAdditionalColor
+ //
+ labelAdditionalColor.AllowDrop = true;
+ labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
+ labelAdditionalColor.Location = new Point(221, 14);
+ labelAdditionalColor.Name = "labelAdditionalColor";
+ labelAdditionalColor.Size = new Size(150, 36);
+ labelAdditionalColor.TabIndex = 3;
+ labelAdditionalColor.Text = "Доп. цвет";
+ labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelAdditionalColor.DragDrop += LabelColor_DragDrop;
+ labelAdditionalColor.DragEnter += LabelColor_DragEnter;
+ //
+ // labelColor
+ //
+ labelColor.AllowDrop = true;
+ labelColor.BorderStyle = BorderStyle.FixedSingle;
+ labelColor.Location = new Point(26, 14);
+ labelColor.Name = "labelColor";
+ labelColor.Size = new Size(150, 36);
+ labelColor.TabIndex = 2;
+ labelColor.Text = "Цвет";
+ labelColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelColor.DragDrop += LabelColor_DragDrop;
+ labelColor.DragEnter += LabelColor_DragEnter;
+ //
+ // buttonOk
+ //
+ buttonOk.Location = new Point(569, 225);
+ buttonOk.Name = "buttonOk";
+ buttonOk.Size = new Size(150, 28);
+ buttonOk.TabIndex = 3;
+ buttonOk.Text = "Добавить";
+ buttonOk.UseVisualStyleBackColor = true;
+ buttonOk.Click += buttonOk_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(764, 225);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(150, 28);
+ buttonCancel.TabIndex = 4;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // FormBoatConfig
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(950, 265);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonOk);
+ Controls.Add(panelObject);
+ Controls.Add(groupBox1);
+ Name = "FormBoatConfig";
+ Text = "FormBoatConfig";
+ groupBox1.ResumeLayout(false);
+ groupBox1.PerformLayout();
+ groupBox2.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 groupBox1;
+ private NumericUpDown numericUpDownWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private Label label2;
+ private Label label1;
+ private GroupBox groupBox2;
+ private Panel panelPink;
+ private Panel panelBlack;
+ private Panel panelGray;
+ private Panel panelWhite;
+ private Panel panelYellow;
+ private Panel panelBlue;
+ private Panel panelGreen;
+ private Panel panelRed;
+ private CheckBox checkBoxSail;
+ private CheckBox checkBoxRainforce;
+ private Label labelModifiedObject;
+ private Label labelSimpleObject;
+ private PictureBox pictureBoxObject;
+ private Panel panelObject;
+ private Label labelAdditionalColor;
+ private Label labelColor;
+ private Button buttonOk;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SailBoat/SailBoat/FormBoatConfig.cs b/SailBoat/SailBoat/FormBoatConfig.cs
new file mode 100644
index 0000000..a3f9d88
--- /dev/null
+++ b/SailBoat/SailBoat/FormBoatConfig.cs
@@ -0,0 +1,120 @@
+using SailBoat.DrawningObjects;
+using SailBoat.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 SailBoat
+{
+ public partial class FormBoatConfig : Form
+ {
+
+ public DrawningBoat? _boat = null;
+
+ private event Action? EventAddBoat;
+
+ public void AddEvent(Action ev)
+ {
+ if (EventAddBoat == null)
+ {
+ EventAddBoat = ev;
+ }
+ else
+ {
+ EventAddBoat += ev;
+ }
+ }
+
+ public FormBoatConfig()
+ {
+ InitializeComponent();
+ buttonCancel.Click += (sender, e) => Close();
+ }
+
+ private void DrawBoat()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _boat?.SetPosition(5, 5);
+ _boat?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+
+ private void LabelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void PanelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void panelObject_DragDrop(object sender, DragEventArgs e)
+ {
+ switch (e.Data?.GetData(DataFormats.Text).ToString())
+ {
+ case "labelSimpleObject":
+ _boat = new DrawningBoat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
+ break;
+ case "labelModifiedObject":
+ _boat = new DrawningSailBoat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxSail.Checked, checkBoxRainforce.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
+ break;
+ }
+ DrawBoat();
+ }
+
+ 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 buttonOk_Click(object sender, EventArgs e)
+ {
+ EventAddBoat?.Invoke(_boat);
+ Close();
+ }
+
+ private void LabelColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_boat == null) return;
+ switch (((Label)sender).Name)
+ {
+ case "labelColor":
+ _boat.EntityBoat.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
+ break;
+ case "labelAdditionalColor":
+ (_boat.EntityBoat as EntitySailBoat).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
+ break;
+ }
+ DrawBoat();
+ }
+
+ private void LabelColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ }
+}
diff --git a/SailBoat/SailBoat/FormBoatConfig.resx b/SailBoat/SailBoat/FormBoatConfig.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SailBoat/SailBoat/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
diff --git a/SailBoat/SailBoat/FormSailBoat.cs b/SailBoat/SailBoat/FormSailBoat.cs
index bd68014..e1ef678 100644
--- a/SailBoat/SailBoat/FormSailBoat.cs
+++ b/SailBoat/SailBoat/FormSailBoat.cs
@@ -10,7 +10,7 @@ namespace SailBoat
private AbstractStrategy? _abstractStrategy;
- public DrawningBoat? SelectedBoat { get; private set; }
+ public DrawningBoat? SelectedBoat { get; set; }
public FormSailBoat()
{
diff --git a/SailBoat/SailBoat/Generics/BoatsGenericCollection.cs b/SailBoat/SailBoat/Generics/BoatsGenericCollection.cs
index 3606e9e..6f8a9a2 100644
--- a/SailBoat/SailBoat/Generics/BoatsGenericCollection.cs
+++ b/SailBoat/SailBoat/Generics/BoatsGenericCollection.cs
@@ -35,7 +35,7 @@ namespace SailBoat.Generics
public static bool operator +(BoatsGenericCollection collect, T? obj)
{
if (obj == null) return false;
- return (bool)collect?._collection.Insert(obj);
+ return collect._collection.Insert(obj);
}
public static bool operator -(BoatsGenericCollection collect, int pos)
@@ -83,7 +83,7 @@ namespace SailBoat.Generics
int i = 0;
foreach (var boat in _collection.GetBoats())
{
- if (boat != null)
+ if(boat != null)
{
boat.SetPosition((i % width) * _placeSizeWidth, (i / (height - 1)) * _placeSizeHeight);
boat.DrawTransport(g);
diff --git a/SailBoat/SailBoat/Generics/BoatsGenericStorage.cs b/SailBoat/SailBoat/Generics/BoatsGenericStorage.cs
index 7d7d7aa..e60e4b2 100644
--- a/SailBoat/SailBoat/Generics/BoatsGenericStorage.cs
+++ b/SailBoat/SailBoat/Generics/BoatsGenericStorage.cs
@@ -25,23 +25,27 @@ namespace SailBoat.Generics
_pictureHeight = pictureHeight;
}
- public void AddSet(string name)
+ public void AddSet(string Name)
{
- if (_boatStorages.ContainsKey(name)) return;
- _boatStorages[name] = new BoatsGenericCollection(_pictureWidth, _pictureHeight);
+ if (!_boatStorages.ContainsKey(Name))
+ {
+ _boatStorages[Name] = new BoatsGenericCollection(_pictureWidth, _pictureHeight);
+ }
}
- public void DelSet(string name)
+ public void DelSet(string Name)
{
- if (!_boatStorages.ContainsKey(name)) return;
- _boatStorages.Remove(name);
+ if (_boatStorages.ContainsKey(Name))
+ {
+ _boatStorages.Remove(Name);
+ }
}
public BoatsGenericCollection? this[string ind]
{
get
{
- if (_boatStorages.ContainsKey(ind)) return _boatStorages[ind];
+ if(_boatStorages.ContainsKey(ind)) return _boatStorages[ind];
return null;
}
}
diff --git a/SailBoat/SailBoat/Generics/SetGeneric.cs b/SailBoat/SailBoat/Generics/SetGeneric.cs
index 542915e..342a315 100644
--- a/SailBoat/SailBoat/Generics/SetGeneric.cs
+++ b/SailBoat/SailBoat/Generics/SetGeneric.cs
@@ -32,16 +32,24 @@ namespace SailBoat.Generics
{
return false;
}
- if(Count >= _maxCount) { return false; }
-
- _places.Insert(0, boat);
+ if (Count >= _maxCount)
+ {
+ return false;
+ }
+ _places.Insert(position, boat);
return true;
}
public bool Remove(int position)
{
- if (position < 0 || position >= _maxCount) return false;
- if (position >= Count) return false;
+ if (position < 0 || position >= _maxCount)
+ {
+ return false;
+ }
+ if (Count >= _maxCount)
+ {
+ return false;
+ }
_places.RemoveAt(position);
return true;
}
@@ -50,29 +58,26 @@ namespace SailBoat.Generics
{
get
{
- if (position < 0 || position > _maxCount)
- return null;
+ if (position < 0 || position > _maxCount) { return null; }
return _places[position];
}
set
{
- if (position < 0 || position > _maxCount)
- return;
+ if (position < 0 || position > _maxCount) { return; }
_places[position] = value;
}
}
public IEnumerable GetBoats(int? maxBoats = null)
{
- for (int i = 0; i < _places.Count; ++i)
+ for(int i = 0; i < _places.Count; i++)
{
yield return _places[i];
- if (maxBoats.HasValue && i == maxBoats.Value)
+ if(maxBoats.HasValue && i == maxBoats.Value)
{
yield break;
}
}
}
-
}
}