5 лаба

This commit is contained in:
Geo7312 2024-04-15 11:03:44 +04:00
parent 950db371a3
commit 0c7bc6aa68
3 changed files with 8 additions and 4 deletions

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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;
}