LabWork03

This commit is contained in:
AlyonaFr 2024-04-03 22:10:52 +04:00
parent 1af20534c6
commit bc5127d410
3 changed files with 21 additions and 20 deletions

View File

@ -10,7 +10,7 @@ namespace ProjectCatamaran.CollectiongGenericObjects;
/// <summary>
/// Реализация абстрактной компании - каршеринг
/// </summary>
public class BoatSharingService : AbstractCompany
public class BoatHarborService : AbstractCompany
{
/// <summary>
///
@ -18,7 +18,7 @@ public class BoatSharingService : AbstractCompany
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="collection"></param>
public BoatSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningBoat> collection) : base(picWidth, picHeight, collection)
public BoatHarborService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningBoat> collection) : base(picWidth, picHeight, collection)
{
}
@ -26,14 +26,14 @@ public class BoatSharingService : AbstractCompany
{
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
Pen pen = new(Color.Black, 2);
for (int i = 0; i < width; i++)
Pen pen = new(Color.Black, 4);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < height + 1; ++j)
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight);
g.DrawLine(pen, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight + _placeSizeHeight);
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight + 5, i * _placeSizeWidth + _placeSizeWidth - 90, j * _placeSizeHeight + 5);
}
g.DrawLine(pen, i * _placeSizeWidth,0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight + 5);
}
}
@ -43,14 +43,14 @@ public class BoatSharingService : AbstractCompany
int height = _pictureHeight / _placeSizeHeight;
int curWidth = 0;
int curHeight = 0;
int curHeight = height - 1;
for (int i = 0; i < (_collection?.Count ?? 0); i++)
{
if (_collection.Get(i) != null)
{
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 30, curHeight * _placeSizeHeight);
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 10, curHeight * _placeSizeHeight + 5);
}
if (curWidth < width - 1)
@ -58,10 +58,9 @@ public class BoatSharingService : AbstractCompany
else
{
curWidth = 0;
curHeight++;
curHeight--;
}
if (curHeight >= height)
if (curHeight < 0)
{
return;
}

View File

@ -51,9 +51,9 @@
groupBoxTools.Controls.Add(buttonAddBoat);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(728, 0);
groupBoxTools.Location = new Point(849, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(279, 633);
groupBoxTools.Size = new Size(279, 629);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
@ -140,7 +140,7 @@
pictureBoxBoat.Dock = DockStyle.Fill;
pictureBoxBoat.Location = new Point(0, 0);
pictureBoxBoat.Name = "pictureBoxBoat";
pictureBoxBoat.Size = new Size(728, 633);
pictureBoxBoat.Size = new Size(849, 629);
pictureBoxBoat.TabIndex = 1;
pictureBoxBoat.TabStop = false;
//
@ -148,7 +148,7 @@
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1007, 633);
ClientSize = new Size(1128, 629);
Controls.Add(pictureBoxBoat);
Controls.Add(groupBoxTools);
Name = "FormBoatCollection";

View File

@ -37,7 +37,7 @@ public partial class FormBoatCollection : Form
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new BoatSharingService(pictureBoxBoat.Width,
_company = new BoatHarborService(pictureBoxBoat.Width,
pictureBoxBoat.Height, new MassiveGenericObjects<DrawningBoat>());
break;
}
@ -123,19 +123,21 @@ public partial class FormBoatCollection : Form
{
return;
}
if (MessageBox.Show("удалить объект?", "удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_company - pos != null)
{
MessageBox.Show("объект удален");
MessageBox.Show("Объект удален");
pictureBoxBoat.Image = _company.Show();
}
else
{
MessageBox.Show("не удалось удалить объект");
MessageBox.Show("Не удалось удалить объект");
}
}