Turner I.A. LabWork02 #2

Merged
eegov merged 4 commits from LabWork02 into LabWork01 2022-09-30 11:29:53 +04:00
3 changed files with 84 additions and 0 deletions
Showing only changes of commit 95864521f3 - Show all commits

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();
}
}