+Интерфейс
This commit is contained in:
parent
3e58001f7e
commit
b44b322dbd
40
Traktor/Traktor/DrawningObjectTraktor.cs
Normal file
40
Traktor/Traktor/DrawningObjectTraktor.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
28
Traktor/Traktor/IDrawningObject.cs
Normal file
28
Traktor/Traktor/IDrawningObject.cs
Normal file
@ -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; }
|
||||
/// Установка позиции объекта
|
||||
/// <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);
|
||||
/// Изменение направления пермещения объекта
|
||||
/// <param name="direction">Направление</param>
|
||||
void MoveObject(Direction direction);
|
||||
/// Отрисовка объекта
|
||||
/// <param name="g"></param>
|
||||
void DrawningObject(Graphics g);
|
||||
/// Получение текущей позиции объекта
|
||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user