рабочая 5 лаба
This commit is contained in:
parent
366d614e4a
commit
2b46380712
@ -22,11 +22,11 @@ namespace Battleship.DrawningObjects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureWidth;
|
public int _pictureWidth;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота окна
|
/// Высота окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureHeight;
|
public int _pictureHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата прорисовки
|
/// Левая координата прорисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -100,8 +100,7 @@ namespace Battleship
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
string.Empty];
|
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -109,10 +108,8 @@ namespace Battleship
|
|||||||
|
|
||||||
var FormShipConfig = new FormShipConfig();
|
var FormShipConfig = new FormShipConfig();
|
||||||
FormShipConfig.AddEvent(AddShip);
|
FormShipConfig.AddEvent(AddShip);
|
||||||
FormShipConfig.Show();
|
FormShipConfig.Show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddShip(DrawningShip drawningShip)
|
private void AddShip(DrawningShip drawningShip)
|
||||||
{
|
{
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
@ -15,7 +15,7 @@ namespace Battleship
|
|||||||
public partial class FormShipConfig : Form
|
public partial class FormShipConfig : Form
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Переменная-выбранная машина
|
/// Переменная-выбранный корабль
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DrawningShip? _ship = null;
|
DrawningShip? _ship = null;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -37,9 +37,7 @@ namespace Battleship
|
|||||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
|
||||||
// TODO buttonCancel.Click with lambda
|
|
||||||
buttonCancel.Click += (s, e) => Close();
|
buttonCancel.Click += (s, e) => Close();
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Отрисовать машину
|
/// Отрисовать машину
|
||||||
@ -113,7 +111,6 @@ namespace Battleship
|
|||||||
}
|
}
|
||||||
DrawShip();
|
DrawShip();
|
||||||
}
|
}
|
||||||
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление машины
|
/// Добавление машины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -73,11 +73,14 @@ namespace Battleship.Generics
|
|||||||
}
|
}
|
||||||
private void DrawObjects(Graphics g)
|
private void DrawObjects(Graphics g)
|
||||||
{
|
{
|
||||||
|
int width = _pictureWidth/ _placeSizeWidth;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach(var ship in _collection.GetShips())
|
foreach(var ship in _collection.GetShips())
|
||||||
{
|
{
|
||||||
if(ship != null)
|
if(ship != null)
|
||||||
{
|
{
|
||||||
|
ship._pictureWidth = _pictureWidth;
|
||||||
|
ship._pictureHeight = _pictureHeight;
|
||||||
int inRow = _pictureWidth / _placeSizeWidth;
|
int inRow = _pictureWidth / _placeSizeWidth;
|
||||||
ship.SetPosition(i % inRow * _placeSizeWidth, _pictureHeight - _pictureHeight % _placeSizeHeight - (i / inRow + 1) * _placeSizeHeight + 5);
|
ship.SetPosition(i % inRow * _placeSizeWidth, _pictureHeight - _pictureHeight % _placeSizeHeight - (i / inRow + 1) * _placeSizeHeight + 5);
|
||||||
ship.DrawTransport(g);
|
ship.DrawTransport(g);
|
||||||
|
Loading…
Reference in New Issue
Block a user