diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs
index de49ee1..48bb52d 100644
--- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs
+++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ListGenericObjects.cs
@@ -20,16 +20,16 @@ namespace HoistingCrane.CollectionGenericObjects
/// Максимально допустимое число объектов в списке
///
private int _maxCount;
- public int Count
+ public int Count
{
get { return list.Count; }
}
- public int SetMaxCount
+ public int SetMaxCount
{
set
{
- if(value > 0)
+ if (value > 0)
{
_maxCount = value;
}
@@ -39,11 +39,8 @@ namespace HoistingCrane.CollectionGenericObjects
public T? Get(int position)
{
// TODO проверка позиции
- if(position >= 0 && position < _maxCount)
- {
- return list[position];
- }
- return null;
+ if (position >= Count || position < 0) return null;
+ return list[position];
}
@@ -51,9 +48,9 @@ namespace HoistingCrane.CollectionGenericObjects
{
// TODO проверка, что не превышено максимальное количество элементов
// TODO вставка в конец набора
- if (Count == _maxCount)
- {
- return -1;
+ if (Count == _maxCount)
+ {
+ return -1;
}
list.Add(obj);
return Count;
@@ -70,21 +67,18 @@ namespace HoistingCrane.CollectionGenericObjects
}
list.Insert(position, obj);
return position;
-
-
}
-
public T? Remove(int position)
{
// TODO проверка позиции
// TODO удаление объекта из списка
- if(position >= 0 && position < list.Count)
+ if (position >= 0 && position < list.Count)
{
T? temp = list[position];
list.RemoveAt(position);
return temp;
}
return null;
- }
+ }
}
}
diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs
index 0765bd3..d1e5183 100644
--- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs
+++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/StorageCollection.cs
@@ -60,5 +60,4 @@ namespace HoistingCrane.CollectionGenericObjects
}
}
}
-
}
diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.cs b/HoistingCrane/HoistingCrane/FormCarCollection.cs
index 7e10c97..bd42830 100644
--- a/HoistingCrane/HoistingCrane/FormCarCollection.cs
+++ b/HoistingCrane/HoistingCrane/FormCarCollection.cs
@@ -64,9 +64,29 @@ namespace HoistingCrane
}
return color;
}
- private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningHoistingCrane));
+ private void buttonCreateHoistingCrane_Click(object sender, EventArgs e)
+ {
+ FormCarConfig form = new();
+ form.Show();
+ form.AddEvent(SetCar);
+ }
+ private void SetCar(DrawningTrackedVehicle drawningTrackedVehicle)
+ {
+ if (_company == null || drawningTrackedVehicle == null)
+ {
+ return;
+ }
- private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrackedVehicle));
+ if (_company + drawningTrackedVehicle != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
private void buttonDeleteCar_Click(object sender, EventArgs e)
{
diff --git a/HoistingCrane/HoistingCrane/FormCarConfig.cs b/HoistingCrane/HoistingCrane/FormCarConfig.cs
index 3135eb7..9105a92 100644
--- a/HoistingCrane/HoistingCrane/FormCarConfig.cs
+++ b/HoistingCrane/HoistingCrane/FormCarConfig.cs
@@ -117,11 +117,10 @@ namespace HoistingCrane
///
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
- if (car != null)
- {
- car.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
- DrawObject();
- }
+ if (car == null)
+ return;
+ car.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
+ DrawObject();
}
///
/// Передача основного цвета