From 62e53a29d4ba738a3766123322e88131289127cf Mon Sep 17 00:00:00 2001 From: Brian Bicknell Date: Tue, 28 Jul 2026 00:20:41 -0400 Subject: [PATCH] Added playlists view. Added messaging service. Added logic for adding and deleting playlists. --- Harmonia.WinUI/App.xaml.cs | 3 + Harmonia.WinUI/Harmonia.WinUI.csproj | 6 + Harmonia.WinUI/MainWindow.xaml | 4 +- Harmonia.WinUI/Messaging/IMessageService.cs | 8 ++ .../Messaging/WindowsMessageService.cs | 30 ++++ Harmonia.WinUI/Resources/Geometry.xaml | 6 + Harmonia.WinUI/Resources/Styles.xaml | 133 ++++++++++++++++++ .../ViewModels/PlaylistDetailViewModel.cs | 44 +++++- .../ViewModels/PlaylistsViewModel.cs | 65 +++++++++ Harmonia.WinUI/ViewModels/ViewModelLocator.cs | 3 + Harmonia.WinUI/Views/PlaylistDetailView.xaml | 13 +- Harmonia.WinUI/Views/PlaylistsView.xaml | 31 ++++ Harmonia.WinUI/Views/PlaylistsView.xaml.cs | 12 ++ 13 files changed, 353 insertions(+), 5 deletions(-) create mode 100644 Harmonia.WinUI/Messaging/IMessageService.cs create mode 100644 Harmonia.WinUI/Messaging/WindowsMessageService.cs create mode 100644 Harmonia.WinUI/ViewModels/PlaylistsViewModel.cs create mode 100644 Harmonia.WinUI/Views/PlaylistsView.xaml create mode 100644 Harmonia.WinUI/Views/PlaylistsView.xaml.cs diff --git a/Harmonia.WinUI/App.xaml.cs b/Harmonia.WinUI/App.xaml.cs index 66ba4f6..1e06b5e 100644 --- a/Harmonia.WinUI/App.xaml.cs +++ b/Harmonia.WinUI/App.xaml.cs @@ -1,5 +1,6 @@ using Harmonia.Core.Extensions; using Harmonia.WinUI.Caching; +using Harmonia.WinUI.Messaging; using Harmonia.WinUI.Storage; using Harmonia.WinUI.ViewModels; using Microsoft.Extensions.DependencyInjection; @@ -23,10 +24,12 @@ public partial class App : Application //services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddHarmonia(); diff --git a/Harmonia.WinUI/Harmonia.WinUI.csproj b/Harmonia.WinUI/Harmonia.WinUI.csproj index 13cddf0..636d881 100644 --- a/Harmonia.WinUI/Harmonia.WinUI.csproj +++ b/Harmonia.WinUI/Harmonia.WinUI.csproj @@ -17,6 +17,7 @@ + @@ -55,6 +56,11 @@ PreserveNewest + + + MSBuild:Compile + + Designer diff --git a/Harmonia.WinUI/MainWindow.xaml b/Harmonia.WinUI/MainWindow.xaml index fe41142..e346843 100644 --- a/Harmonia.WinUI/MainWindow.xaml +++ b/Harmonia.WinUI/MainWindow.xaml @@ -46,9 +46,11 @@ + - + + diff --git a/Harmonia.WinUI/Messaging/IMessageService.cs b/Harmonia.WinUI/Messaging/IMessageService.cs new file mode 100644 index 0000000..1e42148 --- /dev/null +++ b/Harmonia.WinUI/Messaging/IMessageService.cs @@ -0,0 +1,8 @@ +using System.Threading.Tasks; + +namespace Harmonia.WinUI.Messaging; + +public interface IMessageService +{ + Task ConfirmAsync(string title, string message); +} \ No newline at end of file diff --git a/Harmonia.WinUI/Messaging/WindowsMessageService.cs b/Harmonia.WinUI/Messaging/WindowsMessageService.cs new file mode 100644 index 0000000..4cd86f5 --- /dev/null +++ b/Harmonia.WinUI/Messaging/WindowsMessageService.cs @@ -0,0 +1,30 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using System; +using System.Threading.Tasks; + +namespace Harmonia.WinUI.Messaging; + +public class WindowsMessageService : IMessageService +{ + private static MainWindow MainWindow => App.ServiceProvider.GetRequiredService(); + + public async Task ConfirmAsync(string title, string message) + { + ContentDialog dialog = new() + { + XamlRoot = MainWindow.Content.XamlRoot, + Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style, + Title = title, + Content = message, + PrimaryButtonText = "Yes", + CloseButtonText = "No", + DefaultButton = ContentDialogButton.Primary + }; + + var result = await dialog.ShowAsync(); + + return result == ContentDialogResult.Primary; + } +} \ No newline at end of file diff --git a/Harmonia.WinUI/Resources/Geometry.xaml b/Harmonia.WinUI/Resources/Geometry.xaml index b440101..bc8b164 100644 --- a/Harmonia.WinUI/Resources/Geometry.xaml +++ b/Harmonia.WinUI/Resources/Geometry.xaml @@ -141,5 +141,11 @@ M3 9.5a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3 + + M12 13c0 1.105-1.12 2-2.5 2S7 14.105 7 13s1.12-2 2.5-2 2.5.895 2.5 2 + M12 3v10h-1V3z + M11 2.82a1 1 0 0 1 .804-.98l3-.6A1 1 0 0 1 16 2.22V4l-5 1z + M0 11.5a.5.5 0 0 1 .5-.5H4a.5.5 0 0 1 0 1H.5a.5.5 0 0 1-.5-.5m0-4A.5.5 0 0 1 .5 7H8a.5.5 0 0 1 0 1H.5a.5.5 0 0 1-.5-.5m0-4A.5.5 0 0 1 .5 3H8a.5.5 0 0 1 0 1H.5a.5.5 0 0 1-.5-.5 + diff --git a/Harmonia.WinUI/Resources/Styles.xaml b/Harmonia.WinUI/Resources/Styles.xaml index 58152f6..b4c6c70 100644 --- a/Harmonia.WinUI/Resources/Styles.xaml +++ b/Harmonia.WinUI/Resources/Styles.xaml @@ -20,6 +20,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -167,7 +172,7 @@ - + @@ -177,6 +182,12 @@ + + + + + + + + + + + + + + + + + diff --git a/Harmonia.WinUI/Views/PlaylistsView.xaml.cs b/Harmonia.WinUI/Views/PlaylistsView.xaml.cs new file mode 100644 index 0000000..fc8f6f9 --- /dev/null +++ b/Harmonia.WinUI/Views/PlaylistsView.xaml.cs @@ -0,0 +1,12 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Harmonia.WinUI.Views; + +public sealed partial class PlaylistsView : UserControl +{ + public PlaylistsView() + { + InitializeComponent(); + } +} \ No newline at end of file