重构SMTC

This commit is contained in:
LanZhan-Harmony
2025-09-19 19:41:20 +08:00
parent 7894ed9157
commit efbf3dbda0
26 changed files with 983 additions and 861 deletions

View File

@@ -9,6 +9,7 @@ using The_Untamed_Music_Player.Models;
using The_Untamed_Music_Player.Services;
using The_Untamed_Music_Player.ViewModels;
using WinUIEx;
using ZLogger;
namespace The_Untamed_Music_Player;
@@ -135,19 +136,15 @@ public partial class App : Application
_logger.UnexpectedException(errorMessage, exception);
// 记录堆栈跟踪和内部异常
_logger.LogError(
_logger.ZLogInformation(
exception,
"异常详细信息: {ExceptionType}, 堆栈跟踪: {StackTrace}",
exception.GetType().Name,
exception.StackTrace
$"异常详细信息: {exception.GetType().Name}, 堆栈跟踪: {exception.StackTrace}"
);
if (exception.InnerException is not null)
{
_logger.LogError(
_logger.ZLogInformation(
exception.InnerException,
"内部异常: {InnerExceptionMessage}",
exception.InnerException.Message
$"内部异常: {exception.InnerException.Message}"
);
}
e.Handled = true;

View File

@@ -4,10 +4,10 @@ namespace The_Untamed_Music_Player.Contracts.Services;
public interface IMaterialSelectorService : IDisposable
{
MaterialType Material { get; }
bool IsFallBack { get; }
byte LuminosityOpacity { get; }
Color TintColor { get; }
MaterialType Material { get; set; }
bool IsFallBack { get; set; }
byte LuminosityOpacity { get; set; }
Color TintColor { get; set; }
void InitializeSettings();
Task InitializeMaterialAsync();
Task<(byte, Color)> SetMaterial(
@@ -15,7 +15,6 @@ public interface IMaterialSelectorService : IDisposable
bool firstStart = false,
bool forced = false
);
void SetIsFallBack(bool isFallBack);
void SetLuminosityOpacity(byte opacity, bool firstStart = false);
void SetTintColor(Color color, bool firstStart = false);
}

File diff suppressed because it is too large Load Diff

View File

@@ -391,7 +391,7 @@ public partial class OnlineMusicLibrary : ObservableObject
SuggestResultList = [];
}
public void AutoSuggestBox_Loaded(object sender, RoutedEventArgs e)
public void AutoSuggestBox_Loaded(object sender, RoutedEventArgs _)
{
if (sender is AutoSuggestBox autoSuggestBox)
{
@@ -399,7 +399,7 @@ public partial class OnlineMusicLibrary : ObservableObject
}
}
public async void RetryButton_Click(object sender, RoutedEventArgs e)
public async void RetryButton_Click(object _1, RoutedEventArgs _2)
{
await ForceSearch();
}

View File

@@ -19,6 +19,12 @@ public partial class MaterialSelectorService : IMaterialSelectorService
IsInputActive = true,
};
private ISystemBackdropControllerWithTargets? _currentBackdropController;
// 防抖相关字段
private Timer? _debounceTimer;
private readonly Lock _debounceLock = new();
private const int DEBOUNCE_DELAY_MS = 100; // 100毫秒防抖延迟
public MaterialType Material
{
get;
@@ -79,78 +85,108 @@ public partial class MaterialSelectorService : IMaterialSelectorService
bool forced = false
)
{
if ((Material == material && !forced) || _mainWindow is null)
try
{
return (LuminosityOpacity, TintColor);
}
_mainWindow.SystemBackdrop = null;
_currentBackdropController?.RemoveAllSystemBackdropTargets();
_currentBackdropController?.Dispose();
_currentBackdropController = material switch
{
MaterialType.Mica => new MicaController { Kind = MicaKind.Base },
MaterialType.MicaAlt => new MicaController { Kind = MicaKind.BaseAlt },
MaterialType.DesktopAcrylic => new DesktopAcrylicController
if ((Material == material && !forced) || _mainWindow is null)
{
Kind = DesktopAcrylicKind.Default,
},
MaterialType.AcrylicBase => new DesktopAcrylicController
return (LuminosityOpacity, TintColor);
}
_mainWindow.SystemBackdrop = null;
_currentBackdropController?.RemoveAllSystemBackdropTargets();
_currentBackdropController?.Dispose();
_currentBackdropController = material switch
{
Kind = DesktopAcrylicKind.Base,
},
MaterialType.AcrylicThin => new DesktopAcrylicController
{
Kind = DesktopAcrylicKind.Thin,
},
_ => null,
};
if (_currentBackdropController is not null)
{
SetConfigurationSourceTheme();
_currentBackdropController?.AddSystemBackdropTarget(_backdropTarget);
_currentBackdropController?.SetSystemBackdropConfiguration(_configurationSource);
await Task.Delay(100);
}
else
{
_mainWindow.SystemBackdrop = material switch
{
MaterialType.Blur => new BlurredBackdrop(),
MaterialType.Transparent => new TransparentTintBackdrop(),
MaterialType.Animated => new ColorAnimatedBackdrop(),
MaterialType.Mica => new MicaController { Kind = MicaKind.Base },
MaterialType.MicaAlt => new MicaController { Kind = MicaKind.BaseAlt },
MaterialType.DesktopAcrylic => new DesktopAcrylicController
{
Kind = DesktopAcrylicKind.Default,
},
MaterialType.AcrylicBase => new DesktopAcrylicController
{
Kind = DesktopAcrylicKind.Base,
},
MaterialType.AcrylicThin => new DesktopAcrylicController
{
Kind = DesktopAcrylicKind.Thin,
},
_ => null,
};
}
if (_currentBackdropController is not null)
{
SetConfigurationSourceTheme();
_currentBackdropController?.AddSystemBackdropTarget(_backdropTarget);
_currentBackdropController?.SetSystemBackdropConfiguration(_configurationSource);
await Task.Delay(100);
}
else
{
_mainWindow.SystemBackdrop = material switch
{
MaterialType.Blur => new BlurredBackdrop(),
MaterialType.Transparent => new TransparentTintBackdrop(),
MaterialType.Animated => new ColorAnimatedBackdrop(),
_ => null,
};
}
if (firstStart && ThemeSelectorService.IsDarkTheme == Settings.PreviousIsDarkTheme)
{
SetLuminosityOpacity(LuminosityOpacity, true);
SetTintColor(TintColor, true);
}
else
{
LuminosityOpacity = GetLuminosityOpacity();
TintColor = GetTintColor();
if (firstStart && ThemeSelectorService.IsDarkTheme == Settings.PreviousIsDarkTheme)
{
SetLuminosityOpacity(LuminosityOpacity, true);
SetTintColor(TintColor, true);
}
else
{
LuminosityOpacity = GetLuminosityOpacity();
TintColor = GetTintColor();
}
}
catch { }
Material = material;
return (LuminosityOpacity, TintColor);
}
public void SetIsFallBack(bool isFallBack) => IsFallBack = isFallBack;
public void SetLuminosityOpacity(byte opacity, bool forced = false)
{
if (LuminosityOpacity == opacity && !forced)
{
return;
}
if (_currentBackdropController is MicaController micaController)
lock (_debounceLock)
{
micaController.LuminosityOpacity = opacity / 100f;
}
else if (_currentBackdropController is DesktopAcrylicController desktopAcrylicController)
{
desktopAcrylicController.LuminosityOpacity = opacity / 100f;
_debounceTimer?.Dispose(); // 取消之前的定时器
_debounceTimer = new Timer( // 创建新的定时器,延迟执行
_ =>
{
try
{
if (_currentBackdropController is MicaController micaController)
{
micaController.LuminosityOpacity = opacity / 100f;
}
else if (
_currentBackdropController
is DesktopAcrylicController desktopAcrylicController
)
{
desktopAcrylicController.LuminosityOpacity = opacity / 100f;
}
}
catch { }
finally
{
lock (_debounceLock)
{
_debounceTimer?.Dispose();
_debounceTimer = null;
}
}
},
null,
DEBOUNCE_DELAY_MS,
Timeout.Infinite
);
}
LuminosityOpacity = opacity;
}
@@ -161,13 +197,41 @@ public partial class MaterialSelectorService : IMaterialSelectorService
{
return;
}
if (_currentBackdropController is MicaController micaController)
lock (_debounceLock)
{
micaController.TintColor = color;
}
else if (_currentBackdropController is DesktopAcrylicController desktopAcrylicController)
{
desktopAcrylicController.TintColor = color;
_debounceTimer?.Dispose();
_debounceTimer = new Timer(
_ =>
{
try
{
if (_currentBackdropController is MicaController micaController)
{
micaController.TintColor = color;
}
else if (
_currentBackdropController
is DesktopAcrylicController desktopAcrylicController
)
{
desktopAcrylicController.TintColor = color;
}
}
catch { }
finally
{
lock (_debounceLock)
{
_debounceTimer?.Dispose();
_debounceTimer = null;
}
}
},
null,
DEBOUNCE_DELAY_MS,
Timeout.Infinite
);
}
TintColor = color;
}
@@ -283,6 +347,19 @@ public partial class MaterialSelectorService : IMaterialSelectorService
public void Dispose()
{
// 清理防抖定时器
lock (_debounceLock)
{
_debounceTimer?.Dispose();
_debounceTimer = null;
}
lock (_debounceLock)
{
_debounceTimer?.Dispose();
_debounceTimer = null;
}
_currentBackdropController?.RemoveAllSystemBackdropTargets();
_currentBackdropController?.Dispose();
_currentBackdropController = null;

View File

@@ -0,0 +1,230 @@
using System.Runtime.InteropServices.WindowsRuntime;
using The_Untamed_Music_Player.Contracts.Models;
using The_Untamed_Music_Player.Helpers;
using The_Untamed_Music_Player.Models;
using Windows.Media;
using Windows.Media.Playback;
using Windows.Storage.Streams;
namespace The_Untamed_Music_Player.Services;
/// <summary>
/// 系统媒体传输控件管理器
/// </summary>
public partial class SystemMediaTransportControlsManager : IDisposable
{
/// <summary>
/// 用于获取SMTC的临时播放器
/// </summary>
private readonly MediaPlayer _tempPlayer = new();
/// <summary>
/// 用于SMTC显示封面图片的流
/// </summary>
private static InMemoryRandomAccessStream? _currentCoverStream = null!;
/// <summary>
/// SMTC控件
/// </summary>
private readonly SystemMediaTransportControls _systemControls;
/// <summary>
/// SMTC显示内容更新器
/// </summary>
private readonly SystemMediaTransportControlsDisplayUpdater _displayUpdater;
/// <summary>
/// SMTC时间线属性
/// </summary>
private readonly SystemMediaTransportControlsTimelineProperties _timelineProperties = new();
/// <summary>
/// 播放队列歌曲数量
/// </summary>
private int _playQueueLength = 0;
/// <summary>
/// 当前歌曲在播放队列中的索引
/// </summary>
private int _playQueueIndex = 0;
/// <summary>
/// 循环播放模式
/// </summary>
private byte _repeatMode = 0;
/// <summary>
/// 播放状态变化事件
/// </summary>
public event Action<SystemMediaTransportControlsButton>? ButtonPressed;
public SystemMediaTransportControls Controls => _systemControls;
public SystemMediaTransportControlsManager()
{
_systemControls = _tempPlayer.SystemMediaTransportControls;
_displayUpdater = _systemControls.DisplayUpdater;
_displayUpdater.Type = MediaPlaybackType.Music;
_displayUpdater.AppMediaId = "AppDisplayName".GetLocalized();
_systemControls.IsEnabled = true;
_systemControls.ButtonPressed += OnSystemControlsButtonPressed;
_timelineProperties.StartTime = TimeSpan.Zero;
_timelineProperties.MinSeekTime = TimeSpan.Zero;
}
/// <summary>
/// 系统媒体控制按钮按下事件处理
/// </summary>
private void OnSystemControlsButtonPressed(
SystemMediaTransportControls sender,
SystemMediaTransportControlsButtonPressedEventArgs args
)
{
ButtonPressed?.Invoke(args.Button);
}
/// <summary>
/// 更新播放状态
/// </summary>
/// <param name="playbackStatus">播放状态</param>
public void UpdatePlaybackStatus(MediaPlaybackStatus playbackStatus)
{
_systemControls.PlaybackStatus = playbackStatus;
}
/// <summary>
/// 设置按钮是否可用
/// </summary>
/// <param name="isPlayEnabled">播放按钮是否可用</param>
/// <param name="isPauseEnabled">暂停按钮是否可用</param>
/// <param name="isPreviousEnabled">上一首按钮是否可用</param>
/// <param name="isNextEnabled">下一首按钮是否可用</param>
public void SetButtonsEnabled(
bool isPlayEnabled,
bool isPauseEnabled,
bool isPreviousEnabled,
bool isNextEnabled
)
{
_systemControls.IsPlayEnabled = isPlayEnabled;
_systemControls.IsPauseEnabled = isPauseEnabled;
_systemControls.IsPreviousEnabled = isPreviousEnabled;
_systemControls.IsNextEnabled = isNextEnabled;
}
/// <summary>
/// 更新播放队列信息以计算按钮状态
/// </summary>
/// <param name="playQueueIndex">当前播放索引</param>
/// <param name="playQueueLength">播放队列长度</param>
/// <param name="repeatMode">循环模式</param>
public void UpdatePlayQueueInfo(int playQueueIndex, int playQueueLength, byte repeatMode)
{
_playQueueIndex = playQueueIndex;
_playQueueLength = playQueueLength;
_repeatMode = repeatMode;
UpdateNavigationButtonsState();
}
/// <summary>
/// 更新导航按钮状态
/// </summary>
private void UpdateNavigationButtonsState()
{
var isFirstSong = _playQueueIndex == 0;
var isLastSong = _playQueueIndex == _playQueueLength - 1;
var isRepeatOffOrSingle = _repeatMode == 0 || _repeatMode == 2;
_systemControls.IsPreviousEnabled = !(isFirstSong && isRepeatOffOrSingle);
_systemControls.IsNextEnabled = !(isLastSong && isRepeatOffOrSingle);
}
/// <summary>
/// 更新媒体信息
/// </summary>
/// <param name="title">歌曲标题</param>
/// <param name="artist">艺术家</param>
/// <param name="totalDuration">总时长</param>
public void UpdateMediaInfo(string title, string artist, TimeSpan totalDuration)
{
_displayUpdater.MusicProperties.Title = title;
_displayUpdater.MusicProperties.Artist =
artist == "SongInfo_UnknownArtist".GetLocalized() ? "" : artist;
_timelineProperties.MaxSeekTime = totalDuration;
_timelineProperties.EndTime = totalDuration;
}
/// <summary>
/// 设置封面图片
/// </summary>
/// <param name="song">当前歌曲</param>
public async Task SetCoverImageAsync(IDetailedSongInfoBase song)
{
if (song.Cover is null)
{
_displayUpdater.Thumbnail = RandomAccessStreamReference.CreateFromUri(
new Uri("ms-appx:///Assets/NoCover.png")
);
return;
}
if (song.IsOnline)
{
try
{
var info = (IDetailedOnlineSongInfo)song;
_displayUpdater.Thumbnail = RandomAccessStreamReference.CreateFromUri(
new Uri(info.CoverPath!)
);
}
catch { }
}
else
{
try
{
var info = (DetailedLocalSongInfo)song;
_currentCoverStream?.Dispose();
_currentCoverStream = new InMemoryRandomAccessStream();
await _currentCoverStream.WriteAsync(info.CoverBuffer.AsBuffer());
_currentCoverStream.Seek(0);
_displayUpdater.Thumbnail = RandomAccessStreamReference.CreateFromStream(
_currentCoverStream
);
}
catch
{
_displayUpdater.Thumbnail = RandomAccessStreamReference.CreateFromUri(
new Uri("ms-appx:///Assets/NoCover.png")
);
}
}
}
/// <summary>
/// 更新时间轴属性
/// </summary>
/// <param name="currentTime">当前播放时间</param>
public void UpdateTimelinePosition(TimeSpan currentTime)
{
_timelineProperties.Position = currentTime;
_systemControls.UpdateTimelineProperties(_timelineProperties);
}
/// <summary>
/// 应用所有更改
/// </summary>
public void Update()
{
_displayUpdater.Update();
}
public void Dispose()
{
_systemControls.ButtonPressed -= OnSystemControlsButtonPressed;
_currentCoverStream?.Dispose();
_tempPlayer?.Dispose();
GC.SuppressFinalize(this);
}
}

View File

@@ -67,7 +67,7 @@ public partial class HomeViewModel : ObservableObject
}
public async void SuggestBox_QuerySubmitted(
AutoSuggestBox sender,
AutoSuggestBox _,
AutoSuggestBoxQuerySubmittedEventArgs args
)
{
@@ -97,7 +97,7 @@ public partial class HomeViewModel : ObservableObject
}
}
public void SelectorBar_Loaded(object sender, RoutedEventArgs e)
public void SelectorBar_Loaded(object sender, RoutedEventArgs _)
{
if (sender is SelectorBar selectorBar)
{
@@ -109,7 +109,7 @@ public partial class HomeViewModel : ObservableObject
public void SelectorBar_SelectionChanged(
SelectorBar sender,
SelectorBarSelectionChangedEventArgs args
SelectorBarSelectionChangedEventArgs _
)
{
var selectedItem = sender.SelectedItem;

View File

@@ -18,13 +18,13 @@ public class LocalAlbumDetailViewModel
SongList = [.. Data.MusicLibrary.GetSongsByAlbum(Album)];
}
public void PlayAllButton_Click(object sender, RoutedEventArgs e)
public void PlayAllButton_Click(object _1, RoutedEventArgs _2)
{
Data.MusicPlayer.SetPlayQueue($"LocalSongs:Album:{Album.Name}", SongList);
Data.MusicPlayer.PlaySongByInfo(SongList[0]);
}
public void ShuffledPlayAllButton_Click(object sender, RoutedEventArgs e)
public void ShuffledPlayAllButton_Click(object _1, RoutedEventArgs _2)
{
Data.MusicPlayer.SetShuffledPlayQueue($"ShuffledLocalSongs:Album:{Album.Name}", SongList);
Data.MusicPlayer.PlaySongByIndexedInfo(Data.MusicPlayer.ShuffledPlayQueue[0]);
@@ -48,7 +48,7 @@ public class LocalAlbumDetailViewModel
}
}
public void SongListView_ItemClick(object sender, ItemClickEventArgs e)
public void SongListView_ItemClick(object _, ItemClickEventArgs e)
{
Data.MusicPlayer.SetPlayQueue($"LocalSongs:Album:{Album.Name}", SongList);
if (e.ClickedItem is BriefLocalSongInfo info)

View File

@@ -309,7 +309,7 @@ public partial class LocalAlbumsViewModel
});
}
public async void SortByListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
public async void SortByListView_SelectionChanged(object sender, SelectionChangedEventArgs _)
{
var currentsortmode = SortMode;
SortMode = (byte)(sender as ListView)!.SelectedIndex;
@@ -323,12 +323,12 @@ public partial class LocalAlbumsViewModel
}
}
public void SortByListView_Loaded(object sender, RoutedEventArgs e)
public void SortByListView_Loaded(object sender, RoutedEventArgs _)
{
(sender as ListView)!.SelectedIndex = SortMode;
}
public async void GenreListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
public async void GenreListView_SelectionChanged(object sender, SelectionChangedEventArgs _)
{
var currentGenreMode = GenreMode;
GenreMode = (byte)(sender as ListView)!.SelectedIndex;
@@ -342,7 +342,7 @@ public partial class LocalAlbumsViewModel
}
}
public void GenreListView_Loaded(object sender, RoutedEventArgs e)
public void GenreListView_Loaded(object sender, RoutedEventArgs _)
{
(sender as ListView)!.SelectedIndex = GenreMode;
}

