Compare commits

..

2 Commits

Author SHA1 Message Date
2fd3db0774 fj 2024-05-16 10:28:53 +04:00
Илья
6c9d1aaf82 xv 2024-05-15 19:01:35 +04:00
2 changed files with 30 additions and 11 deletions

View File

@ -1,4 +1,5 @@
using ProjectTrain.Drawnings; using ProjectTrain.Drawnings;
using ProjectTrain.CollectionGenericObjects;
namespace ProjectTrain.CollectionGenericObjects namespace ProjectTrain.CollectionGenericObjects
{ {
@ -14,7 +15,23 @@ namespace ProjectTrain.CollectionGenericObjects
/// </summary> /// </summary>
private T?[] _collection; private T?[] _collection;
public int Count => _collection.Length; public int Count => _collection.Length;
public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } } public int SetMaxCount
{
set
{
if (value > 0)
{
if (_collection.Length > 0)
{
Array.Resize(ref _collection, value);
}
else
{
_collection = new T?[value];
}
}
}
}
/// <summary> /// <summary>
/// Конструктор /// Конструктор
@ -27,11 +44,10 @@ namespace ProjectTrain.CollectionGenericObjects
{ {
// TODO проверка позиции // TODO проверка позиции
if (position >= _collection.Length || position < 0) if (position >= _collection.Length || position < 0)
{ { return null; }
return null;
}
return _collection[position]; return _collection[position];
} }
public int Insert(T obj) public int Insert(T obj)
{ {
// TODO вставка в свободное место набора // TODO вставка в свободное место набора
@ -43,10 +59,12 @@ namespace ProjectTrain.CollectionGenericObjects
_collection[index] = obj; _collection[index] = obj;
return index; return index;
} }
index++; index++;
} }
return -1; return -1;
} }
public int Insert(T obj, int position) public int Insert(T obj, int position)
{ {
// TODO проверка позиции // TODO проверка позиции
@ -83,15 +101,16 @@ namespace ProjectTrain.CollectionGenericObjects
} }
return -1; return -1;
} }
public T Remove(int position) public T Remove(int position)
{ {
// TODO проверка позиции // TODO проверка позиции
// TODO удаление объекта из массива, присвоив элементу массива значение null // TODO удаление объекта из массива, присвоив элементу массива значение null
if (position >= _collection.Length || position < 0) if (position >= _collection.Length || position < 0)
{ return null; } { return null; }
T drawningTrain = _collection[position]; T obj = _collection[position];
_collection[position] = null; _collection[position] = null;
return drawningTrain; return obj;
} }
} }
} }

View File

@ -60,7 +60,7 @@
groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Controls.Add(panelCompanyTools); groupBoxTools.Controls.Add(panelCompanyTools);
groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(510, 0); groupBoxTools.Location = new Point(558, 0);
groupBoxTools.Margin = new Padding(3, 2, 3, 2); groupBoxTools.Margin = new Padding(3, 2, 3, 2);
groupBoxTools.Name = "groupBoxTools"; groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Padding = new Padding(3, 2, 3, 2); groupBoxTools.Padding = new Padding(3, 2, 3, 2);
@ -273,7 +273,7 @@
pictureBoxTrain.Location = new Point(0, 0); pictureBoxTrain.Location = new Point(0, 0);
pictureBoxTrain.Margin = new Padding(3, 2, 3, 2); pictureBoxTrain.Margin = new Padding(3, 2, 3, 2);
pictureBoxTrain.Name = "pictureBoxTrain"; pictureBoxTrain.Name = "pictureBoxTrain";
pictureBoxTrain.Size = new Size(510, 490); pictureBoxTrain.Size = new Size(558, 490);
pictureBoxTrain.TabIndex = 1; pictureBoxTrain.TabIndex = 1;
pictureBoxTrain.TabStop = false; pictureBoxTrain.TabStop = false;
// //
@ -281,7 +281,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(704, 490); ClientSize = new Size(752, 490);
Controls.Add(pictureBoxTrain); Controls.Add(pictureBoxTrain);
Controls.Add(groupBoxTools); Controls.Add(groupBoxTools);
Margin = new Padding(3, 2, 3, 2); Margin = new Padding(3, 2, 3, 2);