Comments and renaming.
This commit is contained in:
parent
f81552565a
commit
e1dfefbadf
@ -14,9 +14,6 @@ namespace LibationWinForms
|
|||||||
{
|
{
|
||||||
internal class GridEntry : INotifyPropertyChanged, IObjectMemberComparable
|
internal class GridEntry : INotifyPropertyChanged, IObjectMemberComparable
|
||||||
{
|
{
|
||||||
public const string LIBERATE_COLUMN_NAME = "Liberate";
|
|
||||||
public const string EDIT_TAGS_COLUMN_NAME = "DisplayTags";
|
|
||||||
|
|
||||||
#region implementation properties
|
#region implementation properties
|
||||||
// hide from public fields from Data Source GUI with [Browsable(false)]
|
// 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 Dictionary<string, Func<object>> _compareValues { get; }
|
||||||
private static Dictionary<Type, IComparer> _objectComparers;
|
private static Dictionary<Type, IComparer> _objectComparers;
|
||||||
|
|
||||||
public virtual object GetMemberValue(string propertyName) => _compareValues[propertyName]();
|
public virtual object GetMemberValue(string memberName) => _compareValues[memberName]();
|
||||||
public virtual IComparer GetComparer(Type propertyType) => _objectComparers[propertyType];
|
public virtual IComparer GetMemberComparer(Type memberType) => _objectComparers[memberType];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Instantiate comparers for every type needed to sort columns.
|
/// Instantiate comparers for every type needed to sort columns.
|
||||||
@ -137,6 +134,7 @@ namespace LibationWinForms
|
|||||||
{ typeof(LiberatedState), new ObjectComparer<LiberatedState>() },
|
{ typeof(LiberatedState), new ObjectComparer<LiberatedState>() },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create getters for all member values by name
|
/// Create getters for all member values by name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -277,7 +275,7 @@ namespace LibationWinForms
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static string GetStarString(Rating rating)
|
private static string GetStarString(Rating rating)
|
||||||
=> (rating?.FirstScore != null && rating?.FirstScore > 0f)
|
=> (rating?.FirstScore > 0f)
|
||||||
? rating?.ToStarString()
|
? rating?.ToStarString()
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace LibationWinForms
|
|||||||
{
|
{
|
||||||
interface IObjectMemberComparable
|
interface IObjectMemberComparable
|
||||||
{
|
{
|
||||||
IComparer GetComparer(Type propertyType);
|
IComparer GetMemberComparer(Type memberType);
|
||||||
object GetMemberValue(string valueName);
|
object GetMemberValue(string memberName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace LibationWinForms
|
|||||||
var val1 = x.GetMemberValue(PropertyName);
|
var val1 = x.GetMemberValue(PropertyName);
|
||||||
var val2 = y.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;
|
private int DirMult => Direction == ListSortDirection.Descending ? -1 : 1;
|
||||||
|
|||||||
@ -23,6 +23,8 @@ namespace LibationWinForms
|
|||||||
// - go to Design view
|
// - go to Design view
|
||||||
// - click on Data Sources > ProductItem. drowdown: DataGridView
|
// - click on Data Sources > ProductItem. drowdown: DataGridView
|
||||||
// - drag/drop ProductItem on design surface
|
// - 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 partial class ProductsGrid : UserControl
|
||||||
{
|
{
|
||||||
public event EventHandler<int> VisibleCountChanged;
|
public event EventHandler<int> VisibleCountChanged;
|
||||||
@ -60,10 +62,10 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
switch (_dataGridView.Columns[e.ColumnIndex].DataPropertyName)
|
switch (_dataGridView.Columns[e.ColumnIndex].DataPropertyName)
|
||||||
{
|
{
|
||||||
case GridEntry.LIBERATE_COLUMN_NAME:
|
case nameof(liveGridEntry.Liberate):
|
||||||
await Liberate_Click(liveGridEntry);
|
await Liberate_Click(liveGridEntry);
|
||||||
break;
|
break;
|
||||||
case GridEntry.EDIT_TAGS_COLUMN_NAME:
|
case nameof(liveGridEntry.DisplayTags):
|
||||||
EditTags_Click(liveGridEntry);
|
EditTags_Click(liveGridEntry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -140,9 +142,7 @@ namespace LibationWinForms
|
|||||||
//
|
//
|
||||||
gridEntryBindingSource.DataSource = new SortableBindingList2<GridEntry>(orderedGridEntries);
|
gridEntryBindingSource.DataSource = new SortableBindingList2<GridEntry>(orderedGridEntries);
|
||||||
|
|
||||||
//
|
|
||||||
// FILTER
|
// FILTER
|
||||||
//
|
|
||||||
Filter();
|
Filter();
|
||||||
|
|
||||||
BackupCountsChanged?.Invoke(this, EventArgs.Empty);
|
BackupCountsChanged?.Invoke(this, EventArgs.Empty);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user