правки лабы 6

This commit is contained in:
Полина Чубыкина 2023-12-06 10:12:12 +04:00
parent 8791edafb8
commit c9a2398e47
4 changed files with 3 additions and 21 deletions

View File

@ -144,20 +144,6 @@ namespace Sailboat.DrawingObjects
g.DrawEllipse(pen, _startPosX + 20, _startPosY + 100, 90, 40); g.DrawEllipse(pen, _startPosX + 20, _startPosY + 100, 90, 40);
} }
public void SetColor(Color color)
{
if (EntityBoat == null)
{
return;
}
EntityBoat.BodyColor = color;
}
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
{
_pictureWidth = pictureBoxWidth;
_pictureHeight = pictureBoxHeight;
}
} }
} }

View File

@ -64,10 +64,5 @@ namespace Sailboat.DrawingObjects
g.DrawLine(pen, new Point(_startPosX + 65, _startPosY + 120), new Point(_startPosX + 65, _startPosY)); g.DrawLine(pen, new Point(_startPosX + 65, _startPosY + 120), new Point(_startPosX + 65, _startPosY));
} }
} }
public void SetAddColor(Color color)
{
((EntitySailboat)EntityBoat).AdditionalColor = color;
}
} }
} }

View File

@ -11,6 +11,7 @@ namespace Sailboat.Entities
public Color AdditionalColor { get; set; } public Color AdditionalColor { get; set; }
public bool Hull { get; private set; } public bool Hull { get; private set; }
public bool Sail { get; private set; } public bool Sail { get; private set; }
public void setAdditionalColor(Color color) { AdditionalColor = color; }
public EntitySailboat(int speed, double weight, Color bodyColor, Color public EntitySailboat(int speed, double weight, Color bodyColor, Color
additionalColor, bool hull, bool sail) : base (speed, weight, bodyColor) additionalColor, bool hull, bool sail) : base (speed, weight, bodyColor)
{ {

View File

@ -101,12 +101,12 @@ namespace Sailboat
switch (((Label)sender).Name) switch (((Label)sender).Name)
{ {
case "labelColor": case "labelColor":
_boat.SetColor((Color)e.Data.GetData(typeof(Color))); _boat.EntityBoat.setBodyColor((Color)e.Data.GetData(typeof(Color)));
break; break;
case "labelAddColor": case "labelAddColor":
if (!(_boat is DrawingSailboat)) if (!(_boat is DrawingSailboat))
return; return;
(_boat as DrawingSailboat).SetAddColor((Color)e.Data.GetData(typeof(Color))); (_boat.EntityBoat as EntitySailboat).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
break; break;
} }
DrawBoat(); DrawBoat();