PIbd-21_Krasnikov_Lab1.base/WinFormsApp1/DrawningObjectTraktor.cs

47 lines
1.2 KiB
C#
Raw Permalink Normal View History

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tractors;
namespace WinFormsApp1
{
class DrawningObjectTractor : IDrawningObject
{
private TractorDraw _tractor = null;
public DrawningObjectTractor(TractorDraw tractor)
{
_tractor = tractor;
}
public float Step => _tractor?.Tractor?.Step ?? 0;
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return _tractor?.GetCurrentPosition() ?? default;
}
public string GetInfo() => _tractor?.GetDataForSave();
public static IDrawningObject Create(string data) => new DrawningObjectTractor(data.CreateDrawingTraktor());
public void MoveObject(Direction direction)
{
_tractor?.MoveTransport(direction);
}
public void SetObject(int x, int y, int width, int height)
{
_tractor.SetPosition(x, y, width, height);
}
void IDrawningObject.DrawningObject(Graphics g)
{
_tractor.DrawEntity(g);
}
}
}