From b44b322dbd938a6865b3e537f42aed0f688649d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=97=D0=B0=D1=85=D0=B0=D1=80=D0=BE=D0=B2?= Date: Mon, 26 Sep 2022 23:04:44 +0400 Subject: [PATCH] =?UTF-8?q?+=D0=98=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5?= =?UTF-8?q?=D0=B9=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Traktor/Traktor/DrawningObjectTraktor.cs | 40 ++++++++++++++++++++++++ Traktor/Traktor/IDrawningObject.cs | 28 +++++++++++++++++ Traktor/Traktor/TraktorDraw.cs | 5 +++ 3 files changed, 73 insertions(+) create mode 100644 Traktor/Traktor/DrawningObjectTraktor.cs create mode 100644 Traktor/Traktor/IDrawningObject.cs 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