mirror of
https://github.com/LanZhan-Harmony/WindowsMusicPlayer-TheUntamedMusicPlayer.git
synced 2026-05-06 19:20:18 +08:00
更新Equlizer
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
xmlns:local="using:The_Untamed_Music_Player.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:toolkitConverters="using:CommunityToolkit.WinUI.Converters"
|
||||
CloseButtonClick="CloseButtonClick"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonClick="SaveButtonClick"
|
||||
Style="{StaticResource DefaultContentDialogStyle}"
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
using Microsoft.Windows.Storage.Pickers;
|
||||
using The_Untamed_Music_Player.Helpers;
|
||||
using The_Untamed_Music_Player.Messages;
|
||||
using The_Untamed_Music_Player.Models;
|
||||
using The_Untamed_Music_Player.Services;
|
||||
using Windows.Storage;
|
||||
@@ -14,7 +16,10 @@ using ZLogger;
|
||||
|
||||
namespace The_Untamed_Music_Player.Controls;
|
||||
|
||||
public sealed partial class EditAlbumInfoDialog : ContentDialog, INotifyPropertyChanged
|
||||
public sealed partial class EditAlbumInfoDialog
|
||||
: ContentDialog,
|
||||
INotifyPropertyChanged,
|
||||
IRecipient<ThemeChangeMessage>
|
||||
{
|
||||
private static readonly string[] _supportedEditTypes = [".mp3", ".flac"];
|
||||
private readonly ILogger _logger = LoggingService.CreateLogger<EditAlbumInfoDialog>();
|
||||
@@ -45,6 +50,7 @@ public sealed partial class EditAlbumInfoDialog : ContentDialog, INotifyProperty
|
||||
|
||||
public EditAlbumInfoDialog(LocalAlbumInfo info)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Register(this);
|
||||
_album = info;
|
||||
var songs = Data.MusicLibrary.GetSongsByAlbum(info);
|
||||
_tempSongs = [.. songs.AsValueEnumerable().Select(song => new TempSongInfo(song))];
|
||||
@@ -58,6 +64,11 @@ public sealed partial class EditAlbumInfoDialog : ContentDialog, INotifyProperty
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Receive(ThemeChangeMessage message)
|
||||
{
|
||||
RequestedTheme = message.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
}
|
||||
|
||||
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!uint.TryParse((sender as TextBox)!.Text, out var _))
|
||||
@@ -207,6 +218,11 @@ public sealed partial class EditAlbumInfoDialog : ContentDialog, INotifyProperty
|
||||
(sender as Button)!.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private new void CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Unregister<ThemeChangeMessage>(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class TempSongInfo(BriefLocalSongInfo originalSong)
|
||||
|
||||
@@ -19,7 +19,10 @@ using ZLogger;
|
||||
|
||||
namespace The_Untamed_Music_Player.Controls;
|
||||
|
||||
public sealed partial class EditPlaylistInfoDialog : ContentDialog, INotifyPropertyChanged
|
||||
public sealed partial class EditPlaylistInfoDialog
|
||||
: ContentDialog,
|
||||
INotifyPropertyChanged,
|
||||
IRecipient<ThemeChangeMessage>
|
||||
{
|
||||
private readonly ILogger _logger = LoggingService.CreateLogger<EditPlaylistInfoDialog>();
|
||||
private readonly PlaylistInfo _playlist;
|
||||
@@ -114,6 +117,7 @@ public sealed partial class EditPlaylistInfoDialog : ContentDialog, INotifyPrope
|
||||
|
||||
public EditPlaylistInfoDialog(PlaylistInfo info)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Register(this);
|
||||
_playlist = info;
|
||||
_originalName = info.Name;
|
||||
_name = info.Name;
|
||||
@@ -136,6 +140,11 @@ public sealed partial class EditPlaylistInfoDialog : ContentDialog, INotifyPrope
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Receive(ThemeChangeMessage message)
|
||||
{
|
||||
RequestedTheme = message.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
}
|
||||
|
||||
private void PlaylistNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
IsPrimaryButtonEnabled = !string.IsNullOrEmpty((sender as TextBox)!.Text);
|
||||
@@ -403,5 +412,6 @@ public sealed partial class EditPlaylistInfoDialog : ContentDialog, INotifyPrope
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
StrongReferenceMessenger.Default.Unregister<ThemeChangeMessage>(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
xmlns:local="using:The_Untamed_Music_Player.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:toolkitConverters="using:CommunityToolkit.WinUI.Converters"
|
||||
CloseButtonClick="CloseButtonClick"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonClick="SaveButtonClick"
|
||||
Style="{StaticResource DefaultContentDialogStyle}"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.UI.Text;
|
||||
using Microsoft.UI.Xaml;
|
||||
@@ -8,6 +9,7 @@ using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
using Microsoft.Windows.Storage.Pickers;
|
||||
using The_Untamed_Music_Player.Helpers;
|
||||
using The_Untamed_Music_Player.Messages;
|
||||
using The_Untamed_Music_Player.Models;
|
||||
using The_Untamed_Music_Player.Services;
|
||||
using Windows.Storage;
|
||||
@@ -17,7 +19,10 @@ using TextBox = Microsoft.UI.Xaml.Controls.TextBox;
|
||||
|
||||
namespace The_Untamed_Music_Player.Controls;
|
||||
|
||||
public sealed partial class EditSongInfoDialog : ContentDialog, INotifyPropertyChanged
|
||||
public sealed partial class EditSongInfoDialog
|
||||
: ContentDialog,
|
||||
INotifyPropertyChanged,
|
||||
IRecipient<ThemeChangeMessage>
|
||||
{
|
||||
private static readonly string[] _supportedEditTypes = [".mp3", ".flac"];
|
||||
private readonly ILogger _logger = LoggingService.CreateLogger<EditSongInfoDialog>();
|
||||
@@ -71,6 +76,7 @@ public sealed partial class EditSongInfoDialog : ContentDialog, INotifyPropertyC
|
||||
|
||||
public EditSongInfoDialog(BriefLocalSongInfo info)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Register(this);
|
||||
var detailedInfo = new DetailedLocalSongInfo(info);
|
||||
_song = detailedInfo;
|
||||
_title = detailedInfo.Title;
|
||||
@@ -88,6 +94,11 @@ public sealed partial class EditSongInfoDialog : ContentDialog, INotifyPropertyC
|
||||
LyricEditor.Document.SetText(TextSetOptions.None, _lyric);
|
||||
}
|
||||
|
||||
public void Receive(ThemeChangeMessage message)
|
||||
{
|
||||
RequestedTheme = message.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
}
|
||||
|
||||
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!uint.TryParse((sender as TextBox)!.Text, out var _))
|
||||
@@ -287,4 +298,9 @@ public sealed partial class EditSongInfoDialog : ContentDialog, INotifyPropertyC
|
||||
(sender as Button)!.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private new void CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Unregister<ThemeChangeMessage>(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,175 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:helper="using:The_Untamed_Music_Player.Helpers"
|
||||
xmlns:local="using:The_Untamed_Music_Player.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
CloseButtonClick="CloseButtonClick"
|
||||
Style="{StaticResource DefaultContentDialogStyle}"
|
||||
mc:Ignorable="d">
|
||||
<ContentDialog.Resources>
|
||||
<helper:DoubleToDecibelConverter x:Key="DoubleToDecibelConverter"/>
|
||||
<x:Double x:Key="ContentDialogMaxWidth">2000</x:Double>
|
||||
<Style x:Key="SliderStyle"
|
||||
BasedOn="{StaticResource DefaultSliderStyle}"
|
||||
TargetType="Slider">
|
||||
<Setter Property="Grid.Row" Value="0"/>
|
||||
<Setter Property="Height" Value="120"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="IsThumbToolTipEnabled" Value="True"/>
|
||||
<Setter Property="Maximum" Value="12"/>
|
||||
<Setter Property="Minimum" Value="-12"/>
|
||||
<Setter Property="Orientation" Value="Vertical"/>
|
||||
<Setter Property="SmallChange" Value="1"/>
|
||||
<Setter Property="SnapsTo" Value="StepValues"/>
|
||||
<Setter Property="StepFrequency" Value="0.1"/>
|
||||
<Setter Property="ThumbToolTipValueConverter" Value="{StaticResource DoubleToDecibelConverter}"/>
|
||||
<Setter Property="TickFrequency" Value="6"/>
|
||||
<Setter Property="TickPlacement" Value="Outside"/>
|
||||
</Style>
|
||||
<Style x:Key="HzTextStyle" TargetType="TextBlock">
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="Grid.Row" Value="2"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
<Style x:Key="dbTextStyle" TargetType="TextBlock">
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="Grid.Column" Value="0"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||
</Style>
|
||||
</ContentDialog.Resources>
|
||||
<Grid/>
|
||||
|
||||
<ContentDialog.Title>
|
||||
<Grid Width="490">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Uid="EqualizerDialog_Title"
|
||||
Grid.Column="0"
|
||||
FontWeight="Normal"/>
|
||||
<ToggleSwitch x:Name="IsEqualizerOnSwitch"
|
||||
Grid.Column="2"
|
||||
Margin="0,-4,0,0"
|
||||
FlowDirection="RightToLeft"
|
||||
IsOn="{x:Bind IsEqualizerOn, Mode=TwoWay}"/>
|
||||
</Grid>
|
||||
</ContentDialog.Title>
|
||||
|
||||
<StackPanel Width="486" Spacing="8">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<TextBlock x:Uid="EqualizerDialog_Preset" VerticalAlignment="Center"/>
|
||||
<ComboBox IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="8"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1.1*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="1.1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Row="0" Grid.Column="0"
|
||||
Spacing="10">
|
||||
<TextBlock Grid.Row="0" Style="{StaticResource dbTextStyle}">
|
||||
<Run Text="+12"/>
|
||||
<Run x:Uid="EqualizerDialog_Decibel1"/>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="1" Style="{StaticResource dbTextStyle}">
|
||||
<Run Text="+6"/>
|
||||
<Run x:Uid="EqualizerDialog_Decibel1"/>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="2" Style="{StaticResource dbTextStyle}">
|
||||
<Run Text="0"/>
|
||||
<Run x:Uid="EqualizerDialog_Decibel1"/>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="3" Style="{StaticResource dbTextStyle}">
|
||||
<Run Text="-6"/>
|
||||
<Run x:Uid="EqualizerDialog_Decibel1"/>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="4" Style="{StaticResource dbTextStyle}">
|
||||
<Run Text="-12"/>
|
||||
<Run x:Uid="EqualizerDialog_Decibel1"/>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<Slider Grid.Column="1"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"
|
||||
Style="{StaticResource SliderStyle}"/>
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource HzTextStyle}">
|
||||
<Run Text="62"/>
|
||||
<Run x:Uid="EqualizerDialog_Hz"/>
|
||||
</TextBlock>
|
||||
<Slider Grid.Column="2"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"
|
||||
Style="{StaticResource SliderStyle}"/>
|
||||
<TextBlock Grid.Column="2" Style="{StaticResource HzTextStyle}">
|
||||
<Run Text="125"/>
|
||||
<Run x:Uid="EqualizerDialog_Hz"/>
|
||||
</TextBlock>
|
||||
<Slider Grid.Column="3"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"
|
||||
Style="{StaticResource SliderStyle}"/>
|
||||
<TextBlock Grid.Column="3" Style="{StaticResource HzTextStyle}">
|
||||
<Run Text="250"/>
|
||||
<Run x:Uid="EqualizerDialog_Hz"/>
|
||||
</TextBlock>
|
||||
<Slider Grid.Column="4"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"
|
||||
Style="{StaticResource SliderStyle}"/>
|
||||
<TextBlock Grid.Column="4" Style="{StaticResource HzTextStyle}">
|
||||
<Run Text="500"/>
|
||||
<Run x:Uid="EqualizerDialog_Hz"/>
|
||||
</TextBlock>
|
||||
<Slider Grid.Column="5"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"
|
||||
Style="{StaticResource SliderStyle}"/>
|
||||
<TextBlock Grid.Column="5" Style="{StaticResource HzTextStyle}">
|
||||
<Run Text="1"/>
|
||||
<Run x:Uid="EqualizerDialog_kHz"/>
|
||||
</TextBlock>
|
||||
<Slider Grid.Column="6"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"
|
||||
Style="{StaticResource SliderStyle}"/>
|
||||
<TextBlock Grid.Column="6" Style="{StaticResource HzTextStyle}">
|
||||
<Run Text="2"/>
|
||||
<Run x:Uid="EqualizerDialog_kHz"/>
|
||||
</TextBlock>
|
||||
<Slider Grid.Column="7"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"
|
||||
Style="{StaticResource SliderStyle}"/>
|
||||
<TextBlock Grid.Column="7" Style="{StaticResource HzTextStyle}">
|
||||
<Run Text="4"/>
|
||||
<Run x:Uid="EqualizerDialog_kHz"/>
|
||||
</TextBlock>
|
||||
<Slider Grid.Column="8"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"
|
||||
Style="{StaticResource SliderStyle}"/>
|
||||
<TextBlock Grid.Column="8" Style="{StaticResource HzTextStyle}">
|
||||
<Run Text="8"/>
|
||||
<Run x:Uid="EqualizerDialog_kHz"/>
|
||||
</TextBlock>
|
||||
<Slider Grid.Column="9"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"
|
||||
Style="{StaticResource SliderStyle}"/>
|
||||
<TextBlock Grid.Column="9" Style="{StaticResource HzTextStyle}">
|
||||
<Run Text="16"/>
|
||||
<Run x:Uid="EqualizerDialog_kHz"/>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<CheckBox x:Uid="EqualizerDialog_MoveNearby"
|
||||
Margin="0,16,0,0"
|
||||
IsChecked="{x:Bind _isMoveNearby, Mode=TwoWay}"
|
||||
IsEnabled="{x:Bind IsEqualizerOn, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
</ContentDialog>
|
||||
|
||||
@@ -1,14 +1,52 @@
|
||||
using System.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using The_Untamed_Music_Player.Messages;
|
||||
using The_Untamed_Music_Player.Models;
|
||||
using The_Untamed_Music_Player.Services;
|
||||
|
||||
namespace The_Untamed_Music_Player.Controls;
|
||||
|
||||
public sealed partial class EqualizerDialog : ContentDialog
|
||||
public sealed partial class EqualizerDialog
|
||||
: ContentDialog,
|
||||
INotifyPropertyChanged,
|
||||
IRecipient<ThemeChangeMessage>
|
||||
{
|
||||
private bool IsEqualizerOn
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
field = value;
|
||||
OnPropertyChanged(nameof(IsEqualizerOn));
|
||||
Settings.IsEqualizerOn = value;
|
||||
}
|
||||
} = Settings.IsEqualizerOn;
|
||||
|
||||
private bool _isMoveNearby = Settings.IsMoveNearby;
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public EqualizerDialog()
|
||||
{
|
||||
StrongReferenceMessenger.Default.Register(this);
|
||||
RequestedTheme = ThemeSelectorService.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Receive(ThemeChangeMessage message)
|
||||
{
|
||||
RequestedTheme = message.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
}
|
||||
|
||||
private new void CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Unregister<ThemeChangeMessage>(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,15 @@ using ZLogger;
|
||||
|
||||
namespace The_Untamed_Music_Player.Controls;
|
||||
|
||||
public sealed partial class ImportPlaylistDialog : ContentDialog, INotifyPropertyChanged
|
||||
public sealed partial class ImportPlaylistDialog
|
||||
: ContentDialog,
|
||||
INotifyPropertyChanged,
|
||||
IRecipient<ThemeChangeMessage>
|
||||
{
|
||||
private readonly ILogger _logger = LoggingService.CreateLogger<ImportPlaylistDialog>();
|
||||
|
||||
private ObservableCollection<DisplaySongInfo> Songs { get; set; } = [];
|
||||
|
||||
private int SongCount
|
||||
{
|
||||
get;
|
||||
@@ -33,6 +38,7 @@ public sealed partial class ImportPlaylistDialog : ContentDialog, INotifyPropert
|
||||
OnPropertyChanged(nameof(SongCount));
|
||||
}
|
||||
}
|
||||
|
||||
private Visibility SongListViewVisibility
|
||||
{
|
||||
get;
|
||||
@@ -96,10 +102,16 @@ public sealed partial class ImportPlaylistDialog : ContentDialog, INotifyPropert
|
||||
|
||||
public ImportPlaylistDialog()
|
||||
{
|
||||
StrongReferenceMessenger.Default.Register(this);
|
||||
RequestedTheme = ThemeSelectorService.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Receive(ThemeChangeMessage message)
|
||||
{
|
||||
RequestedTheme = message.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
}
|
||||
|
||||
private void PlaylistNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
IsPrimaryButtonEnabled = !string.IsNullOrEmpty((sender as TextBox)!.Text);
|
||||
@@ -384,6 +396,7 @@ public sealed partial class ImportPlaylistDialog : ContentDialog, INotifyPropert
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
StrongReferenceMessenger.Default.Unregister<ThemeChangeMessage>(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:The_Untamed_Music_Player.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
CloseButtonClick="CloseButtonClick"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonClick="CreateButtonClick"
|
||||
Style="{StaticResource DefaultContentDialogStyle}"
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using The_Untamed_Music_Player.Messages;
|
||||
using The_Untamed_Music_Player.Models;
|
||||
using The_Untamed_Music_Player.Services;
|
||||
|
||||
namespace The_Untamed_Music_Player.Controls;
|
||||
|
||||
public sealed partial class NewPlaylistInfoDialog : ContentDialog
|
||||
public sealed partial class NewPlaylistInfoDialog : ContentDialog, IRecipient<ThemeChangeMessage>
|
||||
{
|
||||
public PlaylistInfo? CreatedPlaylist { get; private set; }
|
||||
|
||||
public NewPlaylistInfoDialog()
|
||||
{
|
||||
StrongReferenceMessenger.Default.Register(this);
|
||||
RequestedTheme = ThemeSelectorService.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Receive(ThemeChangeMessage message)
|
||||
{
|
||||
RequestedTheme = message.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
}
|
||||
|
||||
private void CreateButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
var name = NameTextBox.Text;
|
||||
@@ -25,4 +33,9 @@ public sealed partial class NewPlaylistInfoDialog : ContentDialog
|
||||
{
|
||||
IsPrimaryButtonEnabled = !string.IsNullOrEmpty((sender as TextBox)!.Text);
|
||||
}
|
||||
|
||||
private new void CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Unregister<ThemeChangeMessage>(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:The_Untamed_Music_Player.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
CloseButtonClick="CloseButtonClick"
|
||||
Style="{StaticResource DefaultContentDialogStyle}"
|
||||
mc:Ignorable="d">
|
||||
<ContentDialog.Resources>
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
using System.Diagnostics;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using The_Untamed_Music_Player.Contracts.Models;
|
||||
using The_Untamed_Music_Player.Messages;
|
||||
using The_Untamed_Music_Player.Services;
|
||||
|
||||
namespace The_Untamed_Music_Player.Controls;
|
||||
|
||||
public sealed partial class PropertiesDialog : ContentDialog
|
||||
public sealed partial class PropertiesDialog : ContentDialog, IRecipient<ThemeChangeMessage>
|
||||
{
|
||||
private readonly IDetailedSongInfoBase _song;
|
||||
|
||||
public PropertiesDialog(IDetailedSongInfoBase info)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Register(this);
|
||||
_song = info;
|
||||
RequestedTheme = ThemeSelectorService.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Receive(ThemeChangeMessage message)
|
||||
{
|
||||
RequestedTheme = message.IsDarkTheme ? ElementTheme.Dark : ElementTheme.Light;
|
||||
}
|
||||
|
||||
private void OpenFileLocationButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var filePath = _song.Path;
|
||||
@@ -35,4 +43,9 @@ public sealed partial class PropertiesDialog : ContentDialog
|
||||
Process.Start(startInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private new void CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Unregister<ThemeChangeMessage>(this);
|
||||
}
|
||||
}
|
||||
|
||||
29
The Untamed Music Player/Helpers/DoubleToDecibelConverter.cs
Normal file
29
The Untamed Music Player/Helpers/DoubleToDecibelConverter.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace The_Untamed_Music_Player.Helpers;
|
||||
|
||||
public partial class DoubleToDecibelConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is double decibel)
|
||||
{
|
||||
var sign = decibel switch
|
||||
{
|
||||
> 0 => "+",
|
||||
< 0 => "-",
|
||||
_ => "",
|
||||
};
|
||||
var suffix = "EqualizerDialog_Decibel".GetLocalized();
|
||||
var formattedDecibel =
|
||||
Math.Abs(decibel) % 1 == 0
|
||||
? Math.Abs(decibel).ToString("F0")
|
||||
: Math.Abs(decibel).ToString("F1");
|
||||
return $"{sign}{formattedDecibel} {suffix}";
|
||||
}
|
||||
throw new ArgumentException("将浮点数转换为分贝字符串失败");
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language) =>
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -13,12 +13,9 @@ public partial class EnumToBooleanConverter : IValueConverter
|
||||
{
|
||||
throw new ArgumentException("ExceptionEnumToBooleanConverterValueMustBeAnEnum");
|
||||
}
|
||||
|
||||
var enumValue = Enum.Parse<ElementTheme>(enumString);
|
||||
|
||||
return enumValue.Equals(value);
|
||||
}
|
||||
|
||||
throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName");
|
||||
}
|
||||
|
||||
@@ -28,7 +25,6 @@ public partial class EnumToBooleanConverter : IValueConverter
|
||||
{
|
||||
return Enum.Parse<ElementTheme>(enumString);
|
||||
}
|
||||
|
||||
throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName");
|
||||
}
|
||||
}
|
||||
|
||||
10
The Untamed Music Player/Messages/ThemeChangeMessage.cs
Normal file
10
The Untamed Music Player/Messages/ThemeChangeMessage.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace The_Untamed_Music_Player.Messages;
|
||||
|
||||
/// <summary>
|
||||
/// 用于指示主题更改的消息
|
||||
/// </summary>
|
||||
/// <param name="isDarkTheme"></param>
|
||||
public class ThemeChangeMessage(bool isDarkTheme)
|
||||
{
|
||||
public bool IsDarkTheme { get; } = isDarkTheme;
|
||||
}
|
||||
@@ -10,6 +10,7 @@ public static class Settings
|
||||
private static readonly ILocalSettingsService _localSettingsService =
|
||||
App.GetService<ILocalSettingsService>();
|
||||
|
||||
#region 设置属性
|
||||
/// <summary>
|
||||
/// 是否是第一次使用本软件
|
||||
/// </summary>
|
||||
@@ -203,6 +204,39 @@ public static class Settings
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用均衡器
|
||||
/// </summary>
|
||||
public static bool IsEqualizerOn
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (field != value)
|
||||
{
|
||||
field = value;
|
||||
_localSettingsService.SaveSettingAsync(nameof(IsEqualizerOn), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用一起移动附近的滑块
|
||||
/// </summary>
|
||||
public static bool IsMoveNearby
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (field != value)
|
||||
{
|
||||
field = value;
|
||||
_localSettingsService.SaveSettingAsync(nameof(IsMoveNearby), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task InitializeAsync()
|
||||
{
|
||||
@@ -232,6 +266,7 @@ public static class Settings
|
||||
IsWindowBackgroundFollowsCover = await _localSettingsService.ReadSettingAsync<bool>(
|
||||
nameof(IsWindowBackgroundFollowsCover)
|
||||
);
|
||||
|
||||
if (NotFirstUsed)
|
||||
{
|
||||
var lyricPageCurrentFontSize = await _localSettingsService.ReadSettingAsync<double>(
|
||||
@@ -259,7 +294,19 @@ public static class Settings
|
||||
TintColor =
|
||||
App.Current.RequestedTheme == ApplicationTheme.Dark ? darkColor : lightColor;
|
||||
}
|
||||
InitializedLaterAsync();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void InitializedLaterAsync()
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
IsEqualizerOn = await _localSettingsService.ReadSettingAsync<bool>(
|
||||
nameof(IsEqualizerOn)
|
||||
);
|
||||
IsMoveNearby = await _localSettingsService.ReadSettingAsync<bool>(nameof(IsMoveNearby));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.UI.Composition;
|
||||
using Microsoft.UI.Composition.SystemBackdrops;
|
||||
using Microsoft.UI.Xaml;
|
||||
using The_Untamed_Music_Player.Contracts.Services;
|
||||
using The_Untamed_Music_Player.Helpers;
|
||||
using The_Untamed_Music_Player.Messages;
|
||||
using The_Untamed_Music_Player.Models;
|
||||
using Windows.UI;
|
||||
using WinRT;
|
||||
@@ -340,6 +342,9 @@ public partial class MaterialSelectorService : IMaterialSelectorService
|
||||
|
||||
private void Window_ThemeChanged(FrameworkElement sender, object args)
|
||||
{
|
||||
StrongReferenceMessenger.Default.Send(
|
||||
new ThemeChangeMessage(ThemeSelectorService.IsDarkTheme)
|
||||
);
|
||||
TitleBarHelper.UpdateTitleBar(sender.ActualTheme);
|
||||
SetConfigurationSourceTheme();
|
||||
ChangeTheme();
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
<value>Refresh libraries</value>
|
||||
</data>
|
||||
<data name="Settings_ExclusiveMode.Header" xml:space="preserve">
|
||||
<value>Exclusive mode (Comming soon)</value>
|
||||
<value>Exclusive mode</value>
|
||||
</data>
|
||||
<data name="Settings_OnlyAddSpecificFolder.Description" xml:space="preserve">
|
||||
<value>If you are on the music library's song page with folder sorting enabled, clicking a song will only add songs from that same folder to the playback queue</value>
|
||||
@@ -654,9 +654,36 @@
|
||||
<data name="PropertiesDialog.Title" xml:space="preserve">
|
||||
<value>Properties</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog.Title" xml:space="preserve">
|
||||
<data name="EqualizerDialog_Title.Text" xml:space="preserve">
|
||||
<value>Equalizer</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_On" xml:space="preserve">
|
||||
<value>On</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Decibel" xml:space="preserve">
|
||||
<value>dB</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Decibel1.Text" xml:space="preserve">
|
||||
<value>dB</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Preset.Text" xml:space="preserve">
|
||||
<value>Preset</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Presets" xml:space="preserve">
|
||||
<value>Flat, Treble boost, Bass boost, Headphones, Laptop, Portable speakers, Home stereo, TV, Car, Custom</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_MoveNearby.Content" xml:space="preserve">
|
||||
<value>Move nearby sliders together</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Hz.Text" xml:space="preserve">
|
||||
<value>Hz</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_kHz.Text" xml:space="preserve">
|
||||
<value>kHz</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Off" xml:space="preserve">
|
||||
<value>Off</value>
|
||||
</data>
|
||||
<data name="EditSongInfoDialog.Title" xml:space="preserve">
|
||||
<value>Edit song info</value>
|
||||
</data>
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
<value>刷新库</value>
|
||||
</data>
|
||||
<data name="Settings_ExclusiveMode.Header" xml:space="preserve">
|
||||
<value>独占模式 (敬请期待)</value>
|
||||
<value>独占模式</value>
|
||||
</data>
|
||||
<data name="Settings_OnlyAddSpecificFolder.Description" xml:space="preserve">
|
||||
<value>如果当前位于音乐库歌曲页面且使用文件夹排序方式,点击歌曲仅会将其所在文件夹内的歌曲加入播放队列</value>
|
||||
@@ -654,9 +654,36 @@
|
||||
<data name="PropertiesDialog.Title" xml:space="preserve">
|
||||
<value>属性</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog.Title" xml:space="preserve">
|
||||
<data name="EqualizerDialog_Title.Text" xml:space="preserve">
|
||||
<value>均衡器</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_On" xml:space="preserve">
|
||||
<value>开</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Decibel" xml:space="preserve">
|
||||
<value>分贝</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Decibel1.Text" xml:space="preserve">
|
||||
<value>分贝</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Preset.Text" xml:space="preserve">
|
||||
<value>预设</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Presets" xml:space="preserve">
|
||||
<value>平直, 高音增强, 低音增强, 头戴式耳机, 笔记本电脑, 便携式扬声器, 家庭立体声, 电视, 汽车, 自定义</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_MoveNearby.Content" xml:space="preserve">
|
||||
<value>一起移动附近的滑块</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Hz.Text" xml:space="preserve">
|
||||
<value>赫兹</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_kHz.Text" xml:space="preserve">
|
||||
<value>千赫兹</value>
|
||||
</data>
|
||||
<data name="EqualizerDialog_Off" xml:space="preserve">
|
||||
<value>关</value>
|
||||
</data>
|
||||
<data name="EditSongInfoDialog.Title" xml:space="preserve">
|
||||
<value>编辑歌曲信息</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user