вроде готовая лаба 5
This commit is contained in:
parent
edc908eb30
commit
6f5482f0af
@ -144,6 +144,20 @@ namespace Sailboat.DrawingObjects
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,5 +64,10 @@ namespace Sailboat.DrawingObjects
|
||||
g.DrawLine(pen, new Point(_startPosX + 65, _startPosY + 120), new Point(_startPosX + 65, _startPosY));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAddColor(Color color)
|
||||
{
|
||||
((EntitySailboat)EntityBoat).AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ namespace Sailboat.Entities
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public void setBodyColor(Color color) { BodyColor = color; }
|
||||
public Color BodyColor { get; set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public EntityBoat(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
|
@ -8,8 +8,7 @@ namespace Sailboat.Entities
|
||||
{
|
||||
public class EntitySailboat : EntityBoat
|
||||
{
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public void setAdditionalColor(Color color) { AdditionalColor = color; }
|
||||
public Color AdditionalColor { get; set; }
|
||||
public bool Hull { get; private set; }
|
||||
public bool Sail { get; private set; }
|
||||
public EntitySailboat(int speed, double weight, Color bodyColor, Color
|
||||
|
@ -101,12 +101,12 @@ namespace Sailboat
|
||||
switch (((Label)sender).Name)
|
||||
{
|
||||
case "labelColor":
|
||||
_boat.EntityBoat.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
_boat.SetColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
case "labelAddColor":
|
||||
if (!(_boat is DrawingSailboat))
|
||||
return;
|
||||
(_boat.EntityBoat as EntitySailboat).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||
(_boat as DrawingSailboat).SetAddColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
}
|
||||
DrawBoat();
|
||||
|
Loading…
Reference in New Issue
Block a user