рабочая 5 лаба

This commit is contained in:
Казначеева Елизавета 2023-11-21 15:14:59 +04:00
parent 366d614e4a
commit 2b46380712
4 changed files with 8 additions and 11 deletions

View File

@ -22,11 +22,11 @@ namespace Battleship.DrawningObjects
/// <summary>
/// Ширина окна
/// </summary>
private int _pictureWidth;
public int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
private int _pictureHeight;
public int _pictureHeight;
/// <summary>
/// Левая координата прорисовки
/// </summary>

View File

@ -100,8 +100,7 @@ namespace Battleship
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
string.Empty];
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
@ -110,9 +109,7 @@ namespace Battleship
var FormShipConfig = new FormShipConfig();
FormShipConfig.AddEvent(AddShip);
FormShipConfig.Show();
}
private void AddShip(DrawningShip drawningShip)
{
if (listBoxStorages.SelectedIndex == -1)

View File

@ -15,7 +15,7 @@ namespace Battleship
public partial class FormShipConfig : Form
{
/// <summary>
/// Переменная-выбранная машина
/// Переменная-выбранный корабль
/// </summary>
DrawningShip? _ship = null;
/// <summary>
@ -37,9 +37,7 @@ namespace Battleship
panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
// TODO buttonCancel.Click with lambda
buttonCancel.Click += (s, e) => Close();
}
/// <summary>
/// Отрисовать машину
@ -113,7 +111,6 @@ namespace Battleship
}
DrawShip();
}
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
/// <summary>
/// Добавление машины
/// </summary>

View File

@ -73,11 +73,14 @@ namespace Battleship.Generics
}
private void DrawObjects(Graphics g)
{
int width = _pictureWidth/ _placeSizeWidth;
int i = 0;
foreach(var ship in _collection.GetShips())
{
if(ship != null)
{
ship._pictureWidth = _pictureWidth;
ship._pictureHeight = _pictureHeight;
int inRow = _pictureWidth / _placeSizeWidth;
ship.SetPosition(i % inRow * _placeSizeWidth, _pictureHeight - _pictureHeight % _placeSizeHeight - (i / inRow + 1) * _placeSizeHeight + 5);
ship.DrawTransport(g);