Comments and renaming.
This commit is contained in:
parent
f81552565a
commit
e1dfefbadf
@ -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<string, Func<object>> _compareValues { get; }
|
||||
private static Dictionary<Type, IComparer> _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];
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate comparers for every type needed to sort columns.
|
||||
@ -137,6 +134,7 @@ namespace LibationWinForms
|
||||
{ typeof(LiberatedState), new ObjectComparer<LiberatedState>() },
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create getters for all member values by name
|
||||
/// </summary>
|
||||
@ -277,7 +275,7 @@ namespace LibationWinForms
|
||||
}
|
||||
|
||||
private static string GetStarString(Rating rating)
|
||||
=> (rating?.FirstScore != null && rating?.FirstScore > 0f)
|
||||
=> (rating?.FirstScore > 0f)
|
||||
? rating?.ToStarString()
|
||||
: "";
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ namespace LibationWinForms
|
||||
{
|
||||
interface IObjectMemberComparable
|
||||
{
|
||||
IComparer GetComparer(Type propertyType);
|
||||
object GetMemberValue(string valueName);
|
||||
IComparer GetMemberComparer(Type memberType);
|
||||
object GetMemberValue(string memberName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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<int> 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<GridEntry>(orderedGridEntries);
|
||||
|
||||
//
|
||||
// FILTER
|
||||
//
|
||||
Filter();
|
||||
|
||||
BackupCountsChanged?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user