From 791f7ad61c0083625aefcc17a3f38ec574f5e596 Mon Sep 17 00:00:00 2001 From: shadowik Date: Tue, 20 Sep 2022 05:06:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs | 4 ++ .../DoubleDeckerBus/DrawingObjectBus.cs | 40 +++++++++++++++++++ .../DoubleDeckerBus/IDrawingObject.cs | 22 ++++++++++ 3 files changed, 66 insertions(+) create mode 100644 DoubleDeckerBus/DoubleDeckerBus/DrawingObjectBus.cs create mode 100644 DoubleDeckerBus/DoubleDeckerBus/IDrawingObject.cs diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs index 198539c..fa8b154 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/DrawingBus.cs @@ -117,5 +117,9 @@ namespace DoubleDeckerBus _startPosY = _pictureHeight.Value - _busHeight; } } + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() { + return (_startPosX, _startPosX + _busWidth, _startPosY, _startPosY + _busHeight) + } } } diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawingObjectBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawingObjectBus.cs new file mode 100644 index 0000000..9c09def --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/DrawingObjectBus.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DoubleDeckerBus +{ + internal class DrawingObjectBus : IDrawingObject + { + private DrawingBus _bus = null; + + public DrawingObjectBus(DrawingBus bus) + { + _bus = bus; + } + + public float Step => _bus?.Bus?.Step ?? 0; + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _bus?.GetCurrentPosition() ?? default; + } + + public void MoveObject(Direction direction) + { + _bus?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _bus.SetPosition(x, y, width, height); + } + + void IDrawingObject.DrawingObject(Graphics g) + { + // TODO + } + } +} diff --git a/DoubleDeckerBus/DoubleDeckerBus/IDrawingObject.cs b/DoubleDeckerBus/DoubleDeckerBus/IDrawingObject.cs new file mode 100644 index 0000000..c54ed57 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/IDrawingObject.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DoubleDeckerBus +{ + internal interface IDrawingObject + { + public float Step { get; } + + void SetObject(int x, int y, int width, int height); + + void MoveObject(Direction direction); + + void DrawingObject(Graphics g); + + (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + + } +}