fix
This commit is contained in:
parent
42e483a76d
commit
79c4158fba
@ -68,9 +68,9 @@ public abstract class AbstractCompany
|
|||||||
/// <param name="company">Компания</param>
|
/// <param name="company">Компания</param>
|
||||||
/// <param name="position">Номер удаляемого объекта</param>
|
/// <param name="position">Номер удаляемого объекта</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator -(AbstractCompany company, int position)
|
public static DrawingBoat? operator -(AbstractCompany company, int position)
|
||||||
{
|
{
|
||||||
return company._collection?.Remove(position) ?? false;
|
return company._collection?.Remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -91,7 +91,7 @@ public abstract class AbstractCompany
|
|||||||
{
|
{
|
||||||
Bitmap bitmap = new(_pictureWidth, _pictureHeight);
|
Bitmap bitmap = new(_pictureWidth, _pictureHeight);
|
||||||
Graphics graphics = Graphics.FromImage(bitmap);
|
Graphics graphics = Graphics.FromImage(bitmap);
|
||||||
DrawBackgound(graphics);
|
DrawBackground(graphics);
|
||||||
|
|
||||||
SetObjectsPosition();
|
SetObjectsPosition();
|
||||||
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
|
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
|
||||||
@ -107,7 +107,7 @@ public abstract class AbstractCompany
|
|||||||
/// Вывод заднего фона
|
/// Вывод заднего фона
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
protected abstract void DrawBackgound(Graphics g);
|
protected abstract void DrawBackground(Graphics g);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Расстановка объектов
|
/// Расстановка объектов
|
||||||
|
@ -20,13 +20,13 @@ public class BoatHarborService : AbstractCompany
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void DrawBackgound(Graphics g)
|
protected override void DrawBackground(Graphics g)
|
||||||
{
|
{
|
||||||
Pen pen = new(Color.BurlyWood, 4);
|
Pen pen = new(Color.BurlyWood, 4);
|
||||||
|
|
||||||
for (int startPosX = 5; (startPosX + _placeSizeWidth) < _pictureWidth; startPosX += (_placeSizeWidth + 8))
|
for (int startPosX = 5; (startPosX + _placeSizeWidth) < _pictureWidth; startPosX += _placeSizeWidth)
|
||||||
{
|
{
|
||||||
for (int startPosY = 5; (startPosY + _placeSizeHeight) < _pictureHeight; startPosY += (_placeSizeHeight + 8))
|
for (int startPosY = 5; (startPosY + _placeSizeHeight) < _pictureHeight; startPosY += _placeSizeHeight)
|
||||||
{
|
{
|
||||||
Point[] points =
|
Point[] points =
|
||||||
{
|
{
|
||||||
@ -45,18 +45,18 @@ public class BoatHarborService : AbstractCompany
|
|||||||
int startPosX = 10;
|
int startPosX = 10;
|
||||||
int startPosY = 10;
|
int startPosY = 10;
|
||||||
|
|
||||||
for (int i = 0; _collection.Get(i) != null; i++)
|
for (int i = 0; _collection?.Get(i) != null; i++)
|
||||||
{
|
{
|
||||||
if (startPosX + _placeSizeWidth > _pictureWidth)
|
if (startPosX + _placeSizeWidth > _pictureWidth)
|
||||||
{
|
{
|
||||||
startPosX = 5;
|
startPosX = 10;
|
||||||
startPosY += _placeSizeHeight + 8;
|
startPosY += _placeSizeHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
_collection?.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
|
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
|
||||||
_collection?.Get(i).SetPosition(startPosX, startPosY);
|
_collection.Get(i).SetPosition(startPosX, startPosY);
|
||||||
|
|
||||||
startPosX += _placeSizeWidth + 8;
|
startPosX += _placeSizeWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
||||||
bool Remove(int position);
|
T? Remove(int position);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта по позиции
|
/// Получение объекта по позиции
|
||||||
|
@ -43,7 +43,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции ✔
|
// TODO проверка позиции ✔
|
||||||
if (_collection[position] != null)
|
if (_collection[position] != null && position < Count - 1)
|
||||||
{
|
{
|
||||||
return _collection[position];
|
return _collection[position];
|
||||||
}
|
}
|
||||||
@ -95,16 +95,16 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(int position)
|
public T? Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции ✔
|
// TODO проверка позиции ✔
|
||||||
// TODO удаление объекта из массива, присвоив элементу массива значение null ✔
|
// TODO удаление объекта из массива, присвоив элементу массива значение null ✔
|
||||||
if (_collection[position] != null)
|
if (_collection[position] != null)
|
||||||
{
|
{
|
||||||
_collection[position] = null;
|
_collection[position] = null;
|
||||||
return true;
|
return _collection[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public partial class FormBoatCollection : Form
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_company + drawingBoat != null)
|
if (_company + drawingBoat >= 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
@ -125,7 +125,7 @@ public partial class FormBoatCollection : Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_company - pos)
|
if (_company - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user