Kasatkin S.P LabWork2 #2
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
39
ProjectLocomotive/ProjectLocomotive/DrawningObject.cs
Normal file
39
ProjectLocomotive/ProjectLocomotive/DrawningObject.cs
Normal file
@ -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
|
||||
}
|
||||
}
|
||||
}
|
44
ProjectLocomotive/ProjectLocomotive/IDrawningObject.cs
Normal file
44
ProjectLocomotive/ProjectLocomotive/IDrawningObject.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectLocomotive
|
||||
{
|
||||
/// <summary>
|
||||
/// Интерфейс для работы с объектом, прорисовываемым на форме
|
||||
/// </summary>
|
||||
internal interface IDrawningObject
|
||||
{
|
||||
/// <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>
|
||||
/// <returns></returns>
|
||||
void MoveObject(Direction direction);
|
||||
/// <summary>
|
||||
/// Отрисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
void DrawningObject(Graphics g);
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user