From a74dc705c960c2a87f7bb1ff026c9131779b7715 Mon Sep 17 00:00:00 2001 From: Zhe Fang Date: Tue, 9 Dec 2025 13:02:42 -0500 Subject: [PATCH] feat: search for file name in music gallery --- BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs | 2 +- .../Extensions/TrackExtensions.cs | 2 ++ .../BetterLyrics.WinUI3/Hooks/WindowHook.cs | 11 +++++++++-- .../Renderer/FluidBackgroundRenderer.cs | 12 ++++++------ .../BetterLyrics.WinUI3/Strings/en-US/Resources.resw | 8 ++++---- .../BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw | 2 +- .../BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw | 2 +- .../BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw | 6 +++--- .../BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw | 2 +- .../ViewModels/MusicGalleryPageViewModel.cs | 3 +++ 10 files changed, 31 insertions(+), 19 deletions(-) diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs index 6dbf2d7..f311df6 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs @@ -70,7 +70,7 @@ namespace BetterLyrics.WinUI3 { var settingsService = Ioc.Default.GetRequiredService(); - _ = new SystemTrayWindow(); + WindowHook.OpenOrShowWindow(); if (settingsService.AppSettings.GeneralSettings.AutoStartLyricsWindow) { diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/TrackExtensions.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/TrackExtensions.cs index af02e28..f1c82a0 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/TrackExtensions.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/TrackExtensions.cs @@ -26,6 +26,8 @@ namespace BetterLyrics.WinUI3.Extensions } return ""; } + + public string GetFileName() => Path.GetFileName(track.Path); } } } diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Hooks/WindowHook.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Hooks/WindowHook.cs index 2eef277..a8dd0a0 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Hooks/WindowHook.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Hooks/WindowHook.cs @@ -129,6 +129,10 @@ namespace BetterLyrics.WinUI3.Hooks { window = new LyricsWindowSwitchWindow(); } + else if (typeof(T) == typeof(SystemTrayWindow)) + { + window = new SystemTrayWindow(); + } else { throw new ArgumentException("Unsupported window type", nameof(T)); @@ -137,8 +141,11 @@ namespace BetterLyrics.WinUI3.Hooks TrackWindow(window); var castedWindow = (Window)window; - castedWindow.Restore(); - castedWindow.Activate(); + if (typeof(T) != typeof(SystemTrayWindow)) + { + castedWindow.Restore(); + castedWindow.Activate(); + } if (typeof(T) == typeof(NowPlayingWindow)) { diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Renderer/FluidBackgroundRenderer.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Renderer/FluidBackgroundRenderer.cs index 07eccaa..3349e2e 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Renderer/FluidBackgroundRenderer.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Renderer/FluidBackgroundRenderer.cs @@ -63,14 +63,14 @@ namespace BetterLyrics.WinUI3.Renderer _timeAccumulator += (float)deltaTime.TotalSeconds; - _fluidEffect.Properties["iTime"] = _timeAccumulator; + _fluidEffect?.Properties["iTime"] = _timeAccumulator; - _fluidEffect.Properties["color1"] = _c1; - _fluidEffect.Properties["color2"] = _c2; - _fluidEffect.Properties["color3"] = _c3; - _fluidEffect.Properties["color4"] = _c4; + _fluidEffect?.Properties["color1"] = _c1; + _fluidEffect?.Properties["color2"] = _c2; + _fluidEffect?.Properties["color3"] = _c3; + _fluidEffect?.Properties["color4"] = _c4; - _fluidEffect.Properties["EnableLightWave"] = EnableLightWave; + _fluidEffect?.Properties["EnableLightWave"] = EnableLightWave; } public void Draw(ICanvasAnimatedControl control, CanvasDrawingSession ds) diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw index edea2613..3f05c2d 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw @@ -493,7 +493,7 @@ Single loop - Search for song title, artist, album or folder path + Search for the song name, artist, album, file name, or folder path where the file is located Album @@ -1131,6 +1131,9 @@ Normal + + Font opacity + Lyrics area height factor @@ -1266,9 +1269,6 @@ Opacity - - Font opacity - Open in file explorer diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw index 7025877..6e8a71e 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw @@ -493,7 +493,7 @@ シングルループ - 曲名、アーティスト、アルバム、フォルダパスを検索してください + ファイルが置かれている曲名、アーティスト、アルバム、ファイル名、またはフォルダパスを検索します アルバム diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw index dc746ee..21ddece 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw @@ -493,7 +493,7 @@ 단일 루프 - 노래 제목, 아티스트, 앨범 또는 폴더 경로를 검색하세요 + 파일이 있는 노래 이름, 아티스트, 앨범, 파일 이름 또는 폴더 경로를 검색하세요 앨범 diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw index 5c1ebee..1cd7840 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw @@ -492,9 +492,6 @@ 单曲循环 - - 搜索歌曲名、艺术家、专辑或所在文件夹路径 - 专辑 @@ -1623,4 +1620,7 @@ 使用指南 + + 搜索歌曲名、艺术家、专辑、文件名或文件所在文件夹路径 + \ No newline at end of file diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw index 7146daa..0b323e2 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw @@ -494,7 +494,7 @@ 單曲循環 - 搜尋歌曲名稱、藝人、專輯或所在資料夾路徑 + 搜尋歌曲名稱、藝人、專輯、檔案名稱或檔案所在資料夾路徑 專輯 diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryPageViewModel.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryPageViewModel.cs index 411e321..8b4b2ed 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryPageViewModel.cs +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryPageViewModel.cs @@ -374,6 +374,9 @@ namespace BetterLyrics.WinUI3.ViewModels t.Title.Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase) || t.Artist.Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase) || t.Album.Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase) || + // 文件名(包含后缀) + t.GetFileName().Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase) || + // 文件所在文件夹的路径 t.GetParentFolderPath().Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase)).ToList(); }