Исправлено перемещение влево и вверх. Исправлен pictureBox

This commit is contained in:
Oleg 2022-09-30 11:22:36 +04:00
parent 9da23c5b30
commit ee9c15b506
3 changed files with 11 additions and 11 deletions

View File

@ -25,11 +25,11 @@ namespace Trolleybus
/// <summary> /// <summary>
/// левая координата начала отрисовки /// левая координата начала отрисовки
/// </summary> /// </summary>
private float _startX; //private float _startX;
/// <summary> /// <summary>
/// Верхняя координата начала отрисовки /// Верхняя координата начала отрисовки
/// </summary> /// </summary>
private float _startY; //private float _startY;
/// <summary> /// <summary>
/// Ширина окна отрисовки /// Ширина окна отрисовки
/// </summary> /// </summary>
@ -65,12 +65,12 @@ namespace Trolleybus
/// <param name="width">Ширина картинки</param> /// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</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 startX, int startY, int width, int height) public void SetPosition(int x, int y, int width, int height)
{ {
_startPosX = x; _startPosX = x;
_startPosY = y; _startPosY = y;
_startX = startX; // _startX = startX;
_startY = startY; // _startY = startY;
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
} }
@ -95,14 +95,14 @@ namespace Trolleybus
break; break;
//влево //влево
case Direction.Left: case Direction.Left:
if (_startPosX > _startX) if (_startPosX - Trolleybus.Step > 0)
{ {
_startPosX -= Trolleybus.Step; _startPosX -= Trolleybus.Step;
} }
break; break;
//вверх //вверх
case Direction.Up: case Direction.Up:
if (_startPosY > _startY) if (_startPosY - Trolleybus.Step > 0)
{ {
_startPosY -= Trolleybus.Step; _startPosY -= Trolleybus.Step;
} }

View File

@ -129,9 +129,9 @@ namespace Trolleybus
// //
// pictureBoxTrolleybus // 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.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.TabIndex = 0;
this.pictureBoxTrolleybus.TabStop = false; this.pictureBoxTrolleybus.TabStop = false;
// //

View File

@ -40,8 +40,8 @@ namespace Trolleybus
Random rnd = new Random(); Random rnd = new Random();
_trolleybus = new DrawingTrolleybus(); _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.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), 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(pictureBoxTrolleybus.Size.Height - 150, pictureBoxTrolleybus.Size.Height - 100), pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
toolStripStatusLabelSpeed.Text = $"Скорость: {_trolleybus.Trolleybus.Speed}"; toolStripStatusLabelSpeed.Text = $"Скорость: {_trolleybus.Trolleybus.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {_trolleybus.Trolleybus.Weight}"; toolStripStatusLabelWeight.Text = $"Вес: {_trolleybus.Trolleybus.Weight}";
toolStripStatusLabelBodyColor.Text = $"Цвет: {_trolleybus.Trolleybus.BodyColor.Name}"; toolStripStatusLabelBodyColor.Text = $"Цвет: {_trolleybus.Trolleybus.BodyColor.Name}";