mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 10:54:55 +08:00
fix
This commit is contained in:
@@ -69,11 +69,9 @@ namespace BetterLyrics.WinUI3
|
||||
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
// 先获取一个实例,确保初始化 LyricsWindowStatus
|
||||
var settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
|
||||
|
||||
// 设置托盘
|
||||
WindowHook.OpenOrShowWindow<SystemTrayWindow>();
|
||||
_ = new SystemTrayWindow();
|
||||
|
||||
if (settingsService.AppSettings.GeneralSettings.AutoStartLyricsWindow)
|
||||
{
|
||||
|
||||
@@ -71,12 +71,8 @@
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.AppSettings.MusicGallerySettings.AutoPlay, Mode=TwoWay}" />
|
||||
</dev:SettingsCard>
|
||||
|
||||
<dev:SettingsCard Header="[待实现] 音乐库打开状态下忽略其他播放源" HeaderIcon="{ui:FontIcon FontFamily={StaticResource IconFontFamily}, Glyph=}">
|
||||
<ToggleSwitch />
|
||||
</dev:SettingsCard>
|
||||
|
||||
<dev:SettingsCard Header="[待实现] 关闭音乐库窗口时退出程序" HeaderIcon="{ui:FontIcon FontFamily={StaticResource IconFontFamily}, Glyph=}">
|
||||
<ToggleSwitch />
|
||||
<dev:SettingsCard x:Uid="SettingsPageExitOnGalleryWindowClosed" HeaderIcon="{ui:FontIcon FontFamily={StaticResource IconFontFamily}, Glyph=}">
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.AppSettings.MusicGallerySettings.ExitOnWindowClosed, Mode=TwoWay}" />
|
||||
</dev:SettingsCard>
|
||||
|
||||
<!-- Lyrics window -->
|
||||
|
||||
@@ -252,15 +252,7 @@ namespace BetterLyrics.WinUI3.Controls
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<TimeSpan>>(this);
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<LyricsData?>>(this);
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<SongInfo?>>(this);
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<int>>(this);
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<double>>(this);
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<bool>>(this);
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<TextAlignmentType>>(this);
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<LyricsFontWeight>>(this);
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<string>>(this);
|
||||
WeakReferenceMessenger.Default.RegisterAll(this);
|
||||
|
||||
UpdateRenderLyricsLines();
|
||||
}
|
||||
|
||||
@@ -155,8 +155,15 @@
|
||||
<Grid.TranslationTransition>
|
||||
<Vector3Transition />
|
||||
</Grid.TranslationTransition>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Padding="36,0" Style="{StaticResource SettingsGridStyle}">
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
Padding="36,0"
|
||||
Style="{StaticResource SettingsGridStyle}">
|
||||
<StackPanel Spacing="{StaticResource SettingsCardSpacing}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -178,77 +185,31 @@
|
||||
Style="{StaticResource AccentButtonStyle}" />
|
||||
</Grid>
|
||||
|
||||
<Pivot x:Name="ConfigPivot" SelectionChanged="Pivot_SelectionChanged">
|
||||
<SelectorBar x:Name="ConfigSelectorBar" SelectionChanged="ConfigSelectorBar_SelectionChanged">
|
||||
|
||||
<PivotItem x:Name="WindowPivotItem" Tag="Window">
|
||||
<PivotItem.Header>
|
||||
<TextBlock
|
||||
x:Uid="AppSettingsControlGeneral"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource BodyTextBlockStyle}" />
|
||||
</PivotItem.Header>
|
||||
</PivotItem>
|
||||
<SelectorBarItem
|
||||
x:Name="WindowSelectorBarItem"
|
||||
x:Uid="AppSettingsControlGeneral"
|
||||
Tag="Window" />
|
||||
<SelectorBarItem
|
||||
x:Name="LayoutSelectorBarItem"
|
||||
x:Uid="SettingsPageLayout"
|
||||
Tag="Layout" />
|
||||
<SelectorBarItem
|
||||
x:Name="AlbumArtStyleSelectorBarItem"
|
||||
x:Uid="SettingsPageAlbumStyle"
|
||||
Tag="AlbumArtStyle" />
|
||||
<SelectorBarItem x:Uid="SettingsPageAlbumEffect" Tag="AlbumArtEffect" />
|
||||
<SelectorBarItem x:Uid="SettingsPageLyricsStyle" Tag="LyricsStyle" />
|
||||
<SelectorBarItem x:Uid="SettingsPageLyricsEffect" Tag="LyricsEffect" />
|
||||
<SelectorBarItem x:Uid="SettingsPageBackgroundOverlay" Tag="LyricsBackground" />
|
||||
|
||||
<PivotItem Tag="Layout">
|
||||
<PivotItem.Header>
|
||||
<TextBlock
|
||||
x:Uid="SettingsPageLayout"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource BodyTextBlockStyle}" />
|
||||
</PivotItem.Header>
|
||||
</PivotItem>
|
||||
|
||||
<PivotItem Tag="AlbumArtStyle">
|
||||
<PivotItem.Header>
|
||||
<TextBlock
|
||||
x:Uid="SettingsPageAlbumStyle"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource BodyTextBlockStyle}" />
|
||||
</PivotItem.Header>
|
||||
</PivotItem>
|
||||
|
||||
<PivotItem Tag="AlbumArtEffect">
|
||||
<PivotItem.Header>
|
||||
<TextBlock
|
||||
x:Uid="SettingsPageAlbumEffect"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource BodyTextBlockStyle}" />
|
||||
</PivotItem.Header>
|
||||
</PivotItem>
|
||||
|
||||
<PivotItem Tag="LyricsStyle">
|
||||
<PivotItem.Header>
|
||||
<TextBlock
|
||||
x:Uid="SettingsPageLyricsStyle"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource BodyTextBlockStyle}" />
|
||||
</PivotItem.Header>
|
||||
</PivotItem>
|
||||
|
||||
<PivotItem Tag="LyricsEffect">
|
||||
<PivotItem.Header>
|
||||
<TextBlock
|
||||
x:Uid="SettingsPageLyricsEffect"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource BodyTextBlockStyle}" />
|
||||
</PivotItem.Header>
|
||||
</PivotItem>
|
||||
|
||||
<PivotItem Tag="LyricsBackground">
|
||||
<PivotItem.Header>
|
||||
<TextBlock
|
||||
x:Uid="SettingsPageBackgroundOverlay"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource BodyTextBlockStyle}" />
|
||||
</PivotItem.Header>
|
||||
</PivotItem>
|
||||
|
||||
</Pivot>
|
||||
</SelectorBar>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<controls:SwitchPresenter Margin="0,110,0,0" Value="{x:Bind ViewModel.ListViewSelectedItemTag, Mode=OneWay}">
|
||||
<controls:SwitchPresenter Grid.Row="1" Value="{x:Bind ViewModel.SelectorBarSelectedItemTag, Mode=OneWay}">
|
||||
<controls:SwitchPresenter.ContentTransitions>
|
||||
<TransitionCollection>
|
||||
<PopupThemeTransition />
|
||||
|
||||
@@ -122,17 +122,6 @@ namespace BetterLyrics.WinUI3.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (sender is Pivot pivot)
|
||||
{
|
||||
if (pivot.SelectedItem is PivotItem pivotItem)
|
||||
{
|
||||
ViewModel?.ListViewSelectedItemTag = pivotItem.Tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void ImportButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string[] fileTypeFilter = [".json"];
|
||||
@@ -164,14 +153,16 @@ namespace BetterLyrics.WinUI3.Controls
|
||||
|
||||
private void ConfigButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WindowPivotItem.Visibility = Visibility.Visible;
|
||||
WindowSelectorBarItem.Visibility = LayoutSelectorBarItem.Visibility = Visibility.Visible;
|
||||
ConfigSelectorBar.SelectedItem = WindowSelectorBarItem;
|
||||
LyricsWindowStatus = (LyricsWindowStatus)((Button)sender).DataContext;
|
||||
ViewModel.OpenConfigPanel();
|
||||
}
|
||||
|
||||
private void EmbeddedConfigButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WindowPivotItem.Visibility = Visibility.Collapsed;
|
||||
WindowSelectorBarItem.Visibility = LayoutSelectorBarItem.Visibility = Visibility.Collapsed;
|
||||
ConfigSelectorBar.SelectedItem = AlbumArtStyleSelectorBarItem;
|
||||
LyricsWindowStatus = _settingsService.AppSettings.MusicGallerySettings.LyricsWindowStatus;
|
||||
ViewModel.OpenConfigPanel();
|
||||
}
|
||||
@@ -196,5 +187,15 @@ namespace BetterLyrics.WinUI3.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigSelectorBar_SelectionChanged(SelectorBar sender, SelectorBarSelectionChangedEventArgs args)
|
||||
{
|
||||
if (sender is SelectorBar bar)
|
||||
{
|
||||
if (bar.SelectedItem is SelectorBarItem item)
|
||||
{
|
||||
ViewModel?.SelectorBarSelectedItemTag = item.Tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,9 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid Grid.Column="0" RowSpacing="18">
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
@@ -42,51 +43,53 @@
|
||||
</interactivity:DataTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
|
||||
<!-- 播放源列表 -->
|
||||
<ListView
|
||||
x:Name="MediaSourceProvidersListView"
|
||||
<InfoBar
|
||||
Grid.Row="0"
|
||||
AllowDrop="True"
|
||||
CanDragItems="True"
|
||||
CanReorderItems="True"
|
||||
DragItemsCompleted="MediaSourceProvidersListView_DragItemsCompleted"
|
||||
ItemsSource="{x:Bind ViewModel.AppSettings.MediaSourceProvidersInfo, Mode=OneWay}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.HorizontalScrollMode="Enabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollMode="Disabled"
|
||||
SelectedItem="{x:Bind ViewModel.SelectedMediaSourceProvider, Mode=TwoWay}">
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:MediaSourceProviderInfo">
|
||||
<StackPanel Orientation="Horizontal" Spacing="6">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding Provider, Mode=OneWay}" />
|
||||
</ToolTipService.ToolTip>
|
||||
<FontIcon
|
||||
FontFamily="Segoe UI Symbol"
|
||||
FontSize="12"
|
||||
Glyph="⠿" />
|
||||
<Grid
|
||||
Width="16"
|
||||
Height="16"
|
||||
CornerRadius="4">
|
||||
<ImageIcon Source="{Binding LogoPath}" />
|
||||
</Grid>
|
||||
<TextBlock
|
||||
MaxWidth="200"
|
||||
Text="{Binding DisplayName, Mode=OneWay}"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
IsClosable="False"
|
||||
IsOpen="{x:Bind ViewModel.AppSettings.MusicGallerySettings.LyricsWindowStatus.IsOpened, Mode=OneWay}"
|
||||
Message="音乐库窗口已打开,将忽略对其他播放源的监听"
|
||||
Severity="Informational" />
|
||||
|
||||
<ScrollViewer Grid.Row="1" Style="{StaticResource SettingsScrollViewerStyle}">
|
||||
<!-- 播放源列表 -->
|
||||
<Grid Grid.Row="1" Margin="36,0,36,4">
|
||||
<StackPanel Spacing="{StaticResource SettingsCardSpacing}">
|
||||
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="Config playback source" />
|
||||
<ComboBox
|
||||
x:Name="MediaSourceProvidersListView"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{x:Bind ViewModel.AppSettings.MediaSourceProvidersInfo, Mode=OneWay}"
|
||||
SelectedItem="{x:Bind ViewModel.SelectedMediaSourceProvider, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:MediaSourceProviderInfo">
|
||||
<Grid Padding="2,4" ColumnSpacing="12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{Binding Provider, Mode=OneWay}" />
|
||||
</ToolTipService.ToolTip>
|
||||
<Grid
|
||||
Grid.Column="0"
|
||||
Width="16"
|
||||
Height="16"
|
||||
CornerRadius="4">
|
||||
<ImageIcon Source="{Binding LogoPath}" />
|
||||
</Grid>
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding DisplayName, Mode=OneWay}"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- 播放源配置 -->
|
||||
<ScrollViewer Grid.Row="2" Style="{StaticResource SettingsScrollViewerStyle}">
|
||||
<Grid Style="{StaticResource SettingsGridStyle}">
|
||||
<StackPanel Spacing="{StaticResource SettingsCardSpacing}">
|
||||
|
||||
@@ -269,6 +272,7 @@
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- 播放源空白占位 -->
|
||||
<StackPanel
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Center"
|
||||
@@ -294,6 +298,8 @@
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- 右侧杂项设置 -->
|
||||
<Grid Grid.Column="1">
|
||||
<ScrollViewer Style="{StaticResource SettingsScrollViewerStyle}">
|
||||
<Grid Style="{StaticResource SettingsGridStyle}">
|
||||
@@ -518,6 +524,7 @@
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
|
||||
@@ -76,13 +76,13 @@ namespace BetterLyrics.WinUI3.Controls
|
||||
private void UpdateShadowCastGridCornerRadius()
|
||||
{
|
||||
var minSize = Math.Min(ShadowCastGrid.ActualHeight, ShadowCastGrid.ActualWidth);
|
||||
ShadowCastGrid.CornerRadius = new(CornerRadiusAmount / 100.0 * minSize);
|
||||
ShadowCastGrid.CornerRadius = new(CornerRadiusAmount / 100.0 * (minSize / 2));
|
||||
}
|
||||
|
||||
private void UpdateShadowRectCornerRadius()
|
||||
{
|
||||
var minSize = Math.Min(ShadowRect.ActualHeight, ShadowRect.ActualWidth);
|
||||
ShadowRect.CornerRadius = new(CornerRadiusAmount / 100.0 * minSize);
|
||||
ShadowRect.CornerRadius = new(CornerRadiusAmount / 100.0 * (minSize / 2));
|
||||
}
|
||||
|
||||
private void ShadowCastGrid_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace BetterLyrics.WinUI3.Helper
|
||||
|
||||
public static bool IsAppleMusic(string? id) => id is PlayerID.AppleMusic or PlayerID.AppleMusicAlternative;
|
||||
|
||||
public static bool IsBetterLyrics(string? id) => id is PlayerID.BetterLyrics or PlayerID.BetterLyricsDebug;
|
||||
|
||||
public static string? GetDisplayName(string? id) => id switch
|
||||
{
|
||||
PlayerID.Spotify => PlayerName.Spotify,
|
||||
|
||||
@@ -5,6 +5,7 @@ using BetterLyrics.WinUI3.Helper;
|
||||
using BetterLyrics.WinUI3.Models;
|
||||
|
||||
using BetterLyrics.WinUI3.Services.MediaSessionsService;
|
||||
using BetterLyrics.WinUI3.Services.SettingsService;
|
||||
using BetterLyrics.WinUI3.Views;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using CommunityToolkit.WinUI;
|
||||
@@ -30,8 +31,6 @@ namespace BetterLyrics.WinUI3.Hooks
|
||||
private static readonly Dictionary<HWND, WindowStyle> _defaultWindowStyle = [];
|
||||
private static readonly Dictionary<HWND, ExtendedWindowStyle> _defaultExtendedWindowStyle = [];
|
||||
|
||||
private static readonly IMediaSessionsService _mediaSessionsService = Ioc.Default.GetRequiredService<IMediaSessionsService>();
|
||||
|
||||
public static void HideWindow(this Window window)
|
||||
{
|
||||
window.Hide();
|
||||
@@ -39,21 +38,16 @@ namespace BetterLyrics.WinUI3.Hooks
|
||||
|
||||
public static void CloseWindow(this Window window)
|
||||
{
|
||||
if (window is Window w)
|
||||
if (window is NowPlayingWindow nowPlayingWindow)
|
||||
{
|
||||
w.Close();
|
||||
_activeWindows.Remove(w);
|
||||
if (GetWindowHandle(window) is IntPtr hwnd)
|
||||
{
|
||||
UnregisterWorkArea(hwnd);
|
||||
}
|
||||
nowPlayingWindow.LyricsWindowStatus.IsOpened = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CloseWindow(this NowPlayingWindow window)
|
||||
{
|
||||
if (GetWindowHandle(window) is IntPtr hwnd)
|
||||
{
|
||||
UnregisterWorkArea(hwnd);
|
||||
}
|
||||
window.LyricsWindowStatus.IsOpened = false;
|
||||
((Window)window).CloseWindow();
|
||||
window.Close();
|
||||
_activeWindows.Remove(window);
|
||||
}
|
||||
|
||||
public static void MinimizeWindow(this Window window)
|
||||
@@ -140,13 +134,6 @@ namespace BetterLyrics.WinUI3.Hooks
|
||||
{
|
||||
window = new LyricsWindowSwitchWindow();
|
||||
}
|
||||
else if (typeof(T) == typeof(SystemTrayWindow))
|
||||
{
|
||||
window = new SystemTrayWindow();
|
||||
var systemTrayWindow = (SystemTrayWindow)window;
|
||||
systemTrayWindow.EnsureLyricsWindowStatus();
|
||||
systemTrayWindow.InitShortcuts();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Unsupported window type", nameof(T));
|
||||
@@ -155,14 +142,8 @@ namespace BetterLyrics.WinUI3.Hooks
|
||||
TrackWindow(window);
|
||||
var castedWindow = (Window)window;
|
||||
|
||||
if (typeof(T) == typeof(SystemTrayWindow))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
castedWindow.Restore();
|
||||
castedWindow.Activate();
|
||||
}
|
||||
castedWindow.Restore();
|
||||
castedWindow.Activate();
|
||||
|
||||
if (typeof(T) == typeof(NowPlayingWindow))
|
||||
{
|
||||
@@ -438,7 +419,7 @@ namespace BetterLyrics.WinUI3.Hooks
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dispatcherQueue">请确保此参数指向同一个对象,建议传值 BaseViewModel._dispatcherQueue</param>
|
||||
public static void SetLyricsWindowVisibilityByPlayingStatus(this NowPlayingWindow window, DispatcherQueue dispatcherQueue)
|
||||
public static void SetLyricsWindowVisibilityByPlayingStatus(this NowPlayingWindow window, bool isPlaying, DispatcherQueue dispatcherQueue)
|
||||
{
|
||||
var status = window.LyricsWindowStatus;
|
||||
|
||||
@@ -449,7 +430,7 @@ namespace BetterLyrics.WinUI3.Hooks
|
||||
var window = GetWindow<NowPlayingWindow>();
|
||||
if (window == null) return;
|
||||
|
||||
if (status.AutoShowOrHideWindow && !_mediaSessionsService.CurrentIsPlaying)
|
||||
if (status.AutoShowOrHideWindow && !isPlaying)
|
||||
{
|
||||
if (status.IsWorkArea)
|
||||
{
|
||||
@@ -457,7 +438,7 @@ namespace BetterLyrics.WinUI3.Hooks
|
||||
}
|
||||
window.HideWindow();
|
||||
}
|
||||
else if (window.LyricsWindowStatus.AutoShowOrHideWindow && _mediaSessionsService.CurrentIsPlaying)
|
||||
else if (window.LyricsWindowStatus.AutoShowOrHideWindow && isPlaying)
|
||||
{
|
||||
if (window.LyricsWindowStatus.IsWorkArea)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using BetterLyrics.WinUI3.Helper;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BetterLyrics.WinUI3.Models
|
||||
{
|
||||
@@ -34,11 +35,11 @@ namespace BetterLyrics.WinUI3.Models
|
||||
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsSearchType LyricsSearchType { get; set; } = LyricsSearchType.Sequential;
|
||||
[ObservableProperty][NotifyPropertyChangedRecipients] public partial int MatchingThreshold { get; set; } = 0;
|
||||
|
||||
public string LogoPath => PlayerIDHelper.GetLogoPath(Provider);
|
||||
[JsonIgnore] public string LogoPath => PlayerIDHelper.GetLogoPath(Provider);
|
||||
|
||||
public string? DisplayName => PlayerIDHelper.GetDisplayName(Provider);
|
||||
[JsonIgnore] public string? DisplayName => PlayerIDHelper.GetDisplayName(Provider);
|
||||
|
||||
public bool IsLXMusic => PlayerIDHelper.IsLXMusic(Provider);
|
||||
[JsonIgnore] public bool IsLXMusic => PlayerIDHelper.IsLXMusic(Provider);
|
||||
|
||||
public MediaSourceProviderInfo()
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace BetterLyrics.WinUI3.Models.Settings
|
||||
[ObservableProperty][NotifyPropertyChangedRecipients] public partial bool AutoOpen { get; set; } = false;
|
||||
[ObservableProperty][NotifyPropertyChangedRecipients] public partial bool AutoPlay { get; set; } = false;
|
||||
[ObservableProperty][NotifyPropertyChangedRecipients] public partial LyricsWindowStatus LyricsWindowStatus { get; set; } = new();
|
||||
[ObservableProperty][NotifyPropertyChangedRecipients] public partial bool ExitOnWindowClosed { get; set; } = false;
|
||||
|
||||
public MusicGallerySettings() { }
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
Task ChangeLyricsLine(int index);
|
||||
|
||||
void UpdateLyrics();
|
||||
void UpdateTranslations();
|
||||
|
||||
MediaSourceProviderInfo? CurrentMediaSourceProviderInfo { get; }
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using BetterLyrics.WinUI3.Events;
|
||||
using BetterLyrics.WinUI3.Extensions;
|
||||
using BetterLyrics.WinUI3.Helper;
|
||||
using BetterLyrics.WinUI3.Models;
|
||||
using BetterLyrics.WinUI3.Models.Settings;
|
||||
using BetterLyrics.WinUI3.Parsers.LyricsParser;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Lyricify.Lyrics.Helpers.General;
|
||||
@@ -19,7 +20,6 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
public partial class MediaSessionsService : IMediaSessionsService
|
||||
{
|
||||
private LatestOnlyTaskRunner _refreshLyricsRunner = new();
|
||||
private LatestOnlyTaskRunner _refreshTranslationRunner = new();
|
||||
|
||||
private int _langIndex = 0;
|
||||
private List<LyricsData> _lyricsDataArr = [];
|
||||
@@ -36,34 +36,33 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
|
||||
private void SetCurrentLyricsData()
|
||||
{
|
||||
CurrentLyricsData = _lyricsDataArr.ElementAtOrDefault(_langIndex);
|
||||
App.Current.Resources.DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
CurrentLyricsData = _lyricsDataArr.ElementAtOrDefault(_langIndex);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task RefreshTranslationAsync(CancellationToken token)
|
||||
private async Task RefreshTranslationAsync(TranslationSettings settings, CancellationToken token)
|
||||
{
|
||||
TranslationSearchProvider = null;
|
||||
_lyricsDataArr.ElementAtOrDefault(0)?.ClearTranslatedText();
|
||||
|
||||
App.Current.Resources.DispatcherQueue.TryEnqueue(SetCurrentLyricsData);
|
||||
|
||||
IsTranslating = true;
|
||||
|
||||
await SetPhoneticTextAsync(token);
|
||||
await SetTranslatedTextAsync(token);
|
||||
SetPhoneticText();
|
||||
|
||||
await SetTranslatedTextAsync(settings, token);
|
||||
if (token.IsCancellationRequested) return;
|
||||
|
||||
IsTranslating = false;
|
||||
|
||||
App.Current.Resources.DispatcherQueue.TryEnqueue(SetCurrentLyricsData);
|
||||
|
||||
}
|
||||
|
||||
private async Task SetTranslatedTextAsync(CancellationToken token)
|
||||
private async Task SetTranslatedTextAsync(TranslationSettings settings, CancellationToken token)
|
||||
{
|
||||
if (!_settingsService.AppSettings.TranslationSettings.IsTranslationEnabled) return;
|
||||
if (!settings.IsTranslationEnabled) return;
|
||||
|
||||
_logger.LogInformation("SetTranslatedTextAsync");
|
||||
string targetLangCode = _settingsService.AppSettings.TranslationSettings.SelectedTargetLanguageCode;
|
||||
string targetLangCode = settings.SelectedTargetLanguageCode;
|
||||
_logger.LogInformation("Target language code: {TargetLangCode}", targetLangCode);
|
||||
string? originalText = _lyricsDataArr.FirstOrDefault()?.WrappedOriginalText;
|
||||
if (originalText == null) return;
|
||||
@@ -88,7 +87,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
_lyricsDataArr.FirstOrDefault()?.SetTranslatedText(_lyricsDataArr[found], 50);
|
||||
TranslationSearchProvider = CurrentLyricsSearchResult?.Provider.ToTranslationSearchProvider();
|
||||
}
|
||||
else if (_settingsService.AppSettings.TranslationSettings.IsLibreTranslateEnabled)
|
||||
else if (settings.IsLibreTranslateEnabled)
|
||||
{
|
||||
_logger.LogInformation("LibreTranslate is enabled, trying to translate lyrics...");
|
||||
string translated = string.Empty;
|
||||
@@ -110,7 +109,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SetPhoneticTextAsync(CancellationToken token)
|
||||
private void SetPhoneticText()
|
||||
{
|
||||
_logger.LogInformation("Showing phonetic text for lyrics...");
|
||||
string targetPhoneticCode = "";
|
||||
@@ -145,14 +144,14 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
|
||||
}
|
||||
|
||||
private async Task RefreshLyricsAsync(CancellationToken token)
|
||||
private async Task RefreshLyricsAsync(TranslationSettings settings, CancellationToken token)
|
||||
{
|
||||
_logger.LogInformation("RefreshLyricsAsync");
|
||||
|
||||
CurrentLyricsSearchResult = null;
|
||||
_lyricsDataArr = [LyricsData.GetLoadingPlaceholder()];
|
||||
|
||||
App.Current.Resources.DispatcherQueue.TryEnqueue(SetCurrentLyricsData);
|
||||
SetCurrentLyricsData();
|
||||
|
||||
if (CurrentSongInfo != null)
|
||||
{
|
||||
@@ -175,9 +174,11 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
// Show original first while loading phonetic and translated
|
||||
ApplyChinesePreference();
|
||||
|
||||
App.Current.Resources.DispatcherQueue.TryEnqueue(SetCurrentLyricsData);
|
||||
SetCurrentLyricsData();
|
||||
|
||||
UpdateTranslations();
|
||||
await RefreshTranslationAsync(settings, token);
|
||||
|
||||
SetCurrentLyricsData();
|
||||
}
|
||||
|
||||
private void ApplyChinesePreference()
|
||||
@@ -193,14 +194,13 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLyrics()
|
||||
public async void UpdateLyrics()
|
||||
{
|
||||
_ = _refreshLyricsRunner.RunAsync(RefreshLyricsAsync);
|
||||
await _refreshLyricsRunner.RunAsync(async (token) =>
|
||||
{
|
||||
await RefreshLyricsAsync(_settingsService.AppSettings.TranslationSettings, token);
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateTranslations()
|
||||
{
|
||||
_ = _refreshTranslationRunner.RunAsync(RefreshTranslationAsync);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ using BetterLyrics.WinUI3.Models.Settings;
|
||||
using BetterLyrics.WinUI3.Services.AlbumArtSearchService;
|
||||
using BetterLyrics.WinUI3.Services.DiscordService;
|
||||
using BetterLyrics.WinUI3.Services.LibWatcherService;
|
||||
|
||||
using BetterLyrics.WinUI3.Services.LyricsSearchService;
|
||||
using BetterLyrics.WinUI3.Services.SettingsService;
|
||||
using BetterLyrics.WinUI3.Services.TranslateService;
|
||||
@@ -158,7 +157,22 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
|
||||
private bool IsMediaSourceEnabled(string id)
|
||||
{
|
||||
return _settingsService.AppSettings.MediaSourceProvidersInfo.FirstOrDefault(s => s.Provider == id)?.IsEnabled ?? true;
|
||||
var found = _settingsService.AppSettings.MediaSourceProvidersInfo.FirstOrDefault(s => s.Provider == id);
|
||||
if (_settingsService.AppSettings.MusicGallerySettings.LyricsWindowStatus.IsOpened)
|
||||
{
|
||||
if (PlayerIDHelper.IsBetterLyrics(found?.Provider))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return found?.IsEnabled ?? true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsMediaSourceTimelineSyncEnabled(string? id)
|
||||
@@ -453,14 +467,12 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
GlobalSystemMediaTransportControlsSessionMediaProperties? mediaProps = null;
|
||||
|
||||
var desiredSession = GetCurrentSession();
|
||||
//if (desiredSession == null || desiredSession.ControlSession == null) return;
|
||||
|
||||
try
|
||||
{
|
||||
mediaProps = await desiredSession?.ControlSession?.TryGetMediaPropertiesAsync();
|
||||
}
|
||||
catch (Exception) { }
|
||||
//if (desiredSession == null || desiredSession.ControlSession == null) return;
|
||||
|
||||
MediaManager_OnAnyTimelinePropertyChanged(desiredSession, desiredSession?.ControlSession?.GetTimelineProperties());
|
||||
MediaManager_OnAnyMediaPropertyChanged(desiredSession, mediaProps);
|
||||
@@ -642,25 +654,32 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
{
|
||||
if (message.PropertyName == nameof(TranslationSettings.IsLibreTranslateEnabled))
|
||||
{
|
||||
UpdateTranslations();
|
||||
UpdateLyrics();
|
||||
}
|
||||
else if (message.PropertyName == nameof(TranslationSettings.IsTranslationEnabled))
|
||||
{
|
||||
UpdateTranslations();
|
||||
UpdateLyrics();
|
||||
}
|
||||
else if (message.PropertyName == nameof(TranslationSettings.IsChineseRomanizationEnabled))
|
||||
{
|
||||
UpdateTranslations();
|
||||
UpdateLyrics();
|
||||
}
|
||||
else if (message.PropertyName == nameof(TranslationSettings.IsJapaneseRomanizationEnabled))
|
||||
{
|
||||
UpdateTranslations();
|
||||
UpdateLyrics();
|
||||
}
|
||||
else if (message.PropertyName == nameof(TranslationSettings.IsTraditionalChineseEnabled))
|
||||
{
|
||||
UpdateLyrics();
|
||||
}
|
||||
}
|
||||
else if (message.Sender is LyricsWindowStatus)
|
||||
{
|
||||
if (message.PropertyName == nameof(MusicGallerySettings.LyricsWindowStatus.IsOpened))
|
||||
{
|
||||
MediaManager_OnFocusedSessionChanged(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Receive(PropertyChangedMessage<string> message)
|
||||
@@ -670,7 +689,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
if (message.PropertyName == nameof(TranslationSettings.SelectedTargetLanguageCode))
|
||||
{
|
||||
_logger.LogInformation("Target LibreTranslate language code changed: {code}", _settingsService.AppSettings.TranslationSettings.SelectedTargetLanguageCode);
|
||||
UpdateTranslations();
|
||||
UpdateLyrics();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,7 +701,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
{
|
||||
if (message.PropertyName == nameof(TranslationSettings.ChineseRomanization))
|
||||
{
|
||||
UpdateTranslations();
|
||||
UpdateLyrics();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// 2025/6/23 by Zhe Fang
|
||||
|
||||
using BetterLyrics.WinUI3.Models.Settings;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterLyrics.WinUI3.Services.SettingsService
|
||||
{
|
||||
|
||||
@@ -8,11 +8,13 @@ using BetterLyrics.WinUI3.Models;
|
||||
using BetterLyrics.WinUI3.Models.Settings;
|
||||
using BetterLyrics.WinUI3.Serialization;
|
||||
using BetterLyrics.WinUI3.ViewModels;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Globalization;
|
||||
|
||||
namespace BetterLyrics.WinUI3.Services.SettingsService
|
||||
@@ -20,7 +22,7 @@ namespace BetterLyrics.WinUI3.Services.SettingsService
|
||||
// 新建一个 AppSettings 类
|
||||
public partial class SettingsService : BaseViewModel, ISettingsService
|
||||
{
|
||||
private DispatcherQueueTimer _writeAppSettingsTimer;
|
||||
private readonly DispatcherQueueTimer _writeAppSettingsTimer;
|
||||
|
||||
public AppSettings AppSettings { get; set; }
|
||||
|
||||
|
||||
@@ -849,6 +849,9 @@
|
||||
<data name="SettingsPageEnvColorSampleInner.Content" xml:space="preserve">
|
||||
<value>Inside the window</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnGalleryWindowClosed.Header" xml:space="preserve">
|
||||
<value>Exit the program when closing the music library window</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnLyricsWindowClosed.Header" xml:space="preserve">
|
||||
<value>Exit the program when you close the lyrics window</value>
|
||||
</data>
|
||||
|
||||
@@ -849,6 +849,9 @@
|
||||
<data name="SettingsPageEnvColorSampleInner.Content" xml:space="preserve">
|
||||
<value>窓の中だ</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnGalleryWindowClosed.Header" xml:space="preserve">
|
||||
<value>音楽ライブラリウィンドウを閉じてプログラムを終了してください</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnLyricsWindowClosed.Header" xml:space="preserve">
|
||||
<value>歌詞ウィンドウを閉じてプログラムを終了してください</value>
|
||||
</data>
|
||||
|
||||
@@ -849,6 +849,9 @@
|
||||
<data name="SettingsPageEnvColorSampleInner.Content" xml:space="preserve">
|
||||
<value>창문 안쪽</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnGalleryWindowClosed.Header" xml:space="preserve">
|
||||
<value>음악 라이브러리 창을 닫을 때 프로그램을 종료하십시오</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnLyricsWindowClosed.Header" xml:space="preserve">
|
||||
<value>가사 창을 닫으면 프로그램을 종료하세요</value>
|
||||
</data>
|
||||
|
||||
@@ -849,6 +849,9 @@
|
||||
<data name="SettingsPageEnvColorSampleInner.Content" xml:space="preserve">
|
||||
<value>窗口内部</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnGalleryWindowClosed.Header" xml:space="preserve">
|
||||
<value>关闭音乐库窗口时退出程序</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnLyricsWindowClosed.Header" xml:space="preserve">
|
||||
<value>关闭歌词窗口时退出程序</value>
|
||||
</data>
|
||||
|
||||
@@ -849,6 +849,9 @@
|
||||
<data name="SettingsPageEnvColorSampleInner.Content" xml:space="preserve">
|
||||
<value>視窗內部</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnGalleryWindowClosed.Header" xml:space="preserve">
|
||||
<value>關閉音樂庫視窗時退出程式</value>
|
||||
</data>
|
||||
<data name="SettingsPageExitOnLyricsWindowClosed.Header" xml:space="preserve">
|
||||
<value>關閉歌詞視窗時退出程式</value>
|
||||
</data>
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BetterLyrics.WinUI3.ViewModels
|
||||
public partial AppSettings AppSettings { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial object ListViewSelectedItemTag { get; set; } = "General";
|
||||
public partial object SelectorBarSelectedItemTag { get; set; } = "AlbumArtStyle";
|
||||
|
||||
[ObservableProperty]
|
||||
public partial bool IsConfigPanelOpened { get; set; } = false;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
xmlns:ui="using:CommunityToolkit.WinUI"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid x:Name="RootGrid">
|
||||
<Grid x:Name="RootGrid" Loaded="RootGrid_Loaded" Unloaded="RootGrid_Unloaded">
|
||||
|
||||
<local:MusicGalleryPage x:Name="MusicGalleryPage" Margin="0,40,0,0" />
|
||||
|
||||
|
||||
@@ -38,8 +38,7 @@ namespace BetterLyrics.WinUI3.Views
|
||||
|
||||
AppWindow.Closing += AppWindow_Closing;
|
||||
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<BitmapDecoder?>>(this);
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<ElementTheme>>(this);
|
||||
WeakReferenceMessenger.Default.RegisterAll(this);
|
||||
|
||||
_ = UpdateAlbumArtThemeColorsAsync();
|
||||
}
|
||||
@@ -56,7 +55,14 @@ namespace BetterLyrics.WinUI3.Views
|
||||
|
||||
private void AppWindow_Closing(AppWindow sender, AppWindowClosingEventArgs args)
|
||||
{
|
||||
this.CloseWindow();
|
||||
if (ViewModel.AppSettings.MusicGallerySettings.ExitOnWindowClosed)
|
||||
{
|
||||
WindowHook.ExitApp();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CloseWindow();
|
||||
}
|
||||
}
|
||||
|
||||
public async void Receive(PropertyChangedMessage<BitmapDecoder?> message)
|
||||
@@ -102,5 +108,15 @@ namespace BetterLyrics.WinUI3.Views
|
||||
await Task.Delay(Constants.Time.AnimationDuration);
|
||||
NowPlayingPage.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void RootGrid_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.AppSettings.MusicGallerySettings.LyricsWindowStatus.IsOpened = true;
|
||||
}
|
||||
|
||||
private void RootGrid_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.AppSettings.MusicGallerySettings.LyricsWindowStatus.IsOpened = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace BetterLyrics.WinUI3.Views
|
||||
|
||||
DataContext = Ioc.Default.GetRequiredService<NowPlayingPageViewModel>();
|
||||
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<SongInfo?>>(this);
|
||||
WeakReferenceMessenger.Default.RegisterAll(this);
|
||||
}
|
||||
|
||||
private static void OnDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace BetterLyrics.WinUI3.Views
|
||||
|
||||
private void OnAutoShowOrHideWindowChanged()
|
||||
{
|
||||
this.SetLyricsWindowVisibilityByPlayingStatus(DispatcherQueue);
|
||||
this.SetLyricsWindowVisibilityByPlayingStatus(_mediaSessionsService.CurrentIsPlaying, DispatcherQueue);
|
||||
}
|
||||
|
||||
private void OnWorkAreaChanged()
|
||||
@@ -378,7 +378,7 @@ namespace BetterLyrics.WinUI3.Views
|
||||
{
|
||||
if (message.PropertyName == nameof(IMediaSessionsService.CurrentIsPlaying))
|
||||
{
|
||||
this.SetLyricsWindowVisibilityByPlayingStatus(DispatcherQueue);
|
||||
this.SetLyricsWindowVisibilityByPlayingStatus(_mediaSessionsService.CurrentIsPlaying, DispatcherQueue);
|
||||
}
|
||||
}
|
||||
else if (message.Sender == LyricsWindowStatus)
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Threading.Tasks;
|
||||
using Vanara.PInvoke;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
@@ -36,22 +37,27 @@ namespace BetterLyrics.WinUI3.Views;
|
||||
/// </summary>
|
||||
public sealed partial class SystemTrayWindow : Window, IRecipient<PropertyChangedMessage<List<string>>>
|
||||
{
|
||||
private readonly ISettingsService _settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
|
||||
private ISettingsService _settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
|
||||
private readonly IMediaSessionsService _mediaSessionsService = Ioc.Default.GetRequiredService<IMediaSessionsService>();
|
||||
|
||||
private readonly WindowMessageMonitor _wmm;
|
||||
private WindowMessageMonitor _wmm;
|
||||
|
||||
public SystemTrayWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
WeakReferenceMessenger.Default.Register<PropertyChangedMessage<List<string>>>(this);
|
||||
SystemBackdrop = SystemBackdropHelper.CreateSystemBackdrop(BackdropType.Transparent);
|
||||
|
||||
_wmm = new WindowMessageMonitor(this);
|
||||
_wmm.WindowMessageReceived += Wmm_WindowMessageReceived;
|
||||
|
||||
WeakReferenceMessenger.Default.RegisterAll(this);
|
||||
|
||||
InitShortcuts();
|
||||
|
||||
EnsureLyricsWindowStatus();
|
||||
}
|
||||
|
||||
public void InitShortcuts()
|
||||
private void InitShortcuts()
|
||||
{
|
||||
UpdateLyricsWindowSwitchShortcut();
|
||||
UpdatePlayOrPauseSongShortcut();
|
||||
@@ -67,13 +73,9 @@ public sealed partial class SystemTrayWindow : Window, IRecipient<PropertyChange
|
||||
int id = (int)e.Message.WParam;
|
||||
GlobalHotKeyHook.TryInvokeAction(id);
|
||||
}
|
||||
else if (e.Message.MessageId == (uint)User32.WindowMessage.WM_WININICHANGE)
|
||||
{
|
||||
Debug.WriteLine("==========");
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureLyricsWindowStatus()
|
||||
private void EnsureLyricsWindowStatus()
|
||||
{
|
||||
var records = _settingsService.AppSettings.WindowBoundsRecords;
|
||||
if (records.Count == 0)
|
||||
|
||||
Reference in New Issue
Block a user