Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c4de4279c9 | ||
|
98281c3db4 | ||
|
37f598f718 | ||
|
9db213aec2 |
140
Trolleybus/Trolleybus/AbstractMap.cs
Normal file
140
Trolleybus/Trolleybus/AbstractMap.cs
Normal file
@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Trolleybus
|
||||
{
|
||||
internal abstract class AbstractMap
|
||||
{
|
||||
private IDrawningObject _drawningObject = null;
|
||||
protected int[,] _map = null;
|
||||
protected int _width;
|
||||
protected int _height;
|
||||
protected float _size_x;
|
||||
protected float _size_y;
|
||||
protected readonly Random _random = new Random();
|
||||
protected readonly int _freeRoad = 0;
|
||||
protected readonly int _barrier = 1;
|
||||
|
||||
public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject)
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
_drawningObject = drawningObject;
|
||||
GenerateMap();
|
||||
while (!SetObjectOnMap())
|
||||
{
|
||||
GenerateMap();
|
||||
}
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
public Bitmap MoveObject(Direction direction)
|
||||
{
|
||||
(float leftX, float topY, float rightX, float bottomY) = _drawningObject.GetCurrentPosition();
|
||||
|
||||
for (int i = 0; i < _map.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); j++)
|
||||
{
|
||||
if (_map[i, j] == _barrier)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Up:
|
||||
if (_size_y * (j + 1) >= topY - _drawningObject.Step && _size_y * (j + 1) < topY && _size_x * (i + 1) > leftX
|
||||
&& _size_x * (i + 1) <= rightX)
|
||||
{
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
if (_size_y * j <= bottomY + _drawningObject.Step && _size_y * j > bottomY && _size_x * (i + 1) > leftX
|
||||
&& _size_x * (i + 1) <= rightX)
|
||||
{
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
break;
|
||||
case Direction.Left:
|
||||
if (_size_x * (i + 1) >= leftX - _drawningObject.Step && _size_x * (i + 1) < leftX && _size_y * (j + 1) < bottomY
|
||||
&& _size_y * (j + 1) >= topY)
|
||||
{
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
break;
|
||||
case Direction.Right:
|
||||
if (_size_x * i <= rightX + _drawningObject.Step && _size_x * i > leftX && _size_y * (j + 1) < bottomY
|
||||
&& _size_y * (j + 1) >= topY)
|
||||
{
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_drawningObject.MoveObject(direction);
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
private bool SetObjectOnMap()
|
||||
{
|
||||
(float leftX, float topY, float rightX, float bottomY) = _drawningObject.GetCurrentPosition();
|
||||
if (_drawningObject == null || _map == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float airplaneWidth = rightX - leftX;
|
||||
float airplaneHeight = bottomY - topY;
|
||||
|
||||
int x = _random.Next(0, 10);
|
||||
int y = _random.Next(0, 10);
|
||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||
{
|
||||
if (_map[i, j] == _barrier)
|
||||
{
|
||||
if (x + airplaneWidth >= _size_x * i && x <= _size_x * i && y + airplaneHeight > _size_y * j && y <= _size_y * j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_drawningObject.SetObject(x, y, _width, _height);
|
||||
return true;
|
||||
}
|
||||
private Bitmap DrawMapWithObject()
|
||||
{
|
||||
Bitmap bmp = new(_width, _height);
|
||||
if (_drawningObject == null || _map == null)
|
||||
{
|
||||
return bmp;
|
||||
}
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||
{
|
||||
if (_map[i, j] == _freeRoad)
|
||||
{
|
||||
DrawRoadPart(gr, i, j);
|
||||
}
|
||||
else if (_map[i, j] == _barrier)
|
||||
{
|
||||
DrawBarrierPart(gr, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
_drawningObject.DrawningObject(gr);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
protected abstract void GenerateMap();
|
||||
protected abstract void DrawRoadPart(Graphics g, int i, int j);
|
||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ namespace Trolleybus
|
||||
/// </summary>
|
||||
internal enum Direction
|
||||
{
|
||||
None = 0,
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
|
84
Trolleybus/Trolleybus/DrawingSmallTrolleybus.cs
Normal file
84
Trolleybus/Trolleybus/DrawingSmallTrolleybus.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Trolleybus
|
||||
{
|
||||
internal class DrawningSmallTrolleybus : DrawingTrolleybus
|
||||
{
|
||||
public DrawningSmallTrolleybus(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool horns, bool battary) :
|
||||
base(speed, weight, bodyColor, 110, 60)
|
||||
{
|
||||
Trolleybus = new EntitySmallTrolleybus(speed, weight, bodyColor, dopColor, bodyKit, wing, horns, battary);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (Trolleybus is not EntitySmallTrolleybus smallTrolleybus)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new Pen(Color.Black);
|
||||
Brush dopBrush = new SolidBrush(smallTrolleybus.DopColor);
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
Brush dBlue = new SolidBrush(Color.DarkBlue);
|
||||
Brush bWhite = new SolidBrush(Color.White);
|
||||
Pen WinBlue = new Pen(Color.Blue);
|
||||
|
||||
//_startPosY = _startPosY + 100;
|
||||
base.DrawTransport(g);
|
||||
if (smallTrolleybus.BodyKit)
|
||||
{
|
||||
g.DrawRectangle(pen, _startPosX, _startPosY, 200, 50);
|
||||
g.DrawRectangle(pen, _startPosX + 100, _startPosY + 10, 20, 40);
|
||||
g.FillEllipse(brBlue, _startPosX, _startPosY + 5, 20, 25);
|
||||
g.DrawEllipse(WinBlue, _startPosX, _startPosY + 5, 20, 25);
|
||||
g.FillEllipse(brBlue, _startPosX + 25, _startPosY + 5, 20, 25);
|
||||
g.DrawEllipse(WinBlue, _startPosX + 25, _startPosY + 5, 20, 25);
|
||||
g.FillEllipse(brBlue, _startPosX + 50, _startPosY + 5, 20, 25);
|
||||
g.DrawEllipse(WinBlue, _startPosX + 50, _startPosY + 5, 20, 25);
|
||||
g.FillEllipse(brBlue, _startPosX + 75, _startPosY + 5, 20, 25);
|
||||
g.DrawEllipse(WinBlue, _startPosX + 75, _startPosY + 5, 20, 25);
|
||||
g.FillEllipse(brBlue, _startPosX + 120, _startPosY + 5, 20, 25);
|
||||
g.DrawEllipse(WinBlue, _startPosX + 120, _startPosY + 5, 20, 25);
|
||||
g.FillEllipse(brBlue, _startPosX + 145, _startPosY + 5, 20, 25);
|
||||
g.DrawEllipse(WinBlue, _startPosX + 145, _startPosY + 5, 20, 25);
|
||||
g.FillEllipse(brBlue, _startPosX + 170, _startPosY + 5, 20, 25);
|
||||
g.DrawEllipse(WinBlue, _startPosX + 170, _startPosY + 5, 20, 25);
|
||||
g.FillEllipse(bWhite, _startPosX, _startPosY + 40, 30, 30);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY + 40, 30, 30);
|
||||
g.FillEllipse(bWhite, _startPosX + 170, _startPosY + 40, 30, 30);
|
||||
g.DrawEllipse(pen, _startPosX + 170, _startPosY + 40, 30, 30);
|
||||
}
|
||||
|
||||
//_startPosX += 10;
|
||||
//_startPosY += 5;
|
||||
//base.DrawTransport(g);
|
||||
//_startPosX -= 10;
|
||||
//_startPosY -= 5;
|
||||
|
||||
if (smallTrolleybus.Horns)
|
||||
{
|
||||
g.DrawLine(pen, _startPosX + 100, _startPosY - 10, _startPosX + 150, _startPosY - 20);
|
||||
g.DrawLine(pen, _startPosX + 150, _startPosY - 20, _startPosX, _startPosY - 30);
|
||||
//g.DrawRectangle(pen, _startPosX + 50, _startPosY - 40, 100, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 50, _startPosY - 10, 100, 10);
|
||||
}
|
||||
|
||||
if (smallTrolleybus.Battary)
|
||||
{
|
||||
g.DrawRectangle(pen, _startPosX + 100, _startPosY, 10, 10);
|
||||
}
|
||||
|
||||
if (smallTrolleybus.Wing)
|
||||
{
|
||||
//g.FillRectangle(dopBrush, _startPosX, _startPosY + 5, 10, 50);
|
||||
//g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,23 +13,23 @@ namespace Trolleybus
|
||||
/// </summary>
|
||||
internal class DrawingTrolleybus
|
||||
{
|
||||
public EntityTrolleybus Trolleybus { get; private set; }
|
||||
public EntityTrolleybus Trolleybus { get; protected set; }
|
||||
/// <summary>
|
||||
/// левая координата отрисовки
|
||||
/// </summary>
|
||||
private float _startPosX;
|
||||
public float _startPosX;
|
||||
/// <summary>
|
||||
/// верхняя координата отрисовки
|
||||
/// </summary>
|
||||
private float _startPosY;
|
||||
public float _startPosY;
|
||||
/// <summary>
|
||||
/// левая координата начала отрисовки
|
||||
/// </summary>
|
||||
private float _startX;
|
||||
public float _startX;
|
||||
/// <summary>
|
||||
/// Верхняя координата начала отрисовки
|
||||
/// </summary>
|
||||
private float _startY;
|
||||
public float _startY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
@ -52,10 +52,15 @@ namespace Trolleybus
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public DrawingTrolleybus(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Trolleybus = new EntityTrolleybus();
|
||||
Trolleybus.Init(speed, weight, bodyColor);
|
||||
Trolleybus = new EntityTrolleybus(speed, weight, bodyColor);
|
||||
}
|
||||
protected DrawingTrolleybus(int speed, float weight, Color bodyColor, int trolleybusWidth, int trolleybusHeight)
|
||||
{
|
||||
Trolleybus = new EntityTrolleybus(speed, weight, bodyColor);
|
||||
_trolleybusWidth = trolleybusWidth;
|
||||
_trolleybusHeight = trolleybusHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
@ -65,12 +70,12 @@ namespace Trolleybus
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
// public void SetPosition(int x, int y, int startX, int startY, int width, int height)
|
||||
public void SetPosition(int x, int y, int startX, int startY, int width, int height)
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_startX = startX;
|
||||
_startY = startY;
|
||||
// _startX = startX;
|
||||
// _startY = startY;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
@ -95,14 +100,16 @@ namespace Trolleybus
|
||||
break;
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if (_startPosX > _startX)
|
||||
{
|
||||
_startPosX -= Trolleybus.Step;
|
||||
// if (_startPosX > _startX)
|
||||
if (_startPosX - Trolleybus.Step > 0)
|
||||
{
|
||||
_startPosX -= Trolleybus.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
if (_startPosY > _startY)
|
||||
// if (_startPosY > _startY)
|
||||
if (_startPosY - Trolleybus.Step > 0)
|
||||
{
|
||||
_startPosY -= Trolleybus.Step;
|
||||
}
|
||||
@ -120,7 +127,7 @@ namespace Trolleybus
|
||||
/// Отрисовка троллейбуса
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
@ -177,5 +184,10 @@ namespace Trolleybus
|
||||
_startPosY = _pictureHeight.Value - _trolleybusHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _trolleybusWidth, _startPosY + _trolleybusHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
48
Trolleybus/Trolleybus/DrawningObject.cs
Normal file
48
Trolleybus/Trolleybus/DrawningObject.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.AxHost;
|
||||
|
||||
namespace Trolleybus
|
||||
{
|
||||
internal class DrawningObject : IDrawningObject
|
||||
{
|
||||
private DrawingTrolleybus _trolleybus = null;
|
||||
|
||||
public DrawningObject(DrawingTrolleybus car)
|
||||
{
|
||||
_trolleybus = car;
|
||||
}
|
||||
|
||||
public float Step => _trolleybus?.Trolleybus?.Step ?? 0;
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return _trolleybus?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_trolleybus?.MoveTransport(direction);
|
||||
}
|
||||
|
||||
public void nothing()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetObject(int x, int y, int width, int height)
|
||||
{
|
||||
// _trolleybus.SetPosition(x, y, startX, startY, width, height);
|
||||
_trolleybus.SetPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
void IDrawningObject.DrawningObject(Graphics g)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
46
Trolleybus/Trolleybus/DrawningObjectTrolleybus.cs
Normal file
46
Trolleybus/Trolleybus/DrawningObjectTrolleybus.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Trolleybus
|
||||
{
|
||||
internal class DrawningObjectTrolleybus : IDrawningObject
|
||||
{
|
||||
private DrawingTrolleybus _trolleybus = null;
|
||||
|
||||
public DrawningObjectTrolleybus(DrawingTrolleybus trolleybus)
|
||||
{
|
||||
_trolleybus = trolleybus;
|
||||
}
|
||||
|
||||
public float Step => _trolleybus?.Trolleybus?.Step ?? 0;
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return _trolleybus?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_trolleybus?.MoveTransport(direction);
|
||||
}
|
||||
|
||||
public void nothing()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetObject(int x, int y, int width, int height)
|
||||
{
|
||||
_trolleybus.SetPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
void IDrawningObject.DrawningObject(Graphics g)
|
||||
{
|
||||
_trolleybus.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
}
|
50
Trolleybus/Trolleybus/EntitySmallTrolleybus.cs
Normal file
50
Trolleybus/Trolleybus/EntitySmallTrolleybus.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Trolleybus
|
||||
{
|
||||
class EntitySmallTrolleybus : EntityTrolleybus
|
||||
{
|
||||
/// <summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color DopColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия обвеса
|
||||
/// </summary>
|
||||
public bool BodyKit { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия антикрыла
|
||||
/// </summary>
|
||||
public bool Wing { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия гоночной полосы
|
||||
/// </summary>
|
||||
public bool Horns { get; private set; }
|
||||
public bool Battary { get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="wing">Признак наличия антикрыла</param>
|
||||
/// <param name="horns">Признак наличия гоночной полосы</param>
|
||||
/// /// <param name="battary">Признак наличия гоночной полосы</param>
|
||||
public EntitySmallTrolleybus(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool horns, bool battary) :
|
||||
base(speed, weight, bodyColor)
|
||||
{
|
||||
DopColor = dopColor;
|
||||
BodyKit = bodyKit;
|
||||
Wing = wing;
|
||||
Horns = horns;
|
||||
Battary = battary;
|
||||
}
|
||||
}
|
||||
}
|
@ -35,12 +35,12 @@ namespace Trolleybus
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public EntityTrolleybus(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Speed = speed <= 0? rnd.Next(50, 150): speed;
|
||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||
bodyColor = bodyColor;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
17
Trolleybus/Trolleybus/Form1.Designer.cs
generated
17
Trolleybus/Trolleybus/Form1.Designer.cs
generated
@ -39,6 +39,7 @@ namespace Trolleybus
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.pictureBoxTrolleybus = new System.Windows.Forms.PictureBox();
|
||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTrolleybus)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -129,17 +130,28 @@ namespace Trolleybus
|
||||
//
|
||||
// pictureBoxTrolleybus
|
||||
//
|
||||
this.pictureBoxTrolleybus.Location = new System.Drawing.Point(12, 12);
|
||||
this.pictureBoxTrolleybus.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxTrolleybus.Name = "pictureBoxTrolleybus";
|
||||
this.pictureBoxTrolleybus.Size = new System.Drawing.Size(776, 413);
|
||||
this.pictureBoxTrolleybus.Size = new System.Drawing.Size(800, 450);
|
||||
this.pictureBoxTrolleybus.TabIndex = 0;
|
||||
this.pictureBoxTrolleybus.TabStop = false;
|
||||
//
|
||||
// buttonCreateModif
|
||||
//
|
||||
this.buttonCreateModif.Location = new System.Drawing.Point(94, 389);
|
||||
this.buttonCreateModif.Name = "buttonCreateModif";
|
||||
this.buttonCreateModif.Size = new System.Drawing.Size(86, 23);
|
||||
this.buttonCreateModif.TabIndex = 7;
|
||||
this.buttonCreateModif.Text = "Модификация";
|
||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonCreateModif);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
@ -169,6 +181,7 @@ namespace Trolleybus
|
||||
private System.Windows.Forms.Button buttonLeft;
|
||||
private System.Windows.Forms.Button buttonRight;
|
||||
private System.Windows.Forms.Button buttonUp;
|
||||
private System.Windows.Forms.Button buttonCreateModif;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,19 @@ namespace Trolleybus
|
||||
pictureBoxTrolleybus.Image = bmp;
|
||||
}
|
||||
|
||||
private void SetData()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
//Bitmap bmp = new Bitmap(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
//Graphics gr = Graphics.FromImage(bmp);
|
||||
//_trolleybus?.DrawTransport(gr);
|
||||
//pictureBoxTrolleybus.Image = bmp;
|
||||
_trolleybus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_trolleybus.Trolleybus.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {_trolleybus.Trolleybus.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {_trolleybus.Trolleybus.BodyColor.Name}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Создать"
|
||||
/// </summary>
|
||||
@ -38,13 +51,13 @@ namespace Trolleybus
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
_trolleybus = new DrawingTrolleybus();
|
||||
_trolleybus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_trolleybus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), Location.X, Location.Y, pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
// _trolleybus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_trolleybus.Trolleybus.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {_trolleybus.Trolleybus.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {_trolleybus.Trolleybus.BodyColor.Name}";
|
||||
_trolleybus = new DrawingTrolleybus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
// _trolleybus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), Location.X, Location.Y, pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
//_trolleybus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
//toolStripStatusLabelSpeed.Text = $"Скорость: {_trolleybus.Trolleybus.Speed}";
|
||||
//toolStripStatusLabelWeight.Text = $"Вес: {_trolleybus.Trolleybus.Weight}";
|
||||
//toolStripStatusLabelBodyColor.Text = $"Цвет: {_trolleybus.Trolleybus.BodyColor.Name}";
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
|
||||
@ -74,5 +87,16 @@ namespace Trolleybus
|
||||
_trolleybus?.ChangeBorders(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
_trolleybus = new DrawningSmallTrolleybus(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, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
199
Trolleybus/Trolleybus/FormMap.Designer.cs
generated
Normal file
199
Trolleybus/Trolleybus/FormMap.Designer.cs
generated
Normal file
@ -0,0 +1,199 @@
|
||||
namespace Trolleybus
|
||||
{
|
||||
partial class FormMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.pictureBoxTrolleybus = new System.Windows.Forms.PictureBox();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTrolleybus)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
this.toolStripStatusLabelBodyColor});
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 428);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(800, 22);
|
||||
this.statusStrip1.TabIndex = 1;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// toolStripStatusLabelSpeed
|
||||
//
|
||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(59, 17);
|
||||
this.toolStripStatusLabelSpeed.Text = "Скорость";
|
||||
//
|
||||
// toolStripStatusLabelWeight
|
||||
//
|
||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(26, 17);
|
||||
this.toolStripStatusLabelWeight.Text = "Вес";
|
||||
//
|
||||
// toolStripStatusLabelBodyColor
|
||||
//
|
||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(33, 17);
|
||||
this.toolStripStatusLabelBodyColor.Text = "Цвет";
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Location = new System.Drawing.Point(12, 390);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCreate.TabIndex = 2;
|
||||
this.buttonCreate.Text = "Создать";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// buttonCreateModif
|
||||
//
|
||||
this.buttonCreateModif.Location = new System.Drawing.Point(94, 389);
|
||||
this.buttonCreateModif.Name = "buttonCreateModif";
|
||||
this.buttonCreateModif.Size = new System.Drawing.Size(86, 23);
|
||||
this.buttonCreateModif.TabIndex = 7;
|
||||
this.buttonCreateModif.Text = "Модификация";
|
||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 21);
|
||||
this.comboBoxSelectorMap.TabIndex = 8;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.BackgroundImage = global::Trolleybus.Properties.Resources.up30;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(722, 353);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 6;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.BackgroundImage = global::Trolleybus.Properties.Resources.right30;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(758, 389);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 5;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.BackgroundImage = global::Trolleybus.Properties.Resources.left30;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(686, 389);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 4;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.BackgroundImage = global::Trolleybus.Properties.Resources.down30;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(722, 389);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 3;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// pictureBoxTrolleybus
|
||||
//
|
||||
this.pictureBoxTrolleybus.Location = new System.Drawing.Point(12, 12);
|
||||
this.pictureBoxTrolleybus.Name = "pictureBoxTrolleybus";
|
||||
this.pictureBoxTrolleybus.Size = new System.Drawing.Size(776, 413);
|
||||
this.pictureBoxTrolleybus.TabIndex = 0;
|
||||
this.pictureBoxTrolleybus.TabStop = false;
|
||||
//
|
||||
// FormMap
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.Controls.Add(this.buttonCreateModif);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
this.Controls.Add(this.pictureBoxTrolleybus);
|
||||
this.Name = "FormMap";
|
||||
this.Text = "Карта";
|
||||
this.statusStrip1.ResumeLayout(false);
|
||||
this.statusStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTrolleybus)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pictureBoxTrolleybus;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||
private System.Windows.Forms.Button buttonCreate;
|
||||
private System.Windows.Forms.Button buttonDown;
|
||||
private System.Windows.Forms.Button buttonLeft;
|
||||
private System.Windows.Forms.Button buttonRight;
|
||||
private System.Windows.Forms.Button buttonUp;
|
||||
private System.Windows.Forms.Button buttonCreateModif;
|
||||
private System.Windows.Forms.ComboBox comboBoxSelectorMap;
|
||||
}
|
||||
}
|
101
Trolleybus/Trolleybus/FormMap.cs
Normal file
101
Trolleybus/Trolleybus/FormMap.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Trolleybus
|
||||
{
|
||||
public partial class FormMap : Form
|
||||
{
|
||||
private AbstractMap _abstractMap;
|
||||
public FormMap()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractMap = new SimpleMap();
|
||||
}
|
||||
/// <summary>
|
||||
/// Заполнение информации по объекту
|
||||
/// </summary>
|
||||
/// <param name="trolleybus"></param>
|
||||
private void SetData(DrawingTrolleybus trolleybus)
|
||||
{
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {trolleybus.Trolleybus.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {trolleybus.Trolleybus.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {trolleybus.Trolleybus.BodyColor.Name}";
|
||||
pictureBoxTrolleybus.Image = _abstractMap.CreateMap(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height,
|
||||
new DrawningObjectTrolleybus(trolleybus));
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
var trolleybus = new DrawingTrolleybus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
SetData(trolleybus);
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение размеров формы
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//получаем имя кнопки
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
Direction dir = Direction.None;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
dir = Direction.Up;
|
||||
break;
|
||||
case "buttonDown":
|
||||
dir = Direction.Down;
|
||||
break;
|
||||
case "buttonLeft":
|
||||
dir = Direction.Left;
|
||||
break;
|
||||
case "buttonRight":
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
}
|
||||
pictureBoxTrolleybus.Image = _abstractMap?.MoveObject(dir);
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Модификация"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
var trolleybus = new DrawningSmallTrolleybus(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, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData(trolleybus);
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void comboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (comboBoxSelectorMap.Text)
|
||||
{
|
||||
case "Простая карта":
|
||||
_abstractMap = new SimpleMap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
Trolleybus/Trolleybus/FormMap.resx
Normal file
123
Trolleybus/Trolleybus/FormMap.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
42
Trolleybus/Trolleybus/IDrawingObject.cs
Normal file
42
Trolleybus/Trolleybus/IDrawingObject.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Trolleybus
|
||||
{
|
||||
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>
|
||||
void nothing();
|
||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace Trolleybus
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
54
Trolleybus/Trolleybus/SimpleMap.cs
Normal file
54
Trolleybus/Trolleybus/SimpleMap.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Trolleybus
|
||||
{
|
||||
class SimpleMap : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Цвет участка закрытого
|
||||
/// </summary>
|
||||
private readonly Brush barrierColor = new SolidBrush(Color.Black);
|
||||
/// <summary>
|
||||
/// Цвет участка открытого
|
||||
/// </summary>
|
||||
private readonly Brush roadColor = new SolidBrush(Color.Gray);
|
||||
|
||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
}
|
||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
}
|
||||
protected override void GenerateMap()
|
||||
{
|
||||
_map = new int[100, 100];
|
||||
_size_x = (float)_width / _map.GetLength(0);
|
||||
_size_y = (float)_height / _map.GetLength(1);
|
||||
int counter = 0;
|
||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||
{
|
||||
_map[i, j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
while (counter < 50)
|
||||
{
|
||||
int x = _random.Next(0, 100);
|
||||
int y = _random.Next(0, 100);
|
||||
if (_map[x, y] == _freeRoad)
|
||||
{
|
||||
_map[x, y] = _barrier;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
@ -46,8 +47,13 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AbstractMap.cs" />
|
||||
<Compile Include="Direction.cs" />
|
||||
<Compile Include="DrawingSmallTrolleybus.cs" />
|
||||
<Compile Include="DrawingTrolleybus.cs" />
|
||||
<Compile Include="DrawningObject.cs" />
|
||||
<Compile Include="DrawningObjectTrolleybus.cs" />
|
||||
<Compile Include="EntitySmallTrolleybus.cs" />
|
||||
<Compile Include="EntityTrolleybus.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
@ -55,11 +61,22 @@
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FormMap.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FormMap.Designer.cs">
|
||||
<DependentUpon>FormMap.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="IDrawingObject.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SimpleMap.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FormMap.resx">
|
||||
<DependentUpon>FormMap.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
114
Trolleybus/Trolleybus/save/Trolleybus.csproj
Normal file
114
Trolleybus/Trolleybus/save/Trolleybus.csproj
Normal file
@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{07E18270-5508-4D1A-A699-8B170C1E8502}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Trolleybus</RootNamespace>
|
||||
<AssemblyName>Trolleybus</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AbstractMap.cs" />
|
||||
<Compile Include="Direction.cs" />
|
||||
<Compile Include="DrawingSmallTrolleybus.cs" />
|
||||
<Compile Include="DrawingTrolleybus.cs" />
|
||||
<Compile Include="DrawningObject.cs" />
|
||||
<Compile Include="EntitySmallTrolleybus.cs" />
|
||||
<Compile Include="EntityTrolleybus.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FormMap.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FormMap.Designer.cs">
|
||||
<DependentUpon>FormMap.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="IDrawingObject.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SimpleMap.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FormMap.resx">
|
||||
<DependentUpon>FormMap.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\up30.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\left30.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\down30.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\right30.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user