From bc5127d41017e7f072acb410e7402d482b6f0037 Mon Sep 17 00:00:00 2001 From: AlyonaFr <149268946+AlyonaFr@users.noreply.github.com> Date: Wed, 3 Apr 2024 22:10:52 +0400 Subject: [PATCH] LabWork03 --- ...SharingService.cs => BoatHarborService.cs} | 23 +++++++++---------- .../FormBoatCollection.Designer.cs | 8 +++---- .../ProjectCatamaran/FormBoatCollection.cs | 10 ++++---- 3 files changed, 21 insertions(+), 20 deletions(-) rename ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/{BoatSharingService.cs => BoatHarborService.cs} (66%) diff --git a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatSharingService.cs b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatHarborService.cs similarity index 66% rename from ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatSharingService.cs rename to ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatHarborService.cs index 96723c5..b443156 100644 --- a/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatSharingService.cs +++ b/ProjectCatamaran/ProjectCatamaran/CollectiongGenericObjects/BoatHarborService.cs @@ -10,7 +10,7 @@ namespace ProjectCatamaran.CollectiongGenericObjects; /// /// Реализация абстрактной компании - каршеринг /// -public class BoatSharingService : AbstractCompany +public class BoatHarborService : AbstractCompany { /// /// @@ -18,7 +18,7 @@ public class BoatSharingService : AbstractCompany /// /// /// - public BoatSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) + public BoatHarborService(int picWidth, int picHeight, ICollectionGenericObjects 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; } diff --git a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs index b96b5d1..9e0b36c 100644 --- a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs +++ b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs @@ -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"; diff --git a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs index 888131c..e185b94 100644 --- a/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs +++ b/ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs @@ -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()); 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("Не удалось удалить объект"); } }