diff --git a/base/Catamaran/Catamaran/Catamaran.Designer.cs b/base/Catamaran/Catamaran/Catamaran.Designer.cs
index 213cc04..89919aa 100644
--- a/base/Catamaran/Catamaran/Catamaran.Designer.cs
+++ b/base/Catamaran/Catamaran/Catamaran.Designer.cs
@@ -35,8 +35,9 @@
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
- this.buttonStep = new System.Windows.Forms.Button();
+ this.buttonStrategyStep = new System.Windows.Forms.Button();
this.buttonCreateSailCatamaran = new System.Windows.Forms.Button();
+ this.buttonSelectCatamaran = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCatamaran)).BeginInit();
this.SuspendLayout();
//
@@ -116,20 +117,20 @@
this.comboBoxStrategy.Items.AddRange(new object[] {
"До центра",
"До края"});
- this.comboBoxStrategy.Location = new System.Drawing.Point(688, 12);
+ this.comboBoxStrategy.Location = new System.Drawing.Point(711, 12);
this.comboBoxStrategy.Name = "comboBoxStrategy";
this.comboBoxStrategy.Size = new System.Drawing.Size(151, 23);
this.comboBoxStrategy.TabIndex = 7;
//
- // buttonStep
+ // buttonStrategyStep
//
- this.buttonStep.Location = new System.Drawing.Point(770, 41);
- this.buttonStep.Name = "buttonStep";
- this.buttonStep.Size = new System.Drawing.Size(75, 23);
- this.buttonStep.TabIndex = 7;
- this.buttonStep.Text = "Шаг";
- this.buttonStep.UseVisualStyleBackColor = true;
- this.buttonStep.Click += new System.EventHandler(this.ButtonStep_Click);
+ this.buttonStrategyStep.Location = new System.Drawing.Point(787, 41);
+ this.buttonStrategyStep.Name = "buttonStrategyStep";
+ this.buttonStrategyStep.Size = new System.Drawing.Size(75, 23);
+ this.buttonStrategyStep.TabIndex = 7;
+ this.buttonStrategyStep.Text = "Шаг";
+ this.buttonStrategyStep.UseVisualStyleBackColor = true;
+ this.buttonStrategyStep.Click += new System.EventHandler(this.buttonStrategyStep_Click);
//
// buttonCreateSailCatamaran
//
@@ -142,11 +143,23 @@
this.buttonCreateSailCatamaran.UseVisualStyleBackColor = true;
this.buttonCreateSailCatamaran.Click += new System.EventHandler(this.buttonCreateSailCatamaran_Click);
//
+ // buttonSelectCatamaran
+ //
+ this.buttonSelectCatamaran.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonSelectCatamaran.Location = new System.Drawing.Point(268, 398);
+ this.buttonSelectCatamaran.Name = "buttonSelectCatamaran";
+ this.buttonSelectCatamaran.Size = new System.Drawing.Size(167, 51);
+ this.buttonSelectCatamaran.TabIndex = 11;
+ this.buttonSelectCatamaran.Text = "Выбрать катамаран";
+ this.buttonSelectCatamaran.UseVisualStyleBackColor = true;
+ this.buttonSelectCatamaran.Click += new System.EventHandler(this.buttonSelectCatamaran_Click);
+ //
// FormCatamaran
//
this.ClientSize = new System.Drawing.Size(884, 461);
+ this.Controls.Add(this.buttonSelectCatamaran);
this.Controls.Add(this.buttonCreateSailCatamaran);
- this.Controls.Add(this.buttonStep);
+ this.Controls.Add(this.buttonStrategyStep);
this.Controls.Add(this.comboBoxStrategy);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonLeft);
@@ -173,7 +186,8 @@
private Button buttonLeft;
private Button buttonDown;
private ComboBox comboBoxStrategy;
- private Button buttonStep;
+ private Button buttonStrategyStep;
private Button buttonCreateSailCatamaran;
+ private Button buttonSelectCatamaran;
}
}
\ No newline at end of file
diff --git a/base/Catamaran/Catamaran/Catamaran.cs b/base/Catamaran/Catamaran/Catamaran.cs
index ceda018..5549617 100644
--- a/base/Catamaran/Catamaran/Catamaran.cs
+++ b/base/Catamaran/Catamaran/Catamaran.cs
@@ -1,4 +1,3 @@
-using Catamaran.Entities;
using Catamaran.DrawningObjects;
using Catamaran.MovementStrategy;
@@ -7,7 +6,6 @@ namespace Catamaran
///
/// ""
///
-
public partial class FormCatamaran : Form
{
///
@@ -18,7 +16,12 @@ namespace Catamaran
///
///
///
- private AbstractStrategy? _abstractStrategy;
+ private AbstractStrategy? _strategy;
+
+ ///
+ ///
+ ///
+ public DrawningCatamaran? SelectedCatamaran { get; private set; }
///
///
@@ -26,8 +29,10 @@ namespace Catamaran
public FormCatamaran()
{
InitializeComponent();
+ _strategy = null;
+ SelectedCatamaran = null;
}
-
+
///
///
///
@@ -52,25 +57,48 @@ namespace Catamaran
private void buttonCreateSailCatamaran_Click(object sender, EventArgs e)
{
Random random = new();
- _drawningCatamaran = new DrawningSailCatamaran(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)),
+ //TODO
+ Color color = Color.FromArgb(random.Next(0, 256),
+ random.Next(0, 256), random.Next(0, 256));
+ ColorDialog dialogColor = new();
+ if (dialogColor.ShowDialog() == DialogResult.OK)
+ {
+ color = dialogColor.Color;
+ }
+ //TODO
+ Color dopColor = Color.FromArgb(random.Next(0, 256),
+ random.Next(0, 256), random.Next(0, 256));
+ ColorDialog dialogDopColor = new();
+ if (dialogDopColor.ShowDialog() == DialogResult.OK)
+ {
+ dopColor = dialogDopColor.Color;
+ }
+
+ _drawningCatamaran = new DrawningSailCatamaran(random.Next(100, 300),
+ random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)),
- Convert.ToBoolean(random.Next(0, 2)), pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
+ pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
_drawningCatamaran.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
///
- /// " "
+ ///
///
///
///
private void buttonCreateCatamaran_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;
+ }
_drawningCatamaran = new DrawningCatamaran(random.Next(100, 300),
- random.Next(1000, 3000),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
- random.Next(0, 256)),
+ random.Next(1000, 3000), color,
pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
_drawningCatamaran.SetPosition(random.Next(10, 100), random.Next(10,
100));
@@ -108,11 +136,11 @@ namespace Catamaran
}
///
- /// ""
+ ///
///
///
///
- private void ButtonStep_Click(object sender, EventArgs e)
+ private void buttonStrategyStep_Click(object sender, EventArgs e)
{
if (_drawningCatamaran == null)
{
@@ -120,32 +148,41 @@ namespace Catamaran
}
if (comboBoxStrategy.Enabled)
{
- _abstractStrategy = comboBoxStrategy.SelectedIndex
- switch
+ _strategy = comboBoxStrategy.SelectedIndex switch
{
0 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null,
};
- if (_abstractStrategy == null)
+ if (_strategy == null)
{
return;
}
- _abstractStrategy.SetData(new DrawningObjectCatamaran(_drawningCatamaran), pictureBoxCatamaran.Width,
- pictureBoxCatamaran.Height);
- comboBoxStrategy.Enabled = false;
+ _strategy.SetData(_drawningCatamaran.GetMoveableObject,
+ pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
}
- if (_abstractStrategy == null)
+ if (_strategy == null)
{
return;
}
- _abstractStrategy.MakeStep();
+ comboBoxStrategy.Enabled = false;
+ _strategy.MakeStep();
Draw();
- if (_abstractStrategy.GetStatus() == Status.Finish)
+ if (_strategy.GetStatus() == Status.Finish)
{
comboBoxStrategy.Enabled = true;
- _abstractStrategy = null;
+ _strategy = null;
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void buttonSelectCatamaran_Click(object sender, EventArgs e)
+ {
+ SelectedCatamaran = _drawningCatamaran;
+ DialogResult = DialogResult.OK;
+ }
}
}
diff --git a/base/Catamaran/Catamaran/CatamaransGenericCollection.cs b/base/Catamaran/Catamaran/CatamaransGenericCollection.cs
index c75563d..49eb219 100644
--- a/base/Catamaran/Catamaran/CatamaransGenericCollection.cs
+++ b/base/Catamaran/Catamaran/CatamaransGenericCollection.cs
@@ -28,11 +28,11 @@ namespace Catamaran.Generics
///
/// Размер занимаемого объектом места (ширина)
///
- private readonly int _placeSizeWidth = 190;
+ private readonly int _placeSizeWidth = 200;
///
/// Размер занимаемого объектом места (высота)
///
- private readonly int _placeSizeHeight = 120;
+ private readonly int _placeSizeHeight = 150;
///
/// Набор объектов
///
@@ -126,32 +126,29 @@ namespace Catamaran.Generics
///
private void DrawObjects(Graphics g)
{
- //for (int i = 0; i < _collection.Count; i++)
- //{
- // TODO получение объекта
- // TODO установка позиции
- // TODO прорисовка объекта
- T? obj;
- int width = _pictureWidth / _placeSizeWidth;
- int height = _pictureHeight / _placeSizeHeight;
- int diff = 1, currWidth = 0;
- for (int i = 0; i < _collection.Count; i++)
+ // TODO получение объекта
+ // TODO установка позиции
+ // TODO прорисовка объекта
+ T? obj;
+ int width = _pictureWidth / _placeSizeWidth;
+ int height = _pictureHeight / _placeSizeHeight;
+ int diff = 1, currWidth = 0;
+ for (int i = 0; i < _collection.Count; i++)
+ {
+ currWidth++;
+ if (currWidth > width)
{
- currWidth++;
- if (currWidth > width)
- {
- diff++;
- currWidth = 1;
- }
- obj = _collection.Get(i);
- if (obj != null)
- {
- obj.SetPosition(i % width * _placeSizeWidth + _placeSizeWidth / 40,
- (height - diff) * _placeSizeHeight + _placeSizeHeight / 15);
- obj.DrawTransport(g);
- }
+ diff++;
+ currWidth = 1;
}
- //}
+ obj = _collection.Get(i);
+ if (obj != null)
+ {
+ obj.SetPosition(i % width * _placeSizeWidth + _placeSizeWidth / 40,
+ (height - diff) * _placeSizeHeight + _placeSizeHeight / 15);
+ obj.DrawTransport(g);
+ }
+ }
}
}
}
diff --git a/base/Catamaran/Catamaran/FormCatamaranCollection.Designer.cs b/base/Catamaran/Catamaran/FormCatamaranCollection.Designer.cs
new file mode 100644
index 0000000..c133790
--- /dev/null
+++ b/base/Catamaran/Catamaran/FormCatamaranCollection.Designer.cs
@@ -0,0 +1,124 @@
+namespace Catamaran
+{
+ partial class FormCatamaranCollection
+ {
+ ///
+ /// 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()
+ {
+ this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
+ this.groupBoxTools = new System.Windows.Forms.GroupBox();
+ this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
+ this.ButtonRefreshCollection = new System.Windows.Forms.Button();
+ this.ButtonRemoveCatamaran = new System.Windows.Forms.Button();
+ this.ButtonAddCatamaran = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
+ this.groupBoxTools.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // pictureBoxCollection
+ //
+ this.pictureBoxCollection.Location = new System.Drawing.Point(0, 1);
+ this.pictureBoxCollection.Name = "pictureBoxCollection";
+ this.pictureBoxCollection.Size = new System.Drawing.Size(741, 459);
+ this.pictureBoxCollection.TabIndex = 0;
+ this.pictureBoxCollection.TabStop = false;
+ //
+ // groupBoxTools
+ //
+ this.groupBoxTools.Controls.Add(this.maskedTextBoxNumber);
+ this.groupBoxTools.Controls.Add(this.ButtonRefreshCollection);
+ this.groupBoxTools.Controls.Add(this.ButtonRemoveCatamaran);
+ this.groupBoxTools.Controls.Add(this.ButtonAddCatamaran);
+ this.groupBoxTools.Location = new System.Drawing.Point(739, 1);
+ this.groupBoxTools.Name = "groupBoxTools";
+ this.groupBoxTools.Size = new System.Drawing.Size(147, 460);
+ this.groupBoxTools.TabIndex = 1;
+ this.groupBoxTools.TabStop = false;
+ this.groupBoxTools.Text = "Инструменты";
+ //
+ // maskedTextBoxNumber
+ //
+ this.maskedTextBoxNumber.Location = new System.Drawing.Point(0, 108);
+ this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
+ this.maskedTextBoxNumber.Size = new System.Drawing.Size(141, 23);
+ this.maskedTextBoxNumber.TabIndex = 3;
+ //
+ // ButtonRefreshCollection
+ //
+ this.ButtonRefreshCollection.Location = new System.Drawing.Point(0, 211);
+ this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
+ this.ButtonRefreshCollection.Size = new System.Drawing.Size(141, 34);
+ this.ButtonRefreshCollection.TabIndex = 2;
+ this.ButtonRefreshCollection.Text = "Обновить коллекцию";
+ this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
+ this.ButtonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
+ //
+ // ButtonRemoveCatamaran
+ //
+ this.ButtonRemoveCatamaran.Location = new System.Drawing.Point(0, 157);
+ this.ButtonRemoveCatamaran.Name = "ButtonRemoveCatamaran";
+ this.ButtonRemoveCatamaran.Size = new System.Drawing.Size(141, 34);
+ this.ButtonRemoveCatamaran.TabIndex = 1;
+ this.ButtonRemoveCatamaran.Text = "Удалить катамаран";
+ this.ButtonRemoveCatamaran.UseVisualStyleBackColor = true;
+ this.ButtonRemoveCatamaran.Click += new System.EventHandler(this.ButtonRemoveCatamaran_Click);
+ //
+ // ButtonAddCatamaran
+ //
+ this.ButtonAddCatamaran.Location = new System.Drawing.Point(0, 22);
+ this.ButtonAddCatamaran.Name = "ButtonAddCatamaran";
+ this.ButtonAddCatamaran.Size = new System.Drawing.Size(141, 34);
+ this.ButtonAddCatamaran.TabIndex = 0;
+ this.ButtonAddCatamaran.Text = "Добавить катамаран";
+ this.ButtonAddCatamaran.UseVisualStyleBackColor = true;
+ this.ButtonAddCatamaran.Click += new System.EventHandler(this.ButtonAddCatamaran_Click);
+ //
+ // FormCatamaranCollection
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(884, 461);
+ this.Controls.Add(this.groupBoxTools);
+ this.Controls.Add(this.pictureBoxCollection);
+ this.Name = "FormCatamaranCollection";
+ this.Text = "FormCatamaranCollection";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
+ this.groupBoxTools.ResumeLayout(false);
+ this.groupBoxTools.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private PictureBox pictureBoxCollection;
+ private GroupBox groupBoxTools;
+ private Button ButtonAddCatamaran;
+ private Button ButtonRefreshCollection;
+ private Button ButtonRemoveCatamaran;
+ private MaskedTextBox maskedTextBoxNumber;
+ }
+}
\ No newline at end of file
diff --git a/base/Catamaran/Catamaran/FormCatamaranCollection.cs b/base/Catamaran/Catamaran/FormCatamaranCollection.cs
new file mode 100644
index 0000000..3db931c
--- /dev/null
+++ b/base/Catamaran/Catamaran/FormCatamaranCollection.cs
@@ -0,0 +1,81 @@
+using Catamaran.DrawningObjects;
+using Catamaran.Generics;
+using Catamaran.MovementStrategy;
+
+namespace Catamaran
+{
+ ///
+ /// Форма для работы с набором объектов класса DrawningCatamaran
+ ///
+ public partial class FormCatamaranCollection : Form
+ {
+ ///
+ /// Набор объектов
+ ///
+ private readonly CatamaransGenericCollection _catamarans;
+ ///
+ /// Конструктор
+ ///
+ public FormCatamaranCollection()
+ {
+ InitializeComponent();
+ _catamarans = new CatamaransGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height);
+ }
+ ///
+ /// Добавление объекта в набор
+ ///
+ ///
+ ///
+ private void ButtonAddCatamaran_Click(object sender, EventArgs e)
+ {
+ FormCatamaran form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (_catamarans + form.SelectedCatamaran != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollection.Image = _catamarans.ShowCatamarans();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+ ///
+ /// Удаление объекта из набора
+ ///
+ ///
+ ///
+ private void ButtonRemoveCatamaran_Click(object sender, EventArgs e)
+ {
+ if (MessageBox.Show("Удалить объект?", "Удаление",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ return;
+ }
+ int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
+ if (_catamarans - pos != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBoxCollection.Image = _catamarans.ShowCatamarans();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+ ///
+ /// Обновление рисунка по набору
+ ///
+ ///
+ ///
+ private void ButtonRefreshCollection_Click(object sender, EventArgs
+ e)
+ {
+ pictureBoxCollection.Image = _catamarans.ShowCatamarans();
+ }
+ }
+}
diff --git a/base/Catamaran/Catamaran/FormCatamaranCollection.resx b/base/Catamaran/Catamaran/FormCatamaranCollection.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/base/Catamaran/Catamaran/FormCatamaranCollection.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/base/Catamaran/Catamaran/Program.cs b/base/Catamaran/Catamaran/Program.cs
index cad1371..290fdf6 100644
--- a/base/Catamaran/Catamaran/Program.cs
+++ b/base/Catamaran/Catamaran/Program.cs
@@ -11,7 +11,7 @@ namespace Catamaran
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormCatamaran());
+ Application.Run(new FormCatamaranCollection());
}
}
}
\ No newline at end of file