labWork_04 #5

Merged
gettterot merged 11 commits from labWork_04 into labWork_05 2024-04-17 08:11:23 +04:00
2 changed files with 10 additions and 6 deletions
Showing only changes of commit bd746e9288 - Show all commits

View File

@ -50,10 +50,9 @@ public class DrawningLiner
/// <param name="anchor">Признак наличия якоря</param>
/// <param name="boats">Признак наличия шлюпок</param>
/// <param name="pipe">Признак наличия трубы</param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool anchor, bool boats, bool pipe)
public void Init(EntityLiner liner)
{
EntityLiner = new EntityLiner();
EntityLiner.Init(speed, weight, bodyColor, additionalColor, anchor, boats, pipe);
EntityLiner = liner;
_pictureWidth = null;
_pictureHeight = null;
_startPosX = null;
@ -108,7 +107,10 @@ public class DrawningLiner
{
_startPosX = x;
_startPosY = y;
if (_startPosX.Value < 0)
_startPosX = 0;
if (_startPosY.Value < 0)
_startPosY = 0;
if (_startPosX.Value + _drawningLinerWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningLinerWidth;

View File

@ -42,11 +42,13 @@ namespace ProjectLiner
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new();
_drawningLiner = new DrawningLiner();
_drawningLiner.Init(random.Next(100, 300), random.Next(1000, 3000),
EntityLiner liner = new EntityLiner();
liner.Init(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_drawningLiner = new DrawningLiner();
_drawningLiner.Init(liner);
_drawningLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height);
_drawningLiner.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();