Исправлено перемещение влево и вверх. Исправлен pictureBox
This commit is contained in:
parent
9da23c5b30
commit
ee9c15b506
@ -25,11 +25,11 @@ namespace Trolleybus
|
||||
/// <summary>
|
||||
/// левая координата начала отрисовки
|
||||
/// </summary>
|
||||
private float _startX;
|
||||
//private float _startX;
|
||||
/// <summary>
|
||||
/// Верхняя координата начала отрисовки
|
||||
/// </summary>
|
||||
private float _startY;
|
||||
//private float _startY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
@ -65,12 +65,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 +95,14 @@ namespace Trolleybus
|
||||
break;
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if (_startPosX > _startX)
|
||||
if (_startPosX - Trolleybus.Step > 0)
|
||||
{
|
||||
_startPosX -= Trolleybus.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
if (_startPosY > _startY)
|
||||
if (_startPosY - Trolleybus.Step > 0)
|
||||
{
|
||||
_startPosY -= Trolleybus.Step;
|
||||
}
|
||||
|
4
Trolleybus/Trolleybus/Form1.Designer.cs
generated
4
Trolleybus/Trolleybus/Form1.Designer.cs
generated
@ -129,9 +129,9 @@ namespace Trolleybus
|
||||
//
|
||||
// pictureBoxTrolleybus
|
||||
//
|
||||
this.pictureBoxTrolleybus.Location = new System.Drawing.Point(12, 12);
|
||||
this.pictureBoxTrolleybus.Location = new System.Drawing.Point(0, -1);
|
||||
this.pictureBoxTrolleybus.Name = "pictureBoxTrolleybus";
|
||||
this.pictureBoxTrolleybus.Size = new System.Drawing.Size(776, 413);
|
||||
this.pictureBoxTrolleybus.Size = new System.Drawing.Size(800, 451);
|
||||
this.pictureBoxTrolleybus.TabIndex = 0;
|
||||
this.pictureBoxTrolleybus.TabStop = false;
|
||||
//
|
||||
|
@ -40,8 +40,8 @@ namespace Trolleybus
|
||||
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);
|
||||
//_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(pictureBoxTrolleybus.Size.Height - 150, pictureBoxTrolleybus.Size.Height - 100), pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_trolleybus.Trolleybus.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {_trolleybus.Trolleybus.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {_trolleybus.Trolleybus.BodyColor.Name}";
|
||||
|
Loading…
Reference in New Issue
Block a user