Pibd-13 Fathutdinov.A.I LabWork01 Simple #1
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user