Pibd-13 Fathutdinov.A.I LabWork01 Simple #1

Closed
gettterot wants to merge 3 commits from labWork_01 into main
2 changed files with 42 additions and 14 deletions
Showing only changes of commit 997c87a792 - Show all commits

View File

@ -33,7 +33,7 @@ public class DrawningLiner
/// <summary>
/// Ширина прорисовки лайнера
/// </summary>
private readonly int _drawningLinerWidth = 180;
private readonly int _drawningLinerWidth = 150;
/// <summary>
/// Высота прорисовки лайнера
@ -68,9 +68,29 @@ public class DrawningLiner
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
public bool SetPictureSize(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
return true;
if (width > _drawningLinerWidth && height > _drawningLinerHeight)
{
_pictureWidth = width;
_pictureHeight = height;
if (_startPosX != null && _startPosY != null)
{
if (_startPosX.Value < 0)
_startPosX = 0;
if (_startPosY.Value < 0)
_startPosY = 0;
if (_startPosX.Value + _drawningLinerWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningLinerWidth;
}
if (_startPosY.Value + _drawningLinerHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawningLinerHeight;
}
}
return true;
}
return false;
}
/// <summary>
@ -84,16 +104,22 @@ public class DrawningLiner
{
return;
}
if (x < 0 || y < 0)
else
{
return;
_startPosX = x;
_startPosY = y;
if (_startPosX.Value + _drawningLinerWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningLinerWidth;
}
if (_startPosY.Value + _drawningLinerHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawningLinerHeight;
}
}
_startPosX = x;
_startPosY = y;
}
/// <summary>
/// Изменение направления перемещения
/// </summary>
@ -169,7 +195,7 @@ public class DrawningLiner
Point point1 = new Point(_startPosX.Value, _startPosY.Value + 80);
Point point2 = new Point(_startPosX.Value + 50, _startPosY.Value + 130);
Point point3 = new Point(_startPosX.Value + 135, _startPosY.Value + 130);
Point point4 = new Point(_startPosX.Value + 185, _startPosY.Value + 80);
Point point4 = new Point(_startPosX.Value + 155, _startPosY.Value + 80);
Point[] curvePoints = { point1, point2, point3, point4 };
g.FillPolygon(br, curvePoints);
@ -185,9 +211,9 @@ public class DrawningLiner
// шлюпки
if (EntityLiner.Boats)
{
g.FillEllipse(additionalBrush, _startPosX.Value + 60, _startPosY.Value + 85, 30, 15);
g.FillEllipse(additionalBrush, _startPosX.Value + 95, _startPosY.Value + 85, 30, 15);
g.FillEllipse(additionalBrush, _startPosX.Value + 130, _startPosY.Value + 85, 30, 15);
g.FillEllipse(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 85, 30, 15);
g.FillEllipse(additionalBrush, _startPosX.Value + 75, _startPosY.Value + 85, 30, 15);
g.FillEllipse(additionalBrush, _startPosX.Value + 110, _startPosY.Value + 85, 30, 15);
}
// труба

View File

@ -39,6 +39,7 @@
//
// pictureBoxLiner
//
pictureBoxLiner.BackColor = SystemColors.Control;
pictureBoxLiner.Dock = DockStyle.Fill;
pictureBoxLiner.Location = new Point(0, 0);
pictureBoxLiner.Name = "pictureBoxLiner";
@ -48,6 +49,7 @@
//
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreate.Location = new Point(12, 520);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(150, 82);