diff --git a/Sailboat/Sailboat/FormSailboat.Designer.cs b/Sailboat/Sailboat/FormSailboat.Designer.cs
index 4b435b1..3dcc60e 100644
--- a/Sailboat/Sailboat/FormSailboat.Designer.cs
+++ b/Sailboat/Sailboat/FormSailboat.Designer.cs
@@ -37,6 +37,7 @@
buttonCreateSailboat = new Button();
comboBoxStrategy = new ComboBox();
buttonStep = new Button();
+ buttonSelectBoat = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxSailboat).BeginInit();
SuspendLayout();
//
@@ -140,11 +141,22 @@
buttonStep.UseVisualStyleBackColor = true;
buttonStep.Click += buttonStep_Click;
//
+ // buttonSelectBoat
+ //
+ buttonSelectBoat.Location = new Point(137, 243);
+ buttonSelectBoat.Name = "buttonSelectBoat";
+ buttonSelectBoat.Size = new Size(122, 40);
+ buttonSelectBoat.TabIndex = 9;
+ buttonSelectBoat.Text = "Выбрать лодку";
+ buttonSelectBoat.UseVisualStyleBackColor = true;
+ buttonSelectBoat.Click += buttonSelectBoat_Click;
+ //
// FormSailboat
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(882, 453);
+ Controls.Add(buttonSelectBoat);
Controls.Add(buttonStep);
Controls.Add(comboBoxStrategy);
Controls.Add(buttonCreateSailboat);
@@ -173,5 +185,6 @@
private Button buttonCreateSailboat;
private ComboBox comboBoxStrategy;
private Button buttonStep;
+ private Button buttonSelectBoat;
}
}
\ No newline at end of file
diff --git a/Sailboat/Sailboat/FormSailboat.cs b/Sailboat/Sailboat/FormSailboat.cs
index 597a952..99c08d9 100644
--- a/Sailboat/Sailboat/FormSailboat.cs
+++ b/Sailboat/Sailboat/FormSailboat.cs
@@ -12,28 +12,19 @@ using System.Windows.Forms;
namespace Sailboat
{
- ///
- /// Форма работы с объектом "Парусная лодка"
- ///
public partial class FormSailboat : Form
{
- ///
- /// Поле-объект для прорисовки объекта
- ///
private DrawingBoat? _drawingBoat;
private AbstractStrategy? _abstractStrategy;
+ public DrawingBoat? SelectedBoat { get; private set; }
- ///
- /// Инициализация формы
- ///
public FormSailboat()
{
InitializeComponent();
+ _abstractStrategy = null;
+ SelectedBoat = null;
}
- ///
- /// Метод прорисовки лодки
- ///
private void Draw()
{
if (_drawingBoat == null)
@@ -47,40 +38,45 @@ namespace Sailboat
pictureBoxSailboat.Image = bmp;
}
- ///
- /// Обработка нажатия кнопки "Создать лодку"
- ///
- ///
- ///
private void buttonCreateBoat_Click(object sender, EventArgs e)
{
Random random = new();
- _drawingBoat = new DrawingBoat(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), pictureBoxSailboat.Width, pictureBoxSailboat.Height);
- _drawingBoat.SetPosition(random.Next(10, 100), random.Next(10,
- 100));
- Draw();
- }
-
- ///
- /// Обработка нажатия кнопки "Создать улучшеную лодку"
- ///
- ///
- ///
- private void buttonCreateSailboat_Click(object sender, EventArgs e)
- {
- Random random = new();
- _drawingBoat = new DrawingSailboat(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- Convert.ToBoolean(random.Next(0, 2)),
- Convert.ToBoolean(random.Next(0, 2)), pictureBoxSailboat.Width, pictureBoxSailboat.Height);
+ Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+ _drawingBoat = new DrawingBoat(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxSailboat.Width, pictureBoxSailboat.Height);
+ _drawingBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ Draw();
+ }
+
+ private void buttonCreateSailboat_Click(object sender, EventArgs e)
+ {
+ Random random = new();
+ Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+
+ Color dopColor = Color.FromArgb(random.Next(0, 256),
+ random.Next(0, 256), random.Next(0, 256));
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ dopColor = dialog.Color;
+ }
+
+ _drawingBoat = new DrawingSailboat(random.Next(100, 300),
+ random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(0, 2)),
+ Convert.ToBoolean(random.Next(0, 2)),
+ pictureBoxSailboat.Width, pictureBoxSailboat.Height);
_drawingBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
- ///
- /// Изменение размеров формы
- ///
- ///
- ///
private void buttonMove_Click(object sender, EventArgs e)
{
if (_drawingBoat == null)
@@ -106,11 +102,6 @@ namespace Sailboat
Draw();
}
- ///
- /// Обработка нажатия кнопки "Шаг"
- ///
- ///
- ///
private void buttonStep_Click(object sender, EventArgs e)
{
if (_drawingBoat == null)
@@ -146,5 +137,11 @@ namespace Sailboat
_abstractStrategy = null;
}
}
+
+ private void buttonSelectBoat_Click(object sender, EventArgs e)
+ {
+ SelectedBoat = _drawingBoat;
+ DialogResult = DialogResult.OK;
+ }
}
}
\ No newline at end of file