diff --git a/Traktor/Traktor/DrawningObjectTraktor.cs b/Traktor/Traktor/DrawningObjectTraktor.cs new file mode 100644 index 0000000..a0963ed --- /dev/null +++ b/Traktor/Traktor/DrawningObjectTraktor.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Traktor +{ + internal class DrawningObjectTraktor : IDrawningObject + { + private TraktorDraw _traktor = null; + + public DrawningObjectTraktor(TraktorDraw traktor) + { + _traktor = traktor; + } + + public float Step => _traktor?.Traktor?.Step ?? 0; + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _traktor?.GetCurrentPosition() ?? default; + } + + public void MoveObject(Direction direction) + { + _traktor?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _traktor.SetPosition(x, y, width, height); + } + + void IDrawningObject.DrawningObject(Graphics g) + { + _traktor.DrawEntity(g); + } + } +} diff --git a/Traktor/Traktor/IDrawningObject.cs b/Traktor/Traktor/IDrawningObject.cs new file mode 100644 index 0000000..1c3c940 --- /dev/null +++ b/Traktor/Traktor/IDrawningObject.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Traktor +{ + internal interface IDrawningObject + { + /// Шаг перемещения объекта + public float Step { get; } + /// Установка позиции объекта + /// Координата X + /// Координата Y + /// Ширина полотна + /// Высота полотна + void SetObject(int x, int y, int width, int height); + /// Изменение направления пермещения объекта + /// Направление + void MoveObject(Direction direction); + /// Отрисовка объекта + /// + void DrawningObject(Graphics g); + /// Получение текущей позиции объекта + (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + } +} diff --git a/Traktor/Traktor/TraktorDraw.cs b/Traktor/Traktor/TraktorDraw.cs index 1681188..63f7810 100644 --- a/Traktor/Traktor/TraktorDraw.cs +++ b/Traktor/Traktor/TraktorDraw.cs @@ -153,5 +153,10 @@ namespace Traktor startPosY = pictureHeight.Value - entHeight; } } + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (startPosX, startPosY, startPosX + entWidth, startPosY + entHeight); + } } } \ No newline at end of file