From e1dfefbadf321a4a5c7d2a355c188f4c20a0bcde Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Tue, 10 Aug 2021 10:17:02 -0600 Subject: [PATCH] Comments and renaming. --- LibationWinForms/GridEntry.cs | 10 ++++------ LibationWinForms/IObjectMemberComparable.cs | 4 ++-- LibationWinForms/ObjectMemberComparer[T].cs | 2 +- LibationWinForms/ProductsGrid.cs | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/LibationWinForms/GridEntry.cs b/LibationWinForms/GridEntry.cs index 5113d10f..25db3669 100644 --- a/LibationWinForms/GridEntry.cs +++ b/LibationWinForms/GridEntry.cs @@ -14,9 +14,6 @@ namespace LibationWinForms { internal class GridEntry : INotifyPropertyChanged, IObjectMemberComparable { - public const string LIBERATE_COLUMN_NAME = "Liberate"; - public const string EDIT_TAGS_COLUMN_NAME = "DisplayTags"; - #region implementation properties // hide from public fields from Data Source GUI with [Browsable(false)] @@ -120,8 +117,8 @@ namespace LibationWinForms private Dictionary> _compareValues { get; } private static Dictionary _objectComparers; - public virtual object GetMemberValue(string propertyName) => _compareValues[propertyName](); - public virtual IComparer GetComparer(Type propertyType) => _objectComparers[propertyType]; + public virtual object GetMemberValue(string memberName) => _compareValues[memberName](); + public virtual IComparer GetMemberComparer(Type memberType) => _objectComparers[memberType]; /// /// Instantiate comparers for every type needed to sort columns. @@ -137,6 +134,7 @@ namespace LibationWinForms { typeof(LiberatedState), new ObjectComparer() }, }; } + /// /// Create getters for all member values by name /// @@ -277,7 +275,7 @@ namespace LibationWinForms } private static string GetStarString(Rating rating) - => (rating?.FirstScore != null && rating?.FirstScore > 0f) + => (rating?.FirstScore > 0f) ? rating?.ToStarString() : ""; diff --git a/LibationWinForms/IObjectMemberComparable.cs b/LibationWinForms/IObjectMemberComparable.cs index 8bc5b762..ade585ab 100644 --- a/LibationWinForms/IObjectMemberComparable.cs +++ b/LibationWinForms/IObjectMemberComparable.cs @@ -5,7 +5,7 @@ namespace LibationWinForms { interface IObjectMemberComparable { - IComparer GetComparer(Type propertyType); - object GetMemberValue(string valueName); + IComparer GetMemberComparer(Type memberType); + object GetMemberValue(string memberName); } } diff --git a/LibationWinForms/ObjectMemberComparer[T].cs b/LibationWinForms/ObjectMemberComparer[T].cs index 00f29510..aea41e21 100644 --- a/LibationWinForms/ObjectMemberComparer[T].cs +++ b/LibationWinForms/ObjectMemberComparer[T].cs @@ -13,7 +13,7 @@ namespace LibationWinForms var val1 = x.GetMemberValue(PropertyName); var val2 = y.GetMemberValue(PropertyName); - return DirMult * x.GetComparer(val1.GetType()).Compare(val1, val2); + return DirMult * x.GetMemberComparer(val1.GetType()).Compare(val1, val2); } private int DirMult => Direction == ListSortDirection.Descending ? -1 : 1; diff --git a/LibationWinForms/ProductsGrid.cs b/LibationWinForms/ProductsGrid.cs index 10af0c41..292d6a17 100644 --- a/LibationWinForms/ProductsGrid.cs +++ b/LibationWinForms/ProductsGrid.cs @@ -23,6 +23,8 @@ namespace LibationWinForms // - go to Design view // - click on Data Sources > ProductItem. drowdown: DataGridView // - drag/drop ProductItem on design surface + // AS OF AUGUST 2021 THIS DOES NOT WORK IN VS2019 WITH .NET-5 PROJECTS + public partial class ProductsGrid : UserControl { public event EventHandler VisibleCountChanged; @@ -60,10 +62,10 @@ namespace LibationWinForms switch (_dataGridView.Columns[e.ColumnIndex].DataPropertyName) { - case GridEntry.LIBERATE_COLUMN_NAME: + case nameof(liveGridEntry.Liberate): await Liberate_Click(liveGridEntry); break; - case GridEntry.EDIT_TAGS_COLUMN_NAME: + case nameof(liveGridEntry.DisplayTags): EditTags_Click(liveGridEntry); break; } @@ -140,9 +142,7 @@ namespace LibationWinForms // gridEntryBindingSource.DataSource = new SortableBindingList2(orderedGridEntries); - // // FILTER - // Filter(); BackupCountsChanged?.Invoke(this, EventArgs.Empty);