Remain classes and fix adding row to EditTagsDialog
This commit is contained in:
parent
4cfe72a63b
commit
51fee4ae24
22 changed files with 140 additions and 129 deletions
|
|
@ -22,7 +22,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
SomeRemoved
|
||||
}
|
||||
/// <summary>The View Model base for the DataGridView</summary>
|
||||
public abstract class GridEntry2 : ViewModelBase
|
||||
public abstract class GridEntry : ViewModelBase
|
||||
{
|
||||
[Browsable(false)] public string AudibleProductId => Book.AudibleProductId;
|
||||
[Browsable(false)] public LibraryBook LibraryBook { get; protected set; }
|
||||
|
|
@ -50,7 +50,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
protected bool? _remove = false;
|
||||
public abstract bool? Remove { get; set; }
|
||||
public abstract LiberateButtonStatus2 Liberate { get; }
|
||||
public abstract LiberateButtonStatus Liberate { get; }
|
||||
public abstract BookTags BookTags { get; }
|
||||
public abstract bool IsSeries { get; }
|
||||
public abstract bool IsEpisode { get; }
|
||||
|
|
@ -61,7 +61,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
#region Sorting
|
||||
|
||||
public GridEntry2() => _memberValues = CreateMemberValueDictionary();
|
||||
public GridEntry() => _memberValues = CreateMemberValueDictionary();
|
||||
|
||||
// These methods are implementation of Dinah.Core.DataBinding.IMemberComparable
|
||||
// Used by GridEntryBindingList for all sorting
|
||||
|
|
@ -79,7 +79,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
{ typeof(float), new ObjectComparer<float>() },
|
||||
{ typeof(bool), new ObjectComparer<bool>() },
|
||||
{ typeof(DateTime), new ObjectComparer<DateTime>() },
|
||||
{ typeof(LiberateButtonStatus2), new ObjectComparer<LiberateButtonStatus2>() },
|
||||
{ typeof(LiberateButtonStatus), new ObjectComparer<LiberateButtonStatus>() },
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
|
@ -113,7 +113,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
#region Static library display functions
|
||||
|
||||
/// <summary>This information should not change during <see cref="GridEntry2"/> lifetime, so call only once.</summary>
|
||||
/// <summary>This information should not change during <see cref="GridEntry"/> lifetime, so call only once.</summary>
|
||||
protected static string GetDescriptionDisplay(Book book)
|
||||
{
|
||||
var doc = new HtmlAgilityPack.HtmlDocument();
|
||||
|
|
@ -131,7 +131,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// This information should not change during <see cref="GridEntry2"/> lifetime, so call only once.
|
||||
/// This information should not change during <see cref="GridEntry"/> lifetime, so call only once.
|
||||
/// Maximum of 5 text rows will fit in 80-pixel row height.
|
||||
/// </summary>
|
||||
protected static string GetMiscDisplay(LibraryBook libraryBook)
|
||||
|
|
@ -161,7 +161,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
#endregion
|
||||
|
||||
~GridEntry2()
|
||||
~GridEntry()
|
||||
{
|
||||
PictureStorage.PictureCached -= PictureStorage_PictureCached;
|
||||
}
|
||||
|
|
@ -23,32 +23,32 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
* but requires ResetCollection() to be called after all changes
|
||||
* have been made.
|
||||
*/
|
||||
public class GridEntryBindingList2 : ObservableCollection<GridEntry2>
|
||||
public class GridEntryCollection : ObservableCollection<GridEntry>
|
||||
{
|
||||
public GridEntryBindingList2(IEnumerable<GridEntry2> enumeration)
|
||||
: base(new List<GridEntry2>(enumeration)) { }
|
||||
public GridEntryBindingList2(List<GridEntry2> list)
|
||||
public GridEntryCollection(IEnumerable<GridEntry> enumeration)
|
||||
: base(new List<GridEntry>(enumeration)) { }
|
||||
public GridEntryCollection(List<GridEntry> list)
|
||||
: base(list) { }
|
||||
|
||||
public List<GridEntry2> InternalList => Items as List<GridEntry2>;
|
||||
public List<GridEntry> InternalList => Items as List<GridEntry>;
|
||||
/// <returns>All items in the list, including those filtered out.</returns>
|
||||
public List<GridEntry2> AllItems() => Items.Concat(FilterRemoved).ToList();
|
||||
public List<GridEntry> AllItems() => Items.Concat(FilterRemoved).ToList();
|
||||
|
||||
/// <summary>When true, itms will not be checked filtered by search criteria on item changed<summary>
|
||||
public bool SuspendFilteringOnUpdate { get; set; }
|
||||
public string Filter { get => FilterString; set => ApplyFilter(value); }
|
||||
|
||||
/// <summary> Items that were removed from the base list due to filtering </summary>
|
||||
private readonly List<GridEntry2> FilterRemoved = new();
|
||||
private readonly List<GridEntry> FilterRemoved = new();
|
||||
private string FilterString;
|
||||
private SearchResultSet SearchResults;
|
||||
|
||||
#region Items Management
|
||||
|
||||
public void ReplaceList(IEnumerable<GridEntry2> newItems)
|
||||
public void ReplaceList(IEnumerable<GridEntry> newItems)
|
||||
{
|
||||
Items.Clear();
|
||||
((List<GridEntry2>)Items).AddRange(newItems);
|
||||
((List<GridEntry>)Items).AddRange(newItems);
|
||||
ResetCollection();
|
||||
}
|
||||
public void ResetCollection()
|
||||
|
|
@ -67,7 +67,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
FilterString = filterString;
|
||||
SearchResults = SearchEngineCommands.Search(filterString);
|
||||
|
||||
var booksFilteredIn = Items.BookEntries().Join(SearchResults.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => (GridEntry2)lbe);
|
||||
var booksFilteredIn = Items.BookEntries().Join(SearchResults.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => (GridEntry)lbe);
|
||||
|
||||
//Find all series containing children that match the search criteria
|
||||
var seriesFilteredIn = Items.SeriesEntries().Where(s => s.Children.Join(SearchResults.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => lbe).Any());
|
||||
|
|
@ -90,7 +90,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
foreach (var item in FilterRemoved.ToList())
|
||||
{
|
||||
if (item is SeriesEntrys2 || item is LibraryBookEntry2 lbe && (lbe.Parent is null || lbe.Parent.Liberate.Expanded))
|
||||
if (item is SeriesEntry || item is LibraryBookEntry lbe && (lbe.Parent is null || lbe.Parent.Liberate.Expanded))
|
||||
{
|
||||
|
||||
FilterRemoved.Remove(item);
|
||||
|
|
@ -119,7 +119,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
ExpandItem(series);
|
||||
}
|
||||
|
||||
public void CollapseItem(SeriesEntrys2 sEntry)
|
||||
public void CollapseItem(SeriesEntry sEntry)
|
||||
{
|
||||
foreach (var episode in Items.BookEntries().Where(b => b.Parent == sEntry).OrderByDescending(lbe => lbe.SeriesIndex).ToList())
|
||||
{
|
||||
|
|
@ -141,7 +141,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
ResetCollection();
|
||||
}
|
||||
|
||||
public void ExpandItem(SeriesEntrys2 sEntry)
|
||||
public void ExpandItem(SeriesEntry sEntry)
|
||||
{
|
||||
var sindex = Items.IndexOf(sEntry);
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ using System.Collections.Generic;
|
|||
|
||||
namespace LibationWinForms.AvaloniaUI.ViewModels
|
||||
{
|
||||
public class LiberateButtonStatus2 : ViewModelBase, IComparable
|
||||
public class LiberateButtonStatus : ViewModelBase, IComparable
|
||||
{
|
||||
public LiberateButtonStatus2(bool isSeries)
|
||||
public LiberateButtonStatus(bool isSeries)
|
||||
{
|
||||
IsSeries = isSeries;
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
/// <summary> Defines the Liberate column's sorting behavior </summary>
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (obj is not LiberateButtonStatus2 second) return -1;
|
||||
if (obj is not LiberateButtonStatus second) return -1;
|
||||
|
||||
if (IsSeries && !second.IsSeries) return -1;
|
||||
else if (!IsSeries && second.IsSeries) return 1;
|
||||
|
|
@ -10,10 +10,10 @@ using System.Linq;
|
|||
namespace LibationWinForms.AvaloniaUI.ViewModels
|
||||
{
|
||||
/// <summary>The View Model for a LibraryBook that is ContentType.Product or ContentType.Episode</summary>
|
||||
public class LibraryBookEntry2 : GridEntry2
|
||||
public class LibraryBookEntry : GridEntry
|
||||
{
|
||||
[Browsable(false)] public override DateTime DateAdded => LibraryBook.DateAdded;
|
||||
[Browsable(false)] public SeriesEntrys2 Parent { get; init; }
|
||||
[Browsable(false)] public SeriesEntry Parent { get; init; }
|
||||
|
||||
#region Model properties exposed to the view
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public override LiberateButtonStatus2 Liberate
|
||||
public override LiberateButtonStatus Liberate
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -44,7 +44,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
_pdfStatus = LibraryCommands.Pdf_Status(LibraryBook.Book);
|
||||
lastStatusUpdate = DateTime.Now;
|
||||
}
|
||||
return new LiberateButtonStatus2(IsSeries) { BookStatus = _bookStatus, PdfStatus = _pdfStatus };
|
||||
return new LiberateButtonStatus(IsSeries) { BookStatus = _bookStatus, PdfStatus = _pdfStatus };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
#endregion
|
||||
|
||||
public LibraryBookEntry2(LibraryBook libraryBook)
|
||||
public LibraryBookEntry(LibraryBook libraryBook)
|
||||
{
|
||||
LibraryBook = libraryBook;
|
||||
LoadCover();
|
||||
|
|
@ -144,7 +144,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
#endregion
|
||||
|
||||
~LibraryBookEntry2()
|
||||
~LibraryBookEntry()
|
||||
{
|
||||
UserDefinedItem.ItemChanged -= UserDefinedItem_ItemChanged;
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
/// <summary>
|
||||
/// This is the viewmodel for queued processables
|
||||
/// </summary>
|
||||
public class ProcessBook2 : ViewModelBase
|
||||
public class ProcessBookViewModel : ViewModelBase
|
||||
{
|
||||
public event EventHandler Completed;
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
private readonly Queue<Func<Processable>> Processes = new();
|
||||
private readonly ProcessQueue.LogMe Logger;
|
||||
|
||||
public ProcessBook2(LibraryBook libraryBook, ProcessQueue.LogMe logme)
|
||||
public ProcessBookViewModel(LibraryBook libraryBook, ProcessQueue.LogMe logme)
|
||||
{
|
||||
LibraryBook = libraryBook;
|
||||
Logger = logme;
|
||||
|
|
@ -14,10 +14,10 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
public class ProcessQueueViewModel : ViewModelBase, ProcessQueue.ILogForm
|
||||
{
|
||||
public ObservableCollection<LogEntry> LogEntries { get; } = new();
|
||||
public TrackedQueue2<ProcessBook2> Items { get; } = new();
|
||||
public TrackedQueue<ProcessBookViewModel> Items { get; } = new();
|
||||
|
||||
private TrackedQueue2<ProcessBook2> Queue => Items;
|
||||
public ProcessBook2 SelectedItem { get; set; }
|
||||
private TrackedQueue<ProcessBookViewModel> Queue => Items;
|
||||
public ProcessBookViewModel SelectedItem { get; set; }
|
||||
public Task QueueRunner { get; private set; }
|
||||
public bool Running => !QueueRunner?.IsCompleted ?? false;
|
||||
|
||||
|
|
@ -88,13 +88,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
public void AddDownloadPdf(IEnumerable<LibraryBook> entries)
|
||||
{
|
||||
List<ProcessBook2> procs = new();
|
||||
List<ProcessBookViewModel> procs = new();
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
if (isBookInQueue(entry))
|
||||
continue;
|
||||
|
||||
ProcessBook2 pbook = new(entry, Logger);
|
||||
ProcessBookViewModel pbook = new(entry, Logger);
|
||||
pbook.AddDownloadPdf();
|
||||
procs.Add(pbook);
|
||||
}
|
||||
|
|
@ -105,13 +105,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
public void AddDownloadDecrypt(IEnumerable<LibraryBook> entries)
|
||||
{
|
||||
List<ProcessBook2> procs = new();
|
||||
List<ProcessBookViewModel> procs = new();
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
if (isBookInQueue(entry))
|
||||
continue;
|
||||
|
||||
ProcessBook2 pbook = new(entry, Logger);
|
||||
ProcessBookViewModel pbook = new(entry, Logger);
|
||||
pbook.AddDownloadDecryptBook();
|
||||
pbook.AddDownloadPdf();
|
||||
procs.Add(pbook);
|
||||
|
|
@ -123,13 +123,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
public void AddConvertMp3(IEnumerable<LibraryBook> entries)
|
||||
{
|
||||
List<ProcessBook2> procs = new();
|
||||
List<ProcessBookViewModel> procs = new();
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
if (isBookInQueue(entry))
|
||||
continue;
|
||||
|
||||
ProcessBook2 pbook = new(entry, Logger);
|
||||
ProcessBookViewModel pbook = new(entry, Logger);
|
||||
pbook.AddConvertToMp3();
|
||||
procs.Add(pbook);
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
AddToQueue(procs);
|
||||
}
|
||||
|
||||
public void AddToQueue(IEnumerable<ProcessBook2> pbook)
|
||||
public void AddToQueue(IEnumerable<ProcessBookViewModel> pbook)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
private DataGridColumn _currentSortColumn;
|
||||
private DataGrid productsDataGrid;
|
||||
|
||||
private GridEntryBindingList2 _gridEntries;
|
||||
private GridEntryCollection _gridEntries;
|
||||
private bool _removeColumnVisivle;
|
||||
public GridEntryBindingList2 GridEntries { get => _gridEntries; private set => this.RaiseAndSetIfChanged(ref _gridEntries, value); }
|
||||
public GridEntryCollection GridEntries { get => _gridEntries; private set => this.RaiseAndSetIfChanged(ref _gridEntries, value); }
|
||||
public bool RemoveColumnVisivle { get => _removeColumnVisivle; private set => this.RaiseAndSetIfChanged(ref _removeColumnVisivle, value); }
|
||||
|
||||
public List<LibraryBook> GetVisibleBookEntries()
|
||||
|
|
@ -35,14 +35,14 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
.BookEntries()
|
||||
.Select(lbe => lbe.LibraryBook)
|
||||
.ToList();
|
||||
public IEnumerable<LibraryBookEntry2> GetAllBookEntries()
|
||||
public IEnumerable<LibraryBookEntry> GetAllBookEntries()
|
||||
=> GridEntries
|
||||
.AllItems()
|
||||
.BookEntries();
|
||||
public ProductsDisplayViewModel() { }
|
||||
public ProductsDisplayViewModel(List<GridEntry2> items)
|
||||
public ProductsDisplayViewModel(List<GridEntry> items)
|
||||
{
|
||||
GridEntries = new GridEntryBindingList2(items);
|
||||
GridEntries = new GridEntryCollection(items);
|
||||
}
|
||||
|
||||
#region Display Functions
|
||||
|
|
@ -50,7 +50,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
/// <summary>
|
||||
/// Call once on load so we can modify access a private member with reflection
|
||||
/// </summary>
|
||||
public void RegisterCollectionChanged(ProductsDisplay2 productsDisplay = null)
|
||||
public void RegisterCollectionChanged(ProductsDisplay productsDisplay = null)
|
||||
{
|
||||
productsDataGrid ??= productsDisplay?.productsGrid;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
{
|
||||
if (s != GridEntries) return;
|
||||
|
||||
var displayListGE = ((IEnumerable)DataSource_PI.GetValue(DataConnection_PI.GetValue(productsDataGrid))).Cast<GridEntry2>();
|
||||
var displayListGE = ((IEnumerable)DataSource_PI.GetValue(DataConnection_PI.GetValue(productsDataGrid))).Cast<GridEntry>();
|
||||
int index = 0;
|
||||
foreach (var di in displayListGE)
|
||||
{
|
||||
|
|
@ -83,7 +83,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
{
|
||||
try
|
||||
{
|
||||
GridEntries = new GridEntryBindingList2(CreateGridEntries(dbBooks));
|
||||
GridEntries = new GridEntryCollection(CreateGridEntries(dbBooks));
|
||||
GridEntries.CollapseAll();
|
||||
|
||||
int bookEntryCount = GridEntries.BookEntries().Count();
|
||||
|
|
@ -119,7 +119,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
foreach (var series in existingSeriesEntries)
|
||||
{
|
||||
var sEntry = GridEntries.InternalList.FirstOrDefault(ge => ge.AudibleProductId == series.AudibleProductId);
|
||||
if (sEntry is SeriesEntrys2 se && !series.Liberate.Expanded)
|
||||
if (sEntry is SeriesEntry se && !series.Liberate.Expanded)
|
||||
await Dispatcher.UIThread.InvokeAsync(() => GridEntries.CollapseItem(se));
|
||||
}
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
|
|
@ -134,12 +134,12 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<GridEntry2> CreateGridEntries(IEnumerable<LibraryBook> dbBooks)
|
||||
private static IEnumerable<GridEntry> CreateGridEntries(IEnumerable<LibraryBook> dbBooks)
|
||||
{
|
||||
var geList = dbBooks
|
||||
.Where(lb => lb.Book.IsProduct())
|
||||
.Select(b => new LibraryBookEntry2(b))
|
||||
.Cast<GridEntry2>()
|
||||
.Select(b => new LibraryBookEntry(b))
|
||||
.Cast<GridEntry>()
|
||||
.ToList();
|
||||
|
||||
var episodes = dbBooks.Where(lb => lb.Book.IsEpisodeChild());
|
||||
|
|
@ -152,7 +152,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
if (!seriesEpisodes.Any()) continue;
|
||||
|
||||
var seriesEntry = new SeriesEntrys2(parent, seriesEpisodes);
|
||||
var seriesEntry = new SeriesEntry(parent, seriesEpisodes);
|
||||
|
||||
geList.Add(seriesEntry);
|
||||
geList.AddRange(seriesEntry.Children);
|
||||
|
|
@ -160,7 +160,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
return geList.OrderByDescending(e => e.DateAdded);
|
||||
}
|
||||
|
||||
public void ToggleSeriesExpanded(SeriesEntrys2 seriesEntry)
|
||||
public void ToggleSeriesExpanded(SeriesEntry seriesEntry)
|
||||
{
|
||||
if (seriesEntry.Liberate.Expanded)
|
||||
GridEntries.CollapseItem(seriesEntry);
|
||||
|
|
@ -213,7 +213,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
if (_currentSortColumn is null)
|
||||
{
|
||||
//Sort ascending and reverse. That's how the comparer is designed to work to be compatible with Avalonia.
|
||||
var defaultComparer = new RowComparer(ListSortDirection.Descending, nameof(GridEntry2.DateAdded));
|
||||
var defaultComparer = new RowComparer(ListSortDirection.Descending, nameof(GridEntry.DateAdded));
|
||||
GridEntries.InternalList.Sort(defaultComparer);
|
||||
GridEntries.InternalList.Reverse();
|
||||
GridEntries.ResetCollection();
|
||||
|
|
@ -326,7 +326,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(GridEntry2.Remove) && sender is LibraryBookEntry2 lbEntry)
|
||||
if (e.PropertyName == nameof(GridEntry.Remove) && sender is LibraryBookEntry lbEntry)
|
||||
{
|
||||
int removeCount = GetAllBookEntries().Count(lbe => lbe.Remove is true);
|
||||
RemovableCountChanged?.Invoke(this, removeCount);
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
#nullable enable
|
||||
internal static class QueryExtensions
|
||||
{
|
||||
public static IEnumerable<LibraryBookEntry2> BookEntries(this IEnumerable<GridEntry2> gridEntries)
|
||||
=> gridEntries.OfType<LibraryBookEntry2>();
|
||||
public static IEnumerable<LibraryBookEntry> BookEntries(this IEnumerable<GridEntry> gridEntries)
|
||||
=> gridEntries.OfType<LibraryBookEntry>();
|
||||
|
||||
public static IEnumerable<SeriesEntrys2> SeriesEntries(this IEnumerable<GridEntry2> gridEntries)
|
||||
=> gridEntries.OfType<SeriesEntrys2>();
|
||||
public static IEnumerable<SeriesEntry> SeriesEntries(this IEnumerable<GridEntry> gridEntries)
|
||||
=> gridEntries.OfType<SeriesEntry>();
|
||||
|
||||
public static T? FindByAsin<T>(this IEnumerable<T> gridEntries, string audibleProductID) where T : GridEntry2
|
||||
public static T? FindByAsin<T>(this IEnumerable<T> gridEntries, string audibleProductID) where T : GridEntry
|
||||
=> gridEntries.FirstOrDefault(i => i.AudibleProductId == audibleProductID);
|
||||
|
||||
public static IEnumerable<SeriesEntrys2> EmptySeries(this IEnumerable<GridEntry2> gridEntries)
|
||||
public static IEnumerable<SeriesEntry> EmptySeries(this IEnumerable<GridEntry> gridEntries)
|
||||
=> gridEntries.SeriesEntries().Where(i => i.Children.Count == 0);
|
||||
|
||||
public static SeriesEntrys2? FindSeriesParent(this IEnumerable<GridEntry2> gridEntries, LibraryBook seriesEpisode)
|
||||
public static SeriesEntry? FindSeriesParent(this IEnumerable<GridEntry> gridEntries, LibraryBook seriesEpisode)
|
||||
{
|
||||
if (seriesEpisode.Book.SeriesLink is null) return null;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
/// sorted by series index, ascending. Stable sorting is achieved by comparing the GridEntry.ListIndex
|
||||
/// properties when 2 items compare equal.
|
||||
/// </summary>
|
||||
internal class RowComparer : IComparer, IComparer<GridEntry2>
|
||||
internal class RowComparer : IComparer, IComparer<GridEntry>
|
||||
{
|
||||
private static readonly PropertyInfo HeaderCellPi = typeof(DataGridColumn).GetProperty("HeaderCell", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
private static readonly PropertyInfo CurrentSortingStatePi = typeof(DataGridColumnHeader).GetProperty("CurrentSortingState", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
|
@ -39,17 +39,17 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
if (x is not null && y is null) return 1;
|
||||
if (x is null && y is null) return 0;
|
||||
|
||||
var geA = (GridEntry2)x;
|
||||
var geB = (GridEntry2)y;
|
||||
var geA = (GridEntry)x;
|
||||
var geB = (GridEntry)y;
|
||||
|
||||
SortDirection ??= GetSortOrder();
|
||||
|
||||
SeriesEntrys2 parentA = null;
|
||||
SeriesEntrys2 parentB = null;
|
||||
SeriesEntry parentA = null;
|
||||
SeriesEntry parentB = null;
|
||||
|
||||
if (geA is LibraryBookEntry2 lbA && lbA.Parent is SeriesEntrys2 seA)
|
||||
if (geA is LibraryBookEntry lbA && lbA.Parent is SeriesEntry seA)
|
||||
parentA = seA;
|
||||
if (geB is LibraryBookEntry2 lbB && lbB.Parent is SeriesEntrys2 seB)
|
||||
if (geB is LibraryBookEntry lbB && lbB.Parent is SeriesEntry seB)
|
||||
parentB = seB;
|
||||
|
||||
//both a and b are top-level grid entries
|
||||
|
|
@ -88,7 +88,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
private ListSortDirection? GetSortOrder()
|
||||
=> CurrentSortingStatePi.GetValue(HeaderCellPi.GetValue(Column)) as ListSortDirection?;
|
||||
|
||||
private int InternalCompare(GridEntry2 x, GridEntry2 y)
|
||||
private int InternalCompare(GridEntry x, GridEntry y)
|
||||
{
|
||||
var val1 = x.GetMemberValue(PropertyName);
|
||||
var val2 = y.GetMemberValue(PropertyName);
|
||||
|
|
@ -103,7 +103,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
return compareResult;
|
||||
}
|
||||
|
||||
public int Compare(GridEntry2 x, GridEntry2 y)
|
||||
public int Compare(GridEntry x, GridEntry y)
|
||||
{
|
||||
return Compare((object)x, y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ using System.Linq;
|
|||
namespace LibationWinForms.AvaloniaUI.ViewModels
|
||||
{
|
||||
/// <summary>The View Model for a LibraryBook that is ContentType.Parent</summary>
|
||||
public class SeriesEntrys2 : GridEntry2
|
||||
public class SeriesEntry : GridEntry
|
||||
{
|
||||
[Browsable(false)] public List<LibraryBookEntry2> Children { get; }
|
||||
[Browsable(false)] public List<LibraryBookEntry> Children { get; }
|
||||
[Browsable(false)] public override DateTime DateAdded => Children.Max(c => c.DateAdded);
|
||||
|
||||
private bool suspendCounting = false;
|
||||
|
|
@ -44,7 +44,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public override LiberateButtonStatus2 Liberate { get; }
|
||||
public override LiberateButtonStatus Liberate { get; }
|
||||
public override BookTags BookTags { get; } = new();
|
||||
|
||||
public override bool IsSeries => true;
|
||||
|
|
@ -53,16 +53,16 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
|
||||
#endregion
|
||||
|
||||
public SeriesEntrys2(LibraryBook parent, IEnumerable<LibraryBook> children)
|
||||
public SeriesEntry(LibraryBook parent, IEnumerable<LibraryBook> children)
|
||||
{
|
||||
Liberate = new LiberateButtonStatus2(IsSeries) { Expanded = true };
|
||||
Liberate = new LiberateButtonStatus(IsSeries) { Expanded = true };
|
||||
SeriesIndex = -1;
|
||||
LibraryBook = parent;
|
||||
|
||||
LoadCover();
|
||||
|
||||
Children = children
|
||||
.Select(c => new LibraryBookEntry2(c) { Parent = this })
|
||||
.Select(c => new LibraryBookEntry(c) { Parent = this })
|
||||
.OrderBy(c => c.SeriesIndex)
|
||||
.ToList();
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
|||
* and is stored in ObservableCollection.Items. When the primary list changes, the
|
||||
* secondary list is cleared and reset to match the primary.
|
||||
*/
|
||||
public class TrackedQueue2<T> : ObservableCollection<T> where T : class
|
||||
public class TrackedQueue<T> : ObservableCollection<T> where T : class
|
||||
{
|
||||
public event EventHandler<int> CompletedCountChanged;
|
||||
public event EventHandler<int> QueuededCountChanged;
|
||||
Loading…
Add table
Add a link
Reference in a new issue