Добавление интерфейса

This commit is contained in:
ityurner02@mail.ru 2022-09-18 14:39:26 +04:00
parent eb0dcce570
commit 95864521f3
3 changed files with 84 additions and 0 deletions

View File

@ -185,5 +185,12 @@ namespace AntiAircraftGun
_startPosY = _pictureHeight.Value - _antiAircrafGunHeight;
}
}
/// <summary>
/// Получение текущей позиции объекта
/// </summary>
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return (_startPosX, _startPosY, _startPosX + _antiAircrafGunWidth, _startPosY + _antiAircrafGunHeight);
}
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun
{
internal class DrawingObjectAntiAircraftGun : IDrawingObject
{
private DrawingAntiAircraftGun _antiAircraftGun = null;
public DrawingObjectAntiAircraftGun(DrawingAntiAircraftGun antiAircraftGun)
{
_antiAircraftGun = antiAircraftGun;
}
public float Step => _antiAircraftGun?.AntiAircraftGun?.Step ?? 0;
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return _antiAircraftGun?.GetCurrentPosition() ?? default;
}
public void MoveObject(Direction direction)
{
_antiAircraftGun?.MoveTransport(direction);
}
public void SetObject(int x, int y, int width, int height)
{
_antiAircraftGun.SetPosition(x, y, width, height);
}
void IDrawingObject.DrawingObjectAntiAircraftGun(Graphics g)
{
_antiAircraftGun?.DrawTransport(g);
}
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntiAircraftGun
{
/// <summary>
/// Интерфейс для работы с объектом, прорисовываемом на форме
/// </summary>
internal interface IDrawingObject
{
/// <summary>
/// Шаг перемещения объекта
/// </summary>
public float Step { get; }
/// <summary>
/// Установка позиции объекта
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина полотна</param>
/// <param name="height">Высота полотна</param>
void SetObject(int x, int y, int width, int height);
/// <summary>
/// Изменение направления пермещения объекта
/// </summary>
/// <param name="direction">Направление</param>
void MoveObject(Direction direction);
/// <summary>
/// Отрисовка объекта
/// </summary>
/// <param name="g"></param>
void DrawingObjectAntiAircraftGun(Graphics g);
/// <summary>
/// Получение текущей позиции объекта
/// </summary>
/// <returns></returns>
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
}
}