diff --git a/Source/LibationAvalonia/LibationAvalonia.csproj b/Source/LibationAvalonia/LibationAvalonia.csproj
index 4d74e348..0e1d2a8b 100644
--- a/Source/LibationAvalonia/LibationAvalonia.csproj
+++ b/Source/LibationAvalonia/LibationAvalonia.csproj
@@ -17,12 +17,12 @@
- ..\bin\Debug
+ ..\bin-Avalonia\Debug
embedded
- ..\bin\Release
+ ..\bin-Avalonia\Release
embedded
diff --git a/Source/LibationAvalonia/Properties/PublishProfiles/FolderProfile.pubxml b/Source/LibationAvalonia/Properties/PublishProfiles/FolderProfile.pubxml
index 510fb21c..7a5531a3 100644
--- a/Source/LibationAvalonia/Properties/PublishProfiles/FolderProfile.pubxml
+++ b/Source/LibationAvalonia/Properties/PublishProfiles/FolderProfile.pubxml
@@ -9,8 +9,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
..\bin\publish\linux-x64\
FileSystem
net6.0
- linux-x64
- false
+ win-x64
+ true
false
+ false
\ No newline at end of file
diff --git a/Source/LibationAvalonia/Properties/PublishProfiles/LinuxProfile.pubxml b/Source/LibationAvalonia/Properties/PublishProfiles/LinuxProfile.pubxml
new file mode 100644
index 00000000..4f12172b
--- /dev/null
+++ b/Source/LibationAvalonia/Properties/PublishProfiles/LinuxProfile.pubxml
@@ -0,0 +1,16 @@
+
+
+
+
+ Release
+ Any CPU
+ ..\bin-Avalonia\publish\linux-x64\
+ FileSystem
+ net6.0
+ linux-x64
+ false
+ false
+
+
\ No newline at end of file
diff --git a/Source/LibationCli/Properties/PublishProfiles/FolderProfile.pubxml b/Source/LibationCli/Properties/PublishProfiles/FolderProfile.pubxml
index f8c490cc..257cfc2b 100644
--- a/Source/LibationCli/Properties/PublishProfiles/FolderProfile.pubxml
+++ b/Source/LibationCli/Properties/PublishProfiles/FolderProfile.pubxml
@@ -12,5 +12,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
win-x64
true
false
+ false
\ No newline at end of file
diff --git a/Source/LibationCli/Properties/PublishProfiles/LinuxProfile.pubxml b/Source/LibationCli/Properties/PublishProfiles/LinuxProfile.pubxml
index b6b51814..fe716d12 100644
--- a/Source/LibationCli/Properties/PublishProfiles/LinuxProfile.pubxml
+++ b/Source/LibationCli/Properties/PublishProfiles/LinuxProfile.pubxml
@@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
Release
Any CPU
- ..\bin\publish\linux-x64
+ ..\bin-Avalonia\publish\linux-x64
FileSystem
net6.0
linux-x64
diff --git a/Source/LibationWinForms/AvaloniaUI/App.axaml b/Source/LibationWinForms/AvaloniaUI/App.axaml
deleted file mode 100644
index f8ef3650..00000000
--- a/Source/LibationWinForms/AvaloniaUI/App.axaml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Source/LibationWinForms/AvaloniaUI/App.axaml.cs b/Source/LibationWinForms/AvaloniaUI/App.axaml.cs
deleted file mode 100644
index 82de0d3d..00000000
--- a/Source/LibationWinForms/AvaloniaUI/App.axaml.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using Avalonia;
-using Avalonia.Controls.ApplicationLifetimes;
-using Avalonia.Markup.Xaml;
-using Avalonia.Media;
-using LibationFileManager;
-using LibationWinForms.AvaloniaUI.Views;
-using System;
-
-namespace LibationWinForms.AvaloniaUI
-{
- public class App : Application
- {
- public static IBrush ProcessQueueBookFailedBrush { get; private set; }
- public static IBrush ProcessQueueBookCompletedBrush { get; private set; }
- public static IBrush ProcessQueueBookCancelledBrush { get; private set; }
- public static IBrush ProcessQueueBookDefaultBrush { get; private set; }
- public static IBrush SeriesEntryGridBackgroundBrush { get; private set; }
-
- public override void Initialize()
- {
- AvaloniaXamlLoader.Load(this);
- }
-
- public override void OnFrameworkInitializationCompleted()
- {
- LoadStyles();
-
- var SEGOEUI = new Typeface(new FontFamily(new Uri("avares://Libation/AvaloniaUI/Assets/WINGDING.TTF"), "SEGOEUI_Local"));
- var gtf = FontManager.Current.GetOrAddGlyphTypeface(SEGOEUI);
-
-
- if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
- {
- var mainWindow = new MainWindow();
- desktop.MainWindow = mainWindow;
- mainWindow.RestoreSizeAndLocation(Configuration.Instance);
- mainWindow.OnLoad();
- }
-
- base.OnFrameworkInitializationCompleted();
- }
-
- private void LoadStyles()
- {
- ProcessQueueBookFailedBrush = AvaloniaUtils.GetBrushFromResources("ProcessQueueBookFailedBrush");
- ProcessQueueBookCompletedBrush = AvaloniaUtils.GetBrushFromResources("ProcessQueueBookCompletedBrush");
- ProcessQueueBookCancelledBrush = AvaloniaUtils.GetBrushFromResources("ProcessQueueBookCancelledBrush");
- ProcessQueueBookDefaultBrush = AvaloniaUtils.GetBrushFromResources("ProcessQueueBookDefaultBrush");
- SeriesEntryGridBackgroundBrush = AvaloniaUtils.GetBrushFromResources("SeriesEntryGridBackgroundBrush");
- }
- }
-}
\ No newline at end of file
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/1x1.png b/Source/LibationWinForms/AvaloniaUI/Assets/1x1.png
deleted file mode 100644
index 1914264c..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/1x1.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/DataGridTheme.xaml b/Source/LibationWinForms/AvaloniaUI/Assets/DataGridTheme.xaml
deleted file mode 100644
index 904b6a2b..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Assets/DataGridTheme.xaml
+++ /dev/null
@@ -1,658 +0,0 @@
-
-
- 0.6
- 0.8
- 12,0,12,0
-
- M1875 1011l-787 787v-1798h-128v1798l-787 -787l-90 90l941 941l941 -941z
- M515 93l930 931l-930 931l90 90l1022 -1021l-1022 -1021z
- M1939 1581l90 -90l-1005 -1005l-1005 1005l90 90l915 -915z
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/LibationStyles.xaml b/Source/LibationWinForms/AvaloniaUI/Assets/LibationStyles.xaml
deleted file mode 100644
index e1e3f5ce..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Assets/LibationStyles.xaml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
- #FFE6FFE6
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Asterisk.png b/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Asterisk.png
deleted file mode 100644
index c345a8f9..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Asterisk.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Exclamation.png b/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Exclamation.png
deleted file mode 100644
index cc884984..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Exclamation.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Question.png b/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Question.png
deleted file mode 100644
index 3aeb017c..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Question.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/error.png b/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/error.png
deleted file mode 100644
index 916e14f1..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/error.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/SEGOEUI.TTF b/Source/LibationWinForms/AvaloniaUI/Assets/SEGOEUI.TTF
deleted file mode 100644
index 0f52cbd9..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/SEGOEUI.TTF and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/WINGDING.TTF b/Source/LibationWinForms/AvaloniaUI/Assets/WINGDING.TTF
deleted file mode 100644
index 6e38f7fd..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/WINGDING.TTF and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/cancel.png b/Source/LibationWinForms/AvaloniaUI/Assets/cancel.png
deleted file mode 100644
index fa34f935..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/cancel.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/completed.png b/Source/LibationWinForms/AvaloniaUI/Assets/completed.png
deleted file mode 100644
index 3cd61981..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/completed.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/down.png b/Source/LibationWinForms/AvaloniaUI/Assets/down.png
deleted file mode 100644
index 2536c961..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/down.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/edit_25x25.png b/Source/LibationWinForms/AvaloniaUI/Assets/edit_25x25.png
deleted file mode 100644
index 12e70d0f..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/edit_25x25.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/errored.png b/Source/LibationWinForms/AvaloniaUI/Assets/errored.png
deleted file mode 100644
index bb8ba7ef..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/errored.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/first.png b/Source/LibationWinForms/AvaloniaUI/Assets/first.png
deleted file mode 100644
index e470c697..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/first.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/glass-with-glow_16.png b/Source/LibationWinForms/AvaloniaUI/Assets/glass-with-glow_16.png
deleted file mode 100644
index 05e40bec..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/glass-with-glow_16.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/import_16x16.png b/Source/LibationWinForms/AvaloniaUI/Assets/import_16x16.png
deleted file mode 100644
index 40b582b1..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/import_16x16.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/last.png b/Source/LibationWinForms/AvaloniaUI/Assets/last.png
deleted file mode 100644
index 3c3ea886..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/last.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/libation.ico b/Source/LibationWinForms/AvaloniaUI/Assets/libation.ico
deleted file mode 100644
index d3e00443..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/libation.ico and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/queued.png b/Source/LibationWinForms/AvaloniaUI/Assets/queued.png
deleted file mode 100644
index f30221c3..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/queued.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/up.png b/Source/LibationWinForms/AvaloniaUI/Assets/up.png
deleted file mode 100644
index 7c00155a..00000000
Binary files a/Source/LibationWinForms/AvaloniaUI/Assets/up.png and /dev/null differ
diff --git a/Source/LibationWinForms/AvaloniaUI/AvaloniaUtils.cs b/Source/LibationWinForms/AvaloniaUI/AvaloniaUtils.cs
deleted file mode 100644
index 200d8cf5..00000000
--- a/Source/LibationWinForms/AvaloniaUI/AvaloniaUtils.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using Avalonia.Media;
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace LibationWinForms.AvaloniaUI
-{
- internal static class AvaloniaUtils
- {
- public static IBrush GetBrushFromResources(string name)
- => GetBrushFromResources(name, Brushes.Transparent);
- public static IBrush GetBrushFromResources(string name, IBrush defaultBrush)
- {
- if (App.Current.Styles.TryGetResource(name, out var value) && value is IBrush brush)
- return brush;
- return defaultBrush;
- }
-
- public static T ShowDialogSynchronously(this Avalonia.Controls.Window window, Avalonia.Controls.Window owner)
- {
- using var source = new CancellationTokenSource();
- var dialogTask = window.ShowDialog(owner);
- dialogTask.ContinueWith(t => source.Cancel(), TaskScheduler.FromCurrentSynchronizationContext());
- Avalonia.Threading.Dispatcher.UIThread.MainLoop(source.Token);
- return dialogTask.Result;
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml b/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml
deleted file mode 100644
index d67603fe..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
diff --git a/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml.cs
deleted file mode 100644
index 2c7ca7be..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Avalonia.Controls;
-using LibationWinForms.AvaloniaUI.ViewModels;
-using System;
-
-namespace LibationWinForms.AvaloniaUI.Controls
-{
- public partial class DataGridCheckBoxColumnExt : DataGridCheckBoxColumn
- {
- protected override IControl GenerateEditingElementDirect(DataGridCell cell, object dataItem)
- {
- //Only SeriesEntry types have three-state checks, individual LibraryEntry books are binary.
- var ele = base.GenerateEditingElementDirect(cell, dataItem) as CheckBox;
- ele.IsThreeState = dataItem is SeriesEntry;
- return ele;
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/Controls/DirectoryOrCustomSelectControl.axaml b/Source/LibationWinForms/AvaloniaUI/Controls/DirectoryOrCustomSelectControl.axaml
deleted file mode 100644
index afda8d61..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Controls/DirectoryOrCustomSelectControl.axaml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Source/LibationWinForms/AvaloniaUI/Controls/DirectoryOrCustomSelectControl.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Controls/DirectoryOrCustomSelectControl.axaml.cs
deleted file mode 100644
index b215fc40..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Controls/DirectoryOrCustomSelectControl.axaml.cs
+++ /dev/null
@@ -1,178 +0,0 @@
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-using Dinah.Core;
-using LibationFileManager;
-using System.Collections.Generic;
-using ReactiveUI;
-
-namespace LibationWinForms.AvaloniaUI.Controls
-{
- public partial class DirectoryOrCustomSelectControl : UserControl
- {
- public static readonly StyledProperty> KnownDirectoriesProperty =
- AvaloniaProperty.Register>(nameof(KnownDirectories), DirectorySelectControl.DefaultKnownDirectories);
-
- public static readonly StyledProperty SubDirectoryProperty =
- AvaloniaProperty.Register(nameof(SubDirectory));
-
-
- public static readonly StyledProperty DirectoryProperty =
- AvaloniaProperty.Register(nameof(Directory));
-
- public List KnownDirectories
- {
- get => GetValue(KnownDirectoriesProperty);
- set => SetValue(KnownDirectoriesProperty, value);
- }
-
- public string Directory
- {
- get => GetValue(DirectoryProperty);
- set => SetValue(DirectoryProperty, value);
- }
-
- public string SubDirectory
- {
- get => GetValue(SubDirectoryProperty);
- set => SetValue(SubDirectoryProperty, value);
- }
- CustomState customStates = new();
- public DirectoryOrCustomSelectControl()
- {
- InitializeComponent();
-
- customDirBrowseBtn = this.Find
", "\r\n\r\n") ?? "");
- return doc.DocumentNode.InnerText.Trim();
- }
-
- protected static string TrimTextToWord(string text, int maxLength)
- {
- return
- text.Length <= maxLength ?
- text :
- text.Substring(0, maxLength - 3) + "...";
- }
-
-
- ///
- /// This information should not change during lifetime, so call only once.
- /// Maximum of 5 text rows will fit in 80-pixel row height.
- ///
- protected static string GetMiscDisplay(LibraryBook libraryBook)
- {
- var details = new List();
-
- var locale = libraryBook.Book.Locale.DefaultIfNullOrWhiteSpace("[unknown]");
- var acct = libraryBook.Account.DefaultIfNullOrWhiteSpace("[unknown]");
-
- details.Add($"Account: {locale} - {acct}");
-
- if (libraryBook.Book.HasPdf())
- details.Add("Has PDF");
- if (libraryBook.Book.IsAbridged)
- details.Add("Abridged");
- if (libraryBook.Book.DatePublished.HasValue)
- details.Add($"Date pub'd: {libraryBook.Book.DatePublished.Value:MM/dd/yyyy}");
- // this goes last since it's most likely to have a line-break
- if (!string.IsNullOrWhiteSpace(libraryBook.Book.Publisher))
- details.Add($"Pub: {libraryBook.Book.Publisher.Trim()}");
-
- if (!details.Any())
- return "[details not imported]";
-
- return string.Join("\r\n", details);
- }
-
- #endregion
-
- ~GridEntry()
- {
- PictureStorage.PictureCached -= PictureStorage_PictureCached;
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs
deleted file mode 100644
index f7a66be2..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-using ApplicationServices;
-using LibationSearchEngine;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Collections.Specialized;
-using System.Linq;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- /*
- * Allows filtering of the underlying ObservableCollection
- *
- * When filtering is applied, the filtered-out items are removed
- * from the base list and added to the private FilterRemoved list.
- * When filtering is removed, items in the FilterRemoved list are
- * added back to the base list.
- *
- * Items are added and removed to/from the ObservableCollection's
- * internal list instead of the ObservableCollection itself to
- * avoid ObservableCollection firing CollectionChanged for every
- * item. Editing the list this way improve's display performance,
- * but requires ResetCollection() to be called after all changes
- * have been made.
- */
- public class GridEntryCollection : ObservableCollection
- {
- public GridEntryCollection(IEnumerable enumeration)
- : base(new List(enumeration)) { }
- public GridEntryCollection(List list)
- : base(list) { }
-
- public List InternalList => Items as List;
- /// All items in the list, including those filtered out.
- public List AllItems() => Items.Concat(FilterRemoved).ToList();
-
- /// When true, itms will not be checked filtered by search criteria on item changed
- public bool SuspendFilteringOnUpdate { get; set; }
- public string Filter { get => FilterString; set => ApplyFilter(value); }
-
- /// Items that were removed from the base list due to filtering
- private readonly List FilterRemoved = new();
- private string FilterString;
- private SearchResultSet SearchResults;
-
- #region Items Management
-
- ///
- /// Removes all items from the collection, both visible and hidden, adds new items to the visible collection.
- ///
- public void ReplaceList(IEnumerable newItems)
- {
- Items.Clear();
- FilterRemoved.Clear();
- ((List)Items).AddRange(newItems);
- ResetCollection();
- }
- public void ResetCollection()
- => OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
-
- #endregion
-
- #region Filtering
-
-
- private void ApplyFilter(string filterString)
- {
- if (filterString != FilterString)
- RemoveFilter();
-
- FilterString = filterString;
- SearchResults = SearchEngineCommands.Search(filterString);
-
- 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());
-
- var filteredOut = Items.Except(booksFilteredIn.Concat(seriesFilteredIn)).ToList();
-
- foreach (var item in filteredOut)
- {
- FilterRemoved.Add(item);
- Items.Remove(item);
- }
- ResetCollection();
- }
-
- public void RemoveFilter()
- {
- if (FilterString is null) return;
-
- int visibleCount = Items.Count;
-
- foreach (var item in FilterRemoved.ToList())
- {
- if (item is SeriesEntry || item is LibraryBookEntry lbe && (lbe.Parent is null || lbe.Parent.Liberate.Expanded))
- {
-
- FilterRemoved.Remove(item);
- Items.Insert(visibleCount++, item);
- }
- }
-
- FilterString = null;
- SearchResults = null;
- ResetCollection();
- }
-
- #endregion
-
- #region Expand/Collapse
-
- public void CollapseAll()
- {
- foreach (var series in Items.SeriesEntries().ToList())
- CollapseItem(series);
- }
-
- public void ExpandAll()
- {
- foreach (var series in Items.SeriesEntries().ToList())
- ExpandItem(series);
- }
-
- public void CollapseItem(SeriesEntry sEntry)
- {
- foreach (var episode in Items.BookEntries().Where(b => b.Parent == sEntry).OrderByDescending(lbe => lbe.SeriesIndex).ToList())
- {
- /*
- * Bypass ObservationCollection's InsertItem method so that CollectionChanged isn't
- * fired. When adding or removing many items at once, Avalonia's CollectionChanged
- * event handler causes serious performance problems. And unfotrunately, Avalonia
- * doesn't respect the NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction action, IList? changedItems)
- * overload that would fire only once for all changed items.
- *
- * Doing this requires resetting the list so the view knows it needs to rebuild its display.
- */
-
- FilterRemoved.Add(episode);
- Items.Remove(episode);
- }
-
- sEntry.Liberate.Expanded = false;
- ResetCollection();
- }
-
- public void ExpandItem(SeriesEntry sEntry)
- {
- var sindex = Items.IndexOf(sEntry);
-
- foreach (var episode in FilterRemoved.BookEntries().Where(b => b.Parent == sEntry).OrderByDescending(lbe => lbe.SeriesIndex).ToList())
- {
- if (SearchResults is null || SearchResults.Docs.Any(d => d.ProductId == episode.AudibleProductId))
- {
- /*
- * Bypass ObservationCollection's InsertItem method so that CollectionChanged isn't
- * fired. When adding or removing many items at once, Avalonia's CollectionChanged
- * event handler causes serious performance problems. And unfotrunately, Avalonia
- * doesn't respect the NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction action, IList? changedItems)
- * overload that would fire only once for all changed items.
- *
- * Doing this requires resetting the list so the view knows it needs to rebuild its display.
- */
-
- FilterRemoved.Remove(episode);
- Items.Insert(++sindex, episode);
- }
- }
-
- sEntry.Liberate.Expanded = true;
- ResetCollection();
- }
-
- #endregion
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/LiberateButtonStatus.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/LiberateButtonStatus.cs
deleted file mode 100644
index cd82e706..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/LiberateButtonStatus.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-using Avalonia.Media.Imaging;
-using DataLayer;
-using ReactiveUI;
-using System;
-using System.Collections.Generic;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- public class LiberateButtonStatus : ViewModelBase, IComparable
- {
- public LiberateButtonStatus(bool isSeries)
- {
- IsSeries = isSeries;
- }
- public LiberatedStatus BookStatus { get; set; }
- public LiberatedStatus? PdfStatus { get; set; }
-
- private bool _expanded;
- public bool Expanded
- {
- get => _expanded;
- set
- {
- this.RaiseAndSetIfChanged(ref _expanded, value);
- this.RaisePropertyChanged(nameof(Image));
- this.RaisePropertyChanged(nameof(ToolTip));
- }
- }
- private bool IsSeries { get; }
- public Bitmap Image => GetLiberateIcon();
- public string ToolTip => GetTooltip();
-
- static Dictionary iconCache = new();
-
- /// Defines the Liberate column's sorting behavior
- public int CompareTo(object obj)
- {
- if (obj is not LiberateButtonStatus second) return -1;
-
- if (IsSeries && !second.IsSeries) return -1;
- else if (!IsSeries && second.IsSeries) return 1;
- else if (IsSeries && second.IsSeries) return 0;
- else if (BookStatus == LiberatedStatus.Liberated && second.BookStatus != LiberatedStatus.Liberated) return -1;
- else if (BookStatus != LiberatedStatus.Liberated && second.BookStatus == LiberatedStatus.Liberated) return 1;
- else return BookStatus.CompareTo(second.BookStatus);
- }
-
- private Bitmap GetLiberateIcon()
- {
- if (IsSeries)
- return Expanded ? GetFromResources("minus") : GetFromResources("plus");
-
- if (BookStatus == LiberatedStatus.Error)
- return GetFromResources("error");
-
- string image_lib = BookStatus switch
- {
- LiberatedStatus.Liberated => "green",
- LiberatedStatus.PartialDownload => "yellow",
- LiberatedStatus.NotLiberated => "red",
- _ => throw new Exception("Unexpected liberation state")
- };
-
- string image_pdf = PdfStatus switch
- {
- LiberatedStatus.Liberated => "_pdf_yes",
- LiberatedStatus.NotLiberated => "_pdf_no",
- LiberatedStatus.Error => "_pdf_no",
- null => "",
- _ => throw new Exception("Unexpected PDF state")
- };
-
- return GetFromResources($"liberate_{image_lib}{image_pdf}");
- }
- private string GetTooltip()
- {
- if (IsSeries)
- return Expanded ? "Click to Collpase" : "Click to Expand";
-
- if (BookStatus == LiberatedStatus.Error)
- return "Book downloaded ERROR";
-
- string libState = BookStatus switch
- {
- LiberatedStatus.Liberated => "Liberated",
- LiberatedStatus.PartialDownload => "File has been at least\r\npartially downloaded",
- LiberatedStatus.NotLiberated => "Book NOT downloaded",
- _ => throw new Exception("Unexpected liberation state")
- };
-
- string pdfState = PdfStatus switch
- {
- LiberatedStatus.Liberated => "\r\nPDF downloaded",
- LiberatedStatus.NotLiberated => "\r\nPDF NOT downloaded",
- LiberatedStatus.Error => "\r\nPDF downloaded ERROR",
- null => "",
- _ => throw new Exception("Unexpected PDF state")
- };
-
-
- var mouseoverText = libState + pdfState;
-
- if (BookStatus == LiberatedStatus.NotLiberated ||
- BookStatus == LiberatedStatus.PartialDownload ||
- PdfStatus == LiberatedStatus.NotLiberated)
- mouseoverText += "\r\nClick to complete";
-
- return mouseoverText;
- }
-
- private static Bitmap GetFromResources(string rescName)
- {
- if (iconCache.ContainsKey(rescName)) return iconCache[rescName];
-
- var memoryStream = new System.IO.MemoryStream();
-
- ((System.Drawing.Bitmap)Properties.Resources.ResourceManager.GetObject(rescName)).Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
- memoryStream.Position = 0;
- iconCache[rescName] = new Bitmap(memoryStream);
- return iconCache[rescName];
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/LibraryBookEntry.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/LibraryBookEntry.cs
deleted file mode 100644
index ac8140d1..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/LibraryBookEntry.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-using ApplicationServices;
-using DataLayer;
-using Dinah.Core;
-using ReactiveUI;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- /// The View Model for a LibraryBook that is ContentType.Product or ContentType.Episode
- public class LibraryBookEntry : GridEntry
- {
- [Browsable(false)] public override DateTime DateAdded => LibraryBook.DateAdded;
- [Browsable(false)] public SeriesEntry Parent { get; init; }
-
- #region Model properties exposed to the view
-
- private DateTime lastStatusUpdate = default;
- private LiberatedStatus _bookStatus;
- private LiberatedStatus? _pdfStatus;
-
- public override bool? Remove
- {
- get => _remove;
- set
- {
- _remove = value ?? false;
-
- Parent?.ChildRemoveUpdate();
- this.RaisePropertyChanged(nameof(Remove));
- }
- }
-
- public override LiberateButtonStatus Liberate
- {
- get
- {
- //Cache these statuses for faster sorting.
- if ((DateTime.Now - lastStatusUpdate).TotalSeconds > 2)
- {
- _bookStatus = LibraryCommands.Liberated_Status(LibraryBook.Book);
- _pdfStatus = LibraryCommands.Pdf_Status(LibraryBook.Book);
- lastStatusUpdate = DateTime.Now;
- }
- return new LiberateButtonStatus(IsSeries) { BookStatus = _bookStatus, PdfStatus = _pdfStatus };
- }
- }
-
- public override BookTags BookTags => new() { Tags = string.Join("\r\n", Book.UserDefinedItem.TagsEnumerated) };
-
- public override bool IsSeries => false;
- public override bool IsEpisode => Parent is not null;
- public override bool IsBook => Parent is null;
-
- #endregion
-
- public LibraryBookEntry(LibraryBook libraryBook)
- {
- LibraryBook = libraryBook;
- LoadCover();
-
- Title = Book.Title;
- Series = Book.SeriesNames();
- Length = Book.LengthInMinutes == 0 ? "" : $"{Book.LengthInMinutes / 60} hr {Book.LengthInMinutes % 60} min";
- MyRating = Book.UserDefinedItem.Rating?.ToStarString()?.DefaultIfNullOrWhiteSpace("");
- PurchaseDate = libraryBook.DateAdded.ToString("d");
- ProductRating = Book.Rating?.ToStarString()?.DefaultIfNullOrWhiteSpace("");
- Authors = Book.AuthorNames();
- Narrators = Book.NarratorNames();
- Category = string.Join(" > ", Book.CategoriesNames());
- Misc = GetMiscDisplay(libraryBook);
- LongDescription = GetDescriptionDisplay(Book);
- Description = TrimTextToWord(LongDescription, 62);
- SeriesIndex = Book.SeriesLink.FirstOrDefault()?.Index ?? 0;
-
- UserDefinedItem.ItemChanged += UserDefinedItem_ItemChanged;
- }
-
- #region detect changes to the model, update the view.
-
- ///
- /// This event handler receives notifications from the model that it has changed.
- /// Notify the view that it's changed.
- ///
- private void UserDefinedItem_ItemChanged(object sender, string itemName)
- {
- var udi = sender as UserDefinedItem;
-
- if (udi.Book.AudibleProductId != Book.AudibleProductId)
- return;
-
- // UDI changed, possibly in a different context/view. Update this viewmodel. Call NotifyPropertyChanged to notify view.
- // - This method responds to tons of incidental changes. Do not persist to db from here. Committing to db must be a volitional action by the caller, not incidental. Otherwise batch changes would be impossible; we would only have slow one-offs
- // - Don't restrict notifying view to 'only if property changed'. This same book instance can get passed to a different view, then changed there. When the chain of events makes its way back here, the property is unchanged (because it's the same instance), but this view is out of sync. NotifyPropertyChanged will then update this view.
- switch (itemName)
- {
- case nameof(udi.Tags):
- Book.UserDefinedItem.Tags = udi.Tags;
- this.RaisePropertyChanged(nameof(BookTags));
- break;
- case nameof(udi.BookStatus):
- Book.UserDefinedItem.BookStatus = udi.BookStatus;
- _bookStatus = udi.BookStatus;
- this.RaisePropertyChanged(nameof(Liberate));
- break;
- case nameof(udi.PdfStatus):
- Book.UserDefinedItem.PdfStatus = udi.PdfStatus;
- _pdfStatus = udi.PdfStatus;
- this.RaisePropertyChanged(nameof(Liberate));
- break;
- }
- }
-
- #endregion
-
- #region Data Sorting
-
- /// Create getters for all member object values by name
- protected override Dictionary> CreateMemberValueDictionary() => new()
- {
- { nameof(Remove), () => Remove.HasValue ? Remove.Value ? RemoveStatus.Removed : RemoveStatus.NotRemoved : RemoveStatus.SomeRemoved },
- { nameof(Title), () => Book.TitleSortable() },
- { nameof(Series), () => Book.SeriesSortable() },
- { nameof(Length), () => Book.LengthInMinutes },
- { nameof(MyRating), () => Book.UserDefinedItem.Rating.FirstScore() },
- { nameof(PurchaseDate), () => LibraryBook.DateAdded },
- { nameof(ProductRating), () => Book.Rating.FirstScore() },
- { nameof(Authors), () => Authors },
- { nameof(Narrators), () => Narrators },
- { nameof(Description), () => Description },
- { nameof(Category), () => Category },
- { nameof(Misc), () => Misc },
- { nameof(BookTags), () => BookTags?.Tags ?? string.Empty },
- { nameof(Liberate), () => Liberate },
- { nameof(DateAdded), () => DateAdded },
- };
-
- #endregion
-
- ~LibraryBookEntry()
- {
- UserDefinedItem.ItemChanged -= UserDefinedItem_ItemChanged;
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/MainWindowViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/MainWindowViewModel.cs
deleted file mode 100644
index 9e688a2f..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/MainWindowViewModel.cs
+++ /dev/null
@@ -1,239 +0,0 @@
-using ApplicationServices;
-using Dinah.Core;
-using LibationFileManager;
-using ReactiveUI;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- public class MainWindowViewModel : ViewModelBase
- {
- private string _filterString;
- private string _removeBooksButtonText = "Remove # Books from Libation";
- private bool _removeBooksButtonEnabled = true;
- private bool _autoScanChecked = true;
- private bool _firstFilterIsDefault = true;
- private bool _removeButtonsVisible = true;
- private int _numAccountsScanning = 2;
- private int _accountsCount = 0;
- private bool _queueOpen = true;
- private int _visibleCount = 1;
- private LibraryCommands.LibraryStats _libraryStats;
- private int _visibleNotLiberated = 1;
-
- /// The Process Queue's viewmodel
- public ProcessQueueViewModel ProcessQueue { get; } = new ProcessQueueViewModel();
- public ProductsDisplayViewModel ProductsDisplay { get; } = new ProductsDisplayViewModel();
-
-
- /// Library filterting query
- public string FilterString { get => _filterString; set => this.RaiseAndSetIfChanged(ref _filterString, value); }
-
-
- /// Display text for the "Remove # Books from Libation" button
- public string RemoveBooksButtonText { get => _removeBooksButtonText; set => this.RaiseAndSetIfChanged(ref _removeBooksButtonText, value); }
-
-
- /// Indicates if the "Remove # Books from Libation" button is enabled
- public bool RemoveBooksButtonEnabled { get => _removeBooksButtonEnabled; set { this.RaiseAndSetIfChanged(ref _removeBooksButtonEnabled, value); } }
-
-
- /// Auto scanning accounts is enables
- public bool AutoScanChecked
- {
- get => _autoScanChecked;
- set
- {
- if (value != _autoScanChecked)
- Configuration.Instance.AutoScan = value;
- this.RaiseAndSetIfChanged(ref _autoScanChecked, value);
- }
- }
-
-
- /// Indicates if the first quick filter is the default filter
- public bool FirstFilterIsDefault
- {
- get => _firstFilterIsDefault;
- set
- {
- if (value != _firstFilterIsDefault)
- QuickFilters.UseDefault = value;
- this.RaiseAndSetIfChanged(ref _firstFilterIsDefault, value);
- }
- }
-
-
- /// Indicates if the "Remove # Books from Libation" and "Done Removing" buttons should be visible
- public bool RemoveButtonsVisible
- {
- get => _removeButtonsVisible;
- set
- {
- this.RaiseAndSetIfChanged(ref _removeButtonsVisible, value);
- this.RaisePropertyChanged(nameof(RemoveMenuItemsEnabled));
- }
- }
-
-
-
-
- /// The number of accounts currently being scanned
- public int NumAccountsScanning
- {
- get => _numAccountsScanning;
- set
- {
- this.RaiseAndSetIfChanged(ref _numAccountsScanning, value);
- this.RaisePropertyChanged(nameof(ActivelyScanning));
- this.RaisePropertyChanged(nameof(RemoveMenuItemsEnabled));
- this.RaisePropertyChanged(nameof(ScanningText));
- }
- }
-
- /// Indicates if Libation is currently scanning account(s)
- public bool ActivelyScanning => _numAccountsScanning > 0;
- /// Indicates if the "Remove Books" menu items are enabled
- public bool RemoveMenuItemsEnabled => !RemoveButtonsVisible && !ActivelyScanning;
- /// The library scanning status text
- public string ScanningText => _numAccountsScanning == 1 ? "Scanning..." : $"Scanning {_numAccountsScanning} accounts...";
-
-
-
- /// The number of accounts added to Libation
- public int AccountsCount
- {
- get => _accountsCount;
- set
- {
- this.RaiseAndSetIfChanged(ref _accountsCount, value);
- this.RaisePropertyChanged(nameof(ZeroAccounts));
- this.RaisePropertyChanged(nameof(AnyAccounts));
- this.RaisePropertyChanged(nameof(OneAccount));
- this.RaisePropertyChanged(nameof(MultipleAccounts));
- }
- }
-
- /// There are no Audible accounts
- public bool ZeroAccounts => _accountsCount == 0;
- /// There is at least one Audible account
- public bool AnyAccounts => _accountsCount > 0;
- /// There is exactly one Audible account
- public bool OneAccount => _accountsCount == 1;
- /// There are more than 1 Audible accounts
- public bool MultipleAccounts => _accountsCount > 1;
-
-
-
- /// The Process Queue panel is open
- public bool QueueOpen
- {
- get => _queueOpen;
- set
- {
- this.RaiseAndSetIfChanged(ref _queueOpen, value);
- QueueHideButtonText = _queueOpen? "❱❱❱" : "❰❰❰";
- this.RaisePropertyChanged(nameof(QueueHideButtonText));
- }
- }
-
- /// The Process Queue's Expand/Collapse button display text
- public string QueueHideButtonText { get; private set; }
-
-
-
- /// The number of books visible in the Product Display
- public int VisibleCount
- {
- get => _visibleCount;
- set
- {
- this.RaiseAndSetIfChanged(ref _visibleCount, value);
- this.RaisePropertyChanged(nameof(VisibleCountText));
- this.RaisePropertyChanged(nameof(VisibleCountMenuItemText));
- }
- }
-
- /// The Bottom-right visible book count status text
- public string VisibleCountText => $"Visible: {VisibleCount}";
- /// The Visible Books menu item header text
- public string VisibleCountMenuItemText => $"_Visible Books {VisibleCount}";
-
-
-
- /// The user's library statistics
- public LibraryCommands.LibraryStats LibraryStats
- {
- get => _libraryStats;
- set
- {
- this.RaiseAndSetIfChanged(ref _libraryStats, value);
-
- var backupsCountText
- = !LibraryStats.HasBookResults ? "No books. Begin by importing your library"
- : !LibraryStats.HasPendingBooks ? $"All {"book".PluralizeWithCount(LibraryStats.booksFullyBackedUp)} backed up"
- : $"BACKUPS: No progress: {LibraryStats.booksNoProgress} In process: {LibraryStats.booksDownloadedOnly} Fully backed up: {LibraryStats.booksFullyBackedUp} {(LibraryStats.booksError > 0 ? $" Errors : {LibraryStats.booksError}" : "")}";
-
- var pdfCountText
- = !LibraryStats.HasPdfResults ? ""
- : LibraryStats.pdfsNotDownloaded == 0 ? $" | All {LibraryStats.pdfsDownloaded} PDFs downloaded"
- : $" | PDFs: NOT d/l'ed: {LibraryStats.pdfsNotDownloaded} Downloaded: {LibraryStats.pdfsDownloaded}";
-
- StatusCountText = backupsCountText + pdfCountText;
-
- BookBackupsToolStripText
- = LibraryStats.HasPendingBooks
- ? $"Begin _Book and PDF Backups: {LibraryStats.PendingBooks} remaining"
- : "All books have been liberated";
-
- PdfBackupsToolStripText
- = LibraryStats.pdfsNotDownloaded > 0
- ? $"Begin _PDF Only Backups: {LibraryStats.pdfsNotDownloaded} remaining"
- : "All PDFs have been downloaded";
-
- this.RaisePropertyChanged(nameof(StatusCountText));
- this.RaisePropertyChanged(nameof(BookBackupsToolStripText));
- this.RaisePropertyChanged(nameof(PdfBackupsToolStripText));
- }
- }
-
- /// Bottom-left library statistics display text
- public string StatusCountText { get; private set; } = "[Calculating backed up book quantities] | [Calculating backed up PDFs]";
- /// The "Begin Book and PDF Backup" menu item header text
- public string BookBackupsToolStripText { get; private set; } = "Begin _Book and PDF Backups: 0";
- /// The "Begin PDF Only Backup" menu item header text
- public string PdfBackupsToolStripText { get; private set; } = "Begin _PDF Only Backups: 0";
-
-
-
- /// The number of books visible in the Products Display that have not yet been liberated
- public int VisibleNotLiberated
- {
- get => _visibleNotLiberated;
- set
- {
- this.RaiseAndSetIfChanged(ref _visibleNotLiberated, value);
-
- LiberateVisibleToolStripText
- = AnyVisibleNotLiberated
- ? $"Liberate _Visible Books: {VisibleNotLiberated}"
- : "All visible books are liberated";
-
- LiberateVisibleToolStripText_2
- = AnyVisibleNotLiberated
- ? $"_Liberate: {VisibleNotLiberated}"
- : "All visible books are liberated";
-
- this.RaisePropertyChanged(nameof(AnyVisibleNotLiberated));
- this.RaisePropertyChanged(nameof(LiberateVisibleToolStripText));
- this.RaisePropertyChanged(nameof(LiberateVisibleToolStripText_2));
- }
- }
-
- /// Indicates if any of the books visible in the Products Display haven't been liberated
- public bool AnyVisibleNotLiberated => VisibleNotLiberated > 0;
- /// The "Liberate Visible Books" menu item header text (submenu item of the "Liberate Menu" menu item)
- public string LiberateVisibleToolStripText { get; private set; } = "Liberate _Visible Books: 0";
- /// The "Liberate" menu item header text (submenu item of the "Visible Books" menu item)
- public string LiberateVisibleToolStripText_2 { get; private set; } = "_Liberate: 0";
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBookViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBookViewModel.cs
deleted file mode 100644
index 954d1ab2..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBookViewModel.cs
+++ /dev/null
@@ -1,382 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using ApplicationServices;
-using Avalonia.Media;
-using Avalonia.Media.Imaging;
-using DataLayer;
-using Dinah.Core;
-using FileLiberator;
-using LibationFileManager;
-using ReactiveUI;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- public enum ProcessBookResult
- {
- None,
- Success,
- Cancelled,
- ValidationFail,
- FailedRetry,
- FailedSkip,
- FailedAbort
- }
-
- public enum ProcessBookStatus
- {
- Queued,
- Cancelled,
- Working,
- Completed,
- Failed
- }
-
- ///
- /// This is the viewmodel for queued processables
- ///
- public class ProcessBookViewModel : ViewModelBase
- {
- public event EventHandler Completed;
-
- public LibraryBook LibraryBook { get; private set; }
-
- private ProcessBookResult _result = ProcessBookResult.None;
- private ProcessBookStatus _status = ProcessBookStatus.Queued;
- private string _narrator;
- private string _author;
- private string _title;
- private int _progress;
- private string _eta;
- private Bitmap _cover;
-
- #region Properties exposed to the view
- public ProcessBookResult Result { get => _result; set { this.RaiseAndSetIfChanged(ref _result, value); this.RaisePropertyChanged(nameof(StatusText)); } }
- public ProcessBookStatus Status { get => _status; set { this.RaiseAndSetIfChanged(ref _status, value); this.RaisePropertyChanged(nameof(BackgroundColor)); this.RaisePropertyChanged(nameof(IsFinished)); this.RaisePropertyChanged(nameof(IsDownloading)); this.RaisePropertyChanged(nameof(Queued)); } }
- public string Narrator { get => _narrator; set { this.RaiseAndSetIfChanged(ref _narrator, value); } }
- public string Author { get => _author; set { this.RaiseAndSetIfChanged(ref _author, value); } }
- public string Title { get => _title; set { this.RaiseAndSetIfChanged(ref _title, value); } }
- public int Progress { get => _progress; private set { this.RaiseAndSetIfChanged(ref _progress, value); } }
- public string ETA { get => _eta; private set { this.RaiseAndSetIfChanged(ref _eta, value); } }
- public Bitmap Cover { get => _cover; private set { this.RaiseAndSetIfChanged(ref _cover, value); } }
- public bool IsFinished => Status is not ProcessBookStatus.Queued and not ProcessBookStatus.Working;
- public bool IsDownloading => Status is ProcessBookStatus.Working;
- public bool Queued => Status is ProcessBookStatus.Queued;
-
- public IBrush BackgroundColor => Status switch
- {
- ProcessBookStatus.Cancelled => App.ProcessQueueBookCancelledBrush,
- ProcessBookStatus.Completed => App.ProcessQueueBookCompletedBrush,
- ProcessBookStatus.Failed => App.ProcessQueueBookFailedBrush,
- _ => App.ProcessQueueBookDefaultBrush,
- };
- public string StatusText => Result switch
- {
- ProcessBookResult.Success => "Finished",
- ProcessBookResult.Cancelled => "Cancelled",
- ProcessBookResult.ValidationFail => "Validion fail",
- ProcessBookResult.FailedRetry => "Error, will retry later",
- ProcessBookResult.FailedSkip => "Error, Skippping",
- ProcessBookResult.FailedAbort => "Error, Abort",
- _ => Status.ToString(),
- };
-
- #endregion
-
- private TimeSpan TimeRemaining { set { ETA = $"ETA: {value:mm\\:ss}"; } }
- private Processable CurrentProcessable => _currentProcessable ??= Processes.Dequeue().Invoke();
- private Processable NextProcessable() => _currentProcessable = null;
- private Processable _currentProcessable;
- private readonly Queue> Processes = new();
- private readonly LogMe Logger;
-
- public ProcessBookViewModel(LibraryBook libraryBook, LogMe logme)
- {
- LibraryBook = libraryBook;
- Logger = logme;
-
- _title = LibraryBook.Book.Title;
- _author = LibraryBook.Book.AuthorNames();
- _narrator = LibraryBook.Book.NarratorNames();
-
- (bool isDefault, byte[] picture) = PictureStorage.GetPicture(new PictureDefinition(LibraryBook.Book.PictureId, PictureSize._80x80));
-
- if (isDefault)
- PictureStorage.PictureCached += PictureStorage_PictureCached;
-
- // Mutable property. Set the field so PropertyChanged isn't fired.
- using var ms = new System.IO.MemoryStream(picture);
- _cover = new Bitmap(ms);
- }
-
- private void PictureStorage_PictureCached(object sender, PictureCachedEventArgs e)
- {
- if (e.Definition.PictureId == LibraryBook.Book.PictureId)
- {
- using var ms = new System.IO.MemoryStream(e.Picture);
- Cover = new Bitmap(ms);
- PictureStorage.PictureCached -= PictureStorage_PictureCached;
- }
- }
-
- public async Task ProcessOneAsync()
- {
- string procName = CurrentProcessable.Name;
- try
- {
- LinkProcessable(CurrentProcessable);
-
- var statusHandler = await CurrentProcessable.ProcessSingleAsync(LibraryBook, validate: true);
-
- if (statusHandler.IsSuccess)
- return Result = ProcessBookResult.Success;
- else if (statusHandler.Errors.Contains("Cancelled"))
- {
- Logger.Info($"{procName}: Process was cancelled {LibraryBook.Book}");
- return Result = ProcessBookResult.Cancelled;
- }
- else if (statusHandler.Errors.Contains("Validation failed"))
- {
- Logger.Info($"{procName}: Validation failed {LibraryBook.Book}");
- return Result = ProcessBookResult.ValidationFail;
- }
-
- foreach (var errorMessage in statusHandler.Errors)
- Logger.Error($"{procName}: {errorMessage}");
- }
- catch (Exception ex)
- {
- Logger.Error(ex, procName);
- }
- finally
- {
- if (Result == ProcessBookResult.None)
- Result = showRetry(LibraryBook);
-
- Status = Result switch
- {
- ProcessBookResult.Success => ProcessBookStatus.Completed,
- ProcessBookResult.Cancelled => ProcessBookStatus.Cancelled,
- _ => ProcessBookStatus.Failed,
- };
- }
-
- return Result;
- }
-
- public async Task CancelAsync()
- {
- try
- {
- if (CurrentProcessable is AudioDecodable audioDecodable)
- await audioDecodable.CancelAsync();
- }
- catch (Exception ex)
- {
- Logger.Error(ex, $"{CurrentProcessable.Name}: Error while cancelling");
- }
- }
-
- public void AddDownloadPdf() => AddProcessable();
- public void AddDownloadDecryptBook() => AddProcessable();
- public void AddConvertToMp3() => AddProcessable();
-
- private void AddProcessable() where T : Processable, new()
- {
- Processes.Enqueue(() => new T());
- }
-
- public override string ToString() => LibraryBook.ToString();
-
- #region Subscribers and Unsubscribers
-
- private void LinkProcessable(Processable processable)
- {
- processable.Begin += Processable_Begin;
- processable.Completed += Processable_Completed;
- processable.StreamingProgressChanged += Streamable_StreamingProgressChanged;
- processable.StreamingTimeRemaining += Streamable_StreamingTimeRemaining;
-
- if (processable is AudioDecodable audioDecodable)
- {
- audioDecodable.RequestCoverArt += AudioDecodable_RequestCoverArt;
- audioDecodable.TitleDiscovered += AudioDecodable_TitleDiscovered;
- audioDecodable.AuthorsDiscovered += AudioDecodable_AuthorsDiscovered;
- audioDecodable.NarratorsDiscovered += AudioDecodable_NarratorsDiscovered;
- audioDecodable.CoverImageDiscovered += AudioDecodable_CoverImageDiscovered;
- }
- }
-
- private void UnlinkProcessable(Processable processable)
- {
- processable.Begin -= Processable_Begin;
- processable.Completed -= Processable_Completed;
- processable.StreamingProgressChanged -= Streamable_StreamingProgressChanged;
- processable.StreamingTimeRemaining -= Streamable_StreamingTimeRemaining;
-
- if (processable is AudioDecodable audioDecodable)
- {
- audioDecodable.RequestCoverArt -= AudioDecodable_RequestCoverArt;
- audioDecodable.TitleDiscovered -= AudioDecodable_TitleDiscovered;
- audioDecodable.AuthorsDiscovered -= AudioDecodable_AuthorsDiscovered;
- audioDecodable.NarratorsDiscovered -= AudioDecodable_NarratorsDiscovered;
- audioDecodable.CoverImageDiscovered -= AudioDecodable_CoverImageDiscovered;
- }
- }
-
- #endregion
-
- #region AudioDecodable event handlers
-
- private void AudioDecodable_TitleDiscovered(object sender, string title) => Title = title;
-
- private void AudioDecodable_AuthorsDiscovered(object sender, string authors) => Author = authors;
-
- private void AudioDecodable_NarratorsDiscovered(object sender, string narrators) => Narrator = narrators;
-
-
- private byte[] AudioDecodable_RequestCoverArt(object sender, EventArgs e)
- {
- byte[] coverData = PictureStorage
- .GetPictureSynchronously(
- new PictureDefinition(LibraryBook.Book.PictureId, PictureSize._500x500));
-
- AudioDecodable_CoverImageDiscovered(this, coverData);
- return coverData;
- }
-
- private void AudioDecodable_CoverImageDiscovered(object sender, byte[] coverArt)
- {
- using var ms = new System.IO.MemoryStream(coverArt);
- Cover = new Avalonia.Media.Imaging.Bitmap(ms);
- }
-
- #endregion
-
- #region Streamable event handlers
- private void Streamable_StreamingTimeRemaining(object sender, TimeSpan timeRemaining) => TimeRemaining = timeRemaining;
-
-
- private void Streamable_StreamingProgressChanged(object sender, Dinah.Core.Net.Http.DownloadProgress downloadProgress)
- {
- if (!downloadProgress.ProgressPercentage.HasValue)
- return;
-
- if (downloadProgress.ProgressPercentage == 0)
- TimeRemaining = TimeSpan.Zero;
- else
- Progress = (int)downloadProgress.ProgressPercentage;
- }
-
- #endregion
-
- #region Processable event handlers
-
- private void Processable_Begin(object sender, LibraryBook libraryBook)
- {
- Status = ProcessBookStatus.Working;
-
- Logger.Info($"{Environment.NewLine}{((Processable)sender).Name} Step, Begin: {libraryBook.Book}");
-
- Title = libraryBook.Book.Title;
- Author = libraryBook.Book.AuthorNames();
- Narrator = libraryBook.Book.NarratorNames();
- }
-
- private async void Processable_Completed(object sender, LibraryBook libraryBook)
- {
- Logger.Info($"{((Processable)sender).Name} Step, Completed: {libraryBook.Book}");
- UnlinkProcessable((Processable)sender);
-
- if (Processes.Count > 0)
- {
- NextProcessable();
- LinkProcessable(CurrentProcessable);
- var result = await CurrentProcessable.ProcessSingleAsync(libraryBook, validate: true);
-
- if (result.HasErrors)
- {
- foreach (var errorMessage in result.Errors.Where(e => e != "Validation failed"))
- Logger.Error(errorMessage);
-
- Completed?.Invoke(this, EventArgs.Empty);
- }
- }
- else
- {
- Completed?.Invoke(this, EventArgs.Empty);
- }
- }
-
- #endregion
-
- #region Failure Handler
-
- private ProcessBookResult showRetry(LibraryBook libraryBook)
- {
- Logger.Error("ERROR. All books have not been processed. Most recent book: processing failed");
-
- DialogResult? dialogResult = Configuration.Instance.BadBook switch
- {
- Configuration.BadBookAction.Abort => DialogResult.Abort,
- Configuration.BadBookAction.Retry => DialogResult.Retry,
- Configuration.BadBookAction.Ignore => DialogResult.Ignore,
- Configuration.BadBookAction.Ask => null,
- _ => null
- };
-
- string details;
- try
- {
- static string trunc(string str)
- => string.IsNullOrWhiteSpace(str) ? "[empty]"
- : (str.Length > 50) ? $"{str.Truncate(47)}..."
- : str;
-
- details =
-$@" Title: {libraryBook.Book.Title}
- ID: {libraryBook.Book.AudibleProductId}
- Author: {trunc(libraryBook.Book.AuthorNames())}
- Narr: {trunc(libraryBook.Book.NarratorNames())}";
- }
- catch
- {
- details = "[Error retrieving details]";
- }
-
- // if null then ask user
- dialogResult ??= MessageBox.Show(string.Format(SkipDialogText + "\r\n\r\nSee Settings to avoid this box in the future.", details), "Skip importing this book?", SkipDialogButtons, MessageBoxIcon.Question, SkipDialogDefaultButton);
-
- if (dialogResult == DialogResult.Abort)
- return ProcessBookResult.FailedAbort;
-
- if (dialogResult == SkipResult)
- {
- libraryBook.Book.UpdateBookStatus(LiberatedStatus.Error);
-
- Logger.Info($"Error. Skip: [{libraryBook.Book.AudibleProductId}] {libraryBook.Book.Title}");
-
- return ProcessBookResult.FailedSkip;
- }
-
- return ProcessBookResult.FailedRetry;
- }
-
- private string SkipDialogText => @"
-An error occurred while trying to process this book.
-{0}
-
-- ABORT: Stop processing books.
-
-- RETRY: retry this book later. Just skip it for now. Continue processing books. (Will try this book again later.)
-
-- IGNORE: Permanently ignore this book. Continue processing books. (Will not try this book again later.)
-".Trim();
- private MessageBoxButtons SkipDialogButtons => MessageBoxButtons.AbortRetryIgnore;
- private MessageBoxDefaultButton SkipDialogDefaultButton => MessageBoxDefaultButton.Button1;
- private DialogResult SkipResult => DialogResult.Ignore;
- }
-
- #endregion
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs
deleted file mode 100644
index 5bf0990a..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-using ApplicationServices;
-using Avalonia.Controls;
-using Avalonia.Threading;
-using DataLayer;
-using ReactiveUI;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- public class ProcessQueueViewModel : ViewModelBase, ILogForm
- {
- public ObservableCollection LogEntries { get; } = new();
- public TrackedQueue Items { get; } = new();
-
- private TrackedQueue Queue => Items;
- public ProcessBookViewModel SelectedItem { get; set; }
- public Task QueueRunner { get; private set; }
- public bool Running => !QueueRunner?.IsCompleted ?? false;
-
- private readonly LogMe Logger;
-
- public ProcessQueueViewModel()
- {
- Queue.QueuededCountChanged += Queue_QueuededCountChanged;
- Queue.CompletedCountChanged += Queue_CompletedCountChanged;
- Logger = LogMe.RegisterForm(this);
- }
-
- private int _completedCount;
- private int _errorCount;
- private int _queuedCount;
- private string _runningTime;
- private bool _progressBarVisible;
-
- public int CompletedCount { get => _completedCount; private set { this.RaiseAndSetIfChanged(ref _completedCount, value); this.RaisePropertyChanged(nameof(AnyCompleted)); } }
- public int QueuedCount { get => _queuedCount; private set { this.RaiseAndSetIfChanged(ref _queuedCount, value); this.RaisePropertyChanged(nameof(AnyQueued)); } }
- public int ErrorCount { get => _errorCount; private set { this.RaiseAndSetIfChanged(ref _errorCount, value); this.RaisePropertyChanged(nameof(AnyErrors)); } }
- public string RunningTime { get => _runningTime; set { this.RaiseAndSetIfChanged(ref _runningTime, value); } }
- public bool ProgressBarVisible { get => _progressBarVisible; set { this.RaiseAndSetIfChanged(ref _progressBarVisible, value); } }
- public bool AnyCompleted => CompletedCount > 0;
- public bool AnyQueued => QueuedCount > 0;
- public bool AnyErrors => ErrorCount > 0;
- public double Progress => 100d * Queue.Completed.Count / Queue.Count;
-
- private void Queue_CompletedCountChanged(object sender, int e)
- {
- int errCount = Queue.Completed.Count(p => p.Result is ProcessBookResult.FailedAbort or ProcessBookResult.FailedSkip or ProcessBookResult.FailedRetry or ProcessBookResult.ValidationFail);
- int completeCount = Queue.Completed.Count(p => p.Result is ProcessBookResult.Success);
-
- ErrorCount = errCount;
- CompletedCount = completeCount;
- this.RaisePropertyChanged(nameof(Progress));
- }
- private void Queue_QueuededCountChanged(object sender, int cueCount)
- {
- QueuedCount = cueCount;
- this.RaisePropertyChanged(nameof(Progress));
- }
-
- public void WriteLine(string text)
- {
- Dispatcher.UIThread.Post(() =>
- LogEntries.Add(new()
- {
- LogDate = DateTime.Now,
- LogMessage = text.Trim()
- }));
- }
-
-
- #region Add Books to Queue
-
- private bool isBookInQueue(LibraryBook libraryBook)
- => Queue.Any(b => b?.LibraryBook?.Book?.AudibleProductId == libraryBook.Book.AudibleProductId);
-
- public void AddDownloadPdf(LibraryBook libraryBook)
- => AddDownloadPdf(new List() { libraryBook });
-
- public void AddDownloadDecrypt(LibraryBook libraryBook)
- => AddDownloadDecrypt(new List() { libraryBook });
-
- public void AddConvertMp3(LibraryBook libraryBook)
- => AddConvertMp3(new List() { libraryBook });
-
- public void AddDownloadPdf(IEnumerable entries)
- {
- List procs = new();
- foreach (var entry in entries)
- {
- if (isBookInQueue(entry))
- continue;
-
- ProcessBookViewModel pbook = new(entry, Logger);
- pbook.AddDownloadPdf();
- procs.Add(pbook);
- }
-
- Serilog.Log.Logger.Information("Queueing {count} books", procs.Count);
- AddToQueue(procs);
- }
-
- public void AddDownloadDecrypt(IEnumerable entries)
- {
- List procs = new();
- foreach (var entry in entries)
- {
- if (isBookInQueue(entry))
- continue;
-
- ProcessBookViewModel pbook = new(entry, Logger);
- pbook.AddDownloadDecryptBook();
- pbook.AddDownloadPdf();
- procs.Add(pbook);
- }
-
- Serilog.Log.Logger.Information("Queueing {count} books", procs.Count);
- AddToQueue(procs);
- }
-
- public void AddConvertMp3(IEnumerable entries)
- {
- List procs = new();
- foreach (var entry in entries)
- {
- if (isBookInQueue(entry))
- continue;
-
- ProcessBookViewModel pbook = new(entry, Logger);
- pbook.AddConvertToMp3();
- procs.Add(pbook);
- }
-
- Serilog.Log.Logger.Information("Queueing {count} books", procs.Count);
- AddToQueue(procs);
- }
-
- public void AddToQueue(IEnumerable pbook)
- {
- Dispatcher.UIThread.Post(() =>
- {
- Queue.Enqueue(pbook);
- if (!Running)
- QueueRunner = QueueLoop();
- });
- }
-
- #endregion
-
- DateTime StartingTime;
- private async Task QueueLoop()
- {
- try
- {
- Serilog.Log.Logger.Information("Begin processing queue");
-
- RunningTime = string.Empty;
- ProgressBarVisible = true;
- StartingTime = DateTime.Now;
-
- using var counterTimer = new System.Threading.Timer(CounterTimer_Tick, null, 0, 500);
-
- while (Queue.MoveNext())
- {
- var nextBook = Queue.Current;
-
- Serilog.Log.Logger.Information("Begin processing queued item. {item_LibraryBook}", nextBook?.LibraryBook);
-
- var result = await nextBook.ProcessOneAsync();
-
- Serilog.Log.Logger.Information("Completed processing queued item: {item_LibraryBook}\r\nResult: {result}", nextBook?.LibraryBook, result);
-
- if (result == ProcessBookResult.ValidationFail)
- Queue.ClearCurrent();
- else if (result == ProcessBookResult.FailedAbort)
- Queue.ClearQueue();
- else if (result == ProcessBookResult.FailedSkip)
- nextBook.LibraryBook.Book.UpdateBookStatus(DataLayer.LiberatedStatus.Error);
- }
- Serilog.Log.Logger.Information("Completed processing queue");
-
- Queue_CompletedCountChanged(this, 0);
- ProgressBarVisible = false;
- }
- catch (Exception ex)
- {
- Serilog.Log.Logger.Error(ex, "An error was encountered while processing queued items");
- }
- }
-
- private void CounterTimer_Tick(object state)
- {
- string timeToStr(TimeSpan time)
- {
- string minsSecs = $"{time:mm\\:ss}";
- if (time.TotalHours >= 1)
- return $"{time.TotalHours:F0}:{minsSecs}";
- return minsSecs;
- }
- RunningTime = timeToStr(DateTime.Now - StartingTime);
- }
- }
-
- public class LogEntry
- {
- public DateTime LogDate { get; init; }
- public string LogDateString => LogDate.ToShortTimeString();
- public string LogMessage { get; init; }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs
deleted file mode 100644
index c243c77a..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs
+++ /dev/null
@@ -1,338 +0,0 @@
-using Avalonia.Controls;
-using DataLayer;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Threading.Tasks;
-using ReactiveUI;
-using System.Reflection;
-using System.Collections;
-using Avalonia.Threading;
-using ApplicationServices;
-using AudibleUtilities;
-using LibationWinForms.AvaloniaUI.Views;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- public class ProductsDisplayViewModel : ViewModelBase
- {
- /// Number of visible rows has changed
- public event EventHandler VisibleCountChanged;
- public event EventHandler RemovableCountChanged;
- public event EventHandler InitialLoaded;
-
- private DataGridColumn _currentSortColumn;
- private DataGrid productsDataGrid;
-
- private GridEntryCollection _gridEntries;
- private bool _removeColumnVisivle;
- 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 GetVisibleBookEntries()
- => GridEntries.InternalList
- .BookEntries()
- .Select(lbe => lbe.LibraryBook)
- .ToList();
- public IEnumerable GetAllBookEntries()
- => GridEntries
- .AllItems()
- .BookEntries();
- public ProductsDisplayViewModel() { }
- public ProductsDisplayViewModel(List items)
- {
- GridEntries = new GridEntryCollection(items);
- }
-
- #region Display Functions
-
- ///
- /// Call once on load so we can modify access a private member with reflection
- ///
- public void RegisterCollectionChanged(ProductsDisplay productsDisplay = null)
- {
- productsDataGrid ??= productsDisplay?.productsGrid;
-
- if (GridEntries is null)
- return;
-
- //Avalonia displays items in the DataConncetion from an internal copy of
- //the bound list, not the actual bound list. So we need to reflect to get
- //the current display order and set each GridEntry.ListIndex correctly.
- var DataConnection_PI = typeof(DataGrid).GetProperty("DataConnection", BindingFlags.NonPublic | BindingFlags.Instance);
- var DataSource_PI = DataConnection_PI.PropertyType.GetProperty("DataSource", BindingFlags.Public | BindingFlags.Instance);
-
- GridEntries.CollectionChanged += (s, e) =>
- {
- if (s != GridEntries) return;
-
- var displayListGE = ((IEnumerable)DataSource_PI.GetValue(DataConnection_PI.GetValue(productsDataGrid))).Cast();
- int index = 0;
- foreach (var di in displayListGE)
- {
- di.ListIndex = index++;
- }
- };
- }
-
- ///
- /// Only call once per lifetime
- ///
- public void InitialDisplay(List dbBooks)
- {
- try
- {
- GridEntries = new GridEntryCollection(CreateGridEntries(dbBooks));
- GridEntries.CollapseAll();
-
- InitialLoaded?.Invoke(this, EventArgs.Empty);
- VisibleCountChanged?.Invoke(this, GridEntries.BookEntries().Count());
-
- RegisterCollectionChanged();
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, "Error displaying library in {0}", nameof(ProductsDisplayViewModel));
- }
- }
-
- ///
- /// Call when there's been a change to the library
- ///
- public async Task DisplayBooks(List dbBooks)
- {
- try
- {
- //List is already displayed. Replace all items with new ones, refilter, and re-sort
- string existingFilter = GridEntries?.Filter;
- var newEntries = CreateGridEntries(dbBooks);
-
- var existingSeriesEntries = GridEntries.AllItems().SeriesEntries().ToList();
-
- await Dispatcher.UIThread.InvokeAsync(() =>
- {
- GridEntries.ReplaceList(newEntries);
-
- //We're replacing the list, so preserve usere's existing collapse/expand
- //state. When resetting a list, default state is open.
- foreach (var series in existingSeriesEntries)
- {
- var sEntry = GridEntries.InternalList.FirstOrDefault(ge => ge.AudibleProductId == series.AudibleProductId);
- if (sEntry is SeriesEntry se && !series.Liberate.Expanded)
- GridEntries.CollapseItem(se);
- }
-
- GridEntries.Filter = existingFilter;
- ReSort();
- VisibleCountChanged?.Invoke(this, GridEntries.BookEntries().Count());
- });
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, "Error displaying library in {0}", nameof(ProductsDisplayViewModel));
- }
- }
-
- private static IEnumerable CreateGridEntries(IEnumerable dbBooks)
- {
- var geList = dbBooks
- .Where(lb => lb.Book.IsProduct())
- .Select(b => new LibraryBookEntry(b))
- .Cast()
- .ToList();
-
- var episodes = dbBooks.Where(lb => lb.Book.IsEpisodeChild());
-
- var seriesBooks = dbBooks.Where(lb => lb.Book.IsEpisodeParent()).ToList();
-
- foreach (var parent in seriesBooks)
- {
- var seriesEpisodes = episodes.FindChildren(parent);
-
- if (!seriesEpisodes.Any()) continue;
-
- var seriesEntry = new SeriesEntry(parent, seriesEpisodes);
-
- geList.Add(seriesEntry);
- geList.AddRange(seriesEntry.Children);
- }
- return geList.OrderByDescending(e => e.DateAdded);
- }
-
- public void ToggleSeriesExpanded(SeriesEntry seriesEntry)
- {
- if (seriesEntry.Liberate.Expanded)
- GridEntries.CollapseItem(seriesEntry);
- else
- GridEntries.ExpandItem(seriesEntry);
-
- VisibleCountChanged?.Invoke(this, GridEntries.BookEntries().Count());
- }
-
- #endregion
-
- #region Filtering
- public async Task Filter(string searchString)
- {
- await Dispatcher.UIThread.InvokeAsync(() =>
- {
- int visibleCount = GridEntries.Count;
-
- if (string.IsNullOrEmpty(searchString))
- GridEntries.RemoveFilter();
- else
- GridEntries.Filter = searchString;
-
- if (visibleCount != GridEntries.Count)
- VisibleCountChanged?.Invoke(this, GridEntries.BookEntries().Count());
-
- //Re-sort after filtering
- ReSort();
- });
- }
-
- #endregion
-
- #region Sorting
-
- public void Sort(DataGridColumn sortColumn)
- {
- //Force the comparer to get the current sort order. We can't
- //retrieve it from inside this event handler because Avalonia
- //doesn't set the property until after this event.
- var comparer = sortColumn.CustomSortComparer as RowComparer;
- comparer.SortDirection = null;
-
- _currentSortColumn = sortColumn;
- }
-
- //Must be invoked on UI thread
- private void ReSort()
- {
- 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(GridEntry.DateAdded));
- GridEntries.InternalList.Sort(defaultComparer);
- GridEntries.InternalList.Reverse();
- GridEntries.ResetCollection();
- }
- else
- {
- _currentSortColumn.Sort(((RowComparer)_currentSortColumn.CustomSortComparer).SortDirection ?? ListSortDirection.Ascending);
- }
- }
-
- #endregion
-
- #region Scan and Remove Books
-
- public void DoneRemovingBooks()
- {
- foreach (var item in GridEntries.AllItems())
- item.PropertyChanged -= Item_PropertyChanged;
- RemoveColumnVisivle = false;
- }
-
- public async Task RemoveCheckedBooksAsync()
- {
- var selectedBooks = GetAllBookEntries().Where(lbe => lbe.Remove == true).ToList();
-
- if (selectedBooks.Count == 0)
- return;
-
- var libraryBooks = selectedBooks.Select(rge => rge.LibraryBook).ToList();
- var result = MessageBox.ShowConfirmationDialog(
- null,
- libraryBooks,
- $"Are you sure you want to remove {selectedBooks.Count} books from Libation's library?",
- "Remove books from Libation?");
-
- if (result != DialogResult.Yes)
- return;
-
- foreach (var book in selectedBooks)
- book.PropertyChanged -= Item_PropertyChanged;
-
- var idsToRemove = libraryBooks.Select(lb => lb.Book.AudibleProductId).ToList();
- GridEntries.CollectionChanged += BindingList_CollectionChanged;
-
- //The RemoveBooksAsync will fire LibrarySizeChanged, which calls ProductsDisplay2.Display(),
- //so there's no need to remove books from the grid display here.
- var removeLibraryBooks = await LibraryCommands.RemoveBooksAsync(idsToRemove);
-
- foreach (var b in GetAllBookEntries())
- b.Remove = false;
-
- RemovableCountChanged?.Invoke(this, 0);
- }
-
- void BindingList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
- {
- if (e.Action != System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
- return;
-
- //After ProductsDisplay2.Display() re-creates the list,
- //re-subscribe to all items' PropertyChanged events.
-
- foreach (var b in GetAllBookEntries())
- b.PropertyChanged += Item_PropertyChanged;
-
- GridEntries.CollectionChanged -= BindingList_CollectionChanged;
- }
-
- public async Task ScanAndRemoveBooksAsync(params Account[] accounts)
- {
- foreach (var item in GridEntries.AllItems())
- {
- item.Remove = false;
- item.PropertyChanged += Item_PropertyChanged;
- }
-
- RemoveColumnVisivle = true;
- RemovableCountChanged?.Invoke(this, 0);
-
- try
- {
- if (accounts is null || accounts.Length == 0)
- return;
-
- var allBooks = GetAllBookEntries();
-
- foreach (var b in allBooks)
- b.Remove = false;
-
- var lib = allBooks
- .Select(lbe => lbe.LibraryBook)
- .Where(lb => !lb.Book.HasLiberated());
-
- var removedBooks = await LibraryCommands.FindInactiveBooks(Views.Dialogs.Login.AvaloniaLoginChoiceEager.ApiExtendedFunc, lib, accounts);
-
- var removable = allBooks.Where(lbe => removedBooks.Any(rb => rb.Book.AudibleProductId == lbe.AudibleProductId)).ToList();
-
- foreach (var r in removable)
- r.Remove = true;
- }
- catch (Exception ex)
- {
- MessageBox.ShowAdminAlert(
- null,
- "Error scanning library. You may still manually select books to remove from Libation's library.",
- "Error scanning library",
- ex);
- }
- }
-
- private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == nameof(GridEntry.Remove) && sender is LibraryBookEntry lbEntry)
- {
- int removeCount = GetAllBookEntries().Count(lbe => lbe.Remove is true);
- RemovableCountChanged?.Invoke(this, removeCount);
- }
- }
-
- #endregion
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/QueryExtensions.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/QueryExtensions.cs
deleted file mode 100644
index 073bc91f..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/QueryExtensions.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using DataLayer;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
-#nullable enable
- internal static class QueryExtensions
- {
- public static IEnumerable BookEntries(this IEnumerable gridEntries)
- => gridEntries.OfType();
-
- public static IEnumerable SeriesEntries(this IEnumerable gridEntries)
- => gridEntries.OfType();
-
- public static T? FindByAsin(this IEnumerable gridEntries, string audibleProductID) where T : GridEntry
- => gridEntries.FirstOrDefault(i => i.AudibleProductId == audibleProductID);
-
- public static IEnumerable EmptySeries(this IEnumerable gridEntries)
- => gridEntries.SeriesEntries().Where(i => i.Children.Count == 0);
-
- public static SeriesEntry? FindSeriesParent(this IEnumerable gridEntries, LibraryBook seriesEpisode)
- {
- if (seriesEpisode.Book.SeriesLink is null) return null;
-
- try
- {
- //Parent books will always have exactly 1 SeriesBook due to how
- //they are imported in ApiExtended.getChildEpisodesAsync()
- return gridEntries.SeriesEntries().FirstOrDefault(
- lb =>
- seriesEpisode.Book.SeriesLink.Any(
- s => s.Series.AudibleSeriesId == lb.LibraryBook.Book.SeriesLink.Single().Series.AudibleSeriesId));
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, "Query error in {0}", nameof(FindSeriesParent));
- return null;
- }
- }
- }
-#nullable disable
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/RowComparer.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/RowComparer.cs
deleted file mode 100644
index 2551d04e..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/RowComparer.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-using Avalonia.Controls;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Reflection;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- ///
- /// This compare class ensures that all top-level grid entries (standalone books or series parents)
- /// are sorted by PropertyName while all episodes remain immediately beneath their parents and remain
- /// sorted by series index, ascending. Stable sorting is achieved by comparing the GridEntry.ListIndex
- /// properties when 2 items compare equal.
- ///
- internal class RowComparer : IComparer, IComparer
- {
- 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);
-
- public DataGridColumn Column { get; init; }
- public string PropertyName { get; private set; }
- public ListSortDirection? SortDirection { get; set; }
-
- public RowComparer(DataGridColumn column)
- {
- Column = column;
- PropertyName = Column.SortMemberPath;
- }
- public RowComparer(ListSortDirection direction, string propertyName)
- {
- SortDirection = direction;
- PropertyName = propertyName;
- }
-
- public int Compare(object x, object y)
- {
- if (x is null && y is not null) return -1;
- if (x is not null && y is null) return 1;
- if (x is null && y is null) return 0;
-
- var geA = (GridEntry)x;
- var geB = (GridEntry)y;
-
- SortDirection ??= GetSortOrder();
-
- SeriesEntry parentA = null;
- SeriesEntry parentB = null;
-
- if (geA is LibraryBookEntry lbA && lbA.Parent is SeriesEntry seA)
- parentA = seA;
- if (geB is LibraryBookEntry lbB && lbB.Parent is SeriesEntry seB)
- parentB = seB;
-
- //both a and b are top-level grid entries
- if (parentA is null && parentB is null)
- return InternalCompare(geA, geB);
-
- //a is top-level, b is a child
- if (parentA is null && parentB is not null)
- {
- // b is a child of a, parent is always first
- if (parentB == geA)
- return SortDirection is ListSortDirection.Ascending ? -1 : 1;
- else
- return InternalCompare(geA, parentB);
- }
-
- //a is a child, b is a top-level
- if (parentA is not null && parentB is null)
- {
- // a is a child of b, parent is always first
- if (parentA == geB)
- return SortDirection is ListSortDirection.Ascending ? 1 : -1;
- else
- return InternalCompare(parentA, geB);
- }
-
- //both are children of the same series, always present in order of series index, ascending
- if (parentA == parentB)
- return geA.SeriesIndex.CompareTo(geB.SeriesIndex) * (SortDirection is ListSortDirection.Ascending ? 1 : -1);
-
- //a and b are children of different series.
- return InternalCompare(parentA, parentB);
- }
-
- //Avalonia doesn't expose the column's CurrentSortingState, so we must get it through reflection
- private ListSortDirection? GetSortOrder()
- => CurrentSortingStatePi.GetValue(HeaderCellPi.GetValue(Column)) as ListSortDirection?;
-
- private int InternalCompare(GridEntry x, GridEntry y)
- {
- var val1 = x.GetMemberValue(PropertyName);
- var val2 = y.GetMemberValue(PropertyName);
-
- var compareResult = x.GetMemberComparer(val1.GetType()).Compare(val1, val2);
-
- //If items compare equal, compare them by their positions in the the list.
- //This is how you achieve a stable sort.
- if (compareResult == 0)
- return x.ListIndex.CompareTo(y.ListIndex);
- else
- return compareResult;
- }
-
- public int Compare(GridEntry x, GridEntry y)
- {
- return Compare((object)x, y);
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/SeriesEntry.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/SeriesEntry.cs
deleted file mode 100644
index c2ec3177..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/SeriesEntry.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using Avalonia.Media;
-using DataLayer;
-using Dinah.Core;
-using ReactiveUI;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- /// The View Model for a LibraryBook that is ContentType.Parent
- public class SeriesEntry : GridEntry
- {
- [Browsable(false)] public List Children { get; }
- [Browsable(false)] public override DateTime DateAdded => Children.Max(c => c.DateAdded);
-
- private bool suspendCounting = false;
- public void ChildRemoveUpdate()
- {
- if (suspendCounting) return;
-
- var removeCount = Children.Count(c => c.Remove == true);
-
- _remove = removeCount == 0 ? false : (removeCount == Children.Count ? true : null);
- this.RaisePropertyChanged(nameof(Remove));
- }
-
- #region Model properties exposed to the view
- public override bool? Remove
- {
- get => _remove;
- set
- {
- _remove = value ?? false;
-
- suspendCounting = true;
-
- foreach (var item in Children)
- item.Remove = value;
-
- suspendCounting = false;
- this.RaisePropertyChanged(nameof(Remove));
- }
- }
-
- public override LiberateButtonStatus Liberate { get; }
- public override BookTags BookTags { get; } = new();
-
- public override bool IsSeries => true;
- public override bool IsEpisode => false;
- public override bool IsBook => false;
-
- #endregion
-
- public SeriesEntry(LibraryBook parent, IEnumerable children)
- {
- Liberate = new LiberateButtonStatus(IsSeries) { Expanded = true };
- SeriesIndex = -1;
- LibraryBook = parent;
-
- LoadCover();
-
- Children = children
- .Select(c => new LibraryBookEntry(c) { Parent = this })
- .OrderBy(c => c.SeriesIndex)
- .ToList();
-
- Title = Book.Title;
- Series = Book.SeriesNames();
- MyRating = Book.UserDefinedItem.Rating?.ToStarString()?.DefaultIfNullOrWhiteSpace("");
- ProductRating = Book.Rating?.ToStarString()?.DefaultIfNullOrWhiteSpace("");
- Authors = Book.AuthorNames();
- Narrators = Book.NarratorNames();
- Category = string.Join(" > ", Book.CategoriesNames());
- Misc = GetMiscDisplay(LibraryBook);
- LongDescription = GetDescriptionDisplay(Book);
- Description = TrimTextToWord(LongDescription, 62);
-
- PurchaseDate = Children.Min(c => c.LibraryBook.DateAdded).ToString("d");
- int bookLenMins = Children.Sum(c => c.LibraryBook.Book.LengthInMinutes);
- Length = bookLenMins == 0 ? "" : $"{bookLenMins / 60} hr {bookLenMins % 60} min";
- }
-
-
- #region Data Sorting
-
- /// Create getters for all member object values by name
- protected override Dictionary> CreateMemberValueDictionary() => new()
- {
- { nameof(Remove), () => Remove.HasValue ? Remove.Value ? RemoveStatus.Removed : RemoveStatus.NotRemoved : RemoveStatus.SomeRemoved },
- { nameof(Title), () => Book.TitleSortable() },
- { nameof(Series), () => Book.SeriesSortable() },
- { nameof(Length), () => Children.Sum(c => c.LibraryBook.Book.LengthInMinutes) },
- { nameof(MyRating), () => Book.UserDefinedItem.Rating.FirstScore() },
- { nameof(PurchaseDate), () => Children.Min(c => c.LibraryBook.DateAdded) },
- { nameof(ProductRating), () => Book.Rating.FirstScore() },
- { nameof(Authors), () => Authors },
- { nameof(Narrators), () => Narrators },
- { nameof(Description), () => Description },
- { nameof(Category), () => Category },
- { nameof(Misc), () => Misc },
- { nameof(BookTags), () => BookTags?.Tags ?? string.Empty },
- { nameof(Liberate), () => Liberate },
- { nameof(DateAdded), () => DateAdded },
- };
-
- #endregion
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/TrackedQueue[T].cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/TrackedQueue[T].cs
deleted file mode 100644
index dd2ff3a7..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/TrackedQueue[T].cs
+++ /dev/null
@@ -1,240 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- public enum QueuePosition
- {
- Fisrt,
- OneUp,
- OneDown,
- Last,
- }
-
- /*
- * This data structure is like lifting a metal chain one link at a time.
- * Each time you grab and lift a new link (MoveNext call):
- *
- * 1) you're holding a new link in your hand (Current)
- * 2) the remaining chain to be lifted shortens by 1 link (Queued)
- * 3) the pile of chain at your feet grows by 1 link (Completed)
- *
- * The index is the link position from the first link you lifted to the
- * last one in the chain.
- *
- *
- * For this to work with Avalonia's ItemsRepeater, it must be an ObservableCollection
- * (not merely a Collection with INotifyCollectionChanged, INotifyPropertyChanged).
- * So TrackedQueue maintains 2 copies of the list. The primary copy of the list is
- * split into Completed, Current and Queued and is used by ProcessQueue to keep track
- * of what's what. The secondary copy is a concatenation of primary's three sources
- * and is stored in ObservableCollection.Items. When the primary list changes, the
- * secondary list is cleared and reset to match the primary.
- */
- public class TrackedQueue : ObservableCollection where T : class
- {
- public event EventHandler CompletedCountChanged;
- public event EventHandler QueuededCountChanged;
-
- public T Current { get; private set; }
-
- public IReadOnlyList Queued => _queued;
- public IReadOnlyList Completed => _completed;
-
- private readonly List _queued = new();
- private readonly List _completed = new();
- private readonly object lockObject = new();
-
- public bool RemoveQueued(T item)
- {
- bool itemsRemoved;
- int queuedCount;
-
- lock (lockObject)
- {
- itemsRemoved = _queued.Remove(item);
- queuedCount = _queued.Count;
- }
-
- if (itemsRemoved)
- {
- QueuededCountChanged?.Invoke(this, queuedCount);
- RebuildSecondary();
- }
- return itemsRemoved;
- }
-
- public void ClearCurrent()
- {
- lock(lockObject)
- Current = null;
- RebuildSecondary();
- }
-
- public bool RemoveCompleted(T item)
- {
- bool itemsRemoved;
- int completedCount;
-
- lock (lockObject)
- {
- itemsRemoved = _completed.Remove(item);
- completedCount = _completed.Count;
- }
-
- if (itemsRemoved)
- {
- CompletedCountChanged?.Invoke(this, completedCount);
- RebuildSecondary();
- }
- return itemsRemoved;
- }
-
- public void ClearQueue()
- {
- lock (lockObject)
- _queued.Clear();
- QueuededCountChanged?.Invoke(this, 0);
- RebuildSecondary();
- }
-
- public void ClearCompleted()
- {
- lock (lockObject)
- _completed.Clear();
- CompletedCountChanged?.Invoke(this, 0);
- RebuildSecondary();
- }
-
- public bool Any(Func predicate)
- {
- lock (lockObject)
- {
- return (Current != null && predicate(Current)) || _completed.Any(predicate) || _queued.Any(predicate);
- }
- }
-
- public void MoveQueuePosition(T item, QueuePosition requestedPosition)
- {
- lock (lockObject)
- {
- if (_queued.Count == 0 || !_queued.Contains(item)) return;
-
- if ((requestedPosition == QueuePosition.Fisrt || requestedPosition == QueuePosition.OneUp) && _queued[0] == item)
- return;
- if ((requestedPosition == QueuePosition.Last || requestedPosition == QueuePosition.OneDown) && _queued[^1] == item)
- return;
-
- int queueIndex = _queued.IndexOf(item);
-
- if (requestedPosition == QueuePosition.OneUp)
- {
- _queued.RemoveAt(queueIndex);
- _queued.Insert(queueIndex - 1, item);
- }
- else if (requestedPosition == QueuePosition.OneDown)
- {
- _queued.RemoveAt(queueIndex);
- _queued.Insert(queueIndex + 1, item);
- }
- else if (requestedPosition == QueuePosition.Fisrt)
- {
- _queued.RemoveAt(queueIndex);
- _queued.Insert(0, item);
- }
- else
- {
- _queued.RemoveAt(queueIndex);
- _queued.Insert(_queued.Count, item);
- }
- }
- RebuildSecondary();
- }
-
- public bool MoveNext()
- {
- int completedCount = 0, queuedCount = 0;
- bool completedChanged = false;
- try
- {
- lock (lockObject)
- {
- if (Current != null)
- {
- _completed.Add(Current);
- completedCount = _completed.Count;
- completedChanged = true;
- }
- if (_queued.Count == 0)
- {
- Current = null;
- return false;
- }
- Current = _queued[0];
- _queued.RemoveAt(0);
-
- queuedCount = _queued.Count;
- return true;
- }
- }
- finally
- {
- if (completedChanged)
- CompletedCountChanged?.Invoke(this, completedCount);
- QueuededCountChanged?.Invoke(this, queuedCount);
- RebuildSecondary();
- }
- }
-
- public bool TryPeek(out T item)
- {
- lock (lockObject)
- {
- if (_queued.Count == 0)
- {
- item = null;
- return false;
- }
- item = _queued[0];
- return true;
- }
- }
-
- public T Peek()
- {
- lock (lockObject)
- {
- if (_queued.Count == 0) throw new InvalidOperationException("Queue empty");
- return _queued.Count > 0 ? _queued[0] : default;
- }
- }
-
- public void Enqueue(IEnumerable item)
- {
- int queueCount;
- lock (lockObject)
- {
- _queued.AddRange(item);
- queueCount = _queued.Count;
- }
- foreach (var i in item)
- base.Add(i);
- QueuededCountChanged?.Invoke(this, queueCount);
- }
-
- private void RebuildSecondary()
- {
- base.ClearItems();
- foreach (var item in GetAllItems())
- base.Add(item);
- }
-
- public IEnumerable GetAllItems()
- {
- if (Current is null) return Completed.Concat(Queued);
- return Completed.Concat(new List { Current }).Concat(Queued);
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ViewModelBase.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ViewModelBase.cs
deleted file mode 100644
index 060934f0..00000000
--- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ViewModelBase.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Avalonia.Controls;
-using ReactiveUI;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace LibationWinForms.AvaloniaUI.ViewModels
-{
- public class ViewModelBase : ReactiveObject
- {
-
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/AccountsDialog.axaml b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/AccountsDialog.axaml
deleted file mode 100644
index 0942c6f6..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/AccountsDialog.axaml
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/AccountsDialog.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/AccountsDialog.axaml.cs
deleted file mode 100644
index 4bd0301d..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/AccountsDialog.axaml.cs
+++ /dev/null
@@ -1,297 +0,0 @@
-using AudibleUtilities;
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using ReactiveUI;
-using AudibleApi;
-
-namespace LibationWinForms.AvaloniaUI.Views.Dialogs
-{
- public partial class AccountsDialog : DialogWindow
- {
- public ObservableCollection Accounts { get; } = new();
- public class AccountDto : ViewModels.ViewModelBase
- {
- private string _accountId;
- private Locale _selectedLocale;
- public IReadOnlyList Locales => AccountsDialog.Locales;
- public bool LibraryScan { get; set; } = true;
- public string AccountId
- {
- get => _accountId;
- set
- {
- this.RaiseAndSetIfChanged(ref _accountId, value);
- this.RaisePropertyChanged(nameof(IsDefault));
- }
- }
- public Locale SelectedLocale
- {
- get => _selectedLocale;
- set
- {
- this.RaiseAndSetIfChanged(ref _selectedLocale, value);
- this.RaisePropertyChanged(nameof(IsDefault));
- }
- }
- public string AccountName { get; set; }
- public bool IsDefault => string.IsNullOrEmpty(AccountId) && SelectedLocale is null;
- }
-
- private static string GetAudibleCliAppDataPath()
- => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Audible");
-
- private static IReadOnlyList Locales => Localization.Locales.OrderBy(l => l.Name).ToList();
- public AccountsDialog()
- {
- InitializeComponent();
-
- // WARNING: accounts persister will write ANY EDIT to object immediately to file
- // here: copy strings and dispose of persister
- // only persist in 'save' step
- using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
- var accounts = persister.AccountsSettings.Accounts;
- if (accounts.Any())
- {
- foreach (var account in accounts)
- AddAccountToGrid(account);
- }
-
- DataContext = this;
- addBlankAccount();
- }
- private void addBlankAccount()
- {
-
- var newBlank = new AccountDto();
- newBlank.PropertyChanged += AccountDto_PropertyChanged;
- Accounts.Insert(Accounts.Count, newBlank);
- }
-
- private void AddAccountToGrid(Account account)
- {
- AccountDto accountDto = new()
- {
- LibraryScan = account.LibraryScan,
- AccountId = account.AccountId,
- SelectedLocale = Locales.Single(l => l.Name == account.Locale.Name),
- AccountName = account.AccountName,
- };
- accountDto.PropertyChanged += AccountDto_PropertyChanged;
-
- //ObservableCollection doesn't fire CollectionChanged on Add, so use Insert instead
- Accounts.Insert(Accounts.Count, accountDto);
- }
-
- private void AccountDto_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- if (Accounts.Any(a => a.IsDefault))
- return;
-
- addBlankAccount();
- }
-
- public void DeleteButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- if (e.Source is Button expBtn && expBtn.DataContext is AccountDto acc)
- {
- var index = Accounts.IndexOf(acc);
- if (index < 0) return;
-
- acc.PropertyChanged -= AccountDto_PropertyChanged;
- Accounts.Remove(acc);
- }
- }
-
- public async void ImportButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
-
- OpenFileDialog ofd = new();
- ofd.Filters.Add(new() { Name = "JSON File", Extensions = new() { "json" } });
- ofd.Directory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- ofd.AllowMultiple = false;
-
- string audibleAppDataDir = GetAudibleCliAppDataPath();
-
- if (Directory.Exists(audibleAppDataDir))
- ofd.Directory = audibleAppDataDir;
-
- var filePath = await ofd.ShowAsync(this);
-
- if (filePath is null || filePath.Length == 0) return;
-
- try
- {
- var jsonText = File.ReadAllText(filePath[0]);
- var mkbAuth = Mkb79Auth.FromJson(jsonText);
- var account = await mkbAuth.ToAccountAsync();
-
- // without transaction, accounts persister will write ANY EDIT immediately to file
- using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
-
- if (persister.AccountsSettings.Accounts.Any(a => a.AccountId == account.AccountId && a.IdentityTokens.Locale.Name == account.Locale.Name))
- {
- MessageBox.Show(this, $"An account with that account id and country already exists.\r\n\r\nAccount ID: {account.AccountId}\r\nCountry: {account.Locale.Name}", "Cannot Add Duplicate Account");
- return;
- }
-
- persister.AccountsSettings.Add(account);
-
- AddAccountToGrid(account);
- }
- catch (Exception ex)
- {
- MessageBox.ShowAdminAlert(
- this,
- $"An error occurred while importing an account from:\r\n{filePath[0]}\r\n\r\nIs the file encrypted?",
- "Error Importing Account",
- ex);
- }
- }
-
- public void ExportButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- if (e.Source is Button expBtn && expBtn.DataContext is AccountDto acc)
- Export(acc);
- }
-
- protected override void SaveAndClose()
- {
- try
- {
- if (!inputIsValid())
- return;
-
- // without transaction, accounts persister will write ANY EDIT immediately to file
- using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
-
- persister.BeginTransation();
- persist(persister.AccountsSettings);
- persister.CommitTransation();
-
- base.SaveAndClose();
- }
- catch (Exception ex)
- {
- MessageBox.ShowAdminAlert(this, "Error attempting to save accounts", "Error saving accounts", ex);
- }
- }
-
- public async void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
- => await SaveAndCloseAsync();
-
-
- private void InitializeComponent()
- {
- AvaloniaXamlLoader.Load(this);
- }
-
- private void persist(AccountsSettings accountsSettings)
- {
- var existingAccounts = accountsSettings.Accounts;
-
- // editing account id is a special case. an account is defined by its account id, therefore this is really a different account. the user won't care about this distinction though.
- // these will be caught below by normal means and re-created minus the convenience of persisting identity tokens
-
- // delete
- for (var i = existingAccounts.Count - 1; i >= 0; i--)
- {
- var existing = existingAccounts[i];
- if (!Accounts.Any(dto =>
- dto.AccountId?.ToLower().Trim() == existing.AccountId.ToLower()
- && dto.SelectedLocale?.Name == existing.Locale?.Name))
- {
- accountsSettings.Delete(existing);
- }
- }
-
- // upsert each. validation occurs through Account and AccountsSettings
- foreach (var dto in Accounts)
- {
- var acct = accountsSettings.Upsert(dto.AccountId, dto.SelectedLocale?.Name);
- acct.LibraryScan = dto.LibraryScan;
- acct.AccountName
- = string.IsNullOrWhiteSpace(dto.AccountName)
- ? $"{dto.AccountId} - {dto.SelectedLocale?.Name}"
- : dto.AccountName.Trim();
- }
- }
- private bool inputIsValid()
- {
- foreach (var dto in Accounts.ToList())
- {
- if (dto.IsDefault)
- {
- Accounts.Remove(dto);
- continue;
- }
-
- if (string.IsNullOrWhiteSpace(dto.AccountId))
- {
- MessageBox.Show(this, "Account id cannot be blank. Please enter an account id for all accounts.", "Blank account", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return false;
- }
-
- if (string.IsNullOrWhiteSpace(dto.SelectedLocale?.Name))
- {
- MessageBox.Show(this, "Please select a locale (i.e.: country or region) for all accounts.", "Blank region", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return false;
- }
- }
-
- return true;
- }
-
- private async void Export(AccountDto acc)
- {
- // without transaction, accounts persister will write ANY EDIT immediately to file
- using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
-
- var account = persister.AccountsSettings.Accounts.FirstOrDefault(a => a.AccountId == acc.AccountId && a.Locale.Name == acc.SelectedLocale?.Name);
-
- if (account is null)
- return;
-
- if (account.IdentityTokens?.IsValid != true)
- {
- MessageBox.Show(this, "This account hasn't been authenticated yet. First scan your library to log into your account, then try exporting again.", "Account Not Authenticated");
- return;
- }
-
- SaveFileDialog sfd = new();
- sfd.Filters.Add(new() { Name = "JSON File", Extensions = new() { "json" } });
-
- string audibleAppDataDir = GetAudibleCliAppDataPath();
-
- if (Directory.Exists(audibleAppDataDir))
- sfd.Directory = audibleAppDataDir;
-
- string fileName = await sfd.ShowAsync(this);
- if (fileName is null)
- return;
-
- try
- {
- var mkbAuth = Mkb79Auth.FromAccount(account);
- var jsonText = mkbAuth.ToJson();
-
- File.WriteAllText(fileName, jsonText);
-
- MessageBox.Show(this, $"Successfully exported {account.AccountName} to\r\n\r\n{fileName}", "Success!");
- }
- catch (Exception ex)
- {
- MessageBox.ShowAdminAlert(
- this,
- $"An error occurred while exporting account:\r\n{account.AccountName}",
- "Error Exporting Account",
- ex);
- }
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog.axaml b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog.axaml
deleted file mode 100644
index b7a1d646..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog.axaml
+++ /dev/null
@@ -1,148 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Tags are separated by a space. Each tag can contain letters, numbers, and underscores
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog.axaml.cs
deleted file mode 100644
index 87f15729..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog.axaml.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-using ApplicationServices;
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-using Avalonia.Media.Imaging;
-using DataLayer;
-using Dinah.Core;
-using LibationFileManager;
-using LibationWinForms.AvaloniaUI.ViewModels;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-
-namespace LibationWinForms.AvaloniaUI.Views.Dialogs
-{
- public partial class BookDetailsDialog : DialogWindow
- {
- private LibraryBook _libraryBook;
- private BookDetailsDialogViewModel _viewModel;
- public LibraryBook LibraryBook
- {
- get => _libraryBook;
- set
- {
- _libraryBook = value;
- Title = _libraryBook.Book.Title;
- DataContext = _viewModel = new BookDetailsDialogViewModel(_libraryBook);
- }
- }
-
- public string NewTags => _viewModel.Tags;
- public LiberatedStatus BookLiberatedStatus => _viewModel.BookLiberatedSelectedItem.Status;
- public LiberatedStatus? PdfLiberatedStatus => _viewModel.PdfLiberatedSelectedItem?.Status;
-
- public BookDetailsDialog()
- {
- InitializeComponent();
- ControlToFocusOnShow = this.Find(nameof(tagsTbox));
-
- if (Design.IsDesignMode)
- {
- using var context = DbContexts.GetContext();
- LibraryBook = context.GetLibraryBook_Flat_NoTracking("B017V4IM1G");
- }
- }
- public BookDetailsDialog(LibraryBook libraryBook) :this()
- {
- LibraryBook = libraryBook;
- }
-
- protected override void SaveAndClose()
- {
- SaveButton_Clicked(null, null);
- base.SaveAndClose();
- }
-
- public void GoToAudible_Tapped(object sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- var locale = AudibleApi.Localization.Get(_libraryBook.Book.Locale);
- var link = $"https://www.audible.{locale.TopDomain}/pd/{_libraryBook.Book.AudibleProductId}";
- Go.To.Url(link);
- }
-
- public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- LibraryBook.Book.UpdateBook(NewTags, bookStatus: BookLiberatedStatus, pdfStatus: PdfLiberatedStatus);
- }
-
- private void InitializeComponent()
- {
- AvaloniaXamlLoader.Load(this);
- }
-
- private class BookDetailsDialogViewModel : ViewModelBase
- {
- public class liberatedComboBoxItem
- {
- public LiberatedStatus Status { get; set; }
- public string Text { get; set; }
- public override string ToString() => Text;
- }
-
- public Bitmap Cover { get; set; }
- public string DetailsText { get; set; }
- public string Tags { get; set; }
-
- public bool HasPDF => PdfLiberatedItems?.Count > 0;
-
- private liberatedComboBoxItem _bookLiberatedSelectedItem;
- public ObservableCollection BookLiberatedItems { get; } = new();
- public List PdfLiberatedItems { get; } = new();
- public liberatedComboBoxItem PdfLiberatedSelectedItem { get; set; }
-
- public liberatedComboBoxItem BookLiberatedSelectedItem
- {
- get => _bookLiberatedSelectedItem;
- set
- {
- _bookLiberatedSelectedItem = value;
- if (value?.Status is not LiberatedStatus.Error)
- {
- BookLiberatedItems.Remove(BookLiberatedItems.SingleOrDefault(s => s.Status == LiberatedStatus.Error));
- }
- }
- }
-
- public BookDetailsDialogViewModel(LibraryBook libraryBook)
- {
- //init tags
- Tags = libraryBook.Book.UserDefinedItem.Tags;
-
- //init cover image
- var picture = PictureStorage.GetPictureSynchronously(new PictureDefinition(libraryBook.Book.PictureId, PictureSize._80x80));
- using var ms = new System.IO.MemoryStream(picture);
- Cover = new Bitmap(ms);
-
- //init book details
- DetailsText = @$"
-Title: {libraryBook.Book.Title}
-Author(s): {libraryBook.Book.AuthorNames()}
-Narrator(s): {libraryBook.Book.NarratorNames()}
-Length: {(libraryBook.Book.LengthInMinutes == 0 ? "" : $"{libraryBook.Book.LengthInMinutes / 60} hr {libraryBook.Book.LengthInMinutes % 60} min")}
-Audio Bitrate: {libraryBook.Book.AudioFormat}
-Category: {string.Join(" > ", libraryBook.Book.CategoriesNames())}
-Purchase Date: {libraryBook.DateAdded.ToString("d")}
-Audible ID: {libraryBook.Book.AudibleProductId}
-".Trim();
-
- var seriesNames = libraryBook.Book.SeriesNames();
- if (!string.IsNullOrWhiteSpace(seriesNames))
- DetailsText += $"\r\nSeries: {seriesNames}";
-
- var bookRating = libraryBook.Book.Rating?.ToStarString();
- if (!string.IsNullOrWhiteSpace(bookRating))
- DetailsText += $"\r\nBook Rating:\r\n{bookRating}";
-
- var myRating = libraryBook.Book.UserDefinedItem.Rating?.ToStarString();
- if (!string.IsNullOrWhiteSpace(myRating))
- DetailsText += $"\r\nMy Rating:\r\n{myRating}";
-
-
- //init book status
- {
- var status = libraryBook.Book.UserDefinedItem.BookStatus;
-
- BookLiberatedItems.Add(new() { Status = LiberatedStatus.Liberated, Text = "Downloaded" });
- BookLiberatedItems.Add(new() { Status = LiberatedStatus.NotLiberated, Text = "Not Downloaded" });
-
- if (status == LiberatedStatus.Error)
- BookLiberatedItems.Add(new() { Status = LiberatedStatus.Error, Text = "Error" });
-
- BookLiberatedSelectedItem = BookLiberatedItems.SingleOrDefault(s => s.Status == status);
- }
-
- //init pdf status
- {
- var status = libraryBook.Book.UserDefinedItem.PdfStatus;
-
- if (status is not null)
- {
- PdfLiberatedItems.Add(new() { Status = LiberatedStatus.Liberated, Text = "Downloaded" });
- PdfLiberatedItems.Add(new() { Status = LiberatedStatus.NotLiberated, Text = "Not Downloaded" });
-
- PdfLiberatedSelectedItem = PdfLiberatedItems.SingleOrDefault(s => s.Status == status);
- }
- }
- }
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/DescriptionDisplayDialog.axaml b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/DescriptionDisplayDialog.axaml
deleted file mode 100644
index 76aeb1d2..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/DescriptionDisplayDialog.axaml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/DescriptionDisplayDialog.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/DescriptionDisplayDialog.axaml.cs
deleted file mode 100644
index 54f7e257..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/DescriptionDisplayDialog.axaml.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-using System;
-
-namespace LibationWinForms.AvaloniaUI.Views.Dialogs
-{
- public partial class DescriptionDisplayDialog : Window
- {
- public Point SpawnLocation { get; set; }
- public string DescriptionText { get; init; }
- public DescriptionDisplayDialog()
- {
- InitializeComponent();
-#if DEBUG
- this.AttachDevTools();
-#endif
- DescriptionTextBox = this.FindControl(nameof(DescriptionTextBox));
- this.Activated += DescriptionDisplay_Activated;
- Opened += DescriptionDisplay_Opened;
- }
-
- private void DescriptionDisplay_Opened(object sender, EventArgs e)
- {
- DescriptionTextBox.Focus();
- }
-
- private void DescriptionDisplay_Activated(object sender, EventArgs e)
- {
- DataContext = this;
- var workingHeight = this.Screens.Primary.WorkingArea.Height;
- DescriptionTextBox.Measure(new Size(DescriptionTextBox.MinWidth, workingHeight * 0.8));
-
- this.Width = DescriptionTextBox.DesiredSize.Width;
- this.Height = DescriptionTextBox.DesiredSize.Height;
- this.MinWidth = this.Width;
- this.MaxWidth = this.Width;
- this.MinHeight = this.Height;
- this.MaxHeight = this.Height;
-
- DescriptionTextBox.Width = this.Width;
- DescriptionTextBox.Height = this.Height;
- DescriptionTextBox.MinWidth = this.Width;
- DescriptionTextBox.MaxWidth = this.Width;
- DescriptionTextBox.MinHeight = this.Height;
- DescriptionTextBox.MaxHeight = this.Height;
-
- this.Position = new PixelPoint((int)SpawnLocation.X, (int)Math.Min(SpawnLocation.Y, (double)workingHeight - DescriptionTextBox.DesiredSize.Height));
- }
-
- private void DescriptionTextBox_LostFocus(object sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- Close();
- }
-
- private void InitializeComponent()
- {
- AvaloniaXamlLoader.Load(this);
- }
-
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/DialogWindow.cs b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/DialogWindow.cs
deleted file mode 100644
index 7bf399ff..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/DialogWindow.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using Avalonia;
-using Avalonia.Controls;
-using LibationFileManager;
-using System;
-using System.Threading.Tasks;
-
-namespace LibationWinForms.AvaloniaUI.Views.Dialogs
-{
- public abstract class DialogWindow : Window
- {
- public Control ControlToFocusOnShow { get; set; }
- public DialogWindow()
- {
- this.HideMinMaxBtns();
- this.KeyDown += DialogWindow_KeyDown;
- this.Initialized += DialogWindow_Initialized;
- this.Opened += DialogWindow_Opened;
- this.Closing += DialogWindow_Closing;
-
-#if DEBUG
- this.AttachDevTools();
-#endif
- }
-
- private void DialogWindow_Initialized(object sender, EventArgs e)
- {
- this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
- this.RestoreSizeAndLocation(Configuration.Instance);
- }
-
- private void DialogWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
- {
- this.SaveSizeAndLocation(Configuration.Instance);
- }
-
- private void DialogWindow_Opened(object sender, EventArgs e)
- {
- ControlToFocusOnShow?.Focus();
- }
-
- protected virtual void SaveAndClose() => Close(DialogResult.OK);
- protected virtual Task SaveAndCloseAsync() => Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(SaveAndClose);
- protected virtual void CancelAndClose() => Close(DialogResult.Cancel);
- protected virtual Task CancelAndCloseAsync() => Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(CancelAndClose);
-
- private async void DialogWindow_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
- {
- if (e.Key == Avalonia.Input.Key.Escape)
- await CancelAndCloseAsync();
- else if (e.Key == Avalonia.Input.Key.Return)
- await SaveAndCloseAsync();
- }
- }
-}
diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml
deleted file mode 100644
index 7f8f757a..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml
+++ /dev/null
@@ -1,103 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml.cs
deleted file mode 100644
index af7becd4..00000000
--- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using AudibleUtilities;
-using Avalonia.Controls;
-using LibationFileManager;
-using System.Collections.ObjectModel;
-using System.Linq;
-using ReactiveUI;
-
-namespace LibationWinForms.AvaloniaUI.Views.Dialogs
-{
- public partial class EditQuickFilters : DialogWindow
- {
- public ObservableCollection Filters { get; } = new();
-
- public class Filter : ViewModels.ViewModelBase
- {
- private string _filterString;
- public string FilterString
- {
- get => _filterString;
- set
- {
- IsDefault = string.IsNullOrEmpty(value);
- this.RaiseAndSetIfChanged(ref _filterString, value);
- this.RaisePropertyChanged(nameof(IsDefault));
- }
- }
- public bool IsDefault { get; private set; } = true;
- }
- public EditQuickFilters()
- {
- InitializeComponent();
-
- // WARNING: accounts persister will write ANY EDIT to object immediately to file
- // here: copy strings and dispose of persister
- // only persist in 'save' step
- using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
- var accounts = persister.AccountsSettings.Accounts;
- if (!accounts.Any())
- return;
-
- ControlToFocusOnShow = this.FindControl