Доработал SetPosition и SetPictureSize
This commit is contained in:
parent
d50a0855a0
commit
997c87a792
@ -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);
|
||||
}
|
||||
|
||||
// труба
|
||||
|
2
ProjectLiner/ProjectLiner/FormLiner.Designer.cs
generated
2
ProjectLiner/ProjectLiner/FormLiner.Designer.cs
generated
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user