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