LabWork07
This commit is contained in:
parent
d4b74a7d92
commit
1641bff131
@ -1,4 +1,5 @@
|
||||
using ProjectBattleship.DrawingObject;
|
||||
using ProjectBattleship.Exceptions;
|
||||
|
||||
namespace ProjectBattleship.CollectionGenericObjects;
|
||||
/// <summary>
|
||||
@ -40,30 +41,29 @@ public class Docks : AbstractCompany
|
||||
}
|
||||
protected override void SetObjectsPosition()
|
||||
{
|
||||
if (_collection == null) return;
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
int height = _pictureHeight / _placeSizeHeight;
|
||||
|
||||
int curWidth = width - 1;
|
||||
int curHeight = 0;
|
||||
|
||||
for (int i = 0; i < _collection.Count; i++)
|
||||
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
||||
{
|
||||
DrawingWarship? _warship = _collection.Get(i);
|
||||
if (_warship != null)
|
||||
try
|
||||
{
|
||||
if (_warship.SetPictureSize(_pictureWidth, _pictureHeight))
|
||||
{
|
||||
_warship.SetPosition(_placeSizeWidth * curWidth + 20,
|
||||
curHeight * _placeSizeHeight + 15);
|
||||
}
|
||||
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
|
||||
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 10, curHeight * _placeSizeHeight + 10);
|
||||
}
|
||||
catch (ObjectNotFoundException) { }
|
||||
catch (PositionOutOfCollectionException e) { }
|
||||
if (curWidth > 0)
|
||||
curWidth--;
|
||||
if (curWidth < 0)
|
||||
else
|
||||
{
|
||||
curHeight++;
|
||||
curWidth = width - 1;
|
||||
curHeight++;
|
||||
}
|
||||
|
||||
if (curHeight >= height)
|
||||
{
|
||||
return;
|
||||
|
@ -142,29 +142,29 @@ public partial class FormWarshipCollection : Form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveWarship_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)
|
||||
|| _company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_company - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
//private void ButtonRemoveWarship_Click(object sender, EventArgs e)
|
||||
//{
|
||||
// if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)
|
||||
// || _company == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
// MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
// if (_company - pos != null)
|
||||
// {
|
||||
// MessageBox.Show("Объект удален");
|
||||
// pictureBox.Image = _company.Show();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// MessageBox.Show("Не удалось удалить объект");
|
||||
// }
|
||||
//}
|
||||
/// <summary>
|
||||
/// Передача объекта в другую форму
|
||||
/// </summary>
|
||||
|
@ -9,8 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
|
||||
|
Loading…
Reference in New Issue
Block a user