M.A. Zargarov Lab work 02 #2
@ -177,6 +177,13 @@ namespace DoubleDeckerBus
|
||||
_startPosY = _pictureHeight.Value - _busHeight;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _busWidth, _startPosY +_busHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ namespace DoubleDeckerBus
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="wing">Признак наличия антикрыла</param>
|
||||
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
||||
public DrawningDoubleDeckerBus(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) :
|
||||
/// <param name="secondFloor">Признак наличия второго этажа</param>
|
||||
/// <param name="line">Признак наличия полосы</param>
|
||||
public DrawningDoubleDeckerBus(int speed, float weight, Color bodyColor, Color dopColor, bool secondFloor, bool bodyKit, bool line) :
|
||||
base(speed, weight, bodyColor, 112, 50)
|
||||
{
|
||||
Bus = new EntityDoubleDeckerBus(speed, weight, bodyColor, dopColor, bodyKit,wing, sportLine);
|
||||
Bus = new EntityDoubleDeckerBus(speed, weight, bodyColor, dopColor, secondFloor, bodyKit, line);
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
@ -31,18 +31,29 @@ namespace DoubleDeckerBus
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush dopBrush = new SolidBrush(doubleDeckerBus.DopColor);
|
||||
if (doubleDeckerBus.BodyKit)
|
||||
if (doubleDeckerBus.SecondFloor)
|
||||
{
|
||||
//кузов
|
||||
g.FillRectangle(dopBrush, _startPosX, _startPosY, 115, 40);
|
||||
//граница автобуса
|
||||
g.DrawRectangle(pen, _startPosX, _startPosY, 115, 40);
|
||||
//стекла
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
g.FillEllipse(brBlue, _startPosX + 2, _startPosY + 2, 12, 20);
|
||||
g.FillEllipse(brBlue, _startPosX + 20, _startPosY + 2, 12, 20);
|
||||
g.FillEllipse(brBlue, _startPosX + 55, _startPosY + 2 , 12, 20);
|
||||
g.FillEllipse(brBlue, _startPosX + 70, _startPosY + 2, 12, 20);
|
||||
g.FillEllipse(brBlue, _startPosX + 85, _startPosY + 2, 12, 20);
|
||||
g.FillEllipse(brBlue, _startPosX + 100 , _startPosY + 2, 12, 20);
|
||||
|
||||
}
|
||||
_startPosX += 10;
|
||||
_startPosY += 5;
|
||||
_startPosY += 40;
|
||||
base.DrawTransport(g);
|
||||
_startPosX -= 10;
|
||||
_startPosY -= 5;
|
||||
if (doubleDeckerBus.SportLine)
|
||||
_startPosY -= 40;
|
||||
if (doubleDeckerBus.Line)
|
||||
{
|
||||
}
|
||||
if (doubleDeckerBus.Wing)
|
||||
if (doubleDeckerBus.BodyKit)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
35
DoubleDeckerBus/DoubleDeckerBus/DrawningObjectBus.cs
Normal file
35
DoubleDeckerBus/DoubleDeckerBus/DrawningObjectBus.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerBus
|
||||
{
|
||||
class DrawningObjectBus : IDrawningObject
|
||||
{
|
||||
private DrawningBus _bus = null;
|
||||
public DrawningObjectBus(DrawningBus 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);
|
||||
}
|
||||
public void DrawningObject(Graphics g)
|
||||
{
|
||||
_bus.DrawTransport(g);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -15,15 +15,15 @@ namespace DoubleDeckerBus
|
||||
/// <summary>
|
||||
/// Признак наличия обвеса
|
||||
/// </summary>
|
||||
public bool BodyKit { get; private set; }
|
||||
public bool SecondFloor{ get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия антикрыла
|
||||
/// </summary>
|
||||
public bool Wing { get; private set; }
|
||||
public bool BodyKit { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия гоночной полосы
|
||||
/// </summary>
|
||||
public bool SportLine { get; private set; }
|
||||
public bool Line { get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
@ -31,16 +31,16 @@ namespace DoubleDeckerBus
|
||||
/// <param name="weight">Вес автобуса</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="secondFloor">Признак наличия второго этажа</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="wing">Признак наличия антикрыла</param>
|
||||
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
||||
public EntityDoubleDeckerBus(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) :
|
||||
/// <param name="line">Признак наличия полосы</param>
|
||||
public EntityDoubleDeckerBus(int speed, float weight, Color bodyColor, Color dopColor, bool secondFloor, bool bodyKit, bool line) :
|
||||
base(speed, weight, bodyColor)
|
||||
{
|
||||
DopColor = dopColor;
|
||||
SecondFloor = secondFloor;
|
||||
BodyKit = bodyKit;
|
||||
Wing = wing;
|
||||
SportLine = sportLine;
|
||||
Line = line;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ namespace DoubleDeckerBus
|
||||
_bus = new DrawningDoubleDeckerBus(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Convert.ToBoolean(rnd.Next(0,1)), Convert.ToBoolean(rnd.Next(0, 1)), Convert.ToBoolean(rnd.Next(0, 1)));
|
||||
Convert.ToBoolean(rnd.Next(0,2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
|
40
DoubleDeckerBus/DoubleDeckerBus/IDrawningObject.cs
Normal file
40
DoubleDeckerBus/DoubleDeckerBus/IDrawningObject.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerBus
|
||||
{
|
||||
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>
|
||||
public void SetObject(int x, int y, int width, int height);
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения объекта
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns></returns>
|
||||
public void MoveObject(Direction direction);
|
||||
/// <summary>
|
||||
/// Отрисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public 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