From 295918eba26070af8f139665831f28eab319a3d5 Mon Sep 17 00:00:00 2001 From: Chris Bordeman Date: Thu, 17 Oct 2024 18:11:48 -0400 Subject: [PATCH 1/7] Minor cosmetics. --- .../LibationAvalonia/Views/MainWindow.axaml | 2 +- .../Views/ProductsDisplay.axaml | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Source/LibationAvalonia/Views/MainWindow.axaml b/Source/LibationAvalonia/Views/MainWindow.axaml index 49f01599..7d1d78fe 100644 --- a/Source/LibationAvalonia/Views/MainWindow.axaml +++ b/Source/LibationAvalonia/Views/MainWindow.axaml @@ -206,7 +206,7 @@ - + diff --git a/Source/LibationAvalonia/Views/ProductsDisplay.axaml b/Source/LibationAvalonia/Views/ProductsDisplay.axaml index fd90a1c1..ba95e335 100644 --- a/Source/LibationAvalonia/Views/ProductsDisplay.axaml +++ b/Source/LibationAvalonia/Views/ProductsDisplay.axaml @@ -5,8 +5,10 @@ xmlns:views="clr-namespace:LibationAvalonia.Views" xmlns:uibase="clr-namespace:LibationUiBase.GridView;assembly=LibationUiBase" xmlns:controls="clr-namespace:LibationAvalonia.Controls" - mc:Ignorable="d" d:DesignWidth="1560" d:DesignHeight="400" - x:Class="LibationAvalonia.Views.ProductsDisplay"> + xmlns:viewModels="clr-namespace:LibationAvalonia.ViewModels" + mc:Ignorable="d" d:DesignWidth="1560" d:DesignHeight="400" + x:Class="LibationAvalonia.Views.ProductsDisplay" + x:DataType="viewModels:ProductsDisplayViewModel"> @@ -16,7 +18,7 @@ GridLinesVisibility="All" AutoGenerateColumns="False" ItemsSource="{Binding GridEntries}" - CanUserSortColumns="True" BorderThickness="3" + CanUserSortColumns="True" BorderThickness="0" CanUserResizeColumns="True" CanUserReorderColumns="True"> @@ -24,6 +26,9 @@ + - + + @@ -67,7 +75,8 @@ - + Date: Sun, 20 Oct 2024 03:56:54 -0400 Subject: [PATCH 2/7] Before refactoring QueueProcessingControl / QueueProcessingViewModel --- Source/Libation.sln.startup.json | 24 + .../LibationAvalonia/LibationAvalonia.csproj | 4 + Source/LibationAvalonia/ViewModels/MainVM.cs | 2 + .../ViewModels/Player/PlayerViewModel.cs | 16 + .../Player/PlaylistEntryViewModel.cs | 27 + .../LibationAvalonia/Views/MainWindow.axaml | 657 ++++++---- .../Views/ProcessQueueControl.axaml | 430 +++--- .../Views/ProcessQueueControl.axaml.cs | 4 +- .../Views/ProductsDisplay.axaml | 35 +- .../Views/ProductsDisplay.axaml.cs | 1160 +++++++++-------- .../GridView/GridEntry[TStatus].cs | 4 +- Source/LibationUiBase/GridView/IGridEntry.cs | 8 +- .../GridView/LibraryBookEntry[TStatus].cs | 4 +- .../GridView/SeriesEntry[TStatus].cs | 12 +- .../GridView/ProductsGrid.Designer.cs | 596 +++++---- .../LibationWinForms/GridView/ProductsGrid.cs | 1035 +++++++-------- .../GridView/ProductsGrid.resx | 9 +- .../LibationWinForms/LibationWinForms.csproj | 1 + Source/SystemInformation.cs | 9 + 19 files changed, 2262 insertions(+), 1775 deletions(-) create mode 100644 Source/Libation.sln.startup.json create mode 100644 Source/LibationAvalonia/ViewModels/Player/PlayerViewModel.cs create mode 100644 Source/LibationAvalonia/ViewModels/Player/PlaylistEntryViewModel.cs create mode 100644 Source/SystemInformation.cs diff --git a/Source/Libation.sln.startup.json b/Source/Libation.sln.startup.json new file mode 100644 index 00000000..e4def5e0 --- /dev/null +++ b/Source/Libation.sln.startup.json @@ -0,0 +1,24 @@ +/* + This is a configuration file for the SwitchStartupProject Visual Studio Extension + See https://github.com/ernstc/SwitchStartupProject2022/blob/main/Configuration.md +*/ +{ + /* Configuration File Version */ + "Version": 3, + + /* Create an item in the dropdown list for each project in the solution? */ + "ListAllProjects": false, + + "MultiProjectConfigurations": { + "WinForms": { + "Projects": { + "LibationWinForms": {} + } + }, + "Avalonia": { + "Projects": { + "LibationAvalonia": {} + } + } + } +} diff --git a/Source/LibationAvalonia/LibationAvalonia.csproj b/Source/LibationAvalonia/LibationAvalonia.csproj index 91c8de6f..690e7305 100644 --- a/Source/LibationAvalonia/LibationAvalonia.csproj +++ b/Source/LibationAvalonia/LibationAvalonia.csproj @@ -87,6 +87,10 @@ + + + + diff --git a/Source/LibationAvalonia/ViewModels/MainVM.cs b/Source/LibationAvalonia/ViewModels/MainVM.cs index 86c69d9d..65dacfb3 100644 --- a/Source/LibationAvalonia/ViewModels/MainVM.cs +++ b/Source/LibationAvalonia/ViewModels/MainVM.cs @@ -1,4 +1,5 @@ using ApplicationServices; +using LibationAvalonia.ViewModels.Player; using LibationAvalonia.Views; using LibationFileManager; using ReactiveUI; @@ -7,6 +8,7 @@ namespace LibationAvalonia.ViewModels { public partial class MainVM : ViewModelBase { + public PlayerViewModel PlayerViewModel { get; set; } public ProcessQueueViewModel ProcessQueue { get; } = new ProcessQueueViewModel(); public ProductsDisplayViewModel ProductsDisplay { get; } = new ProductsDisplayViewModel(); diff --git a/Source/LibationAvalonia/ViewModels/Player/PlayerViewModel.cs b/Source/LibationAvalonia/ViewModels/Player/PlayerViewModel.cs new file mode 100644 index 00000000..cc170f73 --- /dev/null +++ b/Source/LibationAvalonia/ViewModels/Player/PlayerViewModel.cs @@ -0,0 +1,16 @@ +using ReactiveUI; +using System.Collections.ObjectModel; + +namespace LibationAvalonia.ViewModels.Player; + +public class PlayerViewModel : ViewModelBase +{ + private ObservableCollection items = new(); + public ObservableCollection Items + { + get => items; + set => this.RaiseAndSetIfChanged(ref items, value); + } + + +} \ No newline at end of file diff --git a/Source/LibationAvalonia/ViewModels/Player/PlaylistEntryViewModel.cs b/Source/LibationAvalonia/ViewModels/Player/PlaylistEntryViewModel.cs new file mode 100644 index 00000000..e989090a --- /dev/null +++ b/Source/LibationAvalonia/ViewModels/Player/PlaylistEntryViewModel.cs @@ -0,0 +1,27 @@ +using ReactiveUI; + +namespace LibationAvalonia.ViewModels.Player; + +public class PlaylistEntryViewModel : ViewModelBase +{ + private int sequence; + public int Sequence + { + get => sequence; + set => this.RaiseAndSetIfChanged(ref sequence, value); + } + + private string seriesName = string.Empty; + public string SeriesName + { + get => seriesName; + set => this.RaiseAndSetIfChanged(ref seriesName, value); + } + + private string title = string.Empty; + public string Title + { + get => title; + set => this.RaiseAndSetIfChanged(ref title, value); + } +} \ No newline at end of file diff --git a/Source/LibationAvalonia/Views/MainWindow.axaml b/Source/LibationAvalonia/Views/MainWindow.axaml index 7d1d78fe..bcca6afe 100644 --- a/Source/LibationAvalonia/Views/MainWindow.axaml +++ b/Source/LibationAvalonia/Views/MainWindow.axaml @@ -1,242 +1,417 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/LibationAvalonia/Views/ProcessQueueControl.axaml b/Source/LibationAvalonia/Views/ProcessQueueControl.axaml index 03323d4e..8974fde2 100644 --- a/Source/LibationAvalonia/Views/ProcessQueueControl.axaml +++ b/Source/LibationAvalonia/Views/ProcessQueueControl.axaml @@ -1,151 +1,287 @@ - + + x:Class="LibationAvalonia.Views.ProcessQueueControl" + xmlns="https://github.com/avaloniaui" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:viewModels="clr-namespace:LibationAvalonia.ViewModels" + xmlns:views="clr-namespace:LibationAvalonia.Views" + d:DesignHeight="850" + d:DesignWidth="400" + mc:Ignorable="d"> - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - Process Queue - - - - - - - - - - - - - - - - - - - - - - - - Queue Log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Process Queue + + + + + + + + + + + + + + + + + + + + + + + + Queue Log + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Playlist + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/LibationAvalonia/Views/ProcessQueueControl.axaml.cs b/Source/LibationAvalonia/Views/ProcessQueueControl.axaml.cs index 0b7761d8..a3086b2b 100644 --- a/Source/LibationAvalonia/Views/ProcessQueueControl.axaml.cs +++ b/Source/LibationAvalonia/Views/ProcessQueueControl.axaml.cs @@ -4,6 +4,7 @@ using Avalonia.Data.Converters; using DataLayer; using LibationAvalonia.ViewModels; +using LibationAvalonia.ViewModels.Player; using LibationUiBase; using System; using System.Collections.Generic; @@ -14,7 +15,8 @@ namespace LibationAvalonia.Views { public partial class ProcessQueueControl : UserControl { - private TrackedQueue Queue => _viewModel.Queue; + public PlayerViewModel PlayerViewModel { get; } = new(); + private TrackedQueue Queue => _viewModel.Queue; private ProcessQueueViewModel _viewModel => DataContext as ProcessQueueViewModel; public ProcessQueueControl() diff --git a/Source/LibationAvalonia/Views/ProductsDisplay.axaml b/Source/LibationAvalonia/Views/ProductsDisplay.axaml index ba95e335..9c064a8e 100644 --- a/Source/LibationAvalonia/Views/ProductsDisplay.axaml +++ b/Source/LibationAvalonia/Views/ProductsDisplay.axaml @@ -26,9 +26,9 @@ - + - - - + + + - + - + + + + + - - - + + + + + - - - + + + diff --git a/Source/LibationAvalonia/Views/ProductsDisplay.axaml.cs b/Source/LibationAvalonia/Views/ProductsDisplay.axaml.cs index c615c683..d2d0bc3b 100644 --- a/Source/LibationAvalonia/Views/ProductsDisplay.axaml.cs +++ b/Source/LibationAvalonia/Views/ProductsDisplay.axaml.cs @@ -16,6 +16,11 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using AppScaffolding; +using LibationUiBase; +using System.Diagnostics; +using Dinah.Core.Logging; +using LibationUiBase.ViewModels.Player; namespace LibationAvalonia.Views { @@ -25,6 +30,7 @@ public partial class ProductsDisplay : UserControl public event EventHandler LiberateSeriesClicked; public event EventHandler ConvertToMp3Clicked; + private PlayerViewModel _playerViewModel = ServiceLocator.Get(); private ProductsDisplayViewModel _viewModel => DataContext as ProductsDisplayViewModel; ImageDisplayDialog imageDisplayDialog; @@ -590,24 +596,19 @@ public void OnTagsButtonClick(object sender, Avalonia.Interactivity.RoutedEventA } } - private void AddToPlaylistButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e) + private async void AddToPlaylistButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e) { - IGridEntry gridEntry = (IGridEntry)((Button)sender).DataContext; + var gridEntry = (IGridEntry)((Button)sender).DataContext; if (gridEntry is ISeriesEntry se) { - foreach (var child in se.Children) - { - AddToPlaylist(child); - } + foreach (ILibraryBookEntry child in se.Children) + await _playerViewModel.AddToPlaylist(child); } + else if (gridEntry is ILibraryBookEntry book) + await _playerViewModel.AddToPlaylist(book); else - AddToPlaylist(gridEntry as ILibraryBookEntry); + Serilog.Log.Logger.TryLogError($"Cannot add item type {gridEntry.GetType().Name} to playlist"); } #endregion - - private void AddToPlaylist(ILibraryBookEntry book) - { - // TODO: Implement - } } } diff --git a/Source/LibationAvalonia/Views/ProcessQueueControl.axaml b/Source/LibationAvalonia/Views/SidebarControl.axaml similarity index 94% rename from Source/LibationAvalonia/Views/ProcessQueueControl.axaml rename to Source/LibationAvalonia/Views/SidebarControl.axaml index 8974fde2..37fd52ea 100644 --- a/Source/LibationAvalonia/Views/ProcessQueueControl.axaml +++ b/Source/LibationAvalonia/Views/SidebarControl.axaml @@ -1,6 +1,6 @@ - + mc:Ignorable="d" + x:DataType="viewModels:SidebarViewModel"> + @@ -37,7 +38,8 @@ Process Queue - + + Value="{CompiledBinding SpeedLimit, Mode=TwoWay}" />