diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj index 5ddf8eb..7ddadba 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj @@ -23,11 +23,12 @@ - + + @@ -37,6 +38,7 @@ + @@ -292,7 +294,7 @@ - + MSBuild:Compile @@ -334,6 +336,21 @@ + + + MSBuild:Compile + + + + + MSBuild:Compile + + + + + MSBuild:Compile + + MSBuild:Compile diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtAreaEffectSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtAreaEffectSettingsControl.xaml new file mode 100644 index 0000000..f46859c --- /dev/null +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtAreaEffectSettingsControl.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtAreaEffectSettingsControl.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtAreaEffectSettingsControl.xaml.cs new file mode 100644 index 0000000..fb91ce4 --- /dev/null +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtAreaEffectSettingsControl.xaml.cs @@ -0,0 +1,37 @@ +using BetterLyrics.WinUI3.Models.Settings; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace BetterLyrics.WinUI3.Controls; + +public sealed partial class AlbumArtAreaEffectSettingsControl : UserControl +{ + public static readonly DependencyProperty AlbumArtAreaEffectSettingsProperty = + DependencyProperty.Register(nameof(AlbumArtAreaEffectSettings), typeof(AlbumArtAreaEffectSettings), typeof(AlbumArtAreaEffectSettingsControl), new PropertyMetadata(default)); + + public AlbumArtAreaEffectSettings AlbumArtAreaEffectSettings + { + get => (AlbumArtAreaEffectSettings)GetValue(AlbumArtAreaEffectSettingsProperty); + set => SetValue(AlbumArtAreaEffectSettingsProperty, value); + } + + public AlbumArtAreaEffectSettingsControl() + { + InitializeComponent(); + } +} diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtLayoutSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtAreaStyleSettingsControl.xaml similarity index 98% rename from BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtLayoutSettingsControl.xaml rename to BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtAreaStyleSettingsControl.xaml index 8dc51b8..db14de3 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtLayoutSettingsControl.xaml +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AlbumArtAreaStyleSettingsControl.xaml @@ -1,6 +1,6 @@ (AlbumArtLayoutSettings)GetValue(AlbumArtLayoutSettingsProperty); + get => (AlbumArtAreaStyleSettings)GetValue(AlbumArtLayoutSettingsProperty); set => SetValue(AlbumArtLayoutSettingsProperty, value); } - public AlbumArtLayoutSettingsControl() + public AlbumArtAreaStyleSettingsControl() { InitializeComponent(); } diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ImageSwitcher.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ImageSwitcher.xaml new file mode 100644 index 0000000..1897b24 --- /dev/null +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ImageSwitcher.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ImageSwitcher.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ImageSwitcher.xaml.cs new file mode 100644 index 0000000..f1e6caa --- /dev/null +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ImageSwitcher.xaml.cs @@ -0,0 +1,145 @@ +using BetterLyrics.WinUI3.Enums; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using System.Threading.Tasks; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace BetterLyrics.WinUI3.Controls; + +public sealed partial class ImageSwitcher : UserControl +{ + public int CornerRadiusAmount + { + get { return (int)GetValue(CornerRadiusAmountProperty); } + set { SetValue(CornerRadiusAmountProperty, value); } + } + + public static readonly DependencyProperty CornerRadiusAmountProperty = + DependencyProperty.Register(nameof(CornerRadiusAmount), typeof(int), typeof(ImageSwitcher), new PropertyMetadata(0)); + + public int ShadowAmount + { + get { return (int)GetValue(ShadowAmountProperty); } + set { SetValue(ShadowAmountProperty, value); } + } + + public static readonly DependencyProperty ShadowAmountProperty = + DependencyProperty.Register(nameof(ShadowAmount), typeof(int), typeof(ImageSwitcher), new PropertyMetadata(0)); + + public ImageSource? Source + { + get { return (ImageSource?)GetValue(SourceProperty); } + set { SetValue(SourceProperty, value); } + } + + public static readonly DependencyProperty SourceProperty = + DependencyProperty.Register(nameof(Source), typeof(ImageSource), typeof(ImageSwitcher), new PropertyMetadata(null, OnDependencyPropertyChanged)); + + public ImageSwitchType SwitchType + { + get { return (ImageSwitchType)GetValue(SwitchTypeProperty); } + set { SetValue(SwitchTypeProperty, value); } + } + + public static readonly DependencyProperty SwitchTypeProperty = + DependencyProperty.Register(nameof(SwitchType), typeof(ImageSwitchType), typeof(ImageSwitcher), new PropertyMetadata(ImageSwitchType.Crossfade)); + + public ImageSwitcher() + { + InitializeComponent(); + } + + private void UpdateSource() + { + switch (SwitchType) + { + case ImageSwitchType.Crossfade: + UpdateSourceCrossfade(); + break; + case ImageSwitchType.Slide: + UpdateSourceSlide(); + break; + default: + break; + } + } + + private void UpdateSourceCrossfade() + { + // 为背景图片设置旧源 + LastAlbumArtImage.Source = AlbumArtImage.Source; + // 使其立即可见 + LastAlbumArtImage.TranslationTransition = null; + LastAlbumArtImage.OpacityTransition = null; + LastAlbumArtImage.Translation = new(); + LastAlbumArtImage.Opacity = 1; + LastAlbumArtImage.OpacityTransition = new ScalarTransition { Duration = Constants.Time.AnimationDuration }; + + // 使前景图片立即不可见 + AlbumArtImage.TranslationTransition = null; + AlbumArtImage.OpacityTransition = null; + AlbumArtImage.Translation = new(); + AlbumArtImage.Opacity = 0; + AlbumArtImage.OpacityTransition = new ScalarTransition { Duration = Constants.Time.AnimationDuration }; + // 之后为其设置新源 + AlbumArtImage.Source = Source; + + // 交叉淡出淡入 + LastAlbumArtImage.Opacity = 0; + AlbumArtImage.Opacity = 1; + } + + private void UpdateSourceSlide() + { + // 为背景图片设置旧源 + LastAlbumArtImage.Source = AlbumArtImage.Source; + // 使其归位 + LastAlbumArtImage.TranslationTransition = null; + LastAlbumArtImage.OpacityTransition = null; + LastAlbumArtImage.Translation = new(); + LastAlbumArtImage.Opacity = 1; + LastAlbumArtImage.TranslationTransition = new Vector3Transition { Duration = Constants.Time.AnimationDuration }; + LastAlbumArtImage.OpacityTransition = new ScalarTransition { Duration = Constants.Time.AnimationDuration }; + + // 使前景图片立即不可见 + AlbumArtImage.TranslationTransition = null; + AlbumArtImage.OpacityTransition = null; + AlbumArtImage.Translation = new(-(float)ActualWidth, 0, 0); + AlbumArtImage.Opacity = 0; + AlbumArtImage.TranslationTransition = new Vector3Transition { Duration = Constants.Time.AnimationDuration }; + AlbumArtImage.OpacityTransition = new ScalarTransition { Duration = Constants.Time.AnimationDuration }; + // 之后为其设置新源 + AlbumArtImage.Source = Source; + + // 滑动 + LastAlbumArtImage.Opacity = 0; + AlbumArtImage.Opacity = 1; + LastAlbumArtImage.Translation = new(-(float)ActualWidth, 0, 0); + AlbumArtImage.Translation = new(); + } + + private static void OnDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is ImageSwitcher imageSwitcher) + { + if (e.Property == SourceProperty) + { + imageSwitcher.UpdateSource(); + } + } + } +} diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSettingsControl.xaml index e1493bf..fbbe368 100644 --- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSettingsControl.xaml +++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSettingsControl.xaml @@ -162,7 +162,7 @@ - + + + + + + + - - - - - - - - - - -