Add Series Order column

This commit is contained in:
Mbucari 2023-03-27 12:12:31 -06:00
parent f8c6b836c3
commit a71ccbac6e
6 changed files with 78 additions and 2 deletions

View File

@ -142,6 +142,16 @@
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</controls:DataGridTemplateColumnExt> </controls:DataGridTemplateColumnExt>
<controls:DataGridTemplateColumnExt Width="Auto" Header="Series&#xA;Order" CanUserSort="True" SortMemberPath="SeriesOrder" ClipboardContentBinding="{Binding Series}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="uibase:IGridEntry">
<Panel Opacity="{CompiledBinding Liberate.Opacity}" Background="{CompiledBinding Liberate.BackgroundBrush}">
<TextBlock Text="{CompiledBinding SeriesOrder}" HorizontalAlignment="Center" />
</Panel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</controls:DataGridTemplateColumnExt>
<controls:DataGridTemplateColumnExt MinWidth="100" Width="1*" Header="Description" CanUserSort="True" SortMemberPath="Description" ClipboardContentBinding="{Binding LongDescription}"> <controls:DataGridTemplateColumnExt MinWidth="100" Width="1*" Header="Description" CanUserSort="True" SortMemberPath="Description" ClipboardContentBinding="{Binding LongDescription}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="uibase:IGridEntry"> <DataTemplate x:DataType="uibase:IGridEntry">

View File

@ -142,8 +142,15 @@ namespace LibationFileManager
[Description("Lame target VBR quality [10,100]")] [Description("Lame target VBR quality [10,100]")]
public int LameVBRQuality { get => GetNonString(defaultValue: 2); set => SetNonString(value); } public int LameVBRQuality { get => GetNonString(defaultValue: 2); set => SetNonString(value); }
private static readonly EquatableDictionary<string, bool> DefaultColumns = new(
new KeyValuePair<string, bool>[]
{
new ("SeriesOrder", false),
new ("LastDownload", false)
});
[Description("A Dictionary of GridView data property names and bool indicating its column's visibility in ProductsGrid")] [Description("A Dictionary of GridView data property names and bool indicating its column's visibility in ProductsGrid")]
public Dictionary<string, bool> GridColumnsVisibilities { get => GetNonString(defaultValue: new EquatableDictionary<string, bool>()).Clone(); set => SetNonString(value); } public Dictionary<string, bool> GridColumnsVisibilities { get => GetNonString(defaultValue: DefaultColumns).Clone(); set => SetNonString(value); }
[Description("A Dictionary of GridView data property names and int indicating its column's display index in ProductsGrid")] [Description("A Dictionary of GridView data property names and int indicating its column's display index in ProductsGrid")]
public Dictionary<string, int> GridColumnsDisplayIndices { get => GetNonString(defaultValue: new EquatableDictionary<string, int>()).Clone(); set => SetNonString(value); } public Dictionary<string, int> GridColumnsDisplayIndices { get => GetNonString(defaultValue: new EquatableDictionary<string, int>()).Clone(); set => SetNonString(value); }

View File

