Compare commits
3 Commits
f89e86bd93
...
10edf8895b
Author | SHA1 | Date | |
---|---|---|---|
10edf8895b | |||
7b693f5fd7 | |||
f36062d9d8 |
@ -106,7 +106,7 @@ namespace AntiAircraftGun
|
||||
FormAntiAirCraftGun form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedZenit)
|
||||
if ((obj + form.SelectedZenit)==1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowZenits();
|
||||
|
@ -51,31 +51,26 @@ namespace AntiAircraftGun.Generics
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(AntiAirCraftGunGenericCollection<T, U> collect, T? obj)
|
||||
public static int operator +(AntiAirCraftGunGenericCollection<T,U> collect, T? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
MessageBox.Show("Объект пустой. Невозможно добавить.");
|
||||
return false;
|
||||
}
|
||||
return collect?._collection.Insert(obj) ?? false;
|
||||
return -1;
|
||||
return collect?._collection.Insert(obj) ?? -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
/// </summary>
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static T? operator -(AntiAirCraftGunGenericCollection<T, U> collect, int pos)
|
||||
public static bool operator -(AntiAirCraftGunGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
T? obj = collect._collection.Get(pos);
|
||||
if (obj != null)
|
||||
return collect._collection.Remove(pos);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject
|
||||
/// </summary>
|
||||
@ -156,9 +151,21 @@ namespace AntiAircraftGun.Generics
|
||||
if (y + distance_between_objects >= maxY)
|
||||
{
|
||||
y = 0;
|
||||
x += obj.GetWidth + 10 + _placeSizeWidth;
|
||||
x += _placeSizeWidth;
|
||||
}
|
||||
}
|
||||
if (obj == null)
|
||||
{
|
||||
// Увеличиваем координату Y для следующего объекта
|
||||
y += distance_between_objects;
|
||||
|
||||
// Проверяем, если Y достигло максимума, изменяем X и сбрасываем Y
|
||||
if (y+distance_between_objects >= maxY)
|
||||
{
|
||||
y = 0;
|
||||
x += _placeSizeWidth;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,21 +35,21 @@ namespace AntiAircraftGun.Generics
|
||||
/// </summary>
|
||||
/// <param name="car">Добавляемый автомобиль</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T car)
|
||||
public int Insert(T car)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
return false;
|
||||
return -1;
|
||||
Insert(car, 0);
|
||||
return true;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
public bool Insert(T car, int position)
|
||||
public int Insert(T car, int position)
|
||||
{
|
||||
if (!(position >= 0 && position <= Count && _places.Count < _maxCount))
|
||||
return false;
|
||||
return -1;
|
||||
_places.Insert(position, car);
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user