Add Series Order column
This commit is contained in:
parent
f8c6b836c3
commit
a71ccbac6e
@ -142,6 +142,16 @@
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</controls:DataGridTemplateColumnExt>
|
||||
|
||||
<controls:DataGridTemplateColumnExt Width="Auto" Header="Series
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}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate x:DataType="uibase:IGridEntry">
|
||||
|
||||
@ -142,8 +142,15 @@ namespace LibationFileManager
|
||||
[Description("Lame target VBR quality [10,100]")]
|
||||
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")]
|
||||
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")]
|
||||
public Dictionary<string, int> GridColumnsDisplayIndices { get => GetNonString(defaultValue: new EquatableDictionary<string, int>()).Clone(); set => SetNonString(value); }
|
||||
|
||||
@ -40,6 +40,7 @@ namespace LibationUiBase.GridView
|
||||
private LastDownloadStatus _lastDownload;
|
||||
private object _cover;
|
||||
private string _series;
|
||||
private SeriesOrder _seriesOrder;
|
||||
private string _title;
|
||||
private string _authors;
|
||||
private string _narrators;
|
||||
@ -57,6 +58,7 @@ namespace LibationUiBase.GridView
|
||||
public LastDownloadStatus LastDownload { get => _lastDownload; protected set => RaiseAndSetIfChanged(ref _lastDownload, value); }
|
||||
public object Cover { get => _cover; private set => RaiseAndSetIfChanged(ref _cover, 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 Authors { get => _authors; private set => RaiseAndSetIfChanged(ref _authors, value); }
|
||||
public string Narrators { get => _narrators; private set => RaiseAndSetIfChanged(ref _narrators, value); }
|
||||
@ -105,6 +107,7 @@ namespace LibationUiBase.GridView
|
||||
|
||||
Title = Book.Title;
|
||||
Series = Book.SeriesNames(includeIndex: true);
|
||||
SeriesOrder = new SeriesOrder(Book.SeriesLink);
|
||||
Length = GetBookLengthString();
|
||||
//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.
|
||||
@ -200,6 +203,7 @@ namespace LibationUiBase.GridView
|
||||
{ nameof(Remove), () => Remove.HasValue ? Remove.Value ? RemoveStatus.Removed : RemoveStatus.NotRemoved : RemoveStatus.SomeRemoved },
|
||||
{ nameof(Title), () => Book.TitleSortable() },
|
||||
{ nameof(Series), () => Book.SeriesSortable() },
|
||||
{ nameof(SeriesOrder), () => SeriesOrder },
|
||||
{ nameof(Length), () => GetLengthInMinutes() },
|
||||
{ nameof(MyRating), () => Book.UserDefinedItem.Rating },
|
||||
{ nameof(PurchaseDate), () => GetPurchaseDate() },
|
||||
@ -233,6 +237,7 @@ namespace LibationUiBase.GridView
|
||||
{ typeof(Rating), new ObjectComparer<Rating>() },
|
||||
{ typeof(DateTime), new ObjectComparer<DateTime>() },
|
||||
{ typeof(EntryStatus), new ObjectComparer<EntryStatus>() },
|
||||
{ typeof(SeriesOrder), new ObjectComparer<SeriesOrder>() },
|
||||
{ typeof(LastDownloadStatus), new ObjectComparer<LastDownloadStatus>() },
|
||||
};
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ namespace LibationUiBase.GridView
|
||||
string Length { get; }
|
||||
LastDownloadStatus LastDownload { get; }
|
||||
string Series { get; }
|
||||
SeriesOrder SeriesOrder { get; }
|
||||
string Title { get; }
|
||||
string Authors { get; }
|
||||
string Narrators { get; }
|
||||
|
||||
41
Source/LibationUiBase/GridView/SeriesOrder.cs
Normal file
41
Source/LibationUiBase/GridView/SeriesOrder.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -41,6 +41,7 @@ namespace LibationWinForms.GridView
|
||||
this.narratorsGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.lengthGVColumn = 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.categoryGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.productRatingGVColumn = new LibationWinForms.GridView.MyRatingGridViewColumn();
|
||||
@ -72,7 +73,8 @@ namespace LibationWinForms.GridView
|
||||
this.narratorsGVColumn,
|
||||
this.lengthGVColumn,
|
||||
this.seriesGVColumn,
|
||||
this.descriptionGVColumn,
|
||||
this.seriesOrderGVColumn,
|
||||
this.descriptionGVColumn,
|
||||
this.categoryGVColumn,
|
||||
this.productRatingGVColumn,
|
||||
this.purchaseDateGVColumn,
|
||||
@ -173,6 +175,15 @@ namespace LibationWinForms.GridView
|
||||
this.seriesGVColumn.Name = "seriesGVColumn";
|
||||
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
|
||||
//
|
||||
this.descriptionGVColumn.DataPropertyName = "Description";
|
||||
@ -275,6 +286,7 @@ namespace LibationWinForms.GridView
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn narratorsGVColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn lengthGVColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn seriesGVColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn seriesOrderGVColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn descriptionGVColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn categoryGVColumn;
|
||||
private MyRatingGridViewColumn productRatingGVColumn;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user