Compare commits
No commits in common. "ed5907725473c1f10e2754380137bec85e0dcb16" and "a74bbd4dd3fe924407b299ed9590301f04ab5743" have entirely different histories.
ed59077254
...
a74bbd4dd3
@ -31,11 +31,11 @@ namespace Sailboat.Generics
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Размер занимаемого объектом места (ширина)
|
/// Размер занимаемого объектом места (ширина)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _placeSizeWidth = 200;
|
private readonly int _placeSizeWidth = 160;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Размер занимаемого объектом места (высота)
|
/// Размер занимаемого объектом места (высота)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _placeSizeHeight = 170;
|
private readonly int _placeSizeHeight = 160;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Набор объектов
|
/// Набор объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
84
Sailboat/Sailboat/BoatsGenericStorage.cs
Normal file
84
Sailboat/Sailboat/BoatsGenericStorage.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Sailboat.DrawingObjects;
|
||||||
|
using Sailboat.MovementStrategy;
|
||||||
|
|
||||||
|
namespace Sailboat.Generics
|
||||||
|
{
|
||||||
|
internal class BoatsGenericStorage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Словарь (хранилище)
|
||||||
|
/// </summary>
|
||||||
|
readonly Dictionary<string, BoatsGenericCollection<DrawingBoat, DrawingObjectBoat>> _boatStorages;
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращение списка названий наборов
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Keys => _boatStorages.Keys.ToList();
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pictureWidth"></param>
|
||||||
|
/// <param name="pictureHeight"></param>
|
||||||
|
public BoatsGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_boatStorages = new Dictionary<string,
|
||||||
|
BoatsGenericCollection<DrawingBoat, DrawingObjectBoat>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название набора</param>
|
||||||
|
public void AddSet(string name)
|
||||||
|
{
|
||||||
|
if (_boatStorages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_boatStorages[name] = new BoatsGenericCollection<DrawingBoat, DrawingObjectBoat>(_pictureWidth, _pictureHeight);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название набора</param>
|
||||||
|
public void DelSet(string name)
|
||||||
|
{
|
||||||
|
if (!_boatStorages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_boatStorages.Remove(name);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к набору
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ind"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public BoatsGenericCollection<DrawingBoat, DrawingObjectBoat>?
|
||||||
|
this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_boatStorages.ContainsKey(ind))
|
||||||
|
{
|
||||||
|
return _boatStorages[ind];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
78
Sailboat/Sailboat/FormBoatCollection.Designer.cs
generated
78
Sailboat/Sailboat/FormBoatCollection.Designer.cs
generated
@ -34,22 +34,28 @@
|
|||||||
buttonRefreshCollection = new Button();
|
buttonRefreshCollection = new Button();
|
||||||
maskedTextBoxNumber = new MaskedTextBox();
|
maskedTextBoxNumber = new MaskedTextBox();
|
||||||
groupBoxTools = new GroupBox();
|
groupBoxTools = new GroupBox();
|
||||||
|
groupBoxCollection = new GroupBox();
|
||||||
|
textBoxStorageName = new TextBox();
|
||||||
|
listBoxStorages = new ListBox();
|
||||||
|
buttonDelObject = new Button();
|
||||||
|
buttonAddObject = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
|
groupBoxCollection.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// pictureBoxCollection
|
// pictureBoxCollection
|
||||||
//
|
//
|
||||||
pictureBoxCollection.Location = new Point(0, 0);
|
pictureBoxCollection.Location = new Point(0, 0);
|
||||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
pictureBoxCollection.Size = new Size(750, 450);
|
pictureBoxCollection.Size = new Size(750, 600);
|
||||||
pictureBoxCollection.SizeMode = PictureBoxSizeMode.AutoSize;
|
pictureBoxCollection.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||||
pictureBoxCollection.TabIndex = 0;
|
pictureBoxCollection.TabIndex = 0;
|
||||||
pictureBoxCollection.TabStop = false;
|
pictureBoxCollection.TabStop = false;
|
||||||
//
|
//
|
||||||
// buttonAddBoat
|
// buttonAddBoat
|
||||||
//
|
//
|
||||||
buttonAddBoat.Location = new Point(6, 26);
|
buttonAddBoat.Location = new Point(5, 345);
|
||||||
buttonAddBoat.Name = "buttonAddBoat";
|
buttonAddBoat.Name = "buttonAddBoat";
|
||||||
buttonAddBoat.Size = new Size(197, 45);
|
buttonAddBoat.Size = new Size(197, 45);
|
||||||
buttonAddBoat.TabIndex = 1;
|
buttonAddBoat.TabIndex = 1;
|
||||||
@ -59,7 +65,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRemoveBoat
|
// buttonRemoveBoat
|
||||||
//
|
//
|
||||||
buttonRemoveBoat.Location = new Point(6, 145);
|
buttonRemoveBoat.Location = new Point(5, 462);
|
||||||
buttonRemoveBoat.Name = "buttonRemoveBoat";
|
buttonRemoveBoat.Name = "buttonRemoveBoat";
|
||||||
buttonRemoveBoat.Size = new Size(197, 45);
|
buttonRemoveBoat.Size = new Size(197, 45);
|
||||||
buttonRemoveBoat.TabIndex = 2;
|
buttonRemoveBoat.TabIndex = 2;
|
||||||
@ -69,7 +75,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRefreshCollection
|
// buttonRefreshCollection
|
||||||
//
|
//
|
||||||
buttonRefreshCollection.Location = new Point(6, 227);
|
buttonRefreshCollection.Location = new Point(6, 537);
|
||||||
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||||
buttonRefreshCollection.Size = new Size(197, 45);
|
buttonRefreshCollection.Size = new Size(197, 45);
|
||||||
buttonRefreshCollection.TabIndex = 3;
|
buttonRefreshCollection.TabIndex = 3;
|
||||||
@ -79,29 +85,80 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBoxNumber
|
// maskedTextBoxNumber
|
||||||
//
|
//
|
||||||
maskedTextBoxNumber.Location = new Point(34, 112);
|
maskedTextBoxNumber.Location = new Point(39, 429);
|
||||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
maskedTextBoxNumber.Size = new Size(138, 27);
|
maskedTextBoxNumber.Size = new Size(138, 27);
|
||||||
maskedTextBoxNumber.TabIndex = 4;
|
maskedTextBoxNumber.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
|
groupBoxTools.Controls.Add(groupBoxCollection);
|
||||||
groupBoxTools.Controls.Add(buttonAddBoat);
|
groupBoxTools.Controls.Add(buttonAddBoat);
|
||||||
groupBoxTools.Controls.Add(buttonRefreshCollection);
|
groupBoxTools.Controls.Add(buttonRefreshCollection);
|
||||||
groupBoxTools.Controls.Add(maskedTextBoxNumber);
|
groupBoxTools.Controls.Add(maskedTextBoxNumber);
|
||||||
groupBoxTools.Controls.Add(buttonRemoveBoat);
|
groupBoxTools.Controls.Add(buttonRemoveBoat);
|
||||||
groupBoxTools.Location = new Point(756, 12);
|
groupBoxTools.Location = new Point(756, 12);
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
groupBoxTools.Size = new Size(209, 387);
|
groupBoxTools.Size = new Size(209, 588);
|
||||||
groupBoxTools.TabIndex = 2;
|
groupBoxTools.TabIndex = 2;
|
||||||
groupBoxTools.TabStop = false;
|
groupBoxTools.TabStop = false;
|
||||||
groupBoxTools.Text = "Инструменты";
|
groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// groupBoxCollection
|
||||||
|
//
|
||||||
|
groupBoxCollection.Controls.Add(textBoxStorageName);
|
||||||
|
groupBoxCollection.Controls.Add(listBoxStorages);
|
||||||
|
groupBoxCollection.Controls.Add(buttonDelObject);
|
||||||
|
groupBoxCollection.Controls.Add(buttonAddObject);
|
||||||
|
groupBoxCollection.Location = new Point(6, 26);
|
||||||
|
groupBoxCollection.Name = "groupBoxCollection";
|
||||||
|
groupBoxCollection.Size = new Size(196, 299);
|
||||||
|
groupBoxCollection.TabIndex = 5;
|
||||||
|
groupBoxCollection.TabStop = false;
|
||||||
|
groupBoxCollection.Text = "Наборы";
|
||||||
|
//
|
||||||
|
// textBoxStorageName
|
||||||
|
//
|
||||||
|
textBoxStorageName.Location = new Point(6, 26);
|
||||||
|
textBoxStorageName.Name = "textBoxStorageName";
|
||||||
|
textBoxStorageName.Size = new Size(184, 27);
|
||||||
|
textBoxStorageName.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// listBoxStorages
|
||||||
|
//
|
||||||
|
listBoxStorages.FormattingEnabled = true;
|
||||||
|
listBoxStorages.ItemHeight = 20;
|
||||||
|
listBoxStorages.Location = new Point(21, 101);
|
||||||
|
listBoxStorages.Name = "listBoxStorages";
|
||||||
|
listBoxStorages.Size = new Size(150, 124);
|
||||||
|
listBoxStorages.TabIndex = 2;
|
||||||
|
listBoxStorages.SelectedIndexChanged += listBoxStorages_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// buttonDelObject
|
||||||
|
//
|
||||||
|
buttonDelObject.Location = new Point(5, 256);
|
||||||
|
buttonDelObject.Name = "buttonDelObject";
|
||||||
|
buttonDelObject.Size = new Size(191, 37);
|
||||||
|
buttonDelObject.TabIndex = 1;
|
||||||
|
buttonDelObject.Text = "Удалить набор";
|
||||||
|
buttonDelObject.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelObject.Click += buttonDelObject_Click;
|
||||||
|
//
|
||||||
|
// buttonAddObject
|
||||||
|
//
|
||||||
|
buttonAddObject.Location = new Point(6, 59);
|
||||||
|
buttonAddObject.Name = "buttonAddObject";
|
||||||
|
buttonAddObject.Size = new Size(184, 36);
|
||||||
|
buttonAddObject.TabIndex = 0;
|
||||||
|
buttonAddObject.Text = "Добавить набор";
|
||||||
|
buttonAddObject.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddObject.Click += buttonAddObject_Click;
|
||||||
|
//
|
||||||
// FormBoatCollection
|
// FormBoatCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(973, 403);
|
ClientSize = new Size(970, 606);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Controls.Add(pictureBoxCollection);
|
Controls.Add(pictureBoxCollection);
|
||||||
Name = "FormBoatCollection";
|
Name = "FormBoatCollection";
|
||||||
@ -109,6 +166,8 @@
|
|||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
groupBoxTools.PerformLayout();
|
groupBoxTools.PerformLayout();
|
||||||
|
groupBoxCollection.ResumeLayout(false);
|
||||||
|
groupBoxCollection.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -121,5 +180,10 @@
|
|||||||
private Button buttonRefreshCollection;
|
private Button buttonRefreshCollection;
|
||||||
private MaskedTextBox maskedTextBoxNumber;
|
private MaskedTextBox maskedTextBoxNumber;
|
||||||
private GroupBox groupBoxTools;
|
private GroupBox groupBoxTools;
|
||||||
|
private GroupBox groupBoxCollection;
|
||||||
|
private ListBox listBoxStorages;
|
||||||
|
private Button buttonDelObject;
|
||||||
|
private Button buttonAddObject;
|
||||||
|
private TextBox textBoxStorageName;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,4 @@
|
|||||||
using Sailboat.DrawingObjects;
|
using System;
|
||||||
using Sailboat.Generics;
|
|
||||||
using Sailboat.MovementStrategy;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -11,26 +8,61 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using Sailboat.DrawingObjects;
|
||||||
|
using Sailboat.Generics;
|
||||||
|
using Sailboat.MovementStrategy;
|
||||||
|
|
||||||
namespace Sailboat
|
namespace Sailboat
|
||||||
{
|
{
|
||||||
public partial class FormBoatCollection : Form
|
public partial class FormBoatCollection : Form
|
||||||
{
|
{
|
||||||
private readonly BoatsGenericCollection<DrawingBoat, DrawingObjectBoat> _boats;
|
private readonly BoatsGenericStorage _storage;
|
||||||
public FormBoatCollection()
|
public FormBoatCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_boats = new BoatsGenericCollection<DrawingBoat, DrawingObjectBoat>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
_storage = new BoatsGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
listBoxStorages.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (listBoxStorages.Items.Count > 0 && index > -1 &&
|
||||||
|
index < listBoxStorages.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxStorages.SelectedIndex = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
private void buttonAddBoat_Click(object sender, EventArgs e)
|
private void buttonAddBoat_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||||
|
string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
FormSailboat form = new();
|
FormSailboat form = new();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (_boats + form.SelectedBoat != -1)
|
if (obj + form.SelectedBoat)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBoxCollection.Image = _boats.ShowBoats();
|
pictureBoxCollection.Image = obj.ShowBoats();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -41,26 +73,78 @@ namespace Sailboat
|
|||||||
|
|
||||||
private void buttonRemoveBoat_Click(object sender, EventArgs e)
|
private void buttonRemoveBoat_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||||
|
string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||||
if (_boats - pos != null)
|
if (obj - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBoxCollection.Image = _boats.ShowBoats();
|
pictureBoxCollection.Image = obj.ShowBoats();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonRefreshCollection_Click(object sender, EventArgs e)
|
private void buttonRefreshCollection_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
pictureBoxCollection.Image = _boats.ShowBoats();
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||||
|
string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBoxCollection.Image = obj.ShowBoats();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddObject_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_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)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_storage.DelSet(listBoxStorages.SelectedItem.ToString()
|
||||||
|
?? string.Empty);
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,37 @@ namespace Sailboat.Generics
|
|||||||
{
|
{
|
||||||
internal class SetGeneric<T> where T : class
|
internal class SetGeneric<T> where T : class
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Массив объектов, которые храним
|
||||||
|
/// </summary>
|
||||||
private readonly T?[] _places;
|
private readonly T?[] _places;
|
||||||
|
/// <summary>
|
||||||
|
/// Количество объектов в массиве
|
||||||
|
/// </summary>
|
||||||
public int Count => _places.Length;
|
public int Count => _places.Length;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="count"></param>
|
||||||
public SetGeneric(int count)
|
public SetGeneric(int count)
|
||||||
{
|
{
|
||||||
_places = new T?[count];
|
_places = new T?[count];
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта в набор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="boat">Добавляемая лодка</param>
|
||||||
|
/// <returns></returns>
|
||||||
public int Insert(T boat)
|
public int Insert(T boat)
|
||||||
{
|
{
|
||||||
return Insert(boat, 0);
|
return Insert(boat, 0);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта в набор на конкретную позицию
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="boat">Добавляемая лодка</param>
|
||||||
|
/// <param name="position">Позиция</param>
|
||||||
|
/// <returns></returns>
|
||||||
public int Insert(T boat, int position)
|
public int Insert(T boat, int position)
|
||||||
{
|
{
|
||||||
int nullIndex = -1, i;
|
int nullIndex = -1, i;
|
||||||
@ -49,6 +70,11 @@ namespace Sailboat.Generics
|
|||||||
_places[position] = boat;
|
_places[position] = boat;
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление объекта из набора с конкретной позиции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (position < 0 || position >= Count)
|
||||||
@ -59,6 +85,11 @@ namespace Sailboat.Generics
|
|||||||
_places[position] = null;
|
_places[position] = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объекта из набора по позиции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count)
|
if (position < 0 || position >= Count)
|
||||||
|
Loading…
Reference in New Issue
Block a user