From 42a4585ededaba7c2aabf960b2aeb4469c3328d9 Mon Sep 17 00:00:00 2001 From: Sem730 Date: Tue, 27 Sep 2022 11:07:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5?= =?UTF-8?q?=D0=B9=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectLocomotive/DrawningLocomotive.cs | 4 ++ .../ProjectLocomotive/DrawningObject.cs | 39 ++++++++++++++++ .../ProjectLocomotive/IDrawningObject.cs | 44 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 ProjectLocomotive/ProjectLocomotive/DrawningObject.cs create mode 100644 ProjectLocomotive/ProjectLocomotive/IDrawningObject.cs diff --git a/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs b/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs index ad2118a..38519a0 100644 --- a/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs +++ b/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs @@ -192,5 +192,9 @@ namespace ProjectLocomotive _startPosY = _pictureHeight.Value - _LocHeight; } } + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _LocWidth, _startPosY + _LocHeight); + } } } diff --git a/ProjectLocomotive/ProjectLocomotive/DrawningObject.cs b/ProjectLocomotive/ProjectLocomotive/DrawningObject.cs new file mode 100644 index 0000000..5ed82a4 --- /dev/null +++ b/ProjectLocomotive/ProjectLocomotive/DrawningObject.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLocomotive +{ + internal class DrawningObject : IDrawningObject + { + private DrawningLocomotive _loc = null; + public DrawningObject(DrawningLocomotive loc) + { + _loc = loc; + } + + public float Step => _loc?.Locomotivе?.Step ?? 0; + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _loc?.GetCurrentPosition() ?? default; + } + + public void MoveObject(Direction direction) + { + _loc?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _loc.SetPosition(x, y, width, height); + } + + void IDrawningObject.DrawningObject(Graphics g) + { + // TODO + } + } +} diff --git a/ProjectLocomotive/ProjectLocomotive/IDrawningObject.cs b/ProjectLocomotive/ProjectLocomotive/IDrawningObject.cs new file mode 100644 index 0000000..26a219f --- /dev/null +++ b/ProjectLocomotive/ProjectLocomotive/IDrawningObject.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLocomotive +{ + /// + /// Интерфейс для работы с объектом, прорисовываемым на форме + /// + 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(); + } +} +