From 646780ae8a1e4de74641a5834a447aff90b88918 Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 25 Dec 2023 18:55:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawningObjects/DrawningBoat.cs | 4 +- .../DrawningObjects/DrawningMotorBoat.cs | 3 +- .../ProjectBoat_bae/FormBoatCollection.cs | 108 +----------------- .../Generics/BoatsGenericCollection.cs | 3 +- .../Generics/BoatsGenericStorage.cs | 6 +- .../ProjectBoat_bae/Generics/SetGeneric.cs | 39 ------- 6 files changed, 8 insertions(+), 155 deletions(-) diff --git a/ProjectBoat_base/ProjectBoat_bae/DrawningObjects/DrawningBoat.cs b/ProjectBoat_base/ProjectBoat_bae/DrawningObjects/DrawningBoat.cs index e1f41f8..64bab71 100644 --- a/ProjectBoat_base/ProjectBoat_bae/DrawningObjects/DrawningBoat.cs +++ b/ProjectBoat_base/ProjectBoat_bae/DrawningObjects/DrawningBoat.cs @@ -74,11 +74,11 @@ namespace ProjectBoat_bae.DrawningObjects // Установка позиции public void SetPosition(int x, int y) { - if (x < 0 || x + _boatWidth > _pictureWidth) + if (x < 0 || x + _boatWidth > _pictureWidth + 90) { x = Math.Max(0, _pictureWidth - _boatWidth); } - if (y < 0 || y + _boatHeight > _pictureHeight) + if (y < 0 || y + _boatHeight > _pictureHeight + 60) { y = Math.Max(0, _pictureHeight - _boatHeight); } diff --git a/ProjectBoat_base/ProjectBoat_bae/DrawningObjects/DrawningMotorBoat.cs b/ProjectBoat_base/ProjectBoat_bae/DrawningObjects/DrawningMotorBoat.cs index 3d276c3..7fa26ff 100644 --- a/ProjectBoat_base/ProjectBoat_bae/DrawningObjects/DrawningMotorBoat.cs +++ b/ProjectBoat_base/ProjectBoat_bae/DrawningObjects/DrawningMotorBoat.cs @@ -21,8 +21,7 @@ namespace ProjectBoat_bae.DrawningObjects if (EntityBoat != null) { EntityBoat = new EntityMotorBoat(speed, weight, bodyColor, - additionalColor, body, wing); - + additionalColor, body, wing); } } diff --git a/ProjectBoat_base/ProjectBoat_bae/FormBoatCollection.cs b/ProjectBoat_base/ProjectBoat_bae/FormBoatCollection.cs index 6a290e1..f77a2fa 100644 --- a/ProjectBoat_base/ProjectBoat_bae/FormBoatCollection.cs +++ b/ProjectBoat_base/ProjectBoat_bae/FormBoatCollection.cs @@ -60,15 +60,6 @@ namespace ProjectBoat_bae private void ButtonAddObject_Click_1(object sender, EventArgs e) { - //if (string.IsNullOrEmpty(textBoxStorageName.Text)) - //{ - // MessageBox.Show("Не все данные заполнены", "Ошибка", - // MessageBoxButtons.OK, MessageBoxIcon.Error); - // return; - //} - //_storage.AddSet(textBoxStorageName.Text); - //ReloadObjects(); - //_logger.LogInformation($"Added set: {textBoxStorageName.Text}"); if (string.IsNullOrEmpty(textBoxStorageName.Text)) { MessageBox.Show("Input not complete", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -82,21 +73,7 @@ namespace ProjectBoat_bae // Удаление набора private void ButtonDelObject_Click(object sender, EventArgs e) { - //if (listBoxStorages.SelectedIndex == -1) - //{ - // return; - //} - - //if (string.IsNullOrEmpty(textBoxStorageName.Text)) - //{ - // MessageBox.Show("Не всё заполнено", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - // _logger.LogWarning("Неудачная попытка. Коллекция не добавлена, не все данные заполнены"); - // return; - //} - //_storage.AddSet(textBoxStorageName.Text); - //ReloadObjects(); - - //_logger.LogInformation($"Добавлен набор: {textBoxStorageName.Text}"); + if (listBoxStorages.SelectedIndex == -1) { return; @@ -114,19 +91,6 @@ namespace ProjectBoat_bae // Добавление объекта в набор private void ButtonAddBoat_Click(object sender, EventArgs e) { - //if (listBoxStorages.SelectedIndex == -1) - //{ - // return; - //} - //var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; - //if (obj == null) - //{ - // return; - //} - - //FormBoatConfig formPlaneConfig = new FormBoatConfig(); - //formPlaneConfig.AddEvent(AddBoat); - //formPlaneConfig.Show(); if (listBoxStorages.SelectedIndex == -1) { @@ -144,23 +108,7 @@ namespace ProjectBoat_bae private void AddBoat(Drawningboat boat) { - //boat._pictureWidth = pictureBoxCollection.Width; - //boat._pictureHeight = pictureBoxCollection.Height; - //if (listBoxStorages.SelectedIndex == -1) return; - //var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; - //if (obj == null) return; - - //if (obj + boat) - //{ - // MessageBox.Show("Объект добавлен"); - // pictureBoxCollection.Image = obj.ShowBoats(); - // _logger.LogInformation($"Добавлен объект {obj}"); - //} - //else - //{ - // MessageBox.Show("Не удалось добавить объект"); - //} - + if (listBoxStorages.SelectedIndex == -1) { return; @@ -190,45 +138,6 @@ namespace ProjectBoat_bae private void ButtonRemoveBoat_Click(object sender, EventArgs e) { - //if (listBoxStorages.SelectedIndex == -1) - //{ - // return; - //} - //var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; - //if (obj == null) - //{ - // return; - //} - //if (MessageBox.Show("Удалить объект?", "Удалить", MessageBoxButtons.YesNo, - // MessageBoxIcon.Question) == DialogResult.No) - //{ - // return; - //} - //try - //{ - // int pos = Convert.ToInt32(textBoxBoat.Text); - // if (obj - pos != null) - // { - // MessageBox.Show("Объект удален"); - // pictureBoxCollection.Image = obj.ShowBoats(); - // _logger.LogInformation($"лодка удалена из набора {listBoxStorages.SelectedItem.ToString()}"); - // } - // else - // { - // MessageBox.Show("Объект не удален"); - // _logger.LogWarning($"лодка не удалена из набора {listBoxStorages.SelectedItem.ToString()}"); - // } - //} - //catch (BoatNotFoundException ex) - //{ - // MessageBox.Show(ex.Message); - // _logger.LogWarning($"BoatNotFound: {ex.Message} in set {listBoxStorages.SelectedItem.ToString()}"); - //} - //catch (Exception ex) - //{ - // MessageBox.Show("Объекта нет"); - // _logger.LogWarning("Not input"); - //} if (listBoxStorages.SelectedIndex == -1) { return; @@ -273,17 +182,6 @@ namespace ProjectBoat_bae // Обновление private void ButtonRefreshCollection_Click(object sender, EventArgs e) { - //if (listBoxStorages.SelectedIndex == -1) - //{ - // return; - //} - //var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? - //string.Empty]; - //if (obj == null) - //{ - // return; - //} - //pictureBoxCollection.Image = obj.ShowBoats(); if (listBoxStorages.SelectedIndex == -1) { @@ -300,8 +198,6 @@ namespace ProjectBoat_bae //Выбор набора private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e) { - //pictureBoxCollection.Image = - //_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBoats(); pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBoats(); } diff --git a/ProjectBoat_base/ProjectBoat_bae/Generics/BoatsGenericCollection.cs b/ProjectBoat_base/ProjectBoat_bae/Generics/BoatsGenericCollection.cs index 7f4a2d9..66ce0f6 100644 --- a/ProjectBoat_base/ProjectBoat_bae/Generics/BoatsGenericCollection.cs +++ b/ProjectBoat_base/ProjectBoat_bae/Generics/BoatsGenericCollection.cs @@ -45,11 +45,10 @@ namespace ProjectBoat_bae.Generics { return false; } - //return (bool)collect._collection.Insert(obj); return collect._collection.Insert(obj, new DrawingBoatEqutables()); } - // Перегрузка оператора вычитанияreturn collect._collection.Insert(obj, new DrawingPlaneEqutables()); + // Перегрузка оператора вычитания public static T? operator -(BoatsGenericCollection collect, int pos) { diff --git a/ProjectBoat_base/ProjectBoat_bae/Generics/BoatsGenericStorage.cs b/ProjectBoat_base/ProjectBoat_bae/Generics/BoatsGenericStorage.cs index a9362dd..2ee2d72 100644 --- a/ProjectBoat_base/ProjectBoat_bae/Generics/BoatsGenericStorage.cs +++ b/ProjectBoat_base/ProjectBoat_bae/Generics/BoatsGenericStorage.cs @@ -14,9 +14,8 @@ namespace ProjectBoat_bae.Generics { internal class BoatsGenericStorage { - //readonly Dictionary> _boatStorages; readonly Dictionary> _boatStorages; - // public List Keys => _boatStorages.Keys.ToList(); + public List Keys => _boatStorages.Keys.ToList(); private readonly int _pictureWidth; @@ -29,8 +28,7 @@ namespace ProjectBoat_bae.Generics } public void AddSet(string name) { - //if (_boatStorages.ContainsKey(name)) return; - //_boatStorages[name] = new BoatsGenericCollection(_pictureWidth, _pictureHeight); + if (_boatStorages.ContainsKey(name)) return; _boatStorages[name] = new BoatsGenericCollection(_pictureWidth, _pictureHeight); } diff --git a/ProjectBoat_base/ProjectBoat_bae/Generics/SetGeneric.cs b/ProjectBoat_base/ProjectBoat_bae/Generics/SetGeneric.cs index 78336ff..fdf5967 100644 --- a/ProjectBoat_base/ProjectBoat_bae/Generics/SetGeneric.cs +++ b/ProjectBoat_base/ProjectBoat_bae/Generics/SetGeneric.cs @@ -25,20 +25,6 @@ namespace ProjectBoat_bae.Generics _places = new List(_maxCount); } - //public bool Insert(T boat) - //{ - // return Insert(boat, 0); - //} - //public bool Insert(T boat, int position) - //{ - // if (position < 0 || position >= _maxCount) - // return false; - - // if (Count >= _maxCount) - // return false; - // _places.Insert(0, boat); - // return true; - //} public bool Insert(T boat, IEqualityComparer? equal = null) { if (equal != null) @@ -74,31 +60,6 @@ namespace ProjectBoat_bae.Generics return true; } - //public bool Remove(int position) - //{ - // if (position < 0 || position > _maxCount) - // return false; - // if (position >= Count) - // return false; - // _places.RemoveAt(position); - // return true; - //} - //public T? this[int position] - //{ - // get - // { - // if (position < 0 || position > _maxCount) - // return null; - // return _places[position]; - // } - // set - // { - // if (position < 0 || position > _maxCount) - // return; - // _places[position] = value; - // } - //} - public bool Remove(int position) { if (position >= Count || position < 0)