@ -40,6 +40,7 @@ namespace LibationUiBase.GridView
private LastDownloadStatus _lastDownload; private LastDownloadStatus _lastDownload;
private object _cover; private object _cover;
private string _series; private string _series;
private SeriesOrder _seriesOrder;
private string _title; private string _title;
private string _authors; private string _authors;
private string _narrators; private string _narrators;
@ -57,6 +58,7 @@ namespace LibationUiBase.GridView
public LastDownloadStatus LastDownload { get => _lastDownload; protected set => RaiseAndSetIfChanged(ref _lastDownload, value); } public LastDownloadStatus LastDownload { get => _lastDownload; protected set => RaiseAndSetIfChanged(ref _lastDownload, value); }
public object Cover { get => _cover; private set => RaiseAndSetIfChanged(ref _cover, value); } public object Cover { get => _cover; private set => RaiseAndSetIfChanged(ref _cover, value); }
public string Series { get => _series; private set => RaiseAndSetIfChanged(ref _series, value); } public string Series { get => _series; private set => RaiseAndSetIfChanged(ref _series, value); }
public SeriesOrder SeriesOrder { get => _seriesOrder; private set => RaiseAndSetIfChanged(ref _seriesOrder, value); }
public string Title { get => _title; private set => RaiseAndSetIfChanged(ref _title, value); } public string Title { get => _title; private set => RaiseAndSetIfChanged(ref _title, value); }
public string Authors { get => _authors; private set => RaiseAndSetIfChanged(ref _authors, value); } public string Authors { get => _authors; private set => RaiseAndSetIfChanged(ref _authors, value); }
public string Narrators { get => _narrators; private set => RaiseAndSetIfChanged(ref _narrators, value); } public string Narrators { get => _narrators; private set => RaiseAndSetIfChanged(ref _narrators, value); }
@ -105,6 +107,7 @@ namespace LibationUiBase.GridView
Title = Book.Title; Title = Book.Title;
Series = Book.SeriesNames(includeIndex: true); Series = Book.SeriesNames(includeIndex: true);
SeriesOrder = new SeriesOrder(Book.SeriesLink);
Length = GetBookLengthString(); Length = GetBookLengthString();
//Ratings are changed using Update(), which is a problem for Avalonia data bindings because //Ratings are changed using Update(), which is a problem for Avalonia data bindings because
//the reference doesn't change. Clone the rating so that it updates within Avalonia properly. //the reference doesn't change. Clone the rating so that it updates within Avalonia properly.
@ -200,6 +203,7 @@ namespace LibationUiBase.GridView
{ nameof(Remove), () => Remove.HasValue ? Remove.Value ? RemoveStatus.Removed : RemoveStatus.NotRemoved : RemoveStatus.SomeRemoved }, { nameof(Remove), () => Remove.HasValue ? Remove.Value ? RemoveStatus.Removed : RemoveStatus.NotRemoved : RemoveStatus.SomeRemoved },
{ nameof(Title), () => Book.TitleSortable() }, { nameof(Title), () => Book.TitleSortable() },
{ nameof(Series), () => Book.SeriesSortable() }, { nameof(Series), () => Book.SeriesSortable() },
{ nameof(SeriesOrder), () => SeriesOrder },
{ nameof(Length), () => GetLengthInMinutes() }, { nameof(Length), () => GetLengthInMinutes() },
{ nameof(MyRating), () => Book.UserDefinedItem.Rating }, { nameof(MyRating), () => Book.UserDefinedItem.Rating },
{ nameof(PurchaseDate), () => GetPurchaseDate() }, { nameof(PurchaseDate), () => GetPurchaseDate() },
@ -233,6 +237,7 @@ namespace LibationUiBase.GridView
{ typeof(Rating), new ObjectComparer<Rating>() }, { typeof(Rating), new ObjectComparer<Rating>() },
{ typeof(DateTime), new ObjectComparer<DateTime>() }, { typeof(DateTime), new ObjectComparer<DateTime>() },
{ typeof(EntryStatus), new ObjectComparer<EntryStatus>() }, { typeof(EntryStatus), new ObjectComparer<EntryStatus>() },
{ typeof(SeriesOrder), new ObjectComparer<SeriesOrder>() },
{ typeof(LastDownloadStatus), new ObjectComparer<LastDownloadStatus>() }, { typeof(LastDownloadStatus), new ObjectComparer<LastDownloadStatus>() },
}; };

View File

@ -20,6 +20,7 @@ namespace LibationUiBase.GridView
string Length { get; } string Length { get; }
LastDownloadStatus LastDownload { get; } LastDownloadStatus LastDownload { get; }
string Series { get; } string Series { get; }
SeriesOrder SeriesOrder { get; }
string Title { get; } string Title { get; }
string Authors { get; } string Authors { get; }
string Narrators { get; } string Narrators { get; }

