PIbd-11 Levchenko G.A. Lab Work 05 Base #5
@ -130,12 +130,14 @@ public class DrawningTrolleyB
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
||||
//то надо изменить координаты, чтобы он оставался в этих границах
|
||||
if (x + _drawningVehicleWidth > _pictureWidth)
|
||||
{
|
||||
@ -150,6 +152,7 @@ public class DrawningTrolleyB
|
||||
}
|
||||
else if (y < 0) _startPosY = 0;
|
||||
else _startPosY = y;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ public partial class FormTrolleyBCollection : Form
|
||||
/// Добавление автомобиля в коллекцию
|
||||
/// </summary>
|
||||
/// <param name="car"></param>
|
||||
private void SetTrolleyB(DrawningTrolleyB? trolleyB)
|
||||
private void SetTrolleyB(DrawningTrolleyB trolleyB)
|
||||
{
|
||||
if (_company == null || trolleyB == null)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ public partial class FormTrolleyBConfig : Form
|
||||
/// </summary>
|
||||
public FormTrolleyBConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelRed.MouseDown += Panel_MouseDown;
|
||||
panelGreen.MouseDown += Panel_MouseDown;
|
||||
panelBlue.MouseDown += Panel_MouseDown;
|
||||
@ -35,7 +36,7 @@ public partial class FormTrolleyBConfig : Form
|
||||
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -55,7 +56,7 @@ public partial class FormTrolleyBConfig : Form
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_trolleyB?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
_trolleyB?.SetPosition(5, 5);
|
||||
_trolleyB?.SetPosition(5, 5, Width, Height);
|
||||
_trolleyB?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user