View File

@@ -21,7 +21,7 @@ public class LocalArtistDetailViewModel
AlbumList = Data.MusicLibrary.GetAlbumsByArtist(Artist);
}
public void PlayAllButton_Click(object sender, RoutedEventArgs e)
public void PlayAllButton_Click(object _1, RoutedEventArgs _2)
{
Data.MusicPlayer.SetPlayQueue(
$"LocalSongs:Artist:{Artist.Name}",
@@ -30,7 +30,7 @@ public class LocalArtistDetailViewModel
Data.MusicPlayer.PlaySongByInfo(AlbumList[0].SongList[0]);
}
public void ShuffledPlayAllButton_Click(object sender, RoutedEventArgs e)
public void ShuffledPlayAllButton_Click(object _1, RoutedEventArgs _2)
{
Data.MusicPlayer.SetShuffledPlayQueue(
$"ShuffledLocalSongs:Artist:{Artist.Name}",

View File

@@ -64,7 +64,7 @@ public partial class LocalArtistsViewModel
IsProgressRingActive = false;
}
public async void SortByListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
public async void SortByListView_SelectionChanged(object sender, SelectionChangedEventArgs _)
{
var currentsortmode = SortMode;
SortMode = (byte)(sender as ListView)!.SelectedIndex;
@@ -77,7 +77,7 @@ public partial class LocalArtistsViewModel
}
}
public void SortByListView_Loaded(object sender, RoutedEventArgs e)
public void SortByListView_Loaded(object sender, RoutedEventArgs _)
{
(sender as ListView)!.SelectedIndex = SortMode;
}

View File

@@ -260,7 +260,7 @@ public partial class LocalSongsViewModel
public object GetSongListViewSource(
ICollectionView grouped,
List<BriefLocalSongInfo> notgrouped
List<BriefLocalSongInfo> _
)
{
return _isGrouped ? grouped : NotGroupedSongList;
@@ -492,7 +492,7 @@ public partial class LocalSongsViewModel
});
}
public async void SortByListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
public async void SortByListView_SelectionChanged(object sender, SelectionChangedEventArgs _)
{
var currentsortmode = SortMode;
SortMode = (byte)(sender as ListView)!.SelectedIndex;
@@ -507,12 +507,12 @@ public partial class LocalSongsViewModel
}
}
public void SortByListView_Loaded(object sender, RoutedEventArgs e)
public void SortByListView_Loaded(object sender, RoutedEventArgs _)
{
(sender as ListView)!.SelectedIndex = SortMode;
}
public async void GenreListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
public async void GenreListView_SelectionChanged(object sender, SelectionChangedEventArgs _)
{
var currentGenreMode = GenreMode;
GenreMode = (byte)(sender as ListView)!.SelectedIndex;
@@ -527,18 +527,18 @@ public partial class LocalSongsViewModel
}
}
public void GenreListView_Loaded(object sender, RoutedEventArgs e)
public void GenreListView_Loaded(object sender, RoutedEventArgs _)
{
(sender as ListView)!.SelectedIndex = GenreMode;
}
public void ShuffledPlayAllButton_Click(object sender, RoutedEventArgs e)
public void ShuffledPlayAllButton_Click(object _1, RoutedEventArgs _2)
{
Data.MusicPlayer.SetShuffledPlayQueue("ShuffledLocalSongs:All", ConvertGroupedToFlatList());
Data.MusicPlayer.PlaySongByIndexedInfo(Data.MusicPlayer.ShuffledPlayQueue[0]);
}
public void SongListView_ItemClick(object sender, ItemClickEventArgs e)
public void SongListView_ItemClick(object _, ItemClickEventArgs e)
{
if (e.ClickedItem is BriefLocalSongInfo info)
{

View File

@@ -11,7 +11,7 @@ public class LyricViewModel
{
public LyricViewModel() { }
public void ListView_ItemClick(object sender, ItemClickEventArgs e)
public void ListView_ItemClick(object _, ItemClickEventArgs e)
{
if (e.ClickedItem is LyricSlice lyricSlice)
{
@@ -20,19 +20,19 @@ public class LyricViewModel
}
}
public void PlayButton_Click(object sender, RoutedEventArgs e)
public void PlayButton_Click(object _1, RoutedEventArgs _2)
{
var currentSong = Data.MusicPlayer.CurrentBriefSong;
Data.MusicPlayer.PlaySongByInfo(currentSong!);
}
public void PlayNextButton_Click(object sender, RoutedEventArgs e)
public void PlayNextButton_Click(object _1, RoutedEventArgs _2)
{
var currentSong = Data.MusicPlayer.CurrentBriefSong;
Data.MusicPlayer.AddSongToNextPlay(currentSong!);
}
public void AddToPlayQueueButton_Click(object sender, RoutedEventArgs e)
public void AddToPlayQueueButton_Click(object _1, RoutedEventArgs _2)
{
var currentSong = Data.MusicPlayer.CurrentBriefSong;
Data.MusicPlayer.AddSongToPlayQueue(currentSong!);
@@ -44,7 +44,7 @@ public class LyricViewModel
await Data.PlaylistLibrary.AddToPlaylist(playlist, currentSong!);
}
public async void ShowAlbumButton_Click(object sender, RoutedEventArgs e)
public async void ShowAlbumButton_Click(object _1, RoutedEventArgs _2)
{
Data.RootPlayBarViewModel!.DetailModeUpdate();
var info = Data.MusicPlayer.CurrentBriefSong;
@@ -76,7 +76,7 @@ public class LyricViewModel
}
}
public async void ShowArtistButton_Click(object sender, RoutedEventArgs e)
public async void ShowArtistButton_Click(object _1, RoutedEventArgs _2)
{
Data.RootPlayBarViewModel!.DetailModeUpdate();
var info = Data.MusicPlayer.CurrentBriefSong;

View File

@@ -58,7 +58,7 @@ public partial class MusicLibraryViewModel
: Visibility.Visible;
}
public async void PickMusicFolderButton_Click(object sender, RoutedEventArgs e)
public async void PickMusicFolderButton_Click(object sender, RoutedEventArgs _)
{
(sender as Button)!.IsEnabled = false;
var openPicker = new FolderPicker(App.MainWindow!.AppWindow.Id)

View File

@@ -74,7 +74,7 @@ public partial class OnlineAlbumDetailViewModel : ObservableObject
IsSearchProgressRingActive = false;
}
public void PlayAllButton_Click(object sender, RoutedEventArgs e)
public void PlayAllButton_Click(object _1, RoutedEventArgs _2)
{
if (Album.SongList.Count == 0)
{
@@ -84,7 +84,7 @@ public partial class OnlineAlbumDetailViewModel : ObservableObject
Data.MusicPlayer.PlaySongByInfo(Album.SongList[0]);
}
public void ShuffledPlayAllButton_Click(object sender, RoutedEventArgs e)
public void ShuffledPlayAllButton_Click(object _1, RoutedEventArgs _2)
{
if (Album.SongList.Count == 0)
{
@@ -119,7 +119,7 @@ public partial class OnlineAlbumDetailViewModel : ObservableObject
}
}
public void SongListView_ItemClick(object sender, ItemClickEventArgs e)
public void SongListView_ItemClick(object _, ItemClickEventArgs e)
{
Data.MusicPlayer.SetPlayQueue($"OnlineSongs:Album:{Album.Name}", Album.SongList);
if (e.ClickedItem is IBriefOnlineSongInfo info)

View File

@@ -136,7 +136,7 @@ public partial class OnlineArtistDetailViewModel : ObservableObject
}
}
public void PlayAllButton_Click(object sender, RoutedEventArgs e)
public void PlayAllButton_Click(object _1, RoutedEventArgs _2)
{
if (Artist.AlbumList.Count == 0)
{
@@ -147,7 +147,7 @@ public partial class OnlineArtistDetailViewModel : ObservableObject
Data.MusicPlayer.PlaySongByInfo(allSongs[0]);
}
public void ShuffledPlayAllButton_Click(object sender, RoutedEventArgs e)
public void ShuffledPlayAllButton_Click(object _1, RoutedEventArgs _2)
{
if (Artist.AlbumList.Count == 0)
{

View File

@@ -76,7 +76,7 @@ public partial class OnlinePlayListDetailViewModel : ObservableObject
IsSearchProgressRingActive = false;
}
public void PlayAllButton_Click(object sender, RoutedEventArgs e)
public void PlayAllButton_Click(object _1, RoutedEventArgs _2)
{
if (Playlist.SongList.Count == 0)
{
@@ -111,7 +111,7 @@ public partial class OnlinePlayListDetailViewModel : ObservableObject
}
}
public void SongListView_ItemClick(object sender, ItemClickEventArgs e)
public void SongListView_ItemClick(object _, ItemClickEventArgs e)
{
Data.MusicPlayer.SetPlayQueue($"OnlineSongs:Playlist:{Playlist.Name}", Playlist.SongList);
if (e.ClickedItem is IBriefOnlineSongInfo info)

View File

@@ -10,7 +10,7 @@ public class OnlineSongsViewModel
{
public OnlineSongsViewModel() { }
public void OnlineSongsSongListView_ItemClick(object sender, ItemClickEventArgs e)
public void OnlineSongsSongListView_ItemClick(object _, ItemClickEventArgs e)
{
Data.MusicPlayer.SetPlayQueue(
$"OnlineSongs:{Data.OnlineMusicLibrary.SearchKeyWords}",

View File

@@ -67,7 +67,7 @@ public partial class PlayListDetailViewModel
}
}
public void PlayAllButton_Click(object sender, RoutedEventArgs e)
public void PlayAllButton_Click(object _1, RoutedEventArgs _2)
{
if (SongList.Count == 0)
{
@@ -102,14 +102,14 @@ public partial class PlayListDetailViewModel
}
}
public void DeleteButton_Click(object sender, RoutedEventArgs e)
public void DeleteButton_Click(object _1, RoutedEventArgs _2)
{
Data.SelectedPlaylist = null;
Data.ShellPage!.GoBack();
Data.PlaylistLibrary.DeletePlaylist(Playlist);
}
public void SongListView_ItemClick(object sender, ItemClickEventArgs e)
public void SongListView_ItemClick(object _, ItemClickEventArgs e)
{
var songList = SongList.AsValueEnumerable().Select(s => s.Song).ToArray();
Data.MusicPlayer.SetPlayQueue($"Songs:Playlist:{Playlist.Name}", songList);
@@ -240,7 +240,7 @@ public partial class PlayListDetailViewModel
}
}
public void SongListView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
public void SongListView_DragItemsStarting(object _, DragItemsStartingEventArgs e)
{
if (e.Items.Count > 0)
{
@@ -249,7 +249,7 @@ public partial class PlayListDetailViewModel
}
public void SongListView_DragItemsCompleted(
ListViewBase sender,
ListViewBase _1,
DragItemsCompletedEventArgs args
)
{

View File

@@ -145,12 +145,12 @@ public partial class PlayListsViewModel
});
}
public void SortByListView_Loaded(object sender, RoutedEventArgs e)
public void SortByListView_Loaded(object sender, RoutedEventArgs _)
{
(sender as ListView)!.SelectedIndex = SortMode;
}
public async void SortByListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
public async void SortByListView_SelectionChanged(object sender, SelectionChangedEventArgs _)
{
var currentsortmode = SortMode;
SortMode = (byte)(sender as ListView)!.SelectedIndex;

View File

@@ -61,7 +61,7 @@ public partial class PlayQueueViewModel : ObservableObject
Data.MusicPlayer.AddSongsToPlayQueue(songList);
}
public void PlayQueueListView_ItemClick(object sender, ItemClickEventArgs e)
public void PlayQueueListView_ItemClick(object _, ItemClickEventArgs e)
{
if (e.ClickedItem is IndexedPlayQueueSong info)
{
@@ -164,7 +164,7 @@ public partial class PlayQueueViewModel : ObservableObject
}
}
public void ClearButton_Click(object sender, RoutedEventArgs e)
public void ClearButton_Click(object _1, RoutedEventArgs _2)
{
Data.MusicPlayer.ClearPlayQueue();
}
@@ -230,7 +230,7 @@ public partial class PlayQueueViewModel : ObservableObject
IsButtonEnabled = PlayQueue.Count > 0;
}
public void PlayQueueListView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
public void PlayQueueListView_DragItemsStarting(object _, DragItemsStartingEventArgs e)
{
_currentSong = PlayQueue[Data.MusicPlayer.PlayQueueIndex];
if (e.Items.Count > 0)
@@ -239,7 +239,7 @@ public partial class PlayQueueViewModel : ObservableObject
}
}
public void PlayQueueListView_DragOver(object sender, DragEventArgs e)
public void PlayQueueListView_DragOver(object _, DragEventArgs e)
{
if (e.DataView.Contains(StandardDataFormats.StorageItems))
{
@@ -252,7 +252,7 @@ public partial class PlayQueueViewModel : ObservableObject
}
public void PlayQueueListView_DragItemsCompleted(
object sender,
object _,
DragItemsCompletedEventArgs args
)
{

View File

@@ -122,7 +122,7 @@ public partial class RootPlayBarViewModel : ObservableObject
}
}
public void FullScreenButton_Click(object sender, RoutedEventArgs e)
public void FullScreenButton_Click(object _1, RoutedEventArgs _2)
{
var appWindow = App.MainWindow!.AppWindow;
if (appWindow.Presenter.Kind == AppWindowPresenterKind.FullScreen)
@@ -137,7 +137,7 @@ public partial class RootPlayBarViewModel : ObservableObject
}
}
public void DesktopLyricButton_Click(object sender, RoutedEventArgs e)
public void DesktopLyricButton_Click(object _1, RoutedEventArgs _2)
{
if (!IsDesktopLyricWindowStarted)
{

View File

@@ -158,7 +158,7 @@ public partial class SettingsViewModel
partial void OnIsFallBackChanged(bool value)
{
_materialSelectorService.SetIsFallBack(value);
_materialSelectorService.IsFallBack = value;
}
/// <summary>
@@ -167,12 +167,22 @@ public partial class SettingsViewModel
[ObservableProperty]
public partial byte LuminosityOpacity { get; set; }
partial void OnLuminosityOpacityChanged(byte value)
{
_materialSelectorService.SetLuminosityOpacity(value, false);
}
/// <summary>
/// 背景颜色
/// </summary>
[ObservableProperty]
public partial Color TintColor { get; set; }
partial void OnTintColorChanged(Color value)
{
_materialSelectorService.SetTintColor(value, false);
}
/// <summary>
/// 是否显示歌词背景
/// </summary>
@@ -215,7 +225,7 @@ public partial class SettingsViewModel
IsExportPlaylistsButtonEnabled = message.HasPlaylist;
}
public async void PickMusicFolderButton_Click(object sender, RoutedEventArgs e)
public async void PickMusicFolderButton_Click(object sender, RoutedEventArgs _)
{
(sender as Button)!.IsEnabled = false;
var openPicker = new FolderPicker(App.MainWindow!.AppWindow.Id)
@@ -247,7 +257,7 @@ public partial class SettingsViewModel
await Data.MusicLibrary.LoadLibraryAgainAsync();
}
public async void RefreshButton_Click(object sender, RoutedEventArgs e)
public async void RefreshButton_Click(object sender, RoutedEventArgs _)
{
var senderButton = sender as Button;
senderButton!.IsEnabled = false;
@@ -255,12 +265,12 @@ public partial class SettingsViewModel
senderButton!.IsEnabled = true;
}
public void SongDownloadLocationButton_Click(object sender, RoutedEventArgs e)
public void SongDownloadLocationButton_Click(object _1, RoutedEventArgs _2)
{
Process.Start("explorer.exe", SongDownloadLocation);
}
public async void ChangeSongDownloadLocationButton_Click(object sender, RoutedEventArgs e)
public async void ChangeSongDownloadLocationButton_Click(object sender, RoutedEventArgs _)
{
(sender as Button)!.IsEnabled = false;
try
@@ -282,7 +292,7 @@ public partial class SettingsViewModel
}
}
public async void ImportFromM3u8Button_Click(object sender, RoutedEventArgs e)
public async void ImportFromM3u8Button_Click(object sender, RoutedEventArgs _)
{
(sender as Button)!.IsEnabled = false;
try
@@ -328,7 +338,7 @@ public partial class SettingsViewModel
}
}
public async void ImportFromBinButton_Click(object sender, RoutedEventArgs e)
public async void ImportFromBinButton_Click(object sender, RoutedEventArgs _)
{
(sender as Button)!.IsEnabled = false;
try
@@ -371,7 +381,7 @@ public partial class SettingsViewModel
}
}
public async void ExportToM3u8Button_Click(object sender, RoutedEventArgs e)
public async void ExportToM3u8Button_Click(object sender, RoutedEventArgs _)
{
(sender as Button)!.IsEnabled = false;
try
@@ -408,7 +418,7 @@ public partial class SettingsViewModel
}
}
public async void ExportToBinButton_Click(object sender, RoutedEventArgs e)
public async void ExportToBinButton_Click(object sender, RoutedEventArgs _)
{
(sender as Button)!.IsEnabled = false;
try
@@ -456,7 +466,7 @@ public partial class SettingsViewModel
}
}
public async void MaterialComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
public async void MaterialComboBox_SelectionChanged(object _1, SelectionChangedEventArgs _2)
{
var (opacity, color) = await _materialSelectorService.SetMaterial(
(MaterialType)SelectedMaterial,
@@ -467,7 +477,7 @@ public partial class SettingsViewModel
TintColor = color;
}
public async void ResetMaterialButton_Click(object sender, RoutedEventArgs e)
public async void ResetMaterialButton_Click(object _1, RoutedEventArgs _2)
{
IsFallBack = true;
SelectedMaterial = (byte)MaterialType.DesktopAcrylic;
@@ -481,20 +491,7 @@ public partial class SettingsViewModel
OnPropertyChanged(nameof(SelectedMaterial));
}
public void LuminosityOpacitySlider_ValueChanged(
object sender,
RangeBaseValueChangedEventArgs e
)
{
_materialSelectorService.SetLuminosityOpacity(LuminosityOpacity, false);
}
public void TintColorPicker_ColorChanged(ColorPicker sender, ColorChangedEventArgs args)
{
_materialSelectorService.SetTintColor(args.NewColor, false);
}
public void FontFamilyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
public void FontFamilyComboBox_SelectionChanged(object _, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0 && e.AddedItems[0] is FontInfo selectedFont)
{
@@ -502,7 +499,7 @@ public partial class SettingsViewModel
}
}
public void FontSizeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
public void FontSizeComboBox_SelectionChanged(object _, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0 && e.AddedItems[0] is double fontSize)
{
@@ -522,7 +519,7 @@ public partial class SettingsViewModel
}
}
public void MaterialComboBox_Loaded(object sender, RoutedEventArgs e)
public void MaterialComboBox_Loaded(object sender, RoutedEventArgs _)
{
(sender as ComboBox)!.SelectedIndex = SelectedMaterial;
}
@@ -547,7 +544,7 @@ public partial class SettingsViewModel
FontFamilies = [.. list.AsValueEnumerable().OrderBy(f => f.Name)];
}
public void FontFamilyComboBox_Loaded(object sender, RoutedEventArgs e)
public void FontFamilyComboBox_Loaded(object sender, RoutedEventArgs _)
{
var selectedFontName = SelectedFontFamily.Source;
var index = FontFamilies.FindIndex(f => f.Name == selectedFontName);
@@ -557,7 +554,7 @@ public partial class SettingsViewModel
}
}
public void FontSizeComboBox_Loaded(object sender, RoutedEventArgs e)
public void FontSizeComboBox_Loaded(object sender, RoutedEventArgs _)
{
var selectedItem = FontSizes.FirstOrDefault(f => f == SelectedCurrentFontSize);
if (selectedItem != 0.0)
@@ -570,7 +567,7 @@ public partial class SettingsViewModel
}
}
public void OpenLoggingFolderButton_Click(object sender, RoutedEventArgs e)
public void OpenLoggingFolderButton_Click(object _1, RoutedEventArgs _2)
{
var logFolder = LoggingService.GetLogFolderPath();
Directory.CreateDirectory(logFolder);

View File

@@ -35,7 +35,7 @@ public partial class ShellViewModel : ObservableObject
LoadAsync();
}
public void NavigationFrame_Navigating(object sender, NavigatingCancelEventArgs e)
public void NavigationFrame_Navigating(object _, NavigatingCancelEventArgs e)
{
if (e.NavigationMode == NavigationMode.Back)
{
@@ -95,7 +95,7 @@ public partial class ShellViewModel : ObservableObject
SaveCurrentPageAsync();
}
public void NavigationFrame_DragOver(object sender, DragEventArgs e)
public void NavigationFrame_DragOver(object _, DragEventArgs e)
{
if (CurrentPage == nameof(PlayQueuePage))
{
@@ -111,7 +111,7 @@ public partial class ShellViewModel : ObservableObject
}
}
public async void NavigationFrame_Drop(object sender, DragEventArgs e)
public async void NavigationFrame_Drop(object _, DragEventArgs e)
{
if (CurrentPage == nameof(PlayQueuePage))
{

View File

@@ -411,7 +411,7 @@ public sealed partial class OnlineAlbumDetailPage : Page
}
}
private void AddToPlayQueueButton_Click(object sender, RoutedEventArgs e)
private void AddToPlayQueueButton_Click(object sender, RoutedEventArgs _)
{
if (sender is FrameworkElement { DataContext: IBriefOnlineSongInfo info })
{
@@ -419,7 +419,7 @@ public sealed partial class OnlineAlbumDetailPage : Page
}
}
private async void AddToNewPlaylistButton_Click(object sender, RoutedEventArgs e)
private async void AddToNewPlaylistButton_Click(object sender, RoutedEventArgs _)
{
if (sender is FrameworkElement { DataContext: IBriefOnlineSongInfo info })
{

View File

@@ -272,12 +272,10 @@
<toolkit:SettingsCard x:Uid="Settings_LuminosityOpacity">
<Slider Width="312"
Maximum="100" Minimum="0"
ValueChanged="{x:Bind ViewModel.LuminosityOpacitySlider_ValueChanged}"
Value="{x:Bind ViewModel.LuminosityOpacity, Mode=TwoWay}"/>
</toolkit:SettingsCard>
<toolkit:SettingsCard x:Uid="Settings_WindowBackgroundColor">
<ColorPicker ColorChanged="{x:Bind ViewModel.TintColorPicker_ColorChanged}"
ColorSpectrumShape="Ring" IsAlphaEnabled="True"
<ColorPicker ColorSpectrumShape="Ring" IsAlphaEnabled="True"
IsAlphaSliderVisible="True"
IsAlphaTextInputVisible="True"
IsColorChannelTextInputVisible="True"