View File

@ -0,0 +1,41 @@
using DataLayer;
using System;
using System.Collections.Generic;
using System.Linq;
namespace LibationUiBase.GridView
{
public class SeriesOrder : IComparable
{
private float[] Orders { get; }
public string OrderString { get; }
public SeriesOrder(IEnumerable<SeriesBook> seriesBooks)
{
var orderstrings = seriesBooks
.Where(s => s.Index > 0)
.Select(s => s.Order == "-1" ? "-" : $"#{s.Order}")
.ToList();
OrderString = string.Join(", ", orderstrings);
Orders = seriesBooks.Where(s => s.Index > 0).Select(s => s.Index).ToArray();
}
public override string ToString() => OrderString;
public int CompareTo(object obj)
{
if (obj is not SeriesOrder other) return 1;
int count = int.Min(Orders.Length, other.Orders.Length);
for (int i = 0; i < count; i++)
{
var compare = Orders[i].CompareTo(other.Orders[i]);
if (compare != 0) return compare;
}
if (Orders.Length < other.Orders.Length) return 1;
if (Orders.Length > other.Orders.Length) return -1;
return 0;
}
}
}

View File

@ -41,6 +41,7 @@ namespace LibationWinForms.GridView
this.narratorsGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.narratorsGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.lengthGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.lengthGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.seriesGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.seriesGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.seriesOrderGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.descriptionGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.descriptionGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.categoryGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.categoryGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.productRatingGVColumn = new LibationWinForms.GridView.MyRatingGridViewColumn(); this.productRatingGVColumn = new LibationWinForms.GridView.MyRatingGridViewColumn();
@ -72,6 +73,7 @@ namespace LibationWinForms.GridView
this.narratorsGVColumn, this.narratorsGVColumn,
this.lengthGVColumn, this.lengthGVColumn,
this.seriesGVColumn, this.seriesGVColumn,
this.seriesOrderGVColumn,
this.descriptionGVColumn, this.descriptionGVColumn,
this.categoryGVColumn, this.categoryGVColumn,
this.productRatingGVColumn, this.productRatingGVColumn,
@ -173,6 +175,15 @@ namespace LibationWinForms.GridView
this.seriesGVColumn.Name = "seriesGVColumn"; this.seriesGVColumn.Name = "seriesGVColumn";
this.seriesGVColumn.ReadOnly = true; this.seriesGVColumn.ReadOnly = true;
// //
// seriesOrderGVColumn
//
this.seriesOrderGVColumn.DataPropertyName = "SeriesOrder";
this.seriesOrderGVColumn.HeaderText = "Series\r\nOrder";
this.seriesOrderGVColumn.Name = "seriesOrderGVColumn";
this.seriesOrderGVColumn.Width = 60;
this.seriesOrderGVColumn.ReadOnly = true;
this.seriesOrderGVColumn.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
//
// descriptionGVColumn // descriptionGVColumn
// //
this.descriptionGVColumn.DataPropertyName = "Description"; this.descriptionGVColumn.DataPropertyName = "Description";
@ -275,6 +286,7 @@ namespace LibationWinForms.GridView
private System.Windows.Forms.DataGridViewTextBoxColumn narratorsGVColumn; private System.Windows.Forms.DataGridViewTextBoxColumn narratorsGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn lengthGVColumn; private System.Windows.Forms.DataGridViewTextBoxColumn lengthGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn seriesGVColumn; private System.Windows.Forms.DataGridViewTextBoxColumn seriesGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn seriesOrderGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn descriptionGVColumn; private System.Windows.Forms.DataGridViewTextBoxColumn descriptionGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn categoryGVColumn; private System.Windows.Forms.DataGridViewTextBoxColumn categoryGVColumn;
private MyRatingGridViewColumn productRatingGVColumn; private MyRatingGridViewColumn productRatingGVColumn;