This commit is contained in:
Zhe Fang
2025-08-16 10:51:48 -04:00
parent b834be49ce
commit cbaa81b9bb
38 changed files with 443 additions and 295 deletions

View File

@@ -6,6 +6,7 @@ using BetterLyrics.WinUI3.Services;
using BetterLyrics.WinUI3.Services.AlbumArtSearchService;
using BetterLyrics.WinUI3.Services.LastFMService;
using BetterLyrics.WinUI3.Services.LibWatcherService;
using BetterLyrics.WinUI3.Services.LiveStatesService;
using BetterLyrics.WinUI3.Services.LyricsSearchService;
using BetterLyrics.WinUI3.Services.MediaSessionsService;
using BetterLyrics.WinUI3.Services.SettingsService;
@@ -102,6 +103,7 @@ namespace BetterLyrics.WinUI3
loggingBuilder.AddSerilog();
})
// Services
.AddSingleton<ILiveStatesService, LiveStatesService>()
.AddSingleton<ISettingsService, SettingsService>()
.AddSingleton<IMediaSessionsService, MediaSessionsService>()
.AddSingleton<IAlbumArtSearchService, AlbumArtSearchService>()

View File

@@ -21,16 +21,20 @@
<controls:Case Value="Dock">
<uc:LyricsSettingsControl LyricsEffectSettings="{x:Bind ViewModel.AppSettings.DockLyricsEffectSettings, Mode=OneWay}" LyricsStyleSettings="{x:Bind ViewModel.AppSettings.DockLyricsStyleSettings, Mode=OneWay}" />
</controls:Case>
<controls:Case Value="PictureInPicture">
<uc:LyricsSettingsControl LyricsEffectSettings="{x:Bind ViewModel.AppSettings.PictureInPictureLyricsEffectSettings, Mode=OneWay}" LyricsStyleSettings="{x:Bind ViewModel.AppSettings.PictureInPictureLyricsStyleSettings, Mode=OneWay}" />
</controls:Case>
</controls:SwitchPresenter>
<controls:Segmented
x:Name="LyricsSettingsSegmentedControl"
Margin="36,36,36,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
SelectedIndex="0">
SelectedIndex="{x:Bind ViewModel.SelectedTabIndex, Mode=OneWay}">
<controls:SegmentedItem x:Uid="AllLyricsSettingsControlStandard" Tag="Standard" />
<controls:SegmentedItem x:Uid="AllLyricsSettingsControlDesktop" Tag="Desktop" />
<controls:SegmentedItem x:Uid="AllLyricsSettingsControlDock" Tag="Dock" />
<controls:SegmentedItem x:Uid="AllLyricsSettingsControlDesktop" Tag="Desktop" />
<controls:SegmentedItem x:Uid="AllLyricsSettingsControlPictureInPicture" Tag="PictureInPicture" />
</controls:Segmented>
</Grid>
</UserControl>

View File

@@ -2,10 +2,11 @@
namespace BetterLyrics.WinUI3.Enums
{
public enum AutoStartWindowType
public enum LyricsWindowMode
{
StandardMode,
DockMode,
DesktopMode,
PictureInPictureMode,
}
}

View File

@@ -2,6 +2,7 @@
using BetterLyrics.WinUI3.Enums;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Ude;
@@ -77,6 +78,5 @@ namespace BetterLyrics.WinUI3.Helper
return normFileName == normQ1 + normQ2
|| normFileName == normQ2 + normQ1;
}
}
}

View File

@@ -1,4 +1,7 @@
using System;
using BetterLyrics.WinUI3.Enums;
using BetterLyrics.WinUI3.Models.Settings;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,7 +9,31 @@ using System.Threading.Tasks;
namespace BetterLyrics.WinUI3.Models
{
public partial class LiveStates
public partial class LiveStates : ObservableRecipient
{
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsWindowMode CurrentLyricsWindowMode { get; set; }
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsDisplayType CurrentLyricsDisplayType { get; set; }
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsStyleSettings CurrentLyricsStyleSettings { get; set; }
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsEffectSettings CurrentLyricsEffectSettings { get; set; }
public LiveStates(AppSettings appSettings)
{
CurrentLyricsWindowMode = LyricsWindowMode.StandardMode;
CurrentLyricsDisplayType = appSettings.StandardModeSettings.LyricsDisplayType;
CurrentLyricsStyleSettings = appSettings.StandardLyricsStyleSettings;
CurrentLyricsEffectSettings = appSettings.StandardLyricsEffectSettings;
}
public void ToggleLyricsWindowMode(LyricsWindowMode mode)
{
if (CurrentLyricsWindowMode == mode)
{
CurrentLyricsWindowMode = LyricsWindowMode.StandardMode;
}
else
{
CurrentLyricsWindowMode = mode;
}
}
}
}

View File

@@ -13,14 +13,17 @@ namespace BetterLyrics.WinUI3.Models.Settings
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsStyleSettings StandardLyricsStyleSettings { get; set; } = new LyricsStyleSettings(32, TextAlignmentType.Left, 0);
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsStyleSettings DesktopLyricsStyleSettings { get; set; } = new LyricsStyleSettings(28, TextAlignmentType.Center, 2);
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsStyleSettings DockLyricsStyleSettings { get; set; } = new LyricsStyleSettings(16, TextAlignmentType.Center, 0);
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsStyleSettings PictureInPictureLyricsStyleSettings { get; set; } = new LyricsStyleSettings(28, TextAlignmentType.Left, 0);
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsEffectSettings StandardLyricsEffectSettings { get; set; } = new LyricsEffectSettings(100, 500, 1000, EasingType.EaseInOutQuad);
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsEffectSettings DesktopLyricsEffectSettings { get; set; } = new LyricsEffectSettings(500, 500, 500, EasingType.EaseInOutQuad);
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsEffectSettings DockLyricsEffectSettings { get; set; } = new LyricsEffectSettings(500, 500, 500, EasingType.EaseInOutQuad);
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsEffectSettings PictureInPictureLyricsEffectSettings { get; set; } = new LyricsEffectSettings(500, 500, 500, EasingType.EaseInOutQuad);
[ObservableProperty][NotifyPropertyChangedRecipients] public partial StandardModeSettings StandardModeSettings { get; set; } = new StandardModeSettings();
[ObservableProperty][NotifyPropertyChangedRecipients] public partial DesktopModeSettings DesktopModeSettings { get; set; } = new DesktopModeSettings();
[ObservableProperty][NotifyPropertyChangedRecipients] public partial DockModeSettings DockModeSettings { get; set; } = new DockModeSettings();
[ObservableProperty][NotifyPropertyChangedRecipients] public partial PictureInPictureModeSettings PictureInPictureModeSettings { get; set; } = new PictureInPictureModeSettings();
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsBackgroundSettings LyricsBackgroundSettings { get; set; } = new LyricsBackgroundSettings();
[ObservableProperty][NotifyPropertyChangedRecipients] public partial AlbumArtLayoutSettings AlbumArtLayoutSettings { get; set; } = new AlbumArtLayoutSettings();

View File

@@ -0,0 +1,15 @@
using BetterLyrics.WinUI3.Enums;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BetterLyrics.WinUI3.Models.Settings
{
public partial class BaseModeSettings : ObservableRecipient
{
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsDisplayType LyricsDisplayType { get; set; }
}
}

View File

@@ -9,12 +9,15 @@ using Windows.Graphics;
namespace BetterLyrics.WinUI3.Models.Settings
{
public partial class DesktopModeSettings : ObservableRecipient
public partial class DesktopModeSettings : BaseModeSettings
{
[ObservableProperty][NotifyPropertyChangedRecipients] public partial Rect WindowBounds { get; set; } = new Rect(100, 100, 400, 200);
[ObservableProperty][NotifyPropertyChangedRecipients] public partial bool AutoLockOnDesktopMode { get; set; } = false;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial int LockHotKeyIndex { get; set; } = 'U' - 'A'; // Default to 'U' key
public DesktopModeSettings() { }
public DesktopModeSettings()
{
LyricsDisplayType = Enums.LyricsDisplayType.LyricsOnly;
}
}
}

View File

