From 13de54b639e9c3bd4a6724eea56c754554064fd4 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sat, 16 Dec 2023 20:22:15 +0400 Subject: [PATCH 1/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20DrawingPlaneEqutables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawingPlaneEqutables.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 ProjectStormtrooper/ProjectStormtrooper/DrawingPlaneEqutables.cs diff --git a/ProjectStormtrooper/ProjectStormtrooper/DrawingPlaneEqutables.cs b/ProjectStormtrooper/ProjectStormtrooper/DrawingPlaneEqutables.cs new file mode 100644 index 0000000..9c93c03 --- /dev/null +++ b/ProjectStormtrooper/ProjectStormtrooper/DrawingPlaneEqutables.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectStormtrooper +{ + public class DrawingPlaneEqutables : IEqualityComparer + { + public bool Equals(DrawingPlane? x, DrawingPlane? y) + { + if (x == null || x.EntityPlane == null) + { + throw new ArgumentNullException(nameof(x)); + } + if (y == null || y.EntityPlane == null) + { + throw new ArgumentNullException(nameof(y)); + } + if (x.GetType().Name != y.GetType().Name) + { + return false; + } + if (x.EntityPlane.Speed != y.EntityPlane.Speed) + { + return false; + } + if (x.EntityPlane.Weight != y.EntityPlane.Weight) + { + return false; + } + if (x.EntityPlane.BodyColor != y.EntityPlane.BodyColor) + { + return false; + } + if (x is DrawingStormtrooper && y is DrawingStormtrooper) + { + var xStormtrooper = (x.EntityPlane as EntityStormtrooper); + var yStormtrooper = (y.EntityPlane as EntityStormtrooper); + if (xStormtrooper?.AdditionalColor != yStormtrooper?.AdditionalColor) + { + return false; + } + if (xStormtrooper?.Bombs != yStormtrooper?.Bombs) + { + return false; + } + if (xStormtrooper?.Rockets != yStormtrooper?.Rockets) + { + return false; + } + } + return true; + } + + public int GetHashCode([DisallowNull] DrawingPlane obj) + { + return obj.GetHashCode(); + } + } +} -- 2.25.1 From adbf68e639144aed32504500b33ee8fd50e5ad95 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sat, 16 Dec 2023 22:19:33 +0400 Subject: [PATCH 2/9] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=B2=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D1=81=D0=B5=20SetGeneric?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectStormtrooper/SetGeneric.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs b/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs index 6245de1..b647c8d 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs @@ -38,9 +38,9 @@ namespace ProjectStormtrooper /// /// /// - public int Insert(T plane) + public int Insert(T plane, IEqualityComparer? equal = null) { - return Insert(plane, 0); + return Insert(plane, 0, equal); } /// /// Добавление объекта в набор на конкретную позицию @@ -48,7 +48,7 @@ namespace ProjectStormtrooper /// /// /// - public int Insert(T plane, int position) + public int Insert(T plane, int position, IEqualityComparer? equal = null) { if (_places.Count == _maxCount) { @@ -59,6 +59,16 @@ namespace ProjectStormtrooper { return -1; } + if (equal != null) + { + foreach (var otherPlane in _places) + { + if (equal.Equals(otherPlane, plane)) + { + throw new ApplicationException("Такой объект уже есть в коллекции!"); + } + } + } // Вставка по позиции _places.Insert(position, plane); return position; -- 2.25.1 From 85829c9c39eed2f14498fda14073c5a086028ac3 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sat, 16 Dec 2023 23:13:55 +0400 Subject: [PATCH 3/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D1=8B=20PlaneComp?= =?UTF-8?q?are?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlaneCompareByColor.cs | 33 +++++++++++++++++++ .../ProjectStormtrooper/PlaneCompareByType.cs | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByColor.cs create mode 100644 ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByType.cs diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByColor.cs b/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByColor.cs new file mode 100644 index 0000000..f90183d --- /dev/null +++ b/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByColor.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectStormtrooper +{ + public class PlaneCompareByColor : IComparer + { + public int Compare(DrawingPlane? x, DrawingPlane? y) + { + if (x == null || x.EntityPlane == null) + { + throw new ArgumentNullException(nameof(x)); + } + if (y == null || y.EntityPlane == null) + { + throw new ArgumentNullException(nameof(y)); + } + if (x.EntityPlane.BodyColor != y.EntityPlane.BodyColor) + { + return x.EntityPlane.BodyColor.Name.CompareTo(y.EntityPlane.BodyColor.Name); + } + var speedCompare = x.EntityPlane.Speed.CompareTo(y.EntityPlane.Speed); + if (speedCompare != 0) + { + return speedCompare; + } + return x.EntityPlane.Weight.CompareTo(y.EntityPlane.Weight); + } + } +} diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByType.cs b/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByType.cs new file mode 100644 index 0000000..7dd60c5 --- /dev/null +++ b/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByType.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectStormtrooper +{ + public class PlaneCompareByType : IComparer + { + public int Compare(DrawingPlane? x, DrawingPlane? y) + { + if (x == null || x.EntityPlane == null) + { + throw new ArgumentNullException(nameof(x)); + } + if (y == null || y.EntityPlane == null) + { + throw new ArgumentNullException(nameof(y)); + } + if (x.GetType().Name != y.GetType().Name) + { + return x.GetType().Name.CompareTo(y.GetType().Name); + } + var speedCompare = x.EntityPlane.Speed.CompareTo(y.EntityPlane.Speed); + if (speedCompare != 0) + { + return speedCompare; + } + return x.EntityPlane.Weight.CompareTo(y.EntityPlane.Weight); + } + } +} -- 2.25.1 From 44887378b2fb6ac789b3c221a51e703dd1cdefe7 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sat, 16 Dec 2023 23:28:08 +0400 Subject: [PATCH 4/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20=D1=81?= =?UTF-8?q?=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectStormtrooper/PlanesGenericCollection.cs | 7 ++++++- ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericCollection.cs b/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericCollection.cs index aa3fa4a..e4f1e4b 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericCollection.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericCollection.cs @@ -49,6 +49,11 @@ namespace ProjectStormtrooper _collection = new SetGeneric(horizontalObjectsCount * verticalObjectsCount); } /// + /// Сортировка + /// + /// + public void Sort(IComparer comparer) => _collection.SortSet(comparer); + /// /// Перегрузка оператора сложения /// /// @@ -60,7 +65,7 @@ namespace ProjectStormtrooper { return -1; } - return collect?._collection.Insert(obj) ?? -1; + return collect?._collection.Insert(obj, new DrawingPlaneEqutables()) ?? -1; } /// /// Перегрузка оператора вычитания diff --git a/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs b/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs index b647c8d..407272d 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs @@ -34,6 +34,11 @@ namespace ProjectStormtrooper _places = new List(count); } /// + /// Сортировка набора объектов + /// + /// + public void SortSet(IComparer comparer) => _places.Sort(comparer); + /// /// Добавления объекта в набор /// /// -- 2.25.1 From 83e8f8850ca6fba9599ed474890b2da57d0d25e2 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sat, 16 Dec 2023 23:33:43 +0400 Subject: [PATCH 5/9] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=B2=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormPlaneCollection.Designer.cs | 26 +++++++++++++++++++ .../FormPlaneCollection.cs | 23 +++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs index 1a511d4..4c1c5d1 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.Designer.cs @@ -29,6 +29,8 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); + buttonSortByType = new Button(); + buttonSortByColor = new Button(); groupBoxStorages = new GroupBox(); buttonRemoveStorage = new Button(); listBoxStorages = new ListBox(); @@ -53,6 +55,8 @@ // // groupBoxTools // + groupBoxTools.Controls.Add(buttonSortByType); + groupBoxTools.Controls.Add(buttonSortByColor); groupBoxTools.Controls.Add(groupBoxStorages); groupBoxTools.Controls.Add(maskedTextBoxNumber); groupBoxTools.Controls.Add(buttonRefreshCollection); @@ -66,6 +70,26 @@ groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // + // buttonSortByType + // + buttonSortByType.Location = new Point(6, 273); + buttonSortByType.Name = "buttonSortByType"; + buttonSortByType.Size = new Size(218, 29); + buttonSortByType.TabIndex = 7; + buttonSortByType.Text = "Сортировка по типу"; + buttonSortByType.UseVisualStyleBackColor = true; + buttonSortByType.Click += buttonSortByType_Click; + // + // buttonSortByColor + // + buttonSortByColor.Location = new Point(6, 305); + buttonSortByColor.Name = "buttonSortByColor"; + buttonSortByColor.Size = new Size(218, 29); + buttonSortByColor.TabIndex = 6; + buttonSortByColor.Text = "Сортировка по цвету"; + buttonSortByColor.UseVisualStyleBackColor = true; + buttonSortByColor.Click += buttonSortByColor_Click; + // // groupBoxStorages // groupBoxStorages.Controls.Add(buttonRemoveStorage); @@ -246,5 +270,7 @@ private ToolStripMenuItem загрузитьToolStripMenuItem; private OpenFileDialog openFileDialog; private SaveFileDialog saveFileDialog; + private Button buttonSortByType; + private Button buttonSortByColor; } } \ No newline at end of file diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs index 2884e68..764f543 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs @@ -142,7 +142,7 @@ namespace ProjectStormtrooper { MessageBox.Show(ex.Message); _logger.LogWarning("Ошибка добавления: " + ex.Message); - } + } } /// /// Удаление объекта из набора @@ -246,5 +246,26 @@ namespace ProjectStormtrooper } } } + /// + /// Сортировка по сравнителю + /// + /// + private void ComparePlanes(IComparer comparer) + { + if (listBoxStorages.SelectedIndex == -1) + { + return; + } + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + obj.Sort(comparer); + pictureBoxCollection.Image = obj.ShowPlanes(); + } + private void buttonSortByType_Click(object sender, EventArgs e) => ComparePlanes(new PlaneCompareByType()); + + private void buttonSortByColor_Click(object sender, EventArgs e) => ComparePlanes(new PlaneCompareByColor()); } } -- 2.25.1 From ac3e17579d08735ca54a62cda8296395853cbf31 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sat, 16 Dec 2023 23:47:18 +0400 Subject: [PATCH 6/9] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20PlanesGenericStorage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlanesCollectionInfo.cs | 23 +++++++++++++++++++ .../PlanesGenericStorage.cs | 23 +++++++++++-------- 2 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs b/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs new file mode 100644 index 0000000..c7d1f55 --- /dev/null +++ b/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectStormtrooper +{ + public class PlanesCollectionInfo : IEquatable + { + public string Name { get; private set; } + public string Description { get; private set; } + public PlanesCollectionInfo(string name, string description) + { + Name = name; + Description = description; + } + public bool Equals(PlanesCollectionInfo? other) + { + return Name.Equals(other.Name); + } + } +} diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericStorage.cs b/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericStorage.cs index 3bf2e09..56d27dd 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericStorage.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericStorage.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace ProjectStormtrooper { @@ -23,11 +24,11 @@ namespace ProjectStormtrooper /// /// Словарь (хранилище) /// - readonly Dictionary> _planeStorages; + readonly Dictionary> _planeStorages; /// /// Возвращение списка названий наборов /// - public List Keys => _planeStorages.Keys.ToList(); + public List Keys => _planeStorages.Keys.ToList(); /// /// Ширина окна отрисовки /// @@ -43,7 +44,7 @@ namespace ProjectStormtrooper /// public PlanesGenericStorage(int pictureWidth, int pictureHeight) { - _planeStorages = new Dictionary>(); + _planeStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } @@ -53,7 +54,7 @@ namespace ProjectStormtrooper /// Название набора public void AddSet(string name) { - _planeStorages.Add(name, new PlanesGenericCollection(_pictureWidth, _pictureHeight)); + _planeStorages.Add(new PlanesCollectionInfo(name, ""), new PlanesGenericCollection(_pictureWidth, _pictureHeight)); } /// /// Удаление набора @@ -61,8 +62,9 @@ namespace ProjectStormtrooper /// Название набора public void DelSet(string name) { - if (_planeStorages.ContainsKey(name)) - _planeStorages.Remove(name); + var info = new PlanesCollectionInfo(name, ""); + if (_planeStorages.ContainsKey(info)) + _planeStorages.Remove(info); } /// /// Доступ к набору @@ -73,8 +75,9 @@ namespace ProjectStormtrooper { get { - if (_planeStorages.ContainsKey(ind)) - return _planeStorages[ind]; + var info = new PlanesCollectionInfo(ind, ""); + if (_planeStorages.ContainsKey(info)) + return _planeStorages[info]; return null; } } @@ -104,7 +107,7 @@ namespace ProjectStormtrooper { throw new Exception("Невалиданя операция, нет данных для сохранения"); } - sw.WriteLine($"{storage.Key}{_separatorForKeyValue}{storageString}"); + sw.WriteLine($"{storage.Key.Name}{_separatorForKeyValue}{storageString}"); } } } @@ -152,7 +155,7 @@ namespace ProjectStormtrooper } } } - _planeStorages.Add(record[0], collection); + _planeStorages.Add(new PlanesCollectionInfo(record[0], ""), collection); currentLine = sr.ReadLine(); } } -- 2.25.1 From a96c1b66e04e86141591cfa606e14cc9d5af2ff2 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sat, 16 Dec 2023 23:55:26 +0400 Subject: [PATCH 7/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20GetHashCode=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20PlanesCollectionInfo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectStormtrooper/PlanesCollectionInfo.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs b/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs index c7d1f55..e38ae29 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs @@ -17,7 +17,15 @@ namespace ProjectStormtrooper } public bool Equals(PlanesCollectionInfo? other) { - return Name.Equals(other.Name); + return Name == other.Name; + } + public override int GetHashCode() + { + return Name.GetHashCode(); + } + public override string ToString() + { + return Name; } } } -- 2.25.1 From 703575c8984fe5e75b0ce2c8467081c890b05da7 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 19 Dec 2023 11:52:30 +0400 Subject: [PATCH 8/9] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=20=D1=86=D0=B2=D0=B5=D1=82=D1=83=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B4=D0=B2=D0=B8=D0=BD=D1=83=D1=82=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectStormtrooper/PlaneCompareByColor.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByColor.cs b/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByColor.cs index f90183d..3392ece 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByColor.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/PlaneCompareByColor.cs @@ -22,12 +22,14 @@ namespace ProjectStormtrooper { return x.EntityPlane.BodyColor.Name.CompareTo(y.EntityPlane.BodyColor.Name); } - var speedCompare = x.EntityPlane.Speed.CompareTo(y.EntityPlane.Speed); - if (speedCompare != 0) + if (x.EntityPlane is EntityStormtrooper xStormtrooper && y.EntityPlane is EntityStormtrooper yStormtrooper) { - return speedCompare; + if (xStormtrooper.AdditionalColor != yStormtrooper.AdditionalColor) + { + return xStormtrooper.AdditionalColor.Name.CompareTo(yStormtrooper.AdditionalColor.Name); + } } - return x.EntityPlane.Weight.CompareTo(y.EntityPlane.Weight); + return 0; } } } -- 2.25.1 From fff0f38eeb480a8b777556f153d9ba6de1a3f63c Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 19 Dec 2023 12:03:33 +0400 Subject: [PATCH 9/9] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BE=D0=BA?= =?UTF-8?q?=D0=BE=D1=88=D0=BA=D0=B0=20=D1=81=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectStormtrooper/FormPlaneCollection.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs index 764f543..5e319a7 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/FormPlaneCollection.cs @@ -140,7 +140,12 @@ namespace ProjectStormtrooper } catch (StorageOverflowException ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(ex.Message, "Ошибка добавления", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogWarning("Ошибка добавления: " + ex.Message); + } + catch (ApplicationException ex) + { + MessageBox.Show(ex.Message, "Ошибка добавления", MessageBoxButtons.OK, MessageBoxIcon.Error); _logger.LogWarning("Ошибка добавления: " + ex.Message); } } -- 2.25.1