Лабараторная работа №2 2

This commit is contained in:
IlyasValiulov 2024-02-19 15:29:36 +04:00
parent 75a051074f
commit 0619b0de35
5 changed files with 14 additions and 32 deletions

View File

@ -8,27 +8,22 @@ public class DrawningShip
/// Класс-сущность
/// </summary>
public EntityShip? EntityShip { get; protected set; }
/// <summary>
/// Ширина окна
/// </summary>
private int? _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
private int? _pictureHeight;
/// <summary>
/// Левая координата прорисовки
/// </summary>
protected int? _startPosX;
/// <summary>
/// Верхняя кооридната прорисовки
/// </summary>
protected int? _startPosY;
/// <summary>
/// Ширина прорисовки
/// </summary>

View File

@ -4,10 +4,6 @@ namespace ProjectWarmlyShip.Drawnings;
public class DrawningWarmlyShip : DrawningShip
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityWarmlyShip? EntityWarmlyShip { get; private set; }
/// <summary>
/// Конструктор
/// </summary>
@ -36,15 +32,8 @@ public class DrawningWarmlyShip : DrawningShip
base.DrawTransport(g);
if (warmlyship.FuelTank)
{
//if (EntityWarmlyShip.ShipPipes)
//{
// g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 120, 70, 10);
//}
//else
// g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 60, 70, 10);
g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 60, 70, 10);
}
if (warmlyship.ShipPipes) _startPosY -= 60;
}
}

View File

@ -12,6 +12,17 @@ namespace ProjectWarmlyShip
InitializeComponent();
_strategy = null;
}
private void Draw()
{
if (_drawningShip == null)
{
return;
}
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningShip.DrawTransport(gr);
pictureBoxWarmlyShip.Image = bmp;
}
private void CreateObject(string type)
{
Random random = new Random();
@ -34,11 +45,7 @@ namespace ProjectWarmlyShip
_drawningShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
_strategy = null;
comboBoxStrategy.Enabled = true;
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningShip.DrawTransport(gr);
pictureBoxWarmlyShip.Image = bmp;
Draw();
}
/// <summary>
/// Кнопка создания теплохода
@ -83,10 +90,7 @@ namespace ProjectWarmlyShip
}
if (result)
{
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningShip.DrawTransport(gr);
pictureBoxWarmlyShip.Image = bmp;
Draw();
}
}
private void buttonStrategyStep_Click(object sender, EventArgs e)
@ -116,10 +120,7 @@ namespace ProjectWarmlyShip
}
comboBoxStrategy.Enabled = false;
_strategy.MakeStep();
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningShip.DrawTransport(gr);
pictureBoxWarmlyShip.Image = bmp;
Draw();
if (_strategy.GetStatus == StrategyStatus.Finish)
{
comboBoxStrategy.Enabled = true;
@ -127,5 +128,4 @@ namespace ProjectWarmlyShip
}
}
}
}

View File

@ -2,7 +2,6 @@
public interface IMoveableObjects
{
//Получение координаты обхекта
ObjectParameters? GetObjectPosition { get; }
/// <summary>
/// Шаг объекта

View File

@ -45,5 +45,4 @@ public class MoveableShip : IMoveableObjects
_ => DirectionType.Unknow,
};
}
}