lab3 + edgeColor
This commit is contained in:
parent
ee5d4a6878
commit
153af06a04
@ -29,8 +29,13 @@ namespace Sailboat
|
||||
private void btn_create_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_boat = new DrawingBoat(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
_boat = new DrawingBoat(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
||||
_boat.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||
pictureBoxBoat.Width, pictureBoxBoat.Height);
|
||||
SetData();
|
||||
@ -44,8 +49,19 @@ namespace Sailboat
|
||||
private void btn_create_sailboat_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_boat = new DrawingSailboat(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
Color edgeColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialogDop = new();
|
||||
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
edgeColor = dialogDop.Color;
|
||||
}
|
||||
_boat = new DrawingSailboat(rnd.Next(100, 300), rnd.Next(1000, 2000), color, edgeColor,
|
||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
_boat.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||
pictureBoxBoat.Width, pictureBoxBoat.Height);
|
||||
|
@ -20,10 +20,10 @@ namespace Sailboat
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="sail">Признак наличия паруса</param>
|
||||
/// <param name="extendedBody">Признак наличия усиленного корпуса</param>
|
||||
public DrawingSailboat(int speed, float weight, Color bodyColor, bool sail, bool extendedBody) :
|
||||
public DrawingSailboat(int speed, float weight, Color bodyColor, Color edgeColor , bool sail, bool extendedBody) :
|
||||
base(speed, weight, bodyColor, 80, 135)
|
||||
{
|
||||
Boat = new Sailboat(speed, weight, bodyColor, sail, extendedBody);
|
||||
Boat = new Sailboat(speed, weight, bodyColor, edgeColor, sail, extendedBody);
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
@ -33,7 +33,7 @@ namespace Sailboat
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush brush = new SolidBrush(Color.Black);
|
||||
Brush brush = new SolidBrush(sailboat.EdgeColor);
|
||||
|
||||
_startPosY += 40;
|
||||
_startPosX += 20;
|
||||
|
@ -118,7 +118,6 @@ namespace Sailboat
|
||||
|
||||
for (int i = 0; i < _setBoats.Count; i++)
|
||||
{
|
||||
|
||||
_setBoats.Get(i)?.SetObject(currentWidth * _placeSizeWidth,
|
||||
currentHeight * _placeSizeHeight,
|
||||
_pictureWidth, _pictureHeight);
|
||||
|
@ -17,6 +17,8 @@ namespace Sailboat
|
||||
/// Признак наличия паруса
|
||||
/// </summary>
|
||||
public bool Sail { get; private set; }
|
||||
|
||||
public Color EdgeColor{ get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
@ -25,9 +27,10 @@ namespace Sailboat
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="sail">Признак наличия паруса</param>
|
||||
/// <param name="extendedBody">Признак наличия усиленного корпуса</param>
|
||||
public Sailboat(int speed, float weight, Color bodyColor, bool sail, bool extendedBody) :
|
||||
public Sailboat(int speed, float weight, Color bodyColor, Color edgeColor, bool sail, bool extendedBody) :
|
||||
base(speed, weight, bodyColor)
|
||||
{
|
||||
EdgeColor = edgeColor;
|
||||
Sail = sail;
|
||||
ExtendedBody = extendedBody;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user