diff --git a/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml.cs index d19b222d..2c7ca7be 100644 --- a/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Controls/DataGridCheckBoxColumnExt.axaml.cs @@ -10,7 +10,7 @@ namespace LibationWinForms.AvaloniaUI.Controls { //Only SeriesEntry types have three-state checks, individual LibraryEntry books are binary. var ele = base.GenerateEditingElementDirect(cell, dataItem) as CheckBox; - ele.IsThreeState = dataItem is SeriesEntrys2; + ele.IsThreeState = dataItem is SeriesEntry; return ele; } } diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntry2.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntry.cs similarity index 93% rename from Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntry2.cs rename to Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntry.cs index e04f7205..991ca7ee 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntry2.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntry.cs @@ -22,7 +22,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels SomeRemoved } /// The View Model base for the DataGridView - public abstract class GridEntry2 : ViewModelBase + public abstract class GridEntry : ViewModelBase { [Browsable(false)] public string AudibleProductId => Book.AudibleProductId; [Browsable(false)] public LibraryBook LibraryBook { get; protected set; } @@ -50,7 +50,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels protected bool? _remove = false; public abstract bool? Remove { get; set; } - public abstract LiberateButtonStatus2 Liberate { get; } + public abstract LiberateButtonStatus Liberate { get; } public abstract BookTags BookTags { get; } public abstract bool IsSeries { get; } public abstract bool IsEpisode { get; } @@ -61,7 +61,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels #region Sorting - public GridEntry2() => _memberValues = CreateMemberValueDictionary(); + public GridEntry() => _memberValues = CreateMemberValueDictionary(); // These methods are implementation of Dinah.Core.DataBinding.IMemberComparable // Used by GridEntryBindingList for all sorting @@ -79,7 +79,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels { typeof(float), new ObjectComparer() }, { typeof(bool), new ObjectComparer() }, { typeof(DateTime), new ObjectComparer() }, - { typeof(LiberateButtonStatus2), new ObjectComparer() }, + { typeof(LiberateButtonStatus), new ObjectComparer() }, }; #endregion @@ -113,7 +113,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels #region Static library display functions - /// This information should not change during lifetime, so call only once. + /// This information should not change during lifetime, so call only once. protected static string GetDescriptionDisplay(Book book) { var doc = new HtmlAgilityPack.HtmlDocument(); @@ -131,7 +131,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels /// - /// This information should not change during lifetime, so call only once. + /// 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) @@ -161,7 +161,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels #endregion - ~GridEntry2() + ~GridEntry() { PictureStorage.PictureCached -= PictureStorage_PictureCached; } diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryBindingList2.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs similarity index 86% rename from Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryBindingList2.cs rename to Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs index 0a42cb3c..daa31e6e 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryBindingList2.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs @@ -23,32 +23,32 @@ namespace LibationWinForms.AvaloniaUI.ViewModels * but requires ResetCollection() to be called after all changes * have been made. */ - public class GridEntryBindingList2 : ObservableCollection + public class GridEntryCollection : ObservableCollection { - public GridEntryBindingList2(IEnumerable enumeration) - : base(new List(enumeration)) { } - public GridEntryBindingList2(List list) + public GridEntryCollection(IEnumerable enumeration) + : base(new List(enumeration)) { } + public GridEntryCollection(List list) : base(list) { } - public List InternalList => Items as List; + public List InternalList => Items as List; /// All items in the list, including those filtered out. - public List AllItems() => Items.Concat(FilterRemoved).ToList(); + 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 readonly List FilterRemoved = new(); private string FilterString; private SearchResultSet SearchResults; #region Items Management - public void ReplaceList(IEnumerable newItems) + public void ReplaceList(IEnumerable newItems) { Items.Clear(); - ((List)Items).AddRange(newItems); + ((List)Items).AddRange(newItems); ResetCollection(); } public void ResetCollection() @@ -67,7 +67,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels FilterString = filterString; SearchResults = SearchEngineCommands.Search(filterString); - var booksFilteredIn = Items.BookEntries().Join(SearchResults.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => (GridEntry2)lbe); + var booksFilteredIn = Items.BookEntries().Join(SearchResults.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => (GridEntry)lbe); //Find all series containing children that match the search criteria var seriesFilteredIn = Items.SeriesEntries().Where(s => s.Children.Join(SearchResults.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => lbe).Any()); @@ -90,7 +90,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels foreach (var item in FilterRemoved.ToList()) { - if (item is SeriesEntrys2 || item is LibraryBookEntry2 lbe && (lbe.Parent is null || lbe.Parent.Liberate.Expanded)) + if (item is SeriesEntry || item is LibraryBookEntry lbe && (lbe.Parent is null || lbe.Parent.Liberate.Expanded)) { FilterRemoved.Remove(item); @@ -119,7 +119,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels ExpandItem(series); } - public void CollapseItem(SeriesEntrys2 sEntry) + public void CollapseItem(SeriesEntry sEntry) { foreach (var episode in Items.BookEntries().Where(b => b.Parent == sEntry).OrderByDescending(lbe => lbe.SeriesIndex).ToList()) { @@ -141,7 +141,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels ResetCollection(); } - public void ExpandItem(SeriesEntrys2 sEntry) + public void ExpandItem(SeriesEntry sEntry) { var sindex = Items.IndexOf(sEntry); diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/LiberateButtonStatus2.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/LiberateButtonStatus.cs similarity index 95% rename from Source/LibationWinForms/AvaloniaUI/ViewModels/LiberateButtonStatus2.cs rename to Source/LibationWinForms/AvaloniaUI/ViewModels/LiberateButtonStatus.cs index 2f506133..cd82e706 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/LiberateButtonStatus2.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/LiberateButtonStatus.cs @@ -6,9 +6,9 @@ using System.Collections.Generic; namespace LibationWinForms.AvaloniaUI.ViewModels { - public class LiberateButtonStatus2 : ViewModelBase, IComparable + public class LiberateButtonStatus : ViewModelBase, IComparable { - public LiberateButtonStatus2(bool isSeries) + public LiberateButtonStatus(bool isSeries) { IsSeries = isSeries; } @@ -35,7 +35,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels /// Defines the Liberate column's sorting behavior public int CompareTo(object obj) { - if (obj is not LiberateButtonStatus2 second) return -1; + if (obj is not LiberateButtonStatus second) return -1; if (IsSeries && !second.IsSeries) return -1; else if (!IsSeries && second.IsSeries) return 1; diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/LibraryBookEntry2.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/LibraryBookEntry.cs similarity index 94% rename from Source/LibationWinForms/AvaloniaUI/ViewModels/LibraryBookEntry2.cs rename to Source/LibationWinForms/AvaloniaUI/ViewModels/LibraryBookEntry.cs index 0b5c2f61..445a356b 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/LibraryBookEntry2.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/LibraryBookEntry.cs @@ -10,10 +10,10 @@ using System.Linq; namespace LibationWinForms.AvaloniaUI.ViewModels { /// The View Model for a LibraryBook that is ContentType.Product or ContentType.Episode - public class LibraryBookEntry2 : GridEntry2 + public class LibraryBookEntry : GridEntry { [Browsable(false)] public override DateTime DateAdded => LibraryBook.DateAdded; - [Browsable(false)] public SeriesEntrys2 Parent { get; init; } + [Browsable(false)] public SeriesEntry Parent { get; init; } #region Model properties exposed to the view @@ -33,7 +33,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels } } - public override LiberateButtonStatus2 Liberate + public override LiberateButtonStatus Liberate { get { @@ -44,7 +44,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels _pdfStatus = LibraryCommands.Pdf_Status(LibraryBook.Book); lastStatusUpdate = DateTime.Now; } - return new LiberateButtonStatus2(IsSeries) { BookStatus = _bookStatus, PdfStatus = _pdfStatus }; + return new LiberateButtonStatus(IsSeries) { BookStatus = _bookStatus, PdfStatus = _pdfStatus }; } } @@ -56,7 +56,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels #endregion - public LibraryBookEntry2(LibraryBook libraryBook) + public LibraryBookEntry(LibraryBook libraryBook) { LibraryBook = libraryBook; LoadCover(); @@ -144,7 +144,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels #endregion - ~LibraryBookEntry2() + ~LibraryBookEntry() { UserDefinedItem.ItemChanged -= UserDefinedItem_ItemChanged; } diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBook2.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBookViewModel.cs similarity index 98% rename from Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBook2.cs rename to Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBookViewModel.cs index acde8b07..2e785533 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBook2.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBookViewModel.cs @@ -36,7 +36,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels /// /// This is the viewmodel for queued processables /// - public class ProcessBook2 : ViewModelBase + public class ProcessBookViewModel : ViewModelBase { public event EventHandler Completed; @@ -91,7 +91,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels private readonly Queue> Processes = new(); private readonly ProcessQueue.LogMe Logger; - public ProcessBook2(LibraryBook libraryBook, ProcessQueue.LogMe logme) + public ProcessBookViewModel(LibraryBook libraryBook, ProcessQueue.LogMe logme) { LibraryBook = libraryBook; Logger = logme; diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs index 6351c46c..15521a96 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs @@ -14,10 +14,10 @@ namespace LibationWinForms.AvaloniaUI.ViewModels public class ProcessQueueViewModel : ViewModelBase, ProcessQueue.ILogForm { public ObservableCollection LogEntries { get; } = new(); - public TrackedQueue2 Items { get; } = new(); + public TrackedQueue Items { get; } = new(); - private TrackedQueue2 Queue => Items; - public ProcessBook2 SelectedItem { get; set; } + private TrackedQueue Queue => Items; + public ProcessBookViewModel SelectedItem { get; set; } public Task QueueRunner { get; private set; } public bool Running => !QueueRunner?.IsCompleted ?? false; @@ -88,13 +88,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels public void AddDownloadPdf(IEnumerable entries) { - List procs = new(); + List procs = new(); foreach (var entry in entries) { if (isBookInQueue(entry)) continue; - ProcessBook2 pbook = new(entry, Logger); + ProcessBookViewModel pbook = new(entry, Logger); pbook.AddDownloadPdf(); procs.Add(pbook); } @@ -105,13 +105,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels public void AddDownloadDecrypt(IEnumerable entries) { - List procs = new(); + List procs = new(); foreach (var entry in entries) { if (isBookInQueue(entry)) continue; - ProcessBook2 pbook = new(entry, Logger); + ProcessBookViewModel pbook = new(entry, Logger); pbook.AddDownloadDecryptBook(); pbook.AddDownloadPdf(); procs.Add(pbook); @@ -123,13 +123,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels public void AddConvertMp3(IEnumerable entries) { - List procs = new(); + List procs = new(); foreach (var entry in entries) { if (isBookInQueue(entry)) continue; - ProcessBook2 pbook = new(entry, Logger); + ProcessBookViewModel pbook = new(entry, Logger); pbook.AddConvertToMp3(); procs.Add(pbook); } @@ -138,7 +138,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels AddToQueue(procs); } - public void AddToQueue(IEnumerable pbook) + public void AddToQueue(IEnumerable pbook) { Dispatcher.UIThread.Post(() => { diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs index 8adbe2e1..d27209d5 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs @@ -25,9 +25,9 @@ namespace LibationWinForms.AvaloniaUI.ViewModels private DataGridColumn _currentSortColumn; private DataGrid productsDataGrid; - private GridEntryBindingList2 _gridEntries; + private GridEntryCollection _gridEntries; private bool _removeColumnVisivle; - public GridEntryBindingList2 GridEntries { get => _gridEntries; private set => this.RaiseAndSetIfChanged(ref _gridEntries, value); } + public GridEntryCollection GridEntries { get => _gridEntries; private set => this.RaiseAndSetIfChanged(ref _gridEntries, value); } public bool RemoveColumnVisivle { get => _removeColumnVisivle; private set => this.RaiseAndSetIfChanged(ref _removeColumnVisivle, value); } public List GetVisibleBookEntries() @@ -35,14 +35,14 @@ namespace LibationWinForms.AvaloniaUI.ViewModels .BookEntries() .Select(lbe => lbe.LibraryBook) .ToList(); - public IEnumerable GetAllBookEntries() + public IEnumerable GetAllBookEntries() => GridEntries .AllItems() .BookEntries(); public ProductsDisplayViewModel() { } - public ProductsDisplayViewModel(List items) + public ProductsDisplayViewModel(List items) { - GridEntries = new GridEntryBindingList2(items); + GridEntries = new GridEntryCollection(items); } #region Display Functions @@ -50,7 +50,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels /// /// Call once on load so we can modify access a private member with reflection /// - public void RegisterCollectionChanged(ProductsDisplay2 productsDisplay = null) + public void RegisterCollectionChanged(ProductsDisplay productsDisplay = null) { productsDataGrid ??= productsDisplay?.productsGrid; @@ -67,7 +67,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels { if (s != GridEntries) return; - var displayListGE = ((IEnumerable)DataSource_PI.GetValue(DataConnection_PI.GetValue(productsDataGrid))).Cast(); + var displayListGE = ((IEnumerable)DataSource_PI.GetValue(DataConnection_PI.GetValue(productsDataGrid))).Cast(); int index = 0; foreach (var di in displayListGE) { @@ -83,7 +83,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels { try { - GridEntries = new GridEntryBindingList2(CreateGridEntries(dbBooks)); + GridEntries = new GridEntryCollection(CreateGridEntries(dbBooks)); GridEntries.CollapseAll(); int bookEntryCount = GridEntries.BookEntries().Count(); @@ -119,7 +119,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels foreach (var series in existingSeriesEntries) { var sEntry = GridEntries.InternalList.FirstOrDefault(ge => ge.AudibleProductId == series.AudibleProductId); - if (sEntry is SeriesEntrys2 se && !series.Liberate.Expanded) + if (sEntry is SeriesEntry se && !series.Liberate.Expanded) await Dispatcher.UIThread.InvokeAsync(() => GridEntries.CollapseItem(se)); } await Dispatcher.UIThread.InvokeAsync(() => @@ -134,12 +134,12 @@ namespace LibationWinForms.AvaloniaUI.ViewModels } } - private static IEnumerable CreateGridEntries(IEnumerable dbBooks) + private static IEnumerable CreateGridEntries(IEnumerable dbBooks) { var geList = dbBooks .Where(lb => lb.Book.IsProduct()) - .Select(b => new LibraryBookEntry2(b)) - .Cast() + .Select(b => new LibraryBookEntry(b)) + .Cast() .ToList(); var episodes = dbBooks.Where(lb => lb.Book.IsEpisodeChild()); @@ -152,7 +152,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels if (!seriesEpisodes.Any()) continue; - var seriesEntry = new SeriesEntrys2(parent, seriesEpisodes); + var seriesEntry = new SeriesEntry(parent, seriesEpisodes); geList.Add(seriesEntry); geList.AddRange(seriesEntry.Children); @@ -160,7 +160,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels return geList.OrderByDescending(e => e.DateAdded); } - public void ToggleSeriesExpanded(SeriesEntrys2 seriesEntry) + public void ToggleSeriesExpanded(SeriesEntry seriesEntry) { if (seriesEntry.Liberate.Expanded) GridEntries.CollapseItem(seriesEntry); @@ -213,7 +213,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels if (_currentSortColumn is null) { //Sort ascending and reverse. That's how the comparer is designed to work to be compatible with Avalonia. - var defaultComparer = new RowComparer(ListSortDirection.Descending, nameof(GridEntry2.DateAdded)); + var defaultComparer = new RowComparer(ListSortDirection.Descending, nameof(GridEntry.DateAdded)); GridEntries.InternalList.Sort(defaultComparer); GridEntries.InternalList.Reverse(); GridEntries.ResetCollection(); @@ -326,7 +326,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName == nameof(GridEntry2.Remove) && sender is LibraryBookEntry2 lbEntry) + if (e.PropertyName == nameof(GridEntry.Remove) && sender is LibraryBookEntry lbEntry) { int removeCount = GetAllBookEntries().Count(lbe => lbe.Remove is true); RemovableCountChanged?.Invoke(this, removeCount); diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/QueryExtensions.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/QueryExtensions.cs index df401514..073bc91f 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/QueryExtensions.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/QueryExtensions.cs @@ -8,19 +8,19 @@ namespace LibationWinForms.AvaloniaUI.ViewModels #nullable enable internal static class QueryExtensions { - public static IEnumerable BookEntries(this IEnumerable gridEntries) - => gridEntries.OfType(); + public static IEnumerable BookEntries(this IEnumerable gridEntries) + => gridEntries.OfType(); - public static IEnumerable SeriesEntries(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 : GridEntry2 + 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) + public static IEnumerable EmptySeries(this IEnumerable gridEntries) => gridEntries.SeriesEntries().Where(i => i.Children.Count == 0); - public static SeriesEntrys2? FindSeriesParent(this IEnumerable gridEntries, LibraryBook seriesEpisode) + public static SeriesEntry? FindSeriesParent(this IEnumerable gridEntries, LibraryBook seriesEpisode) { if (seriesEpisode.Book.SeriesLink is null) return null; diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/RowComparer.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/RowComparer.cs index 76532a30..2551d04e 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/RowComparer.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/RowComparer.cs @@ -13,7 +13,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels /// sorted by series index, ascending. Stable sorting is achieved by comparing the GridEntry.ListIndex /// properties when 2 items compare equal. /// - internal class RowComparer : IComparer, IComparer + 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); @@ -39,17 +39,17 @@ namespace LibationWinForms.AvaloniaUI.ViewModels if (x is not null && y is null) return 1; if (x is null && y is null) return 0; - var geA = (GridEntry2)x; - var geB = (GridEntry2)y; + var geA = (GridEntry)x; + var geB = (GridEntry)y; SortDirection ??= GetSortOrder(); - SeriesEntrys2 parentA = null; - SeriesEntrys2 parentB = null; + SeriesEntry parentA = null; + SeriesEntry parentB = null; - if (geA is LibraryBookEntry2 lbA && lbA.Parent is SeriesEntrys2 seA) + if (geA is LibraryBookEntry lbA && lbA.Parent is SeriesEntry seA) parentA = seA; - if (geB is LibraryBookEntry2 lbB && lbB.Parent is SeriesEntrys2 seB) + if (geB is LibraryBookEntry lbB && lbB.Parent is SeriesEntry seB) parentB = seB; //both a and b are top-level grid entries @@ -88,7 +88,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels private ListSortDirection? GetSortOrder() => CurrentSortingStatePi.GetValue(HeaderCellPi.GetValue(Column)) as ListSortDirection?; - private int InternalCompare(GridEntry2 x, GridEntry2 y) + private int InternalCompare(GridEntry x, GridEntry y) { var val1 = x.GetMemberValue(PropertyName); var val2 = y.GetMemberValue(PropertyName); @@ -103,7 +103,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels return compareResult; } - public int Compare(GridEntry2 x, GridEntry2 y) + public int Compare(GridEntry x, GridEntry y) { return Compare((object)x, y); } diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/SeriesEntrys2.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/SeriesEntry.cs similarity index 89% rename from Source/LibationWinForms/AvaloniaUI/ViewModels/SeriesEntrys2.cs rename to Source/LibationWinForms/AvaloniaUI/ViewModels/SeriesEntry.cs index 886131e8..c2ec3177 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/SeriesEntrys2.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/SeriesEntry.cs @@ -10,9 +10,9 @@ using System.Linq; namespace LibationWinForms.AvaloniaUI.ViewModels { /// The View Model for a LibraryBook that is ContentType.Parent - public class SeriesEntrys2 : GridEntry2 + public class SeriesEntry : GridEntry { - [Browsable(false)] public List Children { get; } + [Browsable(false)] public List Children { get; } [Browsable(false)] public override DateTime DateAdded => Children.Max(c => c.DateAdded); private bool suspendCounting = false; @@ -44,7 +44,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels } } - public override LiberateButtonStatus2 Liberate { get; } + public override LiberateButtonStatus Liberate { get; } public override BookTags BookTags { get; } = new(); public override bool IsSeries => true; @@ -53,16 +53,16 @@ namespace LibationWinForms.AvaloniaUI.ViewModels #endregion - public SeriesEntrys2(LibraryBook parent, IEnumerable children) + public SeriesEntry(LibraryBook parent, IEnumerable children) { - Liberate = new LiberateButtonStatus2(IsSeries) { Expanded = true }; + Liberate = new LiberateButtonStatus(IsSeries) { Expanded = true }; SeriesIndex = -1; LibraryBook = parent; LoadCover(); Children = children - .Select(c => new LibraryBookEntry2(c) { Parent = this }) + .Select(c => new LibraryBookEntry(c) { Parent = this }) .OrderBy(c => c.SeriesIndex) .ToList(); diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/TrackedQueue2[T].cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/TrackedQueue[T].cs similarity index 98% rename from Source/LibationWinForms/AvaloniaUI/ViewModels/TrackedQueue2[T].cs rename to Source/LibationWinForms/AvaloniaUI/ViewModels/TrackedQueue[T].cs index 1f2af103..dd2ff3a7 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/TrackedQueue2[T].cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/TrackedQueue[T].cs @@ -33,7 +33,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels * and is stored in ObservableCollection.Items. When the primary list changes, the * secondary list is cleared and reset to match the primary. */ - public class TrackedQueue2 : ObservableCollection where T : class + public class TrackedQueue : ObservableCollection where T : class { public event EventHandler CompletedCountChanged; public event EventHandler QueuededCountChanged; diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml.cs index dd550259..af7becd4 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/EditQuickFilters.axaml.cs @@ -19,8 +19,8 @@ namespace LibationWinForms.AvaloniaUI.Views.Dialogs get => _filterString; set { + IsDefault = string.IsNullOrEmpty(value); this.RaiseAndSetIfChanged(ref _filterString, value); - IsDefault = string.IsNullOrEmpty(_filterString); this.RaisePropertyChanged(nameof(IsDefault)); } } @@ -54,7 +54,9 @@ namespace LibationWinForms.AvaloniaUI.Views.Dialogs { if (Filters.Any(f => f.IsDefault)) return; - Filters.Insert(Filters.Count, new Filter()); + var newBlank = new Filter(); + newBlank.PropertyChanged += Filter_PropertyChanged; + Filters.Insert(Filters.Count, newBlank); } protected override void SaveAndClose() diff --git a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.axaml b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.axaml index 478bd120..ed5f4aae 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.axaml +++ b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.axaml @@ -167,11 +167,11 @@ - + - (nameof(quickFiltersToolStripMenuItem)); - productsDisplay = this.FindControl(nameof(productsDisplay)); + productsDisplay = this.FindControl(nameof(productsDisplay)); } protected override void OnDataContextChanged(EventArgs e) diff --git a/Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl2.axaml b/Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl.axaml similarity index 98% rename from Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl2.axaml rename to Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl.axaml index 7b345880..4e4b63ce 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl2.axaml +++ b/Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl.axaml @@ -3,7 +3,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="90" MaxHeight="90" MinHeight="90" MinWidth="300" - x:Class="LibationWinForms.AvaloniaUI.Views.ProcessBookControl2" Background="{Binding BackgroundColor}"> + x:Class="LibationWinForms.AvaloniaUI.Views.ProcessBookControl" Background="{Binding BackgroundColor}"> diff --git a/Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl2.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl.axaml.cs similarity index 80% rename from Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl2.axaml.cs rename to Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl.axaml.cs index 412f794a..01376344 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl2.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/ProcessBookControl.axaml.cs @@ -8,20 +8,20 @@ using DataLayer; namespace LibationWinForms.AvaloniaUI.Views { - public delegate void QueueItemPositionButtonClicked(ProcessBook2 item, QueuePosition queueButton); - public delegate void QueueItemCancelButtonClicked(ProcessBook2 item); - public partial class ProcessBookControl2 : UserControl + public delegate void QueueItemPositionButtonClicked(ProcessBookViewModel item, QueuePosition queueButton); + public delegate void QueueItemCancelButtonClicked(ProcessBookViewModel item); + public partial class ProcessBookControl : UserControl { public static event QueueItemPositionButtonClicked PositionButtonClicked; public static event QueueItemCancelButtonClicked CancelButtonClicked; - public ProcessBookControl2() + public ProcessBookControl() { InitializeComponent(); if (Design.IsDesignMode) { using var context = DbContexts.GetContext(); - DataContext = new ProcessBook2( + DataContext = new ProcessBookViewModel( context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"), ProcessQueue.LogMe.RegisterForm(default(ProcessQueue.ILogForm)) ); @@ -29,7 +29,7 @@ namespace LibationWinForms.AvaloniaUI.Views } } - private ProcessBook2 DataItem => DataContext is null ? null : DataContext as ProcessBook2; + private ProcessBookViewModel DataItem => DataContext is null ? null : DataContext as ProcessBookViewModel; public void Cancel_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) => CancelButtonClicked?.Invoke(DataItem); diff --git a/Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl2.axaml b/Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl.axaml similarity index 98% rename from Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl2.axaml rename to Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl.axaml index e3cd8f8b..d57b3002 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl2.axaml +++ b/Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl.axaml @@ -6,12 +6,12 @@ xmlns:views="clr-namespace:LibationWinForms.AvaloniaUI.Views" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" mc:Ignorable="d" d:DesignWidth="450" d:DesignHeight="850" - x:Class="LibationWinForms.AvaloniaUI.Views.ProcessQueueControl2"> + x:Class="LibationWinForms.AvaloniaUI.Views.ProcessQueueControl"> - + diff --git a/Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl2.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl.axaml.cs similarity index 72% rename from Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl2.axaml.cs rename to Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl.axaml.cs index 85dad037..0df50ef4 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl2.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/ProcessQueueControl.axaml.cs @@ -10,17 +10,17 @@ using System.Linq; namespace LibationWinForms.AvaloniaUI.Views { - public partial class ProcessQueueControl2 : UserControl + public partial class ProcessQueueControl : UserControl { - private TrackedQueue2 Queue => _viewModel.Items; + private TrackedQueue Queue => _viewModel.Items; private ProcessQueueViewModel _viewModel => DataContext as ProcessQueueViewModel; - public ProcessQueueControl2() + public ProcessQueueControl() { InitializeComponent(); - ProcessBookControl2.PositionButtonClicked += ProcessBookControl2_ButtonClicked; - ProcessBookControl2.CancelButtonClicked += ProcessBookControl2_CancelButtonClicked; + ProcessBookControl.PositionButtonClicked += ProcessBookControl2_ButtonClicked; + ProcessBookControl.CancelButtonClicked += ProcessBookControl2_CancelButtonClicked; #region Design Mode Testing if (Design.IsDesignMode) @@ -29,44 +29,44 @@ namespace LibationWinForms.AvaloniaUI.Views var Logger = ProcessQueue.LogMe.RegisterForm(vm); DataContext = vm; using var context = DbContexts.GetContext(); - List testList = new() + List testList = new() { - new ProcessBook2(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"), Logger) + new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"), Logger) { Result = ProcessBookResult.FailedAbort, Status = ProcessBookStatus.Failed, }, - new ProcessBook2(context.GetLibraryBook_Flat_NoTracking("B017V4IWVG"), Logger) + new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4IWVG"), Logger) { Result = ProcessBookResult.FailedSkip, Status = ProcessBookStatus.Failed, }, - new ProcessBook2(context.GetLibraryBook_Flat_NoTracking("B017V4JA2Q"), Logger) + new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4JA2Q"), Logger) { Result = ProcessBookResult.FailedRetry, Status = ProcessBookStatus.Failed, }, - new ProcessBook2(context.GetLibraryBook_Flat_NoTracking("B017V4NUPO"), Logger) + new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4NUPO"), Logger) { Result = ProcessBookResult.ValidationFail, Status = ProcessBookStatus.Failed, }, - new ProcessBook2(context.GetLibraryBook_Flat_NoTracking("B017V4NMX4"), Logger) + new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4NMX4"), Logger) { Result = ProcessBookResult.Cancelled, Status = ProcessBookStatus.Cancelled, }, - new ProcessBook2(context.GetLibraryBook_Flat_NoTracking("B017V4NOZ0"), Logger) + new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4NOZ0"), Logger) { Result = ProcessBookResult.Success, Status = ProcessBookStatus.Completed, }, - new ProcessBook2(context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6"), Logger) + new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6"), Logger) { Result = ProcessBookResult.None, Status = ProcessBookStatus.Working, }, - new ProcessBook2(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"), Logger) + new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"), Logger) { Result = ProcessBookResult.None, Status = ProcessBookStatus.Queued, @@ -93,14 +93,14 @@ namespace LibationWinForms.AvaloniaUI.Views #region Control event handlers - private async void ProcessBookControl2_CancelButtonClicked(ProcessBook2 item) + private async void ProcessBookControl2_CancelButtonClicked(ProcessBookViewModel item) { if (item is not null) await item.CancelAsync(); Queue.RemoveQueued(item); } - private void ProcessBookControl2_ButtonClicked(ProcessBook2 item, QueuePosition queueButton) + private void ProcessBookControl2_ButtonClicked(ProcessBookViewModel item, QueuePosition queueButton) { Queue.MoveQueuePosition(item, queueButton); } diff --git a/Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay2.axaml b/Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay.axaml similarity index 99% rename from Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay2.axaml rename to Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay.axaml index 5af042a3..99f2dd8f 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay2.axaml +++ b/Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay.axaml @@ -5,7 +5,7 @@ xmlns:views="clr-namespace:LibationWinForms.AvaloniaUI.Views" xmlns:controls="clr-namespace:LibationWinForms.AvaloniaUI.Controls" mc:Ignorable="d" d:DesignWidth="1560" d:DesignHeight="400" - x:Class="LibationWinForms.AvaloniaUI.Views.ProductsDisplay2"> + x:Class="LibationWinForms.AvaloniaUI.Views.ProductsDisplay"> diff --git a/Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay2.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay.axaml.cs similarity index 89% rename from Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay2.axaml.cs rename to Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay.axaml.cs index 39cc0b06..33426bd3 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay2.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/ProductsDisplay.axaml.cs @@ -13,29 +13,29 @@ using System.Linq; namespace LibationWinForms.AvaloniaUI.Views { - public partial class ProductsDisplay2 : UserControl + public partial class ProductsDisplay : UserControl { public event EventHandler LiberateClicked; private ProductsDisplayViewModel _viewModel => DataContext as ProductsDisplayViewModel; ImageDisplayDialog imageDisplayDialog; - public ProductsDisplay2() + public ProductsDisplay() { InitializeComponent(); if (Design.IsDesignMode) { using var context = DbContexts.GetContext(); - List sampleEntries = new() + List sampleEntries = new() { - new LibraryBookEntry2(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G")), - new LibraryBookEntry2(context.GetLibraryBook_Flat_NoTracking("B017V4IWVG")), - new LibraryBookEntry2(context.GetLibraryBook_Flat_NoTracking("B017V4JA2Q")), - new LibraryBookEntry2(context.GetLibraryBook_Flat_NoTracking("B017V4NUPO")), - new LibraryBookEntry2(context.GetLibraryBook_Flat_NoTracking("B017V4NMX4")), - new LibraryBookEntry2(context.GetLibraryBook_Flat_NoTracking("B017V4NOZ0")), - new LibraryBookEntry2(context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6")), + new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G")), + new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4IWVG")), + new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4JA2Q")), + new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4NUPO")), + new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4NMX4")), + new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017V4NOZ0")), + new LibraryBookEntry(context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6")), }; DataContext = new ProductsDisplayViewModel(sampleEntries); return; @@ -101,7 +101,7 @@ namespace LibationWinForms.AvaloniaUI.Views { var itemName = column.SortMemberPath; - if (itemName == nameof(GridEntry2.Remove)) + if (itemName == nameof(GridEntry.Remove)) continue; menuItems.Add @@ -192,7 +192,7 @@ namespace LibationWinForms.AvaloniaUI.Views { var button = args.Source as Button; - if (button.DataContext is SeriesEntrys2 sEntry) + if (button.DataContext is SeriesEntry sEntry) { _viewModel.ToggleSeriesExpanded(sEntry); @@ -200,7 +200,7 @@ namespace LibationWinForms.AvaloniaUI.Views //to the topright cell. Reset focus onto the clicked button's cell. ((sender as Control).Parent.Parent as DataGridCell)?.Focus(); } - else if (button.DataContext is LibraryBookEntry2 lbEntry) + else if (button.DataContext is LibraryBookEntry lbEntry) { LiberateClicked?.Invoke(this, lbEntry.LibraryBook); } @@ -214,7 +214,7 @@ namespace LibationWinForms.AvaloniaUI.Views public void Cover_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args) { - if (sender is not Image tblock || tblock.DataContext is not GridEntry2 gEntry) + if (sender is not Image tblock || tblock.DataContext is not GridEntry gEntry) return; @@ -254,7 +254,7 @@ namespace LibationWinForms.AvaloniaUI.Views public void Description_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args) { - if (sender is TextBlock tblock && tblock.DataContext is GridEntry2 gEntry) + if (sender is TextBlock tblock && tblock.DataContext is GridEntry gEntry) { var pt = tblock.Parent.PointToScreen(tblock.Parent.Bounds.TopRight); var displayWindow = new DescriptionDisplayDialog @@ -283,7 +283,7 @@ namespace LibationWinForms.AvaloniaUI.Views { var button = args.Source as Button; - if (button.DataContext is LibraryBookEntry2 lbEntry && VisualRoot is Window window) + if (button.DataContext is LibraryBookEntry lbEntry && VisualRoot is Window window) { if (bookDetailsForm is null || !bookDetailsForm.IsVisible) { diff --git a/Source/LibationWinForms/LibationWinForms.csproj b/Source/LibationWinForms/LibationWinForms.csproj index 81ecbe2b..ed1695b9 100644 --- a/Source/LibationWinForms/LibationWinForms.csproj +++ b/Source/LibationWinForms/LibationWinForms.csproj @@ -124,6 +124,15 @@ ImageDisplayDialog.axaml + + ProcessBookControl.axaml + + + ProcessQueueControl.axaml + + + ProductsDisplay.axaml + True True