diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest b/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
index 0b8d0ab..0054877 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
@@ -12,7 +12,7 @@
+ Version="1.0.95.0" />
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml
index 2f4c05d..e66994f 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml
@@ -13,8 +13,8 @@
-
+
@@ -66,10 +66,13 @@
+
+
+
4
@@ -305,8 +308,12 @@
-
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs
index 1b4d7fb..c24b383 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs
@@ -9,6 +9,7 @@ using BetterLyrics.WinUI3.Services.LibWatcherService;
using BetterLyrics.WinUI3.Services.LiveStatesService;
using BetterLyrics.WinUI3.Services.LyricsSearchService;
using BetterLyrics.WinUI3.Services.MediaSessionsService;
+using BetterLyrics.WinUI3.Services.ResourceService;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.Services.TranslateService;
using BetterLyrics.WinUI3.ViewModels;
@@ -22,7 +23,6 @@ using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Windows.ApplicationModel.Resources;
using Serilog;
-using ShadowViewer.Controls;
using System;
using System.Diagnostics;
using System.Linq;
@@ -39,12 +39,6 @@ namespace BetterLyrics.WinUI3
private readonly ILogger _logger;
public static new App Current => (App)Application.Current;
- public static DispatcherQueue? DispatcherQueue { get; private set; }
- public static DispatcherQueueTimer? DispatcherQueueTimer { get; private set; }
- public static ResourceLoader? ResourceLoader { get; private set; }
-
- public NotificationPanel? LyricsWindowNotificationPanel { get; set; }
- public NotificationPanel? SettingsWindowNotificationPanel { get; set; }
private static Mutex? _instanceMutex;
@@ -52,10 +46,6 @@ namespace BetterLyrics.WinUI3
{
this.InitializeComponent();
- DispatcherQueue = DispatcherQueue.GetForCurrentThread();
- DispatcherQueueTimer = DispatcherQueue.CreateTimer();
- ResourceLoader = new ResourceLoader();
-
EnsureSingleInstance();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
@@ -72,12 +62,11 @@ namespace BetterLyrics.WinUI3
private void EnsureSingleInstance()
{
- bool createdNew;
- _instanceMutex = new Mutex(true, Constants.App.AppName, out createdNew);
+ _instanceMutex = new Mutex(true, Constants.App.AppName, out bool createdNew);
if (!createdNew)
{
- User32.MessageBox(HWND.NULL, ResourceLoader!.GetString("TryRunMultipleInstance"), null, User32.MB_FLAGS.MB_APPLMODAL);
+ User32.MessageBox(HWND.NULL, new ResourceLoader().GetString("TryRunMultipleInstance"), null, User32.MB_FLAGS.MB_APPLMODAL);
Environment.Exit(0);
}
}
@@ -111,6 +100,7 @@ namespace BetterLyrics.WinUI3
.AddSingleton()
.AddSingleton()
.AddSingleton()
+ .AddSingleton()
// ViewModels
.AddSingleton()
.AddSingleton()
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj
index c575964..c55bf46 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj
@@ -50,20 +50,16 @@
-
-
-
-
-
+
@@ -74,7 +70,7 @@
-
+
@@ -82,7 +78,6 @@
-
@@ -92,7 +87,7 @@
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtLayoutSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtLayoutSettingsControl.xaml
index 7dd9c2a..4ff2b65 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtLayoutSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtLayoutSettingsControl.xaml
@@ -7,6 +7,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:dev="using:DevWinUI"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">
@@ -17,16 +18,16 @@
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
-
-
-
+
+
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AppSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AppSettingsControl.xaml
index 9ce9dff..9a1be26 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AppSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AppSettingsControl.xaml
@@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dev="using:DevWinUI"
xmlns:globalization="using:Windows.Globalization"
xmlns:helper="using:BetterLyrics.WinUI3.Helper"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
@@ -22,7 +23,7 @@
-
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsBackgroundSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsBackgroundSettingsControl.xaml
index 04b9961..a327732 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsBackgroundSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsBackgroundSettingsControl.xaml
@@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dev="using:DevWinUI"
xmlns:enums="using:BetterLyrics.WinUI3.Enums"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="using:BetterLyrics.WinUI3.Controls"
@@ -18,117 +19,110 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsEffectSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsEffectSettingsControl.xaml
index 67cb5c7..a8e5d51 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsEffectSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsEffectSettingsControl.xaml
@@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dev="using:DevWinUI"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -23,36 +24,34 @@
Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="Effect" />
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
+
@@ -248,8 +240,8 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsSearchControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsSearchControl.xaml
index 84cf21e..514ec99 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsSearchControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsSearchControl.xaml
@@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dev="using:DevWinUI"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -105,16 +106,16 @@
-
+
-
+
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsStyleSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsStyleSettingsControl.xaml
index be61a6d..31e2c23 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsStyleSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsStyleSettingsControl.xaml
@@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dev="using:DevWinUI"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -20,26 +21,26 @@
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
+
@@ -53,37 +54,37 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSettingsControl.xaml
index 11e73ad..fb96c1b 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSettingsControl.xaml
@@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dev="using:DevWinUI"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="using:BetterLyrics.WinUI3.Controls"
@@ -171,7 +172,7 @@
-
+
-
+
-
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
@@ -256,59 +257,59 @@
-
-
-
+
+
+
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
-
-
-
+
+
+
-
+
-
+
@@ -341,25 +342,25 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/MediaSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/MediaSettingsControl.xaml
index 9b8c4d3..7ef65f4 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/MediaSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/MediaSettingsControl.xaml
@@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dev="using:DevWinUI"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -18,7 +19,7 @@
-
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PlaybackSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PlaybackSettingsControl.xaml
index f62b051..4e44904 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PlaybackSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PlaybackSettingsControl.xaml
@@ -6,6 +6,7 @@
xmlns:constants="using:BetterLyrics.WinUI3.Constants"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dev="using:DevWinUI"
xmlns:globalization="using:Windows.Globalization"
xmlns:helper="using:BetterLyrics.WinUI3.Helper"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
@@ -25,19 +26,19 @@
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
+
+
+
@@ -80,12 +81,12 @@
-
-
+
+
-
+
-
+
@@ -112,12 +113,12 @@
-
-
+
+
-
+
-
+
@@ -209,25 +210,25 @@
-
+
-
-
+
+
-
+
-
+
-
-
+
+
@@ -237,19 +238,19 @@
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
@@ -304,25 +305,25 @@
Command="{x:Bind ViewModel.LastFMUnAuthCommand}"
IsEnabled="{x:Bind ViewModel.IsLastFMAuthenticated, Mode=OneWay}" />
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml.cs
index 641e172..7ac40dc 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml.cs
@@ -1,4 +1,6 @@
using BetterLyrics.WinUI3.Helper;
+using BetterLyrics.WinUI3.Services.ResourceService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Input;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
@@ -23,6 +25,8 @@ namespace BetterLyrics.WinUI3.Controls
{
public sealed partial class ShortcutTextBox : UserControl
{
+ private readonly IResourceService _resourceService = Ioc.Default.GetRequiredService();
+
public ShortcutTextBox()
{
InitializeComponent();
@@ -98,15 +102,11 @@ namespace BetterLyrics.WinUI3.Controls
bool registered = GlobalHotKeyHelper.IsHotKeyRegistered(Shortcut);
if (registered)
{
- App.Current.SettingsWindowNotificationPanel?.Notify(
- App.ResourceLoader!.GetString("SettingsPageShortcutRegSuccessInfo"),
- InfoBarSeverity.Success);
+ DevWinUI.Growl.Success(_resourceService.GetLocalizedString("SettingsPageShortcutRegSuccessInfo"));
}
else
{
- App.Current.SettingsWindowNotificationPanel?.Notify(
- App.ResourceLoader!.GetString("SettingsPageShortcutRegFailInfo"),
- InfoBarSeverity.Error);
+ DevWinUI.Growl.Success(_resourceService.GetLocalizedString("SettingsPageShortcutRegFailInfo"));
}
}
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/AlbumArtSearchProviderToDisplayNameConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/AlbumArtSearchProviderToDisplayNameConverter.cs
index dde0a44..fd6c0d2 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/AlbumArtSearchProviderToDisplayNameConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/AlbumArtSearchProviderToDisplayNameConverter.cs
@@ -1,4 +1,6 @@
using BetterLyrics.WinUI3.Enums;
+using BetterLyrics.WinUI3.Services.ResourceService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml.Data;
using System;
using System.Collections.Generic;
@@ -10,14 +12,16 @@ namespace BetterLyrics.WinUI3.Converter
{
public partial class AlbumArtSearchProviderToDisplayNameConverter : IValueConverter
{
+ private readonly IResourceService _resourceService = Ioc.Default.GetRequiredService();
+
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is AlbumArtSearchProvider provider)
{
return provider switch
{
- AlbumArtSearchProvider.Local => App.ResourceLoader!.GetString("AlbumArtSearchLocalProvider"),
- AlbumArtSearchProvider.SMTC => App.ResourceLoader!.GetString("AlbumArtSearchSMTCProvider"),
+ AlbumArtSearchProvider.Local => _resourceService.GetLocalizedString("AlbumArtSearchLocalProvider"),
+ AlbumArtSearchProvider.SMTC => _resourceService.GetLocalizedString("AlbumArtSearchSMTCProvider"),
AlbumArtSearchProvider.iTunes => "iTunes",
_ => throw new Exception($"Unknown AlbumArtSearchProvider: {provider}"),
};
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/ByteArrayToImageConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/ByteArrayToImageConverter.cs
index f6c7084..2e20356 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/ByteArrayToImageConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/ByteArrayToImageConverter.cs
@@ -1,4 +1,5 @@
-using Microsoft.UI.Xaml.Data;
+using BetterLyrics.WinUI3.Helper;
+using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media.Imaging;
using System;
using System.Collections.Generic;
@@ -29,11 +30,11 @@ namespace BetterLyrics.WinUI3.Converter
}
catch
{
- return null;
+ return PathHelper.AlbumArtPlaceholderPath;
}
}
- return null;
+ return PathHelper.AlbumArtPlaceholderPath;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/IntToBoolConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/IntToBoolConverter.cs
new file mode 100644
index 0000000..62baef7
--- /dev/null
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/IntToBoolConverter.cs
@@ -0,0 +1,26 @@
+using Microsoft.UI.Xaml.Data;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BetterLyrics.WinUI3.Converter
+{
+ public partial class IntToBoolConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, string language)
+ {
+ if (value is int intValue)
+ {
+ return intValue != 0;
+ }
+ return false;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/LyricsSearchProviderToDisplayNameConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/LyricsSearchProviderToDisplayNameConverter.cs
index 79c65e1..ae79cd5 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/LyricsSearchProviderToDisplayNameConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/LyricsSearchProviderToDisplayNameConverter.cs
@@ -1,13 +1,17 @@
// 2025/6/23 by Zhe Fang
-using System;
using BetterLyrics.WinUI3.Enums;
+using BetterLyrics.WinUI3.Services.ResourceService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml.Data;
+using System;
namespace BetterLyrics.WinUI3.Converter
{
public partial class LyricsSearchProviderToDisplayNameConverter : IValueConverter
{
+ private readonly IResourceService _resourceService = Ioc.Default.GetRequiredService();
+
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is LyricsSearchProvider provider)
@@ -20,10 +24,10 @@ namespace BetterLyrics.WinUI3.Converter
LyricsSearchProvider.Kugou => "酷狗音乐",
LyricsSearchProvider.AmllTtmlDb => "amll-ttml-db",
LyricsSearchProvider.AppleMusic => "Apple Music",
- LyricsSearchProvider.LocalLrcFile => App.ResourceLoader!.GetString("LyricsSearchProviderLocalLrcFile"),
- LyricsSearchProvider.LocalMusicFile => App.ResourceLoader!.GetString("LyricsSearchProviderLocalMusicFile"),
- LyricsSearchProvider.LocalEslrcFile => App.ResourceLoader!.GetString("LyricsSearchProviderEslrcFile"),
- LyricsSearchProvider.LocalTtmlFile => App.ResourceLoader!.GetString("LyricsSearchProviderTtmlFile"),
+ LyricsSearchProvider.LocalLrcFile => _resourceService.GetLocalizedString("LyricsSearchProviderLocalLrcFile"),
+ LyricsSearchProvider.LocalMusicFile => _resourceService.GetLocalizedString("LyricsSearchProviderLocalMusicFile"),
+ LyricsSearchProvider.LocalEslrcFile => _resourceService.GetLocalizedString("LyricsSearchProviderEslrcFile"),
+ LyricsSearchProvider.LocalTtmlFile => _resourceService.GetLocalizedString("LyricsSearchProviderTtmlFile"),
_ => "N/A",
};
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/MatchedLocalFilesPathToVisibilityConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/MatchedLocalFilesPathToVisibilityConverter.cs
index 8a63518..175693e 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/MatchedLocalFilesPathToVisibilityConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/MatchedLocalFilesPathToVisibilityConverter.cs
@@ -1,18 +1,22 @@
// 2025/6/23 by Zhe Fang
-using System;
+using BetterLyrics.WinUI3.Services.ResourceService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
+using System;
namespace BetterLyrics.WinUI3.Converter
{
public partial class MatchedLocalFilesPathToVisibilityConverter : IValueConverter
{
+ private readonly IResourceService _resourceService = Ioc.Default.GetRequiredService();
+
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is string path)
{
- if (path == App.ResourceLoader!.GetString("MainPageNoLocalFilesMatched"))
+ if (path == _resourceService.GetLocalizedString("MainPageNoLocalFilesMatched"))
{
return Visibility.Collapsed;
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/SecondsToFormattedTimeConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/SecondsToFormattedTimeConverter.cs
index 540d024..17fe60e 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/SecondsToFormattedTimeConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/SecondsToFormattedTimeConverter.cs
@@ -11,15 +11,27 @@ namespace BetterLyrics.WinUI3.Converter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
+ TimeSpan timeSpan = TimeSpan.Zero;
if (value is double seconds)
{
- return TimeSpan.FromSeconds(seconds).ToString(@"mm\:ss");
+ timeSpan = TimeSpan.FromSeconds(seconds);
}
else if (value is int secondsInt)
{
- return TimeSpan.FromSeconds(secondsInt).ToString(@"mm\:ss");
+ timeSpan = TimeSpan.FromSeconds(secondsInt);
+ }
+ if (timeSpan.Days > 0)
+ {
+ return timeSpan.ToString(@"dd\.hh\:mm\:ss");
+ }
+ else if (timeSpan.Hours > 0)
+ {
+ return timeSpan.ToString(@"hh\:mm\:ss");
+ }
+ else
+ {
+ return timeSpan.ToString(@"mm\:ss");
}
- return value?.ToString() ?? "";
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TrackToLyricsConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TrackToLyricsConverter.cs
new file mode 100644
index 0000000..9502a3e
--- /dev/null
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TrackToLyricsConverter.cs
@@ -0,0 +1,28 @@
+using ATL;
+using BetterLyrics.WinUI3.Helper;
+using Microsoft.UI.Xaml.Data;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BetterLyrics.WinUI3.Converter
+{
+ public partial class TrackToLyricsConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, string language)
+ {
+ if (value is Track track)
+ {
+ return track.GetLyrics();
+ }
+ return "";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TranslationSearchProviderToDisplayNameConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TranslationSearchProviderToDisplayNameConverter.cs
index 2533db8..d2bfc62 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TranslationSearchProviderToDisplayNameConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TranslationSearchProviderToDisplayNameConverter.cs
@@ -1,13 +1,17 @@
// 2025/6/23 by Zhe Fang
-using System;
using BetterLyrics.WinUI3.Enums;
+using BetterLyrics.WinUI3.Services.ResourceService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml.Data;
+using System;
namespace BetterLyrics.WinUI3.Converter
{
public partial class TranslationSearchProviderToDisplayNameConverter : IValueConverter
{
+ private readonly IResourceService _resourceService = Ioc.Default.GetRequiredService();
+
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is TranslationSearchProvider provider)
@@ -20,10 +24,10 @@ namespace BetterLyrics.WinUI3.Converter
TranslationSearchProvider.Kugou => "酷狗音乐",
TranslationSearchProvider.AmllTtmlDb => "amll-ttml-db",
TranslationSearchProvider.AppleMusic => "Apple Music",
- TranslationSearchProvider.LocalLrcFile => App.ResourceLoader!.GetString("LyricsSearchProviderLocalLrcFile"),
- TranslationSearchProvider.LocalMusicFile => App.ResourceLoader!.GetString("LyricsSearchProviderLocalMusicFile"),
- TranslationSearchProvider.LocalEslrcFile => App.ResourceLoader!.GetString("LyricsSearchProviderEslrcFile"),
- TranslationSearchProvider.LocalTtmlFile => App.ResourceLoader!.GetString("LyricsSearchProviderTtmlFile"),
+ TranslationSearchProvider.LocalLrcFile => _resourceService.GetLocalizedString("LyricsSearchProviderLocalLrcFile"),
+ TranslationSearchProvider.LocalMusicFile => _resourceService.GetLocalizedString("LyricsSearchProviderLocalMusicFile"),
+ TranslationSearchProvider.LocalEslrcFile => _resourceService.GetLocalizedString("LyricsSearchProviderEslrcFile"),
+ TranslationSearchProvider.LocalTtmlFile => _resourceService.GetLocalizedString("LyricsSearchProviderTtmlFile"),
TranslationSearchProvider.LibreTranslate => "LibreTranslate",
_ => "N/A",
};
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Enums/CommonSongProperty.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Enums/CommonSongProperty.cs
index c6980a0..15f3012 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Enums/CommonSongProperty.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Enums/CommonSongProperty.cs
@@ -11,6 +11,7 @@ namespace BetterLyrics.WinUI3.Enums
Title,
Album,
Artist,
- Folder
+ Folder,
+ M3UFilePath
}
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/ImageHelper.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/ImageHelper.cs
index 9065b5c..4354e3e 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/ImageHelper.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/ImageHelper.cs
@@ -49,8 +49,7 @@ namespace BetterLyrics.WinUI3.Helper
public static async Task GetAlbumArtPlaceholderAsync()
{
- Uri uri = new Uri($"ms-appx:///Assets/AlbumArtPlaceholder.png");
- StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri);
+ StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(PathHelper.AlbumArtPlaceholderPath));
IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
return stream;
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/LanguageHelper.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/LanguageHelper.cs
index 06aa4d1..cbcf799 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/LanguageHelper.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/LanguageHelper.cs
@@ -1,5 +1,7 @@
using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Models;
+using BetterLyrics.WinUI3.Services.ResourceService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using NTextCat;
using NTextCat.Commons;
using System.Collections.Generic;
@@ -13,6 +15,7 @@ namespace BetterLyrics.WinUI3.Helper
{
private static readonly RankedLanguageIdentifierFactory _factory = new();
private static readonly RankedLanguageIdentifier _identifier;
+ private static readonly IResourceService _resourceService = Ioc.Default.GetRequiredService();
public static List SupportedTranslationTargetLanguages { get; set; } =
[
@@ -89,7 +92,7 @@ namespace BetterLyrics.WinUI3.Helper
public static List SupportedDisplayLanguages { get; set; } =
[
- new ExtendedLanguage("", App.ResourceLoader!.GetString("SettingsPageSystemLanguage")),
+ new ExtendedLanguage("", _resourceService.GetLocalizedString("SettingsPageSystemLanguage")),
new ExtendedLanguage("en-US", "English"),
new ExtendedLanguage("ja-JP"),
new ExtendedLanguage("ko-KR"),
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PathHelper.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PathHelper.cs
index 65bcc53..7acc429 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PathHelper.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PathHelper.cs
@@ -20,6 +20,7 @@ namespace BetterLyrics.WinUI3.Helper
public static string LanguageProfilePath => Path.Combine(AssetsFolder, "Wiki82.profile.xml");
public static string LogoPath => Path.Combine(AssetsFolder, "Logo.ico");
+ public static string AlbumArtPlaceholderPath => "ms-appx:///Assets/AlbumArtPlaceholder.png";
public static string AIMPLogoPath => Path.Combine(AssetsFolder, "AIMP.png");
public static string Foobar2000LogoPath => Path.Combine(AssetsFolder, "foobar2000.png");
public static string MusicBeeLogoPath => Path.Combine(AssetsFolder, "MusicBee.png");
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PhoneticHelper.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PhoneticHelper.cs
index 8c262fd..a2dc2c2 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PhoneticHelper.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PhoneticHelper.cs
@@ -1,4 +1,6 @@
-using System;
+using BetterLyrics.WinUI3.Services.ResourceService;
+using CommunityToolkit.Mvvm.DependencyInjection;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,6 +10,8 @@ namespace BetterLyrics.WinUI3.Helper
{
public static class PhoneticHelper
{
+ private static readonly IResourceService _resourceService = Ioc.Default.GetRequiredService();
+
public const string PinyinCode = "zh-pinyin";
public const string JyutpingCode = "zh-jyutping";
public const string RomajiCode = "ja-romaji";
@@ -22,11 +26,11 @@ namespace BetterLyrics.WinUI3.Helper
switch (code)
{
case PinyinCode:
- return App.ResourceLoader!.GetString("Pinyin");
+ return _resourceService.GetLocalizedString("Pinyin");
case JyutpingCode:
- return App.ResourceLoader!.GetString("Jyutping");
+ return _resourceService.GetLocalizedString("Jyutping");
case RomajiCode:
- return App.ResourceLoader!.GetString("Romaji");
+ return _resourceService.GetLocalizedString("Romaji");
default:
throw new ArgumentOutOfRangeException(nameof(code));
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/TrackHelper.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/TrackHelper.cs
index f9312f9..3c3659d 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/TrackHelper.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/TrackHelper.cs
@@ -18,5 +18,14 @@ namespace BetterLyrics.WinUI3.Helper
{
return Directory.GetParent(track.Path)?.FullName ?? "";
}
+
+ public static string GetLyrics(this ATL.Track track)
+ {
+ if (track.Path is string path)
+ {
+ return TagLib.File.Create(path).Tag.Lyrics;
+ }
+ return "";
+ }
}
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsData.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsData.cs
index 83e12c3..c150aa4 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsData.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsData.cs
@@ -1,6 +1,8 @@
using BetterLyrics.WinUI3.Enums;
using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Services;
+using BetterLyrics.WinUI3.Services.ResourceService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Lyricify.Lyrics.Helpers.General;
using System;
using System.Collections.Generic;
@@ -13,6 +15,8 @@ namespace BetterLyrics.WinUI3.Models
{
public class LyricsData
{
+ private static readonly IResourceService _resourceService = Ioc.Default.GetRequiredService();
+
public List LyricsLines { get; set; }
private string? _languageCode;
public string? LanguageCode
@@ -138,7 +142,7 @@ namespace BetterLyrics.WinUI3.Models
{
StartMs = 0,
EndMs = durationMs,
- OriginalText = App.ResourceLoader!.GetString("LyricsNotFound"),
+ OriginalText = _resourceService.GetLocalizedString("LyricsNotFound"),
LyricsChars = [],
}]);
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsWindowStatus.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsWindowStatus.cs
index 558040b..7bbdbb2 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsWindowStatus.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsWindowStatus.cs
@@ -1,8 +1,10 @@
using BetterLyrics.WinUI3.Enums;
using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Models.Settings;
+using BetterLyrics.WinUI3.Services.ResourceService;
using BetterLyrics.WinUI3.Views;
using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Windowing;
using System;
using Windows.Foundation;
@@ -171,11 +173,13 @@ namespace BetterLyrics.WinUI3.Models
public static class LyricsWindowStatusExtensions
{
+ private static readonly IResourceService _resourceService = Ioc.Default.GetRequiredService();
+
public static LyricsWindowStatus DesktopMode()
{
return new LyricsWindowStatus
{
- Name = App.ResourceLoader!.GetString("DesktopMode"),
+ Name = _resourceService.GetLocalizedString("DesktopMode"),
LyricsDisplayType = LyricsDisplayType.LyricsOnly,
WindowBounds = new Rect(100, 100, 600, 250),
IsAlwaysOnTop = true,
@@ -201,7 +205,7 @@ namespace BetterLyrics.WinUI3.Models
{
return new LyricsWindowStatus
{
- Name = App.ResourceLoader!.GetString("DockedMode"),
+ Name = _resourceService.GetLocalizedString("DockedMode"),
IsWorkArea = true,
IsAlwaysOnTop = true,
IsAlwaysOnTopPolling = true,
@@ -228,7 +232,7 @@ namespace BetterLyrics.WinUI3.Models
{
return new LyricsWindowStatus
{
- Name = App.ResourceLoader!.GetString("FullscreenMode"),
+ Name = _resourceService.GetLocalizedString("FullscreenMode"),
WindowBounds = monitorBounds,
IsAlwaysOnTop = true,
IsBorderless = true,
@@ -253,7 +257,7 @@ namespace BetterLyrics.WinUI3.Models
{
return new LyricsWindowStatus
{
- Name = App.ResourceLoader!.GetString("StandardMode"),
+ Name = _resourceService.GetLocalizedString("StandardMode"),
};
}
@@ -261,7 +265,7 @@ namespace BetterLyrics.WinUI3.Models
{
return new LyricsWindowStatus
{
- Name = App.ResourceLoader!.GetString("NarrowMode"),
+ Name = _resourceService.GetLocalizedString("NarrowMode"),
WindowBounds = new Rect(100, 100, 400, 800),
LyricsLayoutOrientation = LyricsLayoutOrientation.Vertical,
};
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LastFMService/LastFMService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LastFMService/LastFMService.cs
index f86dc31..c576616 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LastFMService/LastFMService.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LastFMService/LastFMService.cs
@@ -1,10 +1,12 @@
using BetterLyrics.WinUI3.Events;
using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Models;
+using BetterLyrics.WinUI3.Services.ResourceService;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.ViewModels;
using BetterLyrics.WinUI3.Views;
using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
@@ -25,6 +27,8 @@ namespace BetterLyrics.WinUI3.Services.LastFMService
public partial class LastFMService : ILastFMService
{
private readonly ISettingsService _settingsService;
+ private readonly IResourceService _resourceService;
+
private readonly LastfmClient _client;
public event EventHandler? UserChanged;
@@ -34,9 +38,10 @@ namespace BetterLyrics.WinUI3.Services.LastFMService
public bool IsAuthenticated { get; private set; }
- public LastFMService(ISettingsService settingsService)
+ public LastFMService(ISettingsService settingsService, IResourceService resourceService)
{
_settingsService = settingsService;
+ _resourceService = resourceService;
_client = new LastfmClient(Constants.LastFM.ApiKey, Constants.LastFM.SharedSecret);
_client.Session.SessionKey = PasswordVaultHelper.Get(Constants.App.AppName, Constants.LastFM.SessionKeyCredentialKey) ?? string.Empty;
@@ -53,7 +58,7 @@ namespace BetterLyrics.WinUI3.Services.LastFMService
}
catch (Exception)
{
- App.Current.SettingsWindowNotificationPanel?.Notify(App.ResourceLoader?.GetString("LastFMAuthFailed") ?? "", InfoBarSeverity.Error);
+ DevWinUI.Growl.Error(_resourceService.GetLocalizedString("LastFMAuthFailed") ?? "");
}
}
@@ -74,10 +79,10 @@ namespace BetterLyrics.WinUI3.Services.LastFMService
var dialog = new ContentDialog
{
- Title = App.ResourceLoader?.GetString("LastFMRequestAuthTitle") ?? "",
- Content = App.ResourceLoader?.GetString("LastFMRequestAuthDesc") ?? "",
- PrimaryButtonText = App.ResourceLoader?.GetString("LastFMRequestAuthConfirm") ?? "",
- CloseButtonText = App.ResourceLoader?.GetString("Cancel") ?? "",
+ Title = _resourceService.GetLocalizedString("LastFMRequestAuthTitle") ?? "",
+ Content = _resourceService.GetLocalizedString("LastFMRequestAuthDesc") ?? "",
+ PrimaryButtonText = _resourceService.GetLocalizedString("LastFMRequestAuthConfirm") ?? "",
+ CloseButtonText = _resourceService.GetLocalizedString("Cancel") ?? "",
DefaultButton = ContentDialogButton.Close,
XamlRoot = dialogXamlRoot,
};
@@ -101,10 +106,10 @@ namespace BetterLyrics.WinUI3.Services.LastFMService
var dialog = new ContentDialog
{
- Title = App.ResourceLoader?.GetString("LastFMRequestUnAuthTitle") ?? "",
- Content = App.ResourceLoader?.GetString("LastFMRequestUnAuthDesc") ?? "",
- PrimaryButtonText = App.ResourceLoader?.GetString("LastFMRequestUnAuthConfirm") ?? "",
- CloseButtonText = App.ResourceLoader?.GetString("Cancel") ?? "",
+ Title = _resourceService.GetLocalizedString("LastFMRequestUnAuthTitle") ?? "",
+ Content = _resourceService.GetLocalizedString("LastFMRequestUnAuthDesc") ?? "",
+ PrimaryButtonText = _resourceService.GetLocalizedString("LastFMRequestUnAuthConfirm") ?? "",
+ CloseButtonText = _resourceService.GetLocalizedString("Cancel") ?? "",
DefaultButton = ContentDialogButton.Close,
XamlRoot = dialogXamlRoot,
};
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LyricsSearchService/LyricsSearchService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LyricsSearchService/LyricsSearchService.cs
index 604cb9d..32f5093 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LyricsSearchService/LyricsSearchService.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LyricsSearchService/LyricsSearchService.cs
@@ -302,7 +302,7 @@ namespace BetterLyrics.WinUI3.Services.LyricsSearchService
|| (album == "" && track.Title == title && track.Artist == artist)
|| (album == "" && FileHelper.IsSwitchableNormalizedMatch(Path.GetFileNameWithoutExtension(file), title, artist)))
{
- var plain = TagLib.File.Create(file).Tag.Lyrics;
+ var plain = track.GetLyrics();
if (!plain.IsNullOrEmpty())
{
lyricsSearchResult.Raw = plain;
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/MediaSessionsService/MediaSessionsService.LyricsUpdater.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/MediaSessionsService/MediaSessionsService.LyricsUpdater.cs
index dff9068..03a00ca 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/MediaSessionsService/MediaSessionsService.LyricsUpdater.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/MediaSessionsService/MediaSessionsService.LyricsUpdater.cs
@@ -104,7 +104,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
}
catch (Exception)
{
- App.Current.LyricsWindowNotificationPanel?.Notify(App.ResourceLoader?.GetString("LibreTranslateFailed")!, Microsoft.UI.Xaml.Controls.InfoBarSeverity.Error);
+ DevWinUI.Growl.Error(_resourceService.GetLocalizedString("LibreTranslateFailed")!);
}
}
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/MediaSessionsService/MediaSessionsService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/MediaSessionsService/MediaSessionsService.cs
index 31b0f63..276572e 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/MediaSessionsService/MediaSessionsService.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/MediaSessionsService/MediaSessionsService.cs
@@ -10,6 +10,7 @@ using BetterLyrics.WinUI3.Services.AlbumArtSearchService;
using BetterLyrics.WinUI3.Services.LibWatcherService;
using BetterLyrics.WinUI3.Services.LiveStatesService;
using BetterLyrics.WinUI3.Services.LyricsSearchService;
+using BetterLyrics.WinUI3.Services.ResourceService;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.Services.TranslateService;
using BetterLyrics.WinUI3.ViewModels;
@@ -46,6 +47,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
private readonly ISettingsService _settingsService;
private readonly ILibWatcherService _libWatcherService;
private readonly ILiveStatesService _liveStatesService;
+ private readonly IResourceService _resourceService;
private readonly ILogger _logger;
private double _lxMusicPositionSeconds = 0;
@@ -77,7 +79,8 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
ILyricsSearchService musicSearchService,
ILibWatcherService libWatcherService,
ILiveStatesService liveStatesService,
- ITranslateService libreTranslateService)
+ ITranslateService libreTranslateService,
+ IResourceService resourceService)
{
_settingsService = settingsService;
_albumArtSearchService = albumArtSearchService;
@@ -85,6 +88,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
_libWatcherService = libWatcherService;
_translateService = libreTranslateService;
_liveStatesService = liveStatesService;
+ _resourceService = resourceService;
_logger = Ioc.Default.GetRequiredService>();
_settingsService.AppSettings.MediaSourceProvidersInfo.ItemPropertyChanged += MediaSourceProvidersInfo_ItemPropertyChanged;
@@ -485,7 +489,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
_logger.LogError("Failed to start SSE connection for LX Music.");
_dispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
{
- App.Current.LyricsWindowNotificationPanel?.Notify(App.ResourceLoader!.GetString("FailToStartLXMusicServer"), Microsoft.UI.Xaml.Controls.InfoBarSeverity.Error);
+ DevWinUI.Growl.Error(_resourceService.GetLocalizedString("FailToStartLXMusicServer"));
});
StopSSE();
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/ResourceService/IResourceService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/ResourceService/IResourceService.cs
new file mode 100644
index 0000000..776501d
--- /dev/null
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/ResourceService/IResourceService.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BetterLyrics.WinUI3.Services.ResourceService
+{
+ public interface IResourceService
+ {
+ string GetLocalizedString(string id);
+ }
+}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/ResourceService/ResourceService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/ResourceService/ResourceService.cs
new file mode 100644
index 0000000..8ba56c3
--- /dev/null
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/ResourceService/ResourceService.cs
@@ -0,0 +1,19 @@
+using Microsoft.Windows.ApplicationModel.Resources;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BetterLyrics.WinUI3.Services.ResourceService
+{
+ public class ResourceService : IResourceService
+ {
+ private readonly ResourceLoader _resourceLoader = new();
+
+ public string GetLocalizedString(string id)
+ {
+ return _resourceLoader.GetString(id);
+ }
+ }
+}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/TranslateService/TranslateService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/TranslateService/TranslateService.cs
index 9e0e0c1..f124308 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/TranslateService/TranslateService.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/TranslateService/TranslateService.cs
@@ -14,7 +14,7 @@ using System.Threading.Tasks;
namespace BetterLyrics.WinUI3.Services.TranslateService
{
- public class TranslateService : BaseViewModel, ITranslateService
+ public partial class TranslateService : BaseViewModel, ITranslateService
{
private readonly ISettingsService _settingsService;
private readonly HttpClient _httpClient;
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw
index 40fc773..7947a05 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw
@@ -141,6 +141,9 @@
Cancel
+
+ Playlist was created successfully
+
Default
@@ -177,6 +180,9 @@
Settings
+
+ Playlist was imported successfully
+
Settings file import failed, application settings remain unchanged
@@ -346,7 +352,7 @@ If you encounter any problems, please go to the Settings page, About tab, and vi
Welcome to BetterLyrics
-
+
Add to playlist
@@ -355,7 +361,7 @@ If you encounter any problems, please go to the Settings page, About tab, and vi
Next items
-
+
Add to play queue
@@ -388,6 +394,9 @@ If you encounter any problems, please go to the Settings page, About tab, and vi
Format
+
+ Lyrics
+
Path
@@ -403,6 +412,9 @@ If you encounter any problems, please go to the Settings page, About tab, and vi
No songs were found in the media library
+
+ Import from file
+
Create a playlist
@@ -466,6 +478,9 @@ If you encounter any problems, please go to the Settings page, About tab, and vi
Mandarin pinyin
+
+ Unable to view tracks since the path is not existed
+
Romaji
@@ -1330,6 +1345,12 @@ If you encounter any problems, please go to the Settings page, About tab, and vi
Lyrics window switcher
+
+ Unable to add tracks since the path is not existed
+
+
+ Selected tracks have been added to this playlist
+
Translate server is not set, please configure it in settings first
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw
index ffb0fe7..5358555 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw
@@ -141,6 +141,9 @@
キャンセル
+
+ 正常に作成されました
+
デフォルト
@@ -177,6 +180,9 @@
設定
+
+ プレイリストが正常にインポートされました
+
設定ファイルのインポートに失敗し、アプリケーション設定は変更されません
@@ -346,7 +352,7 @@
BetterLyrics へようこそ
-
+
プレイリストに追加します
@@ -355,7 +361,7 @@
次のアイテム
-
+
キューを再生するために追加します
@@ -388,6 +394,9 @@
形式
+
+ 歌詞
+
パス
@@ -403,6 +412,9 @@
メディアライブラリには歌が見つかりませんでした
+
+ ファイルからのインポート
+
プレイリストを作成します
@@ -466,6 +478,9 @@
マンダリンのピンイン
+
+ パスが存在しないため、トラックを表示できません
+
ローマン
@@ -1330,6 +1345,12 @@
歌詞ウィンドウスイッチャー
+
+ パスが存在しないため、トラックを追加できません
+
+
+ 選択したトラックがこのプレイリストに追加されました
+
翻訳サーバーは設定されていません。最初に設定で構成してください
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw
index be43e86..1780fab 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw
@@ -141,6 +141,9 @@
취소
+
+ 재생 목록이 성공적으로 생성되었습니다
+
기본
@@ -177,6 +180,9 @@
설정
+
+ 재생 목록을 성공적으로 가져왔습니다
+
설정 파일 가져 오기 실패, 응용 프로그램 설정은 변경되지 않았습니다
@@ -346,7 +352,7 @@
Betterlyrics에 오신 것을 환영합니다
-
+
재생 목록에 추가하십시오
@@ -355,7 +361,7 @@
다음 항목
-
+
재생 큐에 추가하십시오
@@ -388,6 +394,9 @@
체재
+
+ 가사
+
길
@@ -403,6 +412,9 @@
미디어 라이브러리에는 노래가 없습니다
+
+ 파일에서 가져오기
+
재생 목록을 만듭니다
@@ -466,6 +478,9 @@
만다린의 피니 인
+
+ 경로가 존재하지 않으므로 트랙을 볼 수 없습니다
+
로만
@@ -1330,6 +1345,12 @@
가사 창 전환기
+
+ 경로가 존재하지 않으므로 트랙을 추가할 수 없습니다
+
+
+ 선택한 트랙이 이 재생 목록에 추가되었습니다
+
번역 서버가 설정되지 않았습니다. 먼저 설정으로 구성하십시오.
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw
index 591496d..70fa4e6 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw
@@ -141,6 +141,9 @@
取消
+
+ 播放列表创建成功
+
默认
@@ -177,6 +180,9 @@
设置
+
+ 播放列表已成功导入
+
设置文件导入失败,应用程序设置保持不变
@@ -346,7 +352,7 @@
欢迎使用 BetterLyrics
-
+
添加到歌单
@@ -355,7 +361,7 @@
下一个项目
-
+
添加到播放队列
@@ -388,6 +394,9 @@
格式
+
+ 歌词
+
路径
@@ -403,6 +412,9 @@
未在媒体库内找到任何歌曲
+
+ 从文件导入
+
创建歌单
@@ -466,6 +478,9 @@
普通话拼音
+
+ 无法查看曲目,因为路径不存在
+
罗马音
@@ -1330,6 +1345,12 @@
歌词窗口切换器
+
+ 由于路径不存在,无法添加曲目
+
+
+ 所选曲目已添加到此播放列表
+
未设置Translate服务器,请先在设置中进行配置
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw
index 564895e..27f30b9 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw
@@ -141,6 +141,9 @@
取消
+
+ 已成功建立播放清單
+
預設
@@ -177,6 +180,9 @@
設定
+
+ 已成功匯入播放清單
+
設置文件導入失敗,應用程序設置保持不變
@@ -346,7 +352,7 @@
歡迎使用 BetterLyrics
-
+
添加到歌單
@@ -355,7 +361,7 @@
下一個項目
-
+
新增到播放隊列
@@ -388,6 +394,9 @@
格式
+
+ 歌词
+
路徑
@@ -403,6 +412,9 @@
未在媒體庫內找到任何歌曲
+
+ 從檔案匯入
+
建立歌單
@@ -466,6 +478,9 @@
普通話拼音
+
+ 由於路徑不存在,因此無法檢視曲目
+
羅馬音
@@ -1330,6 +1345,12 @@
歌詞視窗切換器
+
+ 路徑不存在,無法新增曲目
+
+
+ 所選曲目已新增到此播放列表
+
未設定翻譯伺服器,請先在設定中進行配置
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel/LyricsRendererViewModel.Messages.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel/LyricsRendererViewModel.Messages.cs
index dda68c3..6e713eb 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel/LyricsRendererViewModel.Messages.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel/LyricsRendererViewModel.Messages.cs
@@ -408,6 +408,9 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
UpdateSongInfoFontSize();
_isLayoutChanged = true;
+
+ // 模拟设备变更,执行全局强制刷新以避免旧值被误用
+ _isDeviceChanged = true;
}
}
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MediaSettingsControlViewModel.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MediaSettingsControlViewModel.cs
index 842f4c5..4d4773f 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MediaSettingsControlViewModel.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MediaSettingsControlViewModel.cs
@@ -2,9 +2,11 @@
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Services.LibWatcherService;
+using BetterLyrics.WinUI3.Services.ResourceService;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.Views;
using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
@@ -21,13 +23,15 @@ namespace BetterLyrics.WinUI3.ViewModels
public partial class MediaSettingsControlViewModel : BaseViewModel
{
private readonly ISettingsService _settingsService;
+ private readonly IResourceService _resourceService;
[ObservableProperty]
public partial AppSettings AppSettings { get; set; }
- public MediaSettingsControlViewModel(ISettingsService settingsService)
+ public MediaSettingsControlViewModel(ISettingsService settingsService, IResourceService resourceService)
{
_settingsService = settingsService;
+ _resourceService = resourceService;
AppSettings = _settingsService.AppSettings;
}
@@ -57,18 +61,18 @@ namespace BetterLyrics.WinUI3.ViewModels
if (AppSettings.LocalMediaFolders.Any(x => Path.GetFullPath(x.Path).TrimEnd(Path.DirectorySeparatorChar).Equals(normalizedPath.TrimEnd(Path.DirectorySeparatorChar), StringComparison.OrdinalIgnoreCase)))
{
- App.Current.SettingsWindowNotificationPanel?.Notify(App.ResourceLoader!.GetString("SettingsPagePathExistedInfo"), InfoBarSeverity.Warning);
+ DevWinUI.Growl.Warning(_resourceService.GetLocalizedString("SettingsPagePathExistedInfo"));
}
else if (AppSettings.LocalMediaFolders.Any(item => normalizedPath.StartsWith(Path.GetFullPath(item.Path).TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)))
{
// 添加的文件夹是现有文件夹的子文件夹
- App.Current.SettingsWindowNotificationPanel?.Notify(App.ResourceLoader!.GetString("SettingsPagePathBeIncludedInfo"), InfoBarSeverity.Warning);
+ DevWinUI.Growl.Warning(_resourceService.GetLocalizedString("SettingsPagePathBeIncludedInfo"));
}
else if (AppSettings.LocalMediaFolders.Any(item => Path.GetFullPath(item.Path).TrimEnd(Path.DirectorySeparatorChar).StartsWith(normalizedPath, StringComparison.OrdinalIgnoreCase))
)
{
// 添加的文件夹是现有文件夹的父文件夹
- App.Current.SettingsWindowNotificationPanel?.Notify(App.ResourceLoader!.GetString("SettingsPagePathIncludingOthersInfo"), InfoBarSeverity.Warning);
+ DevWinUI.Growl.Warning(_resourceService.GetLocalizedString("SettingsPagePathIncludingOthersInfo"));
}
else
{
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryViewModel.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryViewModel.cs
index 3975f8c..1c23afb 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryViewModel.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryViewModel.cs
@@ -7,8 +7,11 @@ using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Services;
using BetterLyrics.WinUI3.Services.LibWatcherService;
+using BetterLyrics.WinUI3.Services.ResourceService;
using BetterLyrics.WinUI3.Services.SettingsService;
+using BetterLyrics.WinUI3.Views;
using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using CommunityToolkit.WinUI;
@@ -25,6 +28,8 @@ using Windows.ApplicationModel;
using Windows.Media;
using Windows.Media.Core;
using Windows.Media.Playback;
+using Windows.Storage;
+using WinRT.Interop;
namespace BetterLyrics.WinUI3.ViewModels
{
@@ -32,6 +37,7 @@ namespace BetterLyrics.WinUI3.ViewModels
{
private readonly ILibWatcherService _libWatcherService;
private readonly ISettingsService _settingsService;
+ private readonly IResourceService _resourceService;
private readonly MediaPlayer _mediaPlayer = new();
private readonly MediaTimelineController _timelineController = new();
@@ -61,6 +67,9 @@ namespace BetterLyrics.WinUI3.ViewModels
[ObservableProperty]
public partial List