@@ -9,12 +9,15 @@ using System.Threading.Tasks;
namespace BetterLyrics.WinUI3.Models.Settings
{
public partial class DockModeSettings : ObservableRecipient
public partial class DockModeSettings : BaseModeSettings
{
[ObservableProperty][NotifyPropertyChangedRecipients] public partial DockPlacement DockPlacement { get; set; } = DockPlacement.Top;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial int DockWindowHeight { get; set; } = 64;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial string DockMonitorDeviceName { get; set; } = MonitorHelper.GetPrimaryMonitorDeviceName();
public DockModeSettings() { }
public DockModeSettings()
{
LyricsDisplayType = LyricsDisplayType.LyricsOnly;
}
}
}

View File

@@ -10,13 +10,12 @@ namespace BetterLyrics.WinUI3.Models.Settings
{
public partial class GeneralSettings : ObservableRecipient
{
[ObservableProperty][NotifyPropertyChangedRecipients] public partial AutoStartWindowType AutoStartWindowType { get; set; } = AutoStartWindowType.StandardMode;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsWindowMode AutoStartWindowType { get; set; } = LyricsWindowMode.StandardMode;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial Language Language { get; set; } = Language.FollowSystem;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial bool IgnoreFullscreenWindow { get; set; } = false;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial string LXMusicServer { get; set; } = string.Empty;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial bool HideWindowWhenNotPlaying { get; set; } = true;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial bool IsDragEverywhereEnabled { get; set; } = false;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsDisplayType DisplayType { get; set; } = LyricsDisplayType.SplitView;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial bool IsImmersiveMode { get; set; } = false;
[ObservableProperty][NotifyPropertyChangedRecipients] public partial bool ExitOnLyricsWindowClosed { get; set; } = true;

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BetterLyrics.WinUI3.Models.Settings
{
public partial class PictureInPictureModeSettings : BaseModeSettings
{
public PictureInPictureModeSettings()
{
LyricsDisplayType = Enums.LyricsDisplayType.SplitView;
}
}
}

View File

@@ -1,4 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
using BetterLyrics.WinUI3.Enums;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,10 +10,13 @@ using Windows.Graphics;
namespace BetterLyrics.WinUI3.Models.Settings
{
public partial class StandardModeSettings : ObservableRecipient
public partial class StandardModeSettings : BaseModeSettings
{
[ObservableProperty][NotifyPropertyChangedRecipients] public partial Rect WindowBounds { get; set; } = new Rect(100, 100, 1000, 600);
public StandardModeSettings() { }
public StandardModeSettings()
{
LyricsDisplayType = LyricsDisplayType.SplitView;
}
}
}

View File

@@ -70,18 +70,24 @@ namespace BetterLyrics.WinUI3.Services.AlbumArtSearchService
{
if (Directory.Exists(folder.Path) && folder.IsEnabled)
{
foreach (var file in Directory.GetFiles(folder.Path, $"*.*", SearchOption.AllDirectories))
try
{
Track track = new(file);
if ((track.Title == title && track.Artist == artist) || FileHelper.IsSwitchableNormalizedMatch(Path.GetFileNameWithoutExtension(file), artist, title))
foreach (var file in Directory.GetFiles(folder.Path, $"*.*", SearchOption.AllDirectories))
{
var bytes = track.EmbeddedPictures.FirstOrDefault()?.PictureData;
if (bytes != null)
Track track = new(file);
if ((track.Title == title && track.Artist == artist) || FileHelper.IsSwitchableNormalizedMatch(Path.GetFileNameWithoutExtension(file), artist, title))
{
return bytes;
var bytes = track.EmbeddedPictures.FirstOrDefault()?.PictureData;
if (bytes != null)
{
return bytes;
}
}
}
}
catch (Exception)
{
}
}
}
return null;

View File

@@ -0,0 +1,14 @@
using BetterLyrics.WinUI3.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BetterLyrics.WinUI3.Services.LiveStatesService
{
public interface ILiveStatesService
{
LiveStates LiveStates { get; set; }
}
}

View File

@@ -0,0 +1,65 @@
using BetterLyrics.WinUI3.Enums;
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.ViewModels;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BetterLyrics.WinUI3.Services.LiveStatesService
{
public class LiveStatesService : BaseViewModel, ILiveStatesService,
IRecipient<PropertyChangedMessage<LyricsWindowMode>>
{
private readonly ISettingsService _settingsService;
public LiveStates LiveStates { get; set; }
public LiveStatesService(ISettingsService settingsService)
{
_settingsService = settingsService;
LiveStates = new LiveStates(_settingsService.AppSettings);
}
public void Receive(PropertyChangedMessage<LyricsWindowMode> message)
{
if (message.Sender is LiveStates)
{
if (message.PropertyName == nameof(LiveStates.CurrentLyricsWindowMode))
{
switch (message.NewValue)
{
case LyricsWindowMode.StandardMode:
LiveStates.CurrentLyricsStyleSettings = _settingsService.AppSettings.StandardLyricsStyleSettings;
LiveStates.CurrentLyricsEffectSettings = _settingsService.AppSettings.StandardLyricsEffectSettings;
LiveStates.CurrentLyricsDisplayType = _settingsService.AppSettings.StandardModeSettings.LyricsDisplayType;
break;
case LyricsWindowMode.DockMode:
LiveStates.CurrentLyricsStyleSettings = _settingsService.AppSettings.DockLyricsStyleSettings;
LiveStates.CurrentLyricsEffectSettings = _settingsService.AppSettings.DockLyricsEffectSettings;
LiveStates.CurrentLyricsDisplayType = _settingsService.AppSettings.DockModeSettings.LyricsDisplayType;
break;
case LyricsWindowMode.DesktopMode:
LiveStates.CurrentLyricsStyleSettings = _settingsService.AppSettings.DesktopLyricsStyleSettings;
LiveStates.CurrentLyricsEffectSettings = _settingsService.AppSettings.DesktopLyricsEffectSettings;
LiveStates.CurrentLyricsDisplayType = _settingsService.AppSettings.DesktopModeSettings.LyricsDisplayType;
break;
case LyricsWindowMode.PictureInPictureMode:
LiveStates.CurrentLyricsStyleSettings = _settingsService.AppSettings.PictureInPictureLyricsStyleSettings;
LiveStates.CurrentLyricsEffectSettings = _settingsService.AppSettings.PictureInPictureLyricsEffectSettings;
LiveStates.CurrentLyricsDisplayType = _settingsService.AppSettings.PictureInPictureModeSettings.LyricsDisplayType;
break;
default:
break;
}
}
}
}
}
}

View File

@@ -173,17 +173,23 @@ namespace BetterLyrics.WinUI3.Services.LyricsSearchService
{
if (Directory.Exists(folder.Path) && folder.IsEnabled)
{
foreach (var file in Directory.GetFiles(folder.Path, $"*{format.ToFileExtension()}", SearchOption.AllDirectories))
try
{
if (FileHelper.IsSwitchableNormalizedMatch(Path.GetFileNameWithoutExtension(file), title, artist))
foreach (var file in Directory.GetFiles(folder.Path, $"*{format.ToFileExtension()}", SearchOption.AllDirectories))
{
string? raw = await File.ReadAllTextAsync(file, FileHelper.GetEncoding(file));
if (raw != null)
if (FileHelper.IsSwitchableNormalizedMatch(Path.GetFileNameWithoutExtension(file), title, artist))
{
return raw;
string? raw = await File.ReadAllTextAsync(file, FileHelper.GetEncoding(file));
if (raw != null)
{
return raw;
}
}
}
}
catch (Exception)
{
}
}
}
return null;
@@ -195,24 +201,30 @@ namespace BetterLyrics.WinUI3.Services.LyricsSearchService
{
if (Directory.Exists(folder.Path) && folder.IsEnabled)
{
foreach (var file in Directory.GetFiles(folder.Path, $"*.*", SearchOption.AllDirectories))
try
{
var track = new Track(file);
if ((track.Title == title && track.Artist == artist) || FileHelper.IsSwitchableNormalizedMatch(Path.GetFileNameWithoutExtension(file), title, artist))
foreach (var file in Directory.GetFiles(folder.Path, $"*.*", SearchOption.AllDirectories))
{
try
var track = new Track(file);
if ((track.Title == title && track.Artist == artist) || FileHelper.IsSwitchableNormalizedMatch(Path.GetFileNameWithoutExtension(file), title, artist))
{
var plain = TagLib.File.Create(file).Tag.Lyrics;
if (!plain.IsNullOrEmpty())
try
{
var plain = TagLib.File.Create(file).Tag.Lyrics;
if (!plain.IsNullOrEmpty())
{
return plain;
}
}
catch (Exception)
{
return plain;
}
}
catch (Exception)
{
}
}
}
catch (Exception)
{
}
}
}
return null;

View File

@@ -71,10 +71,28 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
_logger = Ioc.Default.GetRequiredService<ILogger<MediaSessionsService>>();
_settingsService.AppSettings.MediaSourceProvidersInfo.ItemPropertyChanged += MediaSourceProvidersInfo_ItemPropertyChanged;
_settingsService.AppSettings.LocalMediaFolders.CollectionChanged += LocalMediaFolders_CollectionChanged;
_settingsService.AppSettings.LocalMediaFolders.ItemPropertyChanged += LocalMediaFolders_ItemPropertyChanged;
InitMediaManager();
}
private void LocalMediaFolders_ItemPropertyChanged(object? sender, ItemPropertyChangedEventArgs e)
{
_ = _albumArtRefreshRunner.RunAsync(async token =>
{
await UpdateAlbumArtRelated(token);
});
}
private void LocalMediaFolders_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
_ = _albumArtRefreshRunner.RunAsync(async token =>
{
await UpdateAlbumArtRelated(token);
});
}
private void MediaSourceProvidersInfo_ItemPropertyChanged(object? sender, ItemPropertyChangedEventArgs e)
{
switch (e.PropertyName)

View File

@@ -32,14 +32,17 @@ namespace BetterLyrics.WinUI3.Services.SettingsService
AppSettings.StandardModeSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.DesktopModeSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.DockModeSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.PictureInPictureModeSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.StandardLyricsStyleSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.DesktopLyricsStyleSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.DockLyricsStyleSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.PictureInPictureLyricsStyleSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.StandardLyricsEffectSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.DesktopLyricsEffectSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.DockLyricsEffectSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.PictureInPictureLyricsEffectSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.LyricsBackgroundSettings.PropertyChanged += AppSettings_PropertyChanged;
AppSettings.AlbumArtLayoutSettings.PropertyChanged += AppSettings_PropertyChanged;

View File

@@ -129,6 +129,9 @@
<data name="AllLyricsSettingsControlDock.Content" xml:space="preserve">
<value>Dock mode</value>
</data>
<data name="AllLyricsSettingsControlPictureInPicture.Content" xml:space="preserve">
<value>Picture-in-picture mode</value>
</data>
<data name="AllLyricsSettingsControlStandard.Content" xml:space="preserve">
<value>Standard</value>
</data>

View File

@@ -129,6 +129,9 @@
<data name="AllLyricsSettingsControlDock.Content" xml:space="preserve">
<value>ドックモード</value>
</data>
<data name="AllLyricsSettingsControlPictureInPicture.Content" xml:space="preserve">
<value>ピクチャーインピクチャーモード</value>
</data>
<data name="AllLyricsSettingsControlStandard.Content" xml:space="preserve">
<value>標準モード</value>
</data>

View File

@@ -129,6 +129,9 @@
<data name="AllLyricsSettingsControlDock.Content" xml:space="preserve">
<value>도크 모드</value>
</data>
<data name="AllLyricsSettingsControlPictureInPicture.Content" xml:space="preserve">
<value>사진 인당 모드</value>
</data>
<data name="AllLyricsSettingsControlStandard.Content" xml:space="preserve">
<value>표준 모드</value>
</data>

View File

@@ -129,6 +129,9 @@
<data name="AllLyricsSettingsControlDock.Content" xml:space="preserve">
<value>停靠模式</value>
</data>
<data name="AllLyricsSettingsControlPictureInPicture.Content" xml:space="preserve">
<value>画中画模式</value>
</data>
<data name="AllLyricsSettingsControlStandard.Content" xml:space="preserve">
<value>标准模式</value>
</data>

View File

@@ -129,6 +129,9 @@
<data name="AllLyricsSettingsControlDock.Content" xml:space="preserve">
<value>停靠模式</value>
</data>
<data name="AllLyricsSettingsControlPictureInPicture.Content" xml:space="preserve">
<value>畫中畫模式</value>
</data>
<data name="AllLyricsSettingsControlStandard.Content" xml:space="preserve">
<value>標準模式</value>
</data>

View File

@@ -1,6 +1,11 @@
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Enums;
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Services.LiveStatesService;
using BetterLyrics.WinUI3.Services.SettingsService;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,17 +14,33 @@ using System.Threading.Tasks;
namespace BetterLyrics.WinUI3.ViewModels
{
public partial class AllLyricsSettingsControlViewModel : BaseViewModel
public partial class AllLyricsSettingsControlViewModel : BaseViewModel,
IRecipient<PropertyChangedMessage<LyricsWindowMode>>
{
private readonly ISettingsService _settingsService;
[ObservableProperty]
public partial AppSettings AppSettings { get; set; }
[ObservableProperty]
public partial int SelectedTabIndex { get; set; } = 0;
public AllLyricsSettingsControlViewModel(ISettingsService settingsService)
{
_settingsService = settingsService;
AppSettings = _settingsService.AppSettings;
}
public void Receive(PropertyChangedMessage<LyricsWindowMode> message)
{
if (message.Sender is LiveStates)
{
if (message.PropertyName == nameof(LiveStates.CurrentLyricsWindowMode))
{
SelectedTabIndex = (int)message.NewValue;
}
}
}
}
}

View File

@@ -4,6 +4,7 @@ using BetterLyrics.WinUI3.Enums;
using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Services.LiveStatesService;
using BetterLyrics.WinUI3.Services.MediaSessionsService;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.Views;
@@ -23,27 +24,22 @@ namespace BetterLyrics.WinUI3.ViewModels
{
public partial class LyricsPageViewModel : BaseViewModel,
IRecipient<PropertyChangedMessage<bool>>,
IRecipient<PropertyChangedMessage<int>>,
IRecipient<PropertyChangedMessage<string>>,
IRecipient<PropertyChangedMessage<TimeSpan>>
{
private readonly IMediaSessionsService _mediaSessionsService;
private readonly ISettingsService _settingsService;
private readonly ILiveStatesService _liveStatesService;
private readonly ThrottleHelper _timelineThrottle = new(TimeSpan.FromSeconds(1));
private bool _isDockMode = false;
private bool _isDesktopMode = false;
public LyricsPageViewModel(ISettingsService settingsService, IMediaSessionsService mediaSessionsService)
public LyricsPageViewModel(ISettingsService settingsService, IMediaSessionsService mediaSessionsService, ILiveStatesService liveStatesService)
{
_settingsService = settingsService;
IsTranslationEnabled = _settingsService.AppSettings.TranslationSettings.IsTranslationEnabled;
DisplayType = _settingsService.AppSettings.GeneralSettings.DisplayType;
IsImmersiveMode = _settingsService.AppSettings.GeneralSettings.IsImmersiveMode;
ShowTranslationOnly = _settingsService.AppSettings.TranslationSettings.ShowTranslationOnly;
_liveStatesService = liveStatesService;
UpdateLyricsStyleSettings();
LiveStates = _liveStatesService.LiveStates;
IsImmersiveMode = _settingsService.AppSettings.GeneralSettings.IsImmersiveMode;
OnIsImmersiveModeChanged(IsImmersiveMode);
@@ -79,6 +75,9 @@ namespace BetterLyrics.WinUI3.ViewModels
SongDurationSeconds = SongInfo?.Duration ?? 0;
}
[ObservableProperty]
public partial LiveStates LiveStates { get; set; }
[ObservableProperty]
public partial double TimelinePositionSeconds { get; set; }
@@ -97,74 +96,17 @@ namespace BetterLyrics.WinUI3.ViewModels
[ObservableProperty]
public partial double BottomCommandFlyoutTriggerOpacity { get; set; }
[ObservableProperty]
[NotifyPropertyChangedRecipients]
public partial LyricsDisplayType DisplayType { get; set; }
[ObservableProperty]
public partial SongInfo? SongInfo { get; set; } = null;
[ObservableProperty]
[NotifyPropertyChangedRecipients]
public partial bool IsTranslationEnabled { get; set; }
[ObservableProperty]
[NotifyPropertyChangedRecipients]
public partial bool ShowTranslationOnly { get; set; }
[ObservableProperty]
public partial bool IsSongPlaying { get; set; }
[ObservableProperty]
public partial LyricsStyleSettings LyricsStyleSettings { get; set; }
private void UpdateLyricsStyleSettings()
{
if (_isDockMode)
{
LyricsStyleSettings = _settingsService.AppSettings.DockLyricsStyleSettings;
}
else if (_isDesktopMode)
{
LyricsStyleSettings = _settingsService.AppSettings.DesktopLyricsStyleSettings;
}
else
{
LyricsStyleSettings = _settingsService.AppSettings.StandardLyricsStyleSettings;
}
}
public void Receive(PropertyChangedMessage<bool> message)
{
if (message.Sender is LyricsWindowViewModel)
{
if (message.PropertyName == nameof(LyricsWindowViewModel.IsDockMode))
{
_isDockMode = message.NewValue;
if (message.NewValue)
{
DisplayType = LyricsDisplayType.LyricsOnly;
}
else
{
DisplayType = _settingsService.AppSettings.GeneralSettings.DisplayType;
}
UpdateLyricsStyleSettings();
}
else if (message.PropertyName == nameof(LyricsWindowViewModel.IsDesktopMode))
{
_isDesktopMode = message.NewValue;
if (message.NewValue)
{
DisplayType = LyricsDisplayType.LyricsOnly;
}
else
{
DisplayType = _settingsService.AppSettings.GeneralSettings.DisplayType;
}
UpdateLyricsStyleSettings();
}
else if (message.PropertyName == nameof(LyricsWindowViewModel.IsImmersiveMode))
if (message.PropertyName == nameof(LyricsWindowViewModel.IsImmersiveMode))
{
IsImmersiveMode = message.NewValue;
}
@@ -201,11 +143,6 @@ namespace BetterLyrics.WinUI3.ViewModels
await _mediaSessionsService.NextAsync();
}
partial void OnIsTranslationEnabledChanged(bool value)
{
_settingsService.AppSettings.TranslationSettings.IsTranslationEnabled = value;
}
partial void OnIsImmersiveModeChanged(bool value)
{
if (value)
@@ -220,33 +157,6 @@ namespace BetterLyrics.WinUI3.ViewModels
}
}
partial void OnShowTranslationOnlyChanged(bool value)
{
_settingsService.AppSettings.TranslationSettings.ShowTranslationOnly = value;
}
public void Receive(PropertyChangedMessage<int> message)
{
if (message.Sender is LyricsStyleSettings)
{
if (message.PropertyName == nameof(LyricsStyleSettings.LyricsFontSize))
{
UpdateLyricsStyleSettings();
}
}
}
public void Receive(PropertyChangedMessage<string> message)
{
if (message.Sender is LyricsStyleSettings)
{
if (message.PropertyName == nameof(LyricsStyleSettings.LyricsFontFamily))
{
UpdateLyricsStyleSettings();
}
}
}
//partial void OnVolumeChanged(int value)
//{
// SystemVolumeHelper.SetMasterVolume(value);

View File

@@ -3,6 +3,7 @@ using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Services.LastFMService;
using BetterLyrics.WinUI3.Services.LibWatcherService;
using BetterLyrics.WinUI3.Services.LiveStatesService;
using BetterLyrics.WinUI3.Services.LyricsSearchService;
using BetterLyrics.WinUI3.Services.MediaSessionsService;
using BetterLyrics.WinUI3.Services.SettingsService;
@@ -22,7 +23,8 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
ILyricsSearchService musicSearchService,
ILibWatcherService libWatcherService,
ITranslateService libreTranslateService,
ILastFMService lastFMService
ILastFMService lastFMService,
ILiveStatesService liveStatesService
)
{
_settingsService = settingsService;
@@ -30,6 +32,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
_mediaSessionsService = mediaSessionsService;
_libWatcherService = libWatcherService;
_translateService = libreTranslateService;
_liveStatesService = liveStatesService;
_lastFMService = lastFMService;
@@ -41,15 +44,10 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
_settingsService.AppSettings.LocalMediaFolders.CollectionChanged += LocalMediaFolders_CollectionChanged;
_settingsService.AppSettings.LocalMediaFolders.ItemPropertyChanged += LocalMediaFolders_ItemPropertyChanged;
_lyricsStyleSettings = _settingsService.AppSettings.StandardLyricsStyleSettings;
_lyricsEffectSettings = _settingsService.AppSettings.StandardLyricsEffectSettings;
_titleTextFormat.HorizontalAlignment = _artistTextFormat.HorizontalAlignment = _settingsService.AppSettings.AlbumArtLayoutSettings.SongInfoAlignmentType.ToCanvasHorizontalAlignment();
_timelineSyncThreshold = 0;
_displayType = _displayTypeReceived = _settingsService.AppSettings.GeneralSettings.DisplayType;
_libWatcherService.MusicLibraryFilesChanged += LibWatcherService_MusicLibraryFilesChanged;
_mediaSessionsService.IsPlayingChanged += PlaybackService_IsPlayingChanged;

View File

@@ -33,18 +33,23 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
using var combined = new CanvasCommandList(control);
using var combinedDs = combined.CreateDrawingSession();
if (_isDockMode)
switch (_liveStatesService.LiveStates.CurrentLyricsWindowMode)
{
FillBackground(control, combinedDs, _immersiveBgColorTransition.Value, 0f, _immersiveBgOpacityTransition.Value * _settingsService.AppSettings.LyricsBackgroundSettings.PureColorOverlayOpacity / 100f);
}
else if (_isDesktopMode)
{
FillBackground(control, combinedDs, _immersiveBgColorTransition.Value, 0f, _immersiveBgOpacityTransition.Value * _settingsService.AppSettings.LyricsBackgroundSettings.PureColorOverlayOpacity / 100f);
}
else
{
FillBackground(control, combinedDs, _albumArtAccentColorTransition.Value, 0f, _settingsService.AppSettings.LyricsBackgroundSettings.PureColorOverlayOpacity / 100.0);
DrawAlbumArtBackground(control, combinedDs);
case LyricsWindowMode.DockMode:
FillBackground(control, combinedDs, _immersiveBgColorTransition.Value, 0f,
_immersiveBgOpacityTransition.Value * _settingsService.AppSettings.LyricsBackgroundSettings.PureColorOverlayOpacity / 100f);
break;
case LyricsWindowMode.DesktopMode:
FillBackground(control, combinedDs, _immersiveBgColorTransition.Value, 0f,
_immersiveBgOpacityTransition.Value * _settingsService.AppSettings.LyricsBackgroundSettings.PureColorOverlayOpacity / 100f);
break;
case LyricsWindowMode.StandardMode:
case LyricsWindowMode.PictureInPictureMode:
FillBackground(control, combinedDs, _albumArtAccentColorTransition.Value, 0f, _settingsService.AppSettings.LyricsBackgroundSettings.PureColorOverlayOpacity / 100.0);
DrawAlbumArtBackground(control, combinedDs);
break;
default:
break;
}
combinedDs.DrawImage(blurredLyrics);
@@ -237,7 +242,8 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
// Mock gradient blurred lyrics layer
// 先铺一层带默认透明度的已经加了模糊效果的歌词作为最底层(背景歌词层次)
// Current line will not be blurred
using var backgroundFontEffect = CanvasHelper.CreateFontEffect(line, control, _strokeFontColor, _lyricsStyleSettings.LyricsFontStrokeWidth, _bgFontColor);
using var backgroundFontEffect = CanvasHelper.CreateFontEffect(line, control, _strokeFontColor,
_liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsFontStrokeWidth, _bgFontColor);
using var backgroundEffect = CanvasHelper.CreateBackgroundEffect(line, backgroundFontEffect, _lyricsOpacityTransition.Value);
combinedDs.DrawImage(backgroundEffect);
@@ -247,26 +253,33 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
GetLinePlayingProgress(i, out int charStartIndex, out int charLength, out double charProgress);
using var charMask = CanvasHelper.CreateCharMask(control, line, charStartIndex, charLength, charProgress);
using var lineStartToCharMask = CanvasHelper.CreateLineStartToCharMask(control, line, charStartIndex, charLength, charProgress, _lyricsEffectSettings.IsLyricsLineFadeEnabled);
using var lineStartToCharMask = CanvasHelper.CreateLineStartToCharMask(control, line, charStartIndex, charLength, charProgress,
_liveStatesService.LiveStates.CurrentLyricsEffectSettings.IsLyricsLineFadeEnabled);
using var lineMask = CanvasHelper.CreateLineMask(control, line);
using var foregroundFontEffect = CanvasHelper.CreateFontEffect(line, control, _strokeFontColor, _lyricsStyleSettings.LyricsFontStrokeWidth, _bgFontColor);
using var foregroundFontEffect = CanvasHelper.CreateFontEffect(line, control, _strokeFontColor,
_liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsFontStrokeWidth, _bgFontColor);
using var effectLayer = new CanvasCommandList(control);
using var effectLayerDs = effectLayer.CreateDrawingSession();
if (_lyricsEffectSettings.IsLyricsShadowEnabled)
if (_liveStatesService.LiveStates.CurrentLyricsEffectSettings.IsLyricsShadowEnabled)
{
var shadowEffectMask = CanvasHelper.GetAlphaMask(control, charMask, lineStartToCharMask, lineMask, _lyricsEffectSettings.LyricsShadowScope);
using var foregroundShadowEffect = CanvasHelper.CreateForegroundShadowEffect(foregroundFontEffect, shadowEffectMask, _albumArtAccentColorTransition.Value, _lyricsEffectSettings.LyricsShadowAmount);
var shadowEffectMask = CanvasHelper.GetAlphaMask(control, charMask, lineStartToCharMask, lineMask,
_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsShadowScope);
using var foregroundShadowEffect = CanvasHelper.CreateForegroundShadowEffect(foregroundFontEffect, shadowEffectMask,
_albumArtAccentColorTransition.Value, _liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsShadowAmount);
effectLayerDs.DrawImage(foregroundShadowEffect);
}
if (_lyricsEffectSettings.IsLyricsGlowEffectEnabled)
if (_liveStatesService.LiveStates.CurrentLyricsEffectSettings.IsLyricsGlowEffectEnabled)
{
var blurEffectMask = CanvasHelper.GetAlphaMask(control, charMask, lineStartToCharMask, lineMask, _lyricsEffectSettings.LyricsGlowEffectScope);
using var foregroundBlurEffect = CanvasHelper.CreateForegroundBlurEffect(foregroundFontEffect, blurEffectMask, _lyricsEffectSettings.LyricsGlowEffectAmount);
var blurEffectMask = CanvasHelper.GetAlphaMask(control, charMask, lineStartToCharMask, lineMask,
_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsGlowEffectScope);
using var foregroundBlurEffect = CanvasHelper.CreateForegroundBlurEffect(foregroundFontEffect, blurEffectMask,
_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsGlowEffectAmount);
effectLayerDs.DrawImage(foregroundBlurEffect);
}
var highlightEffectMask = CanvasHelper.GetAlphaMask(control, charMask, lineStartToCharMask, lineMask, _lyricsEffectSettings.LyricsHighlightScope);
var highlightEffectMask = CanvasHelper.GetAlphaMask(control, charMask, lineStartToCharMask, lineMask,
_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsHighlightScope);
using var foregroundHighlightEffect = CanvasHelper.CreateForegroundHighlightEffect(foregroundFontEffect, highlightEffectMask);
effectLayerDs.DrawImage(foregroundHighlightEffect);
@@ -278,7 +291,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
if (i == _playingLineIndex)
{
if (_lyricsEffectSettings.IsLyricsFloatAnimationEnabled)
if (_liveStatesService.LiveStates.CurrentLyricsEffectSettings.IsLyricsFloatAnimationEnabled)
{
ds.DrawImage(new DisplacementMapEffect
{
@@ -286,7 +299,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
Displacement = lineStartToCharMask,
XChannelSelect = EffectChannelSelect.Red,
YChannelSelect = EffectChannelSelect.Alpha,
Amount = _lyricsEffectSettings.LyricsFloatAmount,
Amount = _liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsFloatAmount,
});
}
else

View File

@@ -20,6 +20,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
IRecipient<PropertyChangedMessage<double>>,
IRecipient<PropertyChangedMessage<bool>>,
IRecipient<PropertyChangedMessage<Color>>,
IRecipient<PropertyChangedMessage<LyricsWindowMode>>,
IRecipient<PropertyChangedMessage<LyricsDisplayType>>,
IRecipient<PropertyChangedMessage<LyricsFontColorType>>,
IRecipient<PropertyChangedMessage<TextAlignmentType>>,
@@ -70,21 +71,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
}
else if (message.Sender is LyricsWindowViewModel)
{
if (message.PropertyName == nameof(LyricsWindowViewModel.IsDockMode))
{
_isDockMode = message.NewValue;
UpdateColorConfig();
UpdateImmersiveBackgroundOpacity();
_isLayoutChanged = true;
}
else if (message.PropertyName == nameof(LyricsWindowViewModel.IsDesktopMode))
{
_isDesktopMode = message.NewValue;
UpdateColorConfig();
UpdateImmersiveBackgroundOpacity();
_isLayoutChanged = true;
}
else if (message.PropertyName == nameof(LyricsWindowViewModel.IsLyricsWindowLocked))
if (message.PropertyName == nameof(LyricsWindowViewModel.IsLyricsWindowLocked))
{
_isLyricsWindowLocked = message.NewValue;
UpdateImmersiveBackgroundOpacity();
@@ -281,7 +268,13 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
public void Receive(PropertyChangedMessage<LyricsDisplayType> message)
{
_displayTypeReceived = message.NewValue;
if (message.Sender is LiveStates)
{
if (message.PropertyName == nameof(LiveStates.CurrentLyricsDisplayType))
{
_isDisplayTypeChanged = true;
}
}
}
public void Receive(PropertyChangedMessage<LyricsFontColorType> message)
@@ -350,5 +343,18 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
}
}
}
public void Receive(PropertyChangedMessage<LyricsWindowMode> message)
{
if (message.Sender is LiveStates)
{
if (message.PropertyName == nameof(LiveStates.CurrentLyricsWindowMode))
{
UpdateColorConfig();
UpdateImmersiveBackgroundOpacity();
_isLayoutChanged = true;
}
}
}
}
}

View File

@@ -74,10 +74,6 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
_isCanvasHeightChanged = _canvasHeight != control.Size.Height;
_canvasHeight = control.Size.Height;
// 检测 DisplayType 变更
_isDisplayTypeChanged = _displayType != _displayTypeReceived;
_displayType = _displayTypeReceived;
if (_isDebugOverlayEnabledChanged)
{
if (_isDebugOverlayEnabled)
@@ -123,7 +119,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
_albumArtYTransition.StartTransition((_canvasHeight - _albumArtSize * 1.05 - _titleTextFormat.FontSize - _artistTextFormat.FontSize) / 2.0, jumpTo);
_titleYTransition.StartTransition(_albumArtYTransition.TargetValue + _albumArtSize * 1.05, jumpTo);
_lyricsYTransition.StartTransition(0, jumpTo);
switch (_displayType)
switch (_liveStatesService.LiveStates.CurrentLyricsDisplayType)
{
case LyricsDisplayType.AlbumArtOnly:
_lyricsOpacityTransition.StartTransition(0f, jumpTo);
@@ -152,7 +148,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
_lyricsXTransition.StartTransition(_leftMargin, jumpTo);
_albumArtXTransition.StartTransition(_leftMargin, jumpTo);
_titleXTransition.StartTransition(_leftMargin + _albumArtSize * 1.2, jumpTo);
switch (_displayType)
switch (_liveStatesService.LiveStates.CurrentLyricsDisplayType)
{
case LyricsDisplayType.AlbumArtOnly:
_lyricsOpacityTransition.StartTransition(0f, jumpTo);
@@ -179,6 +175,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
default:
break;
}
_isDisplayTypeChanged = false;
}
// 先重置这两个的变化状态
@@ -329,28 +326,12 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
if (control == null)
return;
if (_isDockMode)
{
_lyricsStyleSettings = _settingsService.AppSettings.DockLyricsStyleSettings;
_lyricsEffectSettings = _settingsService.AppSettings.DockLyricsEffectSettings;
}
else if (_isDesktopMode)
{
_lyricsStyleSettings = _settingsService.AppSettings.DesktopLyricsStyleSettings;
_lyricsEffectSettings = _settingsService.AppSettings.DesktopLyricsEffectSettings;
}
else
{
_lyricsStyleSettings = _settingsService.AppSettings.StandardLyricsStyleSettings;
_lyricsEffectSettings = _settingsService.AppSettings.StandardLyricsEffectSettings;
}
_lyricsTextFormat.FontSize = _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsFontSize;
_lyricsTextFormat.FontWeight = _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsFontWeight.ToFontWeight();
_lyricsTextFormat.FontFamily = _artistTextFormat.FontFamily = _titleTextFormat.FontFamily = _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsFontFamily;
_lyricsTextFormat.FontSize = _lyricsStyleSettings.LyricsFontSize;
_lyricsTextFormat.FontWeight = _lyricsStyleSettings.LyricsFontWeight.ToFontWeight();
_lyricsTextFormat.FontFamily = _artistTextFormat.FontFamily = _titleTextFormat.FontFamily = _lyricsStyleSettings.LyricsFontFamily;
_canvasYScrollTransition.SetDuration(_lyricsEffectSettings.LyricsScrollDuration / 1000.0);
_canvasYScrollTransition.SetEasingType(_lyricsEffectSettings.LyricsScrollEasingType);
_canvasYScrollTransition.SetDuration(_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsScrollDuration / 1000.0);
_canvasYScrollTransition.SetEasingType(_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsScrollEasingType);
double y = 0;
@@ -365,15 +346,15 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
}
line.Position = new Vector2(0, (float)y);
line.RecreateTextLayout(control, _lyricsTextFormat, _maxLyricsWidth, _canvasHeight, _lyricsStyleSettings.LyricsAlignmentType);
line.UpdateCenterPosition(_maxLyricsWidth, _lyricsStyleSettings.LyricsAlignmentType);
line.RecreateTextLayout(control, _lyricsTextFormat, _maxLyricsWidth, _canvasHeight, _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsAlignmentType);
line.UpdateCenterPosition(_maxLyricsWidth, _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsAlignmentType);
line.RecreateTextGeometry();
y +=
(double)line.CanvasTextLayout!.LayoutBounds.Height
/ line.CanvasTextLayout.LineCount
* (line.CanvasTextLayout.LineCount + _lyricsStyleSettings.LyricsLineSpacingFactor);
* (line.CanvasTextLayout.LineCount + _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsLineSpacingFactor);
}
}
@@ -470,7 +451,8 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
private void UpdateColorConfig()
{
if (_isDesktopMode || _isDockMode)
if (_liveStatesService.LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode ||
_liveStatesService.LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DockMode)
{
ThemeTypeSent = Helper.ColorHelper.GetElementThemeFromBackgroundColor(_environmentalColor);
}
@@ -506,7 +488,8 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
_lyricsBgBrightnessTransition.StartTransition(brightness);
if (_isDesktopMode || _isDockMode)
if (_liveStatesService.LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DockMode ||
_liveStatesService.LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode)
{
_adaptiveColoredFontColor = Helper.ColorHelper.GetForegroundColor(_environmentalColor);
}
@@ -522,7 +505,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
}
}
switch (_lyricsStyleSettings.LyricsBgFontColorType)
switch (_liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsBgFontColorType)
{
case LyricsFontColorType.AdaptiveGrayed:
_bgFontColor = _adaptiveGrayedFontColor;
@@ -531,13 +514,13 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
_bgFontColor = _adaptiveColoredFontColor ?? _adaptiveGrayedFontColor;
break;
case LyricsFontColorType.Custom:
_bgFontColor = _lyricsStyleSettings.LyricsCustomBgFontColor;
_bgFontColor = _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsCustomBgFontColor;
break;
default:
break;
}
switch (_lyricsStyleSettings.LyricsFgFontColorType)
switch (_liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsFgFontColorType)
{
case LyricsFontColorType.AdaptiveGrayed:
_fgFontColor = _adaptiveGrayedFontColor;
@@ -546,13 +529,13 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
_fgFontColor = _adaptiveColoredFontColor ?? _adaptiveGrayedFontColor;
break;
case LyricsFontColorType.Custom:
_fgFontColor = _lyricsStyleSettings.LyricsCustomFgFontColor;
_fgFontColor = _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsCustomFgFontColor;
break;
default:
break;
}
switch (_lyricsStyleSettings.LyricsStrokeFontColorType)
switch (_liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsStrokeFontColorType)
{
case LyricsFontColorType.AdaptiveGrayed:
_strokeFontColor = _grayedEnvironmentalColor.WithBrightness(0.7);
@@ -561,7 +544,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
_strokeFontColor = _environmentalColor.WithBrightness(0.7);
break;
case LyricsFontColorType.Custom:
_strokeFontColor = _lyricsStyleSettings.LyricsCustomStrokeFontColor;
_strokeFontColor = _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsCustomStrokeFontColor;
break;
default:
break;
@@ -591,7 +574,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
double distanceFromPlayingLine = Math.Abs(line.Position.Y - currentPlayingLine.Position.Y);
double distanceFactor = Math.Clamp(distanceFromPlayingLine / (_canvasHeight / 2), 0, 1);
line.AngleTransition.StartTransition(_lyricsEffectSettings.IsFanLyricsEnabled
line.AngleTransition.StartTransition(_liveStatesService.LiveStates.CurrentLyricsEffectSettings.IsFanLyricsEnabled
? Math.PI
* (30.0 / 180.0)
* distanceFactor
@@ -599,15 +582,20 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
: 0
);
line.BlurAmountTransition.StartTransition(_lyricsEffectSettings.LyricsBlurAmount * distanceFactor);
line.BlurAmountTransition.StartTransition(_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsBlurAmount * distanceFactor);
line.ScaleTransition.StartTransition(_highlightedScale - distanceFactor * (_highlightedScale - _defaultScale));
line.OpacityTransition.StartTransition(_lyricsStyleSettings.LyricsBgFontOpacity / 100.0 - distanceFactor * _lyricsStyleSettings.LyricsBgFontOpacity / 100.0 * (1 - _lyricsEffectSettings.LyricsVerticalEdgeOpacity / 100.0));
line.OpacityTransition.StartTransition(
_liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsBgFontOpacity / 100.0 -
distanceFactor * _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsBgFontOpacity / 100.0 *
(1 - _liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsVerticalEdgeOpacity / 100.0));
line.HighlightOpacityTransition.StartTransition(i == _playingLineIndex ? 1f : 0f);
double yScrollDuration;
if (lineCountDelta < 0)
{
yScrollDuration = _canvasYScrollTransition.DurationSeconds + distanceFactor * (_lyricsEffectSettings.LyricsScrollTopDuration / 1000.0 - _canvasYScrollTransition.DurationSeconds);
yScrollDuration =
_canvasYScrollTransition.DurationSeconds +
distanceFactor * (_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsScrollTopDuration / 1000.0 - _canvasYScrollTransition.DurationSeconds);
}
else if (lineCountDelta == 0)
{
@@ -615,7 +603,9 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
}
else
{
yScrollDuration = _canvasYScrollTransition.DurationSeconds + distanceFactor * (_lyricsEffectSettings.LyricsScrollBottomDuration / 1000.0 - _canvasYScrollTransition.DurationSeconds);
yScrollDuration =
_canvasYScrollTransition.DurationSeconds +
distanceFactor * (_liveStatesService.LiveStates.CurrentLyricsEffectSettings.LyricsScrollBottomDuration / 1000.0 - _canvasYScrollTransition.DurationSeconds);
}
line.YOffsetTransition.SetEasingType(_canvasYScrollTransition.EasingType ?? EasingType.Linear);
@@ -635,7 +625,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
private void UpdateImmersiveBackgroundOpacity()
{
double targetOpacity;
if (_isDesktopMode)
if (_liveStatesService.LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode)
{
if (_isLyricsWindowLocked)
{

View File

@@ -8,6 +8,7 @@ using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Services;
using BetterLyrics.WinUI3.Services.LastFMService;
using BetterLyrics.WinUI3.Services.LibWatcherService;
using BetterLyrics.WinUI3.Services.LiveStatesService;
using BetterLyrics.WinUI3.Services.LyricsSearchService;
using BetterLyrics.WinUI3.Services.MediaSessionsService;
using BetterLyrics.WinUI3.Services.SettingsService;
@@ -36,9 +37,6 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
[ObservableProperty]
public partial AppSettings AppSettings { get; set; }
private LyricsStyleSettings _lyricsStyleSettings;
private LyricsEffectSettings _lyricsEffectSettings;
private bool _isLastFMTrackEnabled = false;
private bool _isLastFMTracked = false;
private TimeSpan _totalPlayingTime = TimeSpan.Zero;
@@ -105,6 +103,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
private readonly IMediaSessionsService _mediaSessionsService;
private readonly ITranslateService _translateService;
private readonly ILastFMService _lastFMService;
private readonly ILiveStatesService _liveStatesService;
private readonly ILogger _logger;
private readonly double _leftMargin = 36f;
@@ -134,8 +133,6 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
private int _endVisibleLineIndex = -1;
private bool _isDebugOverlayEnabled = false;
private bool _isDesktopMode = false;
private bool _isDockMode = false;
[ObservableProperty]
public partial bool IsPlaying { get; set; } = false;
@@ -184,9 +181,6 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
private LatestOnlyTaskRunner _refreshLyricsRunner = new();
private LatestOnlyTaskRunner _showTranslationsRunner = new();
private LyricsDisplayType _displayTypeReceived;
private LyricsDisplayType _displayType;
private LyricsLayoutOrientation _lyricsLayoutOrientation;
[ObservableProperty]
@@ -482,7 +476,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
}
else
{
_lyricsDataArr[0].SetDisplayedTextAlongWith(_lyricsDataArr[found], _lyricsStyleSettings.LyricsTranslationSeparator, 50);
_lyricsDataArr[0].SetDisplayedTextAlongWith(_lyricsDataArr[found], _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsTranslationSeparator, 50);
_langIndex = 0;
}
TranslationSearchProvider = LyricsSearchProvider.ToTranslationSearchProvider();
@@ -504,7 +498,7 @@ namespace BetterLyrics.WinUI3.ViewModels.LyricsRendererViewModel
}
else
{
_lyricsDataArr[0].SetDisplayedTextAlongWith(translated, _lyricsStyleSettings.LyricsTranslationSeparator);
_lyricsDataArr[0].SetDisplayedTextAlongWith(translated, _liveStatesService.LiveStates.CurrentLyricsStyleSettings.LyricsTranslationSeparator);
_langIndex = 0;
}
TranslationSearchProvider = Enums.TranslationSearchProvider.LibreTranslate;

View File

@@ -4,6 +4,7 @@ using BetterLyrics.WinUI3.Enums;
using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Services.LiveStatesService;
using BetterLyrics.WinUI3.Services.MediaSessionsService;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.ViewModels;
@@ -35,6 +36,7 @@ namespace BetterLyrics.WinUI3
{
private readonly IMediaSessionsService _mediaSessionsService;
private readonly ISettingsService _settingsService;
private readonly ILiveStatesService _liveStatesService;
private ForegroundWindowWatcher? _windowWatcher = null;
private bool _ignoreFullscreenWindow;
@@ -44,10 +46,13 @@ namespace BetterLyrics.WinUI3
private int _dockWindowHeight;
private string _dockMonitorDeviceName;
public LyricsWindowViewModel(ISettingsService settingsService, IMediaSessionsService mediaSessionsService)
public LyricsWindowViewModel(ISettingsService settingsService, IMediaSessionsService mediaSessionsService, ILiveStatesService liveStatesService)
{
_settingsService = settingsService;
_mediaSessionsService = mediaSessionsService;
_liveStatesService = liveStatesService;
LiveStates = _liveStatesService.LiveStates;
_dockMonitorDeviceName = _settingsService.AppSettings.DockModeSettings.DockMonitorDeviceName;
_ignoreFullscreenWindow = _settingsService.AppSettings.GeneralSettings.IgnoreFullscreenWindow;
@@ -65,18 +70,13 @@ namespace BetterLyrics.WinUI3
UpdateDockOrDesktopWindow();
}
[ObservableProperty]
public partial LiveStates LiveStates { get; set; }
[ObservableProperty]
[NotifyPropertyChangedRecipients]
public partial Color ActivatedWindowAccentColor { get; set; }
[ObservableProperty]
[NotifyPropertyChangedRecipients]
public partial bool IsDesktopMode { get; set; } = false;
[ObservableProperty]
[NotifyPropertyChangedRecipients]
public partial bool IsDockMode { get; set; } = false;
[ObservableProperty]
[NotifyPropertyChangedRecipients]
public partial bool IsLyricsWindowLocked { get; set; } = false;
@@ -108,11 +108,11 @@ namespace BetterLyrics.WinUI3
var hwnd = WindowNative.GetWindowHandle(window);
if (IsDockMode || IsDesktopMode)
if (LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DockMode || LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode)
{
if (_hideWindowWhenNotPlaying && !_mediaSessionsService.IsPlaying)
{
if (IsDockMode)
if (LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DockMode)
{
DockModeHelper.UpdateAppBarHeight(hwnd, _dockMonitorDeviceName, 0, _dockPlacement);
}
@@ -120,7 +120,7 @@ namespace BetterLyrics.WinUI3
}
else
{
if (IsDockMode)
if (LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode)
{
DockModeHelper.UpdateAppBarHeight(hwnd, _dockMonitorDeviceName, _dockWindowHeight, _dockPlacement);
}
@@ -209,7 +209,7 @@ namespace BetterLyrics.WinUI3
(uint)(hotKeyIndex + (int)VirtualKey.A),
() =>
{
if (IsDesktopMode)
if (LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode)
{
ToggleLockWindowCommand.Execute(null);
}
@@ -230,7 +230,7 @@ namespace BetterLyrics.WinUI3
{
_dispatcherQueueTimer.Debounce(() =>
{
if ((IsDockMode || IsDesktopMode) && _ignoreFullscreenWindow && window.AppWindow.Presenter is OverlappedPresenter presenter)
if ((LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DockMode || LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode) && _ignoreFullscreenWindow && window.AppWindow.Presenter is OverlappedPresenter presenter)
{
presenter.IsAlwaysOnTop = true;
}
@@ -250,7 +250,7 @@ namespace BetterLyrics.WinUI3
public void UpdateAccentColor(nint hwnd)
{
WindowPixelSampleMode mode = IsDesktopMode ? WindowPixelSampleMode.WindowEdge : _dockPlacement.ToWindowPixelSampleMode();
WindowPixelSampleMode mode = LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode ? WindowPixelSampleMode.WindowEdge : _dockPlacement.ToWindowPixelSampleMode();
ActivatedWindowAccentColor = ColorHelper.GetAccentColor(hwnd, _settingsService.AppSettings.DockModeSettings.DockMonitorDeviceName, mode).ToColor();
}
@@ -302,8 +302,8 @@ namespace BetterLyrics.WinUI3
StopWatchWindowColorChange();
IsDesktopMode = !IsDesktopMode;
if (IsDesktopMode)
LiveStates.ToggleLyricsWindowMode(LyricsWindowMode.DesktopMode);
if (LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode)
{
DesktopModeHelper.Enable(window);
StartWatchWindowColorChange();
@@ -322,8 +322,8 @@ namespace BetterLyrics.WinUI3
StopWatchWindowColorChange();
IsDockMode = !IsDockMode;
if (IsDockMode)
LiveStates.ToggleLyricsWindowMode(LyricsWindowMode.DockMode);
if (LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DockMode)
{
window.Restore();
DockModeHelper.Enable(window, _dockMonitorDeviceName, _dockWindowHeight, _dockPlacement);

View File

@@ -35,6 +35,7 @@ namespace BetterLyrics.WinUI3.ViewModels
private readonly MediaPlayer _mediaPlayer = new();
private readonly MediaTimelineController _timelineController = new();
private readonly SystemMediaTransportControls _smtc;
// All songs
private List<Track> _tracks = [];
// Songs in current playlist
@@ -251,6 +252,10 @@ namespace BetterLyrics.WinUI3.ViewModels
RefreshSongs();
}
public void CancelRefreshSongs()
{
}
public void RefreshSongs()
{
_dispatcherQueueTimer.Debounce(() =>
@@ -264,11 +269,24 @@ namespace BetterLyrics.WinUI3.ViewModels
{
if (Directory.Exists(folder.Path) && folder.IsEnabled)
{
foreach (var file in Directory.GetFiles(folder.Path, $"*.*", SearchOption.AllDirectories))
try
{
foreach (var file in Directory.GetFiles(folder.Path, $"*.*", SearchOption.AllDirectories))
{
try
{
Track track = new(file);
if (track.Duration <= 0) continue;
_tracks.Add(track);
}
catch (Exception)
{
continue;
}
}
}
catch (Exception)
{
Track track = new(file);
if (track.Duration <= 0) continue;
_tracks.Add(track);
}
}
}

View File

@@ -29,8 +29,8 @@
x:Uid="MainPageNoMusicPlaying"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{x:Bind ViewModel.LyricsStyleSettings.LyricsFontFamily, Mode=OneWay}"
FontSize="{x:Bind ViewModel.LyricsStyleSettings.LyricsFontSize, Mode=OneWay}" />
FontFamily="{x:Bind ViewModel.LiveStates.CurrentLyricsStyleSettings.LyricsFontFamily, Mode=OneWay}"
FontSize="{x:Bind ViewModel.LiveStates.CurrentLyricsStyleSettings.LyricsFontSize, Mode=OneWay}" />
<Grid.OpacityTransition>
<ScalarTransition />
</Grid.OpacityTransition>
@@ -275,10 +275,10 @@
<Setter Property="CornerRadius" Value="8" />
</Style>
</Flyout.FlyoutPresenterStyle>
<RadioButtons MaxColumns="1" SelectedIndex="{x:Bind ViewModel.DisplayType, Mode=OneWay, Converter={StaticResource EnumToIntConverter}}">
<RadioButton x:Uid="MainPageAlbumArtOnly" Click="AlbumArtOnlyRadioButton_Click" />
<RadioButton x:Uid="MainPageLyriscOnly" Click="LyricsOnlyRadioButton_Click" />
<RadioButton x:Uid="MainPageSplitView" Click="SplitViewRadioButton_Click" />
<RadioButtons MaxColumns="1" SelectedIndex="{x:Bind ViewModel.LiveStates.CurrentLyricsDisplayType, Mode=OneWay, Converter={StaticResource EnumToIntConverter}}">
<RadioButton x:Uid="MainPageAlbumArtOnly" />
<RadioButton x:Uid="MainPageLyriscOnly" />
<RadioButton x:Uid="MainPageSplitView" />
</RadioButtons>
</Flyout>
</Button.ContextFlyout>

View File

@@ -30,24 +30,6 @@ namespace BetterLyrics.WinUI3.Views
DataContext = Ioc.Default.GetRequiredService<LyricsPageViewModel>();
}
private void LyricsOnlyRadioButton_Click(object sender, RoutedEventArgs e)
{
ViewModel.DisplayType = LyricsDisplayType.LyricsOnly;
_settingsService.AppSettings.GeneralSettings.DisplayType = ViewModel.DisplayType;
}
private void AlbumArtOnlyRadioButton_Click(object sender, RoutedEventArgs e)
{
ViewModel.DisplayType = LyricsDisplayType.AlbumArtOnly;
_settingsService.AppSettings.GeneralSettings.DisplayType = ViewModel.DisplayType;
}
private void SplitViewRadioButton_Click(object sender, RoutedEventArgs e)
{
ViewModel.DisplayType = LyricsDisplayType.SplitView;
_settingsService.AppSettings.GeneralSettings.DisplayType = ViewModel.DisplayType;
}
private void BottomCommandGrid_PointerEntered(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
{
if (ViewModel.IsImmersiveMode && BottomCommandGrid.Children.Count != 0)

View File

@@ -98,14 +98,14 @@
x:Name="DockFlyoutItem"
x:Uid="HostWindowDockFlyoutItem"
Click="DockFlyoutItem_Click"
Icon="{ui:FontIcon Glyph=&#xE66A;}"
IsChecked="{x:Bind ViewModel.IsDockMode, Mode=OneWay}" />
Icon="{ui:FontIcon Glyph=&#xE66A;}">
</ToggleMenuFlyoutItem>
<ToggleMenuFlyoutItem
x:Name="DesktopFlyoutItem"
x:Uid="HostWindowDesktopFlyoutItem"
Click="DesktopFlyoutItem_Click"
Icon="{ui:FontIcon Glyph=&#xE66C;}"
IsChecked="{x:Bind ViewModel.IsDesktopMode, Mode=OneWay}" />
Icon="{ui:FontIcon Glyph=&#xE66C;}">
</ToggleMenuFlyoutItem>
<ToggleMenuFlyoutItem
x:Name="MiniFlyoutItem"
x:Uid="BaseWindowMiniFlyoutItem"

View File

@@ -69,19 +69,19 @@ namespace BetterLyrics.WinUI3.Views
public LyricsWindowViewModel ViewModel { get; private set; } = Ioc.Default.GetRequiredService<LyricsWindowViewModel>();
public void AutoSelectLyricsMode(AutoStartWindowType? type = null, bool? autoLook = null)
public void AutoSelectLyricsMode(LyricsWindowMode? type = null, bool? autoLook = null)
{
type ??= _settingsService.AppSettings.GeneralSettings.AutoStartWindowType;
switch (type!)
{
case AutoStartWindowType.StandardMode:
case LyricsWindowMode.StandardMode:
AppWindow.MoveAndResize(_settingsService.AppSettings.StandardModeSettings.WindowBounds.ToRectInt32());
break;
case AutoStartWindowType.DockMode:
case LyricsWindowMode.DockMode:
DockFlyoutItem.IsChecked = true;
ViewModel.ToggleDockModeCommand.Execute(null);
break;
case AutoStartWindowType.DesktopMode:
case LyricsWindowMode.DesktopMode:
DesktopFlyoutItem.IsChecked = true;
ViewModel.ToggleDesktopModeCommand.Execute(null);
if (autoLook == null && _settingsService.AppSettings.DesktopModeSettings.AutoLockOnDesktopMode)
@@ -116,11 +116,11 @@ namespace BetterLyrics.WinUI3.Views
}
else
{
if (ViewModel.IsDesktopMode)
if (ViewModel.LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DesktopMode)
{
_settingsService.AppSettings.DesktopModeSettings.WindowBounds = new Windows.Foundation.Rect(rect.X, rect.Y, size.Width, size.Height);
}
else if (ViewModel.IsDockMode)
else if (ViewModel.LiveStates.CurrentLyricsWindowMode == LyricsWindowMode.DockMode)
{
}

View File

@@ -14,6 +14,7 @@
xmlns:models="using:BetterLyrics.WinUI3.Models"
xmlns:templateselector="using:BetterLyrics.WinUI3.TemplateSelector"
xmlns:ui="using:CommunityToolkit.WinUI"
Unloaded="Page_Unloaded"
mc:Ignorable="d">
<Page.Resources>
<CollectionViewSource

View File

@@ -177,5 +177,10 @@ namespace BetterLyrics.WinUI3.Views
ViewModel.PlayingSongIndex = ViewModel.PlayingSongIndex + 1;
ViewModel.PlayTrackAt(ViewModel.PlayingSongIndex);
}
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
ViewModel.CancelRefreshSongs();
}
}
}