From f33034481baca4d8da9987f0821fccc203a29998 Mon Sep 17 00:00:00 2001 From: Jeff Zeng Date: Sun, 14 Jul 2024 21:00:33 +0800 Subject: [PATCH] =?UTF-8?q?[Feat]=20=E5=AE=9E=E7=8E=B0GetCoverAsync?= =?UTF-8?q?=E5=92=8CGetResourcesAsync=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Raspberry-Kan lele2194512339@outlook.com --- src/HyPlayer.App/App.csproj | 11 ++-- src/HyPlayer.App/App.xaml.cs | 39 ++++++------- .../Extensions/CoverExtensions.cs | 10 ++-- .../DIAddExtensions.cs | 2 +- .../MvvmExtensions.cs | 3 +- .../Extensions/Helpers/UIHelper.cs | 12 ++-- .../Extensions/Helpers/WindowHelper.cs | 19 +++--- .../Interfaces/ViewModels/IScopedViewModel.cs | 2 +- .../ViewModels/ISingletonViewModel.cs | 4 +- .../ViewModels/ITransientViewModel.cs | 2 +- .../Interfaces/ViewModels/IViewModel.cs | 2 +- src/HyPlayer.App/Interfaces/Views/AppPage.cs | 4 +- .../Interfaces/Views/INavigationService.cs | 6 +- .../Interfaces/Views/ReactiveControlBase.cs | 6 +- .../Services/NavigationService.cs | 18 +++--- src/HyPlayer.App/Services/PageService.cs | 10 +--- .../ViewModels/AccountViewModel.cs | 13 ++--- .../Converters/ArtistListToStringConverter.cs | 9 +-- .../Converters/BoolToStringConverter.cs | 4 -- .../BooleanToNavButtonVisibleConverter.cs | 12 +--- .../Converters/BrushToColorConverter.cs | 6 +- .../Converters/CountHumanizerConverter.cs | 58 +++++++++---------- .../Converters/CoverToImageSourceConverter.cs | 7 +-- .../Converters/StringListToStringConverter.cs | 4 +- .../StringToImageSourceConverter.cs | 12 +--- .../Converters/TimeStampToDateConverter.cs | 9 +-- .../ViewModels/CurrentPlayingViewModel.cs | 14 ++--- src/HyPlayer.App/ViewModels/HomeViewModel.cs | 58 +++++++++---------- .../ViewModels/NeteasePlaylistViewModel.cs | 30 +++++----- .../ViewModels/SearchViewModel.cs | 4 +- src/HyPlayer.App/ViewModels/ShellViewModel.cs | 15 ++--- src/HyPlayer.App/ViewModels/UserViewModel.cs | 9 ++- .../App/DesktopNavigationView.xaml.cs | 22 ++----- .../Controls/App/HomePageHeaderImage.xaml.cs | 34 +++++++---- .../App/PivotExtensions/PivotEx.xaml.cs | 17 +++--- .../PivotExtensions/PivotExHeaderView.xaml.cs | 6 +- .../App/PivotExtensions/PivotView.xaml.cs | 6 +- .../App/TopChartButton/TopChartButton.cs | 11 +--- .../Views/Controls/Base/NavigationViewBase.cs | 9 +-- .../Controls/CoolControls/AutoScrollView.cs | 5 -- .../CoolControls/ButtonContentSnapBehavior.cs | 5 -- .../Controls/CoolControls/OpacityMaskView.cs | 7 --- .../CoolControls/RedirectVisualView.cs | 7 --- .../Controls/Dialogs/SignInDialog.xaml.cs | 4 +- .../Netease/SongListView/SongListView.xaml.cs | 26 +++------ .../Views/Controls/Search/SearchBox.xaml.cs | 17 +----- .../Views/Pages/ErrorPage.xaml.cs | 13 ----- src/HyPlayer.App/Views/Pages/HomePage.xaml.cs | 31 +++------- .../Views/Pages/PlaylistPage.xaml.cs | 47 +++++++-------- .../Views/Pages/SearchPage.xaml.cs | 13 ----- .../Views/Pages/ShellPage.xaml.cs | 13 ----- src/HyPlayer.App/Views/Pages/UserPage.xaml.cs | 25 ++------ .../Views/Window/MainWindow.xaml.cs | 33 +++++------ .../Views/Window/SmallWindow.xaml.cs | 21 +------ 54 files changed, 285 insertions(+), 501 deletions(-) diff --git a/src/HyPlayer.App/App.csproj b/src/HyPlayer.App/App.csproj index 0738aa4..d6e13d7 100644 --- a/src/HyPlayer.App/App.csproj +++ b/src/HyPlayer.App/App.csproj @@ -1,7 +1,7 @@  WinExe - net8.0-windows10.0.19041.0 + net8.0-windows10.0.22621.0 10.0.17763.0 HyPlayer app.manifest @@ -18,6 +18,7 @@ HyPlayer Team HyPlayer 3e757a82-9759-482b-851c-170ec2aa99dc + 10.0.19041.0 @@ -158,10 +159,10 @@ - - - - + + + + diff --git a/src/HyPlayer.App/App.xaml.cs b/src/HyPlayer.App/App.xaml.cs index 7070fd4..ef71536 100644 --- a/src/HyPlayer.App/App.xaml.cs +++ b/src/HyPlayer.App/App.xaml.cs @@ -1,25 +1,19 @@ -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using WinUIEx; -using System; -using System.IO; -using System.Threading.Tasks; -using Windows.Storage; using Depository.Abstraction.Interfaces; using Depository.Core; using Depository.Extensions; using HyPlayer.Extensions.DependencyInjectionExtensions; +using HyPlayer.Extensions.Helpers; using HyPlayer.Interfaces.Views; -using HyPlayer.Services; using HyPlayer.PlayCore; using HyPlayer.PlayCore.Abstraction; -using Microsoft.UI.Dispatching; +using HyPlayer.Services; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using System; +using System.Threading.Tasks; using DispatcherQueue = Windows.System.DispatcherQueue; -using Window = HyPlayer.Views.Window; -using XamlWindow = Microsoft.UI.Xaml.Window; using Pages = HyPlayer.Views.Pages; -using HyPlayer.ViewModels; -using HyPlayer.Extensions.Helpers; +using XamlWindow = Microsoft.UI.Xaml.Window; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -53,9 +47,9 @@ public static T GetService() return (Current as App)!.DispatcherQueue; } - public static IDepository? GetDIContainer() + public static IDepository GetDIContainer() { - return (Current as App)!.Depository; + return (Current as App)!.Depository!; } /// @@ -79,14 +73,14 @@ protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventA ConfigureServices(); await ConfigurePlayCore(); window = WindowHelper.CreateWindow(); - if(window != null) - { + if (window != null) + { NavigateToRootPage(args); window?.Activate(); } } - + private void ConfigureServices() { Depository?.AddMvvm(); @@ -98,13 +92,16 @@ private async Task ConfigurePlayCore() { Depository?.AddSingleton(); var playCore = Depository?.Resolve(); - await playCore.RegisterMusicProviderAsync(typeof(NeteaseProvider.NeteaseProvider)); + if (playCore != null) + { + await playCore.RegisterMusicProviderAsync(typeof(NeteaseProvider.NeteaseProvider)); + } } private void NavigateToRootPage(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) - { + { GetService().NavigateTo(typeof(Pages.HomePage)); } - + } } diff --git a/src/HyPlayer.App/Extensions/CoverExtensions.cs b/src/HyPlayer.App/Extensions/CoverExtensions.cs index 07c366b..aa77cb5 100644 --- a/src/HyPlayer.App/Extensions/CoverExtensions.cs +++ b/src/HyPlayer.App/Extensions/CoverExtensions.cs @@ -1,18 +1,18 @@ using HyPlayer.NeteaseProvider.Models; using HyPlayer.PlayCore.Abstraction.Interfaces.ProvidableItem; using HyPlayer.PlayCore.Abstraction.Models; -using HyPlayer.PlayCore.Abstraction.Models.Resources; +using System; namespace HyPlayer.Extensions; public static class CoverExtensions { - public static string? GetCoverUrl(this IHasCover item, int pixelX, int pixelY) + public static Uri? GetCoverUrl(this IHasCover item, int pixelX, int pixelY) { - var coverResource = item.GetCoverAsync(new ImageResourceQualityTag(pixelX, pixelY)).GetAwaiter().GetResult(); - if (coverResource is not IResourceResultOf resourceResult) + var coverResource = item.GetCoverAsync(new NeteaseImageResourceQualityTag(pixelX, pixelY)).GetAwaiter().GetResult(); + if (coverResource is not NeteaseImageResourceResult neteaseResourceResult) return null; - return resourceResult + return neteaseResourceResult .GetResourceAsync() .GetAwaiter().GetResult(); } diff --git a/src/HyPlayer.App/Extensions/DependencyInjectionExtensions/DIAddExtensions.cs b/src/HyPlayer.App/Extensions/DependencyInjectionExtensions/DIAddExtensions.cs index 69c3e8a..2301d31 100644 --- a/src/HyPlayer.App/Extensions/DependencyInjectionExtensions/DIAddExtensions.cs +++ b/src/HyPlayer.App/Extensions/DependencyInjectionExtensions/DIAddExtensions.cs @@ -1,7 +1,7 @@ -using System.Reflection; using Depository.Abstraction.Enums; using Depository.Abstraction.Interfaces; using Depository.Extensions; +using System.Reflection; namespace HyPlayer.Extensions.DependencyInjectionExtensions; diff --git a/src/HyPlayer.App/Extensions/DependencyInjectionExtensions/MvvmExtensions.cs b/src/HyPlayer.App/Extensions/DependencyInjectionExtensions/MvvmExtensions.cs index 856673e..1366c5e 100644 --- a/src/HyPlayer.App/Extensions/DependencyInjectionExtensions/MvvmExtensions.cs +++ b/src/HyPlayer.App/Extensions/DependencyInjectionExtensions/MvvmExtensions.cs @@ -1,8 +1,7 @@ -using System.Reflection; using Depository.Abstraction.Enums; using Depository.Abstraction.Interfaces; -using HyPlayer.Interfaces; using HyPlayer.Interfaces.ViewModels; +using System.Reflection; namespace HyPlayer.Extensions.DependencyInjectionExtensions; diff --git a/src/HyPlayer.App/Extensions/Helpers/UIHelper.cs b/src/HyPlayer.App/Extensions/Helpers/UIHelper.cs index 2885467..1247a7e 100644 --- a/src/HyPlayer.App/Extensions/Helpers/UIHelper.cs +++ b/src/HyPlayer.App/Extensions/Helpers/UIHelper.cs @@ -1,7 +1,7 @@ -using System; -using System.Threading.Tasks; -using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using System; +using System.Threading.Tasks; namespace HyPlayer.Extensions.Helpers { @@ -9,11 +9,11 @@ public class UIHelper { public static async Task ShowDialogAsync(ContentDialog dialog, XamlRoot xamlRoot) { - + dialog.DefaultButton = ContentDialogButton.Primary; - dialog.Style = (Style) App.Current.Resources["DefaultContentDialogStyle"]; + dialog.Style = (Style)App.Current.Resources["DefaultContentDialogStyle"]; dialog.XamlRoot = xamlRoot; - + var result = await dialog.ShowAsync(); return result; } diff --git a/src/HyPlayer.App/Extensions/Helpers/WindowHelper.cs b/src/HyPlayer.App/Extensions/Helpers/WindowHelper.cs index 3860072..de1a227 100644 --- a/src/HyPlayer.App/Extensions/Helpers/WindowHelper.cs +++ b/src/HyPlayer.App/Extensions/Helpers/WindowHelper.cs @@ -1,14 +1,8 @@ -using Microsoft.UI.Xaml; +using HyPlayer.Views.Window; using Microsoft.UI; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Windows.ApplicationModel; -using WinRT.Interop; -using HyPlayer.Views.Window; using Microsoft.UI.Windowing; +using Microsoft.UI.Xaml; +using System.Collections.Generic; namespace HyPlayer.Extensions.Helpers { @@ -44,7 +38,8 @@ static public Window CreateBlankWindow() static public void TrackWindow(Window window) { - window.Closed += (sender, args) => { + window.Closed += (sender, args) => + { _activeWindows.Remove(window); }; _activeWindows.Add(window); @@ -81,8 +76,8 @@ static public void InitializeTitleBarForWindow(Window window, bool isTallTitleBa titleBar.ExtendsContentIntoTitleBar = true; } - // A taller title bar is only supported when drawing a fully custom title bar - if (AppWindowTitleBar.IsCustomizationSupported() && titleBar.ExtendsContentIntoTitleBar) + // A taller title bar is only supported when drawing a fully custom title bar + if (AppWindowTitleBar.IsCustomizationSupported() && titleBar.ExtendsContentIntoTitleBar) { if (isTallTitleBar) { diff --git a/src/HyPlayer.App/Interfaces/ViewModels/IScopedViewModel.cs b/src/HyPlayer.App/Interfaces/ViewModels/IScopedViewModel.cs index 7d5e763..d743fbb 100644 --- a/src/HyPlayer.App/Interfaces/ViewModels/IScopedViewModel.cs +++ b/src/HyPlayer.App/Interfaces/ViewModels/IScopedViewModel.cs @@ -2,5 +2,5 @@ namespace HyPlayer.Interfaces.ViewModels; public interface IScopedViewModel : IViewModel { - + } \ No newline at end of file diff --git a/src/HyPlayer.App/Interfaces/ViewModels/ISingletonViewModel.cs b/src/HyPlayer.App/Interfaces/ViewModels/ISingletonViewModel.cs index 74e4642..ed8e94f 100644 --- a/src/HyPlayer.App/Interfaces/ViewModels/ISingletonViewModel.cs +++ b/src/HyPlayer.App/Interfaces/ViewModels/ISingletonViewModel.cs @@ -1,6 +1,6 @@ namespace HyPlayer.Interfaces.ViewModels; -public interface ISingletonViewModel : IViewModel +public interface ISingletonViewModel : IViewModel { - + } \ No newline at end of file diff --git a/src/HyPlayer.App/Interfaces/ViewModels/ITransientViewModel.cs b/src/HyPlayer.App/Interfaces/ViewModels/ITransientViewModel.cs index b7e3114..7f91c23 100644 --- a/src/HyPlayer.App/Interfaces/ViewModels/ITransientViewModel.cs +++ b/src/HyPlayer.App/Interfaces/ViewModels/ITransientViewModel.cs @@ -2,5 +2,5 @@ namespace HyPlayer.Interfaces.ViewModels; public interface ITransientViewModel : IViewModel { - + } \ No newline at end of file diff --git a/src/HyPlayer.App/Interfaces/ViewModels/IViewModel.cs b/src/HyPlayer.App/Interfaces/ViewModels/IViewModel.cs index 1cd64e3..02a7b02 100644 --- a/src/HyPlayer.App/Interfaces/ViewModels/IViewModel.cs +++ b/src/HyPlayer.App/Interfaces/ViewModels/IViewModel.cs @@ -2,5 +2,5 @@ namespace HyPlayer.Interfaces.ViewModels; public interface IViewModel { - + } \ No newline at end of file diff --git a/src/HyPlayer.App/Interfaces/Views/AppPage.cs b/src/HyPlayer.App/Interfaces/Views/AppPage.cs index 6c79879..dae128b 100644 --- a/src/HyPlayer.App/Interfaces/Views/AppPage.cs +++ b/src/HyPlayer.App/Interfaces/Views/AppPage.cs @@ -1,10 +1,10 @@ -using System; -using Depository.Abstraction.Interfaces; +using Depository.Abstraction.Interfaces; using Depository.Core; using Depository.Extensions; using HyPlayer.Interfaces.ViewModels; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using System; namespace HyPlayer.Interfaces.Views; diff --git a/src/HyPlayer.App/Interfaces/Views/INavigationService.cs b/src/HyPlayer.App/Interfaces/Views/INavigationService.cs index f9e3203..03b4d62 100644 --- a/src/HyPlayer.App/Interfaces/Views/INavigationService.cs +++ b/src/HyPlayer.App/Interfaces/Views/INavigationService.cs @@ -1,6 +1,6 @@ -using System; -using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Navigation; +using System; namespace HyPlayer.Interfaces.Views; @@ -15,7 +15,7 @@ bool CanGoBack Frame? Frame { - get; + get; } bool NavigateTo(Type Page, object? parameter = null); diff --git a/src/HyPlayer.App/Interfaces/Views/ReactiveControlBase.cs b/src/HyPlayer.App/Interfaces/Views/ReactiveControlBase.cs index 9cf0b2d..5b351fe 100644 --- a/src/HyPlayer.App/Interfaces/Views/ReactiveControlBase.cs +++ b/src/HyPlayer.App/Interfaces/Views/ReactiveControlBase.cs @@ -1,9 +1,9 @@ -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml; -using Depository.Abstraction.Interfaces; +using Depository.Abstraction.Interfaces; using Depository.Core; using Depository.Extensions; using HyPlayer.Interfaces.ViewModels; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; using System; namespace HyPlayer.Interfaces.Views; diff --git a/src/HyPlayer.App/Services/NavigationService.cs b/src/HyPlayer.App/Services/NavigationService.cs index 9ec60a6..dc84d0f 100644 --- a/src/HyPlayer.App/Services/NavigationService.cs +++ b/src/HyPlayer.App/Services/NavigationService.cs @@ -1,14 +1,14 @@ -using Microsoft.UI.Xaml.Controls; +using HyPlayer.Interfaces.Views; +using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Animation; using Microsoft.UI.Xaml.Navigation; using System; -using HyPlayer.Interfaces.Views; namespace HyPlayer.Services { internal class NavigationService : INavigationService { - public bool CanGoBack => App.contentFrame.CanGoBack; + public bool CanGoBack => App.contentFrame!.CanGoBack; public Frame? Frame => App.contentFrame; @@ -16,7 +16,7 @@ internal class NavigationService : INavigationService public bool GoBack() { - if(CanGoBack) + if (CanGoBack) { Frame?.GoBack(); return true; @@ -24,24 +24,24 @@ public bool GoBack() else return false; } - public bool NavigateTo(Type Page, object parameter) + public bool NavigateTo(Type Page, object? parameter) { if (Frame != null) { return Frame.Navigate(Page, parameter, new SlideNavigationTransitionInfo { Effect = SlideNavigationTransitionEffect.FromRight }); } - else + else { - return false; + return false; } } - public bool NavigateTo(Page Page, object parameter) + public bool NavigateTo(Page Page, object? parameter) { if (Frame != null) { return Frame.Navigate(typeof(Page), parameter, new SlideNavigationTransitionInfo { Effect = SlideNavigationTransitionEffect.FromRight }); - + } else { diff --git a/src/HyPlayer.App/Services/PageService.cs b/src/HyPlayer.App/Services/PageService.cs index d10abdc..7b7b29f 100644 --- a/src/HyPlayer.App/Services/PageService.cs +++ b/src/HyPlayer.App/Services/PageService.cs @@ -1,12 +1,6 @@ -using HyPlayer.Views.Pages; -using Microsoft.UI.Xaml.Controls; +using HyPlayer.Interfaces.Views; +using HyPlayer.Views.Pages; using System; -using System.Collections.Generic; -using System.Diagnostics.Eventing.Reader; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HyPlayer.Interfaces.Views; namespace HyPlayer.Services { diff --git a/src/HyPlayer.App/ViewModels/AccountViewModel.cs b/src/HyPlayer.App/ViewModels/AccountViewModel.cs index 943999f..7aaed84 100644 --- a/src/HyPlayer.App/ViewModels/AccountViewModel.cs +++ b/src/HyPlayer.App/ViewModels/AccountViewModel.cs @@ -1,13 +1,8 @@ using CommunityToolkit.Mvvm.ComponentModel; -using CommunityToolkit.Mvvm.Input; -using System; -using System.Security.Principal; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - using HyPlayer.Interfaces.ViewModels; using HyPlayer.NeteaseProvider.Models; -using HyPlayer.PlayCore.Abstraction.Models.Containers; +using System.Text.RegularExpressions; +using System.Threading.Tasks; namespace HyPlayer.ViewModels @@ -17,7 +12,7 @@ public partial class AccountViewModel : ObservableObject, ISingletonViewModel private readonly NeteaseProvider.NeteaseProvider _provider; public AccountViewModel(NeteaseProvider.NeteaseProvider provider) - { + { _provider = provider; } @@ -25,7 +20,7 @@ public AccountViewModel(NeteaseProvider.NeteaseProvider provider) [ObservableProperty] private NeteaseUser? _user; - public async Task SignInAsync(string usr, string pwd) + public async Task SignInAsync(string usr, string pwd) { bool isPhone = Regex.Match(usr, "^[0-9]+$").Success; if (isPhone) diff --git a/src/HyPlayer.App/ViewModels/Converters/ArtistListToStringConverter.cs b/src/HyPlayer.App/ViewModels/Converters/ArtistListToStringConverter.cs index 7e50722..1a8cfcf 100644 --- a/src/HyPlayer.App/ViewModels/Converters/ArtistListToStringConverter.cs +++ b/src/HyPlayer.App/ViewModels/Converters/ArtistListToStringConverter.cs @@ -1,13 +1,8 @@ -using Microsoft.UI.Xaml.Media; +using HyPlayer.PlayCore.Abstraction.Models.Containers; +using Microsoft.UI.Xaml.Data; using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HyPlayer.NeteaseProvider.Models; -using Microsoft.UI.Xaml.Data; -using HyPlayer.PlayCore.Abstraction.Models.Containers; namespace HyPlayer.ViewModels.Converters { diff --git a/src/HyPlayer.App/ViewModels/Converters/BoolToStringConverter.cs b/src/HyPlayer.App/ViewModels/Converters/BoolToStringConverter.cs index 7d7c6ea..aadefff 100644 --- a/src/HyPlayer.App/ViewModels/Converters/BoolToStringConverter.cs +++ b/src/HyPlayer.App/ViewModels/Converters/BoolToStringConverter.cs @@ -1,9 +1,5 @@ using Microsoft.UI.Xaml.Data; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace HyPlayer.ViewModels.Converters { diff --git a/src/HyPlayer.App/ViewModels/Converters/BooleanToNavButtonVisibleConverter.cs b/src/HyPlayer.App/ViewModels/Converters/BooleanToNavButtonVisibleConverter.cs index 39cb30c..f439dce 100644 --- a/src/HyPlayer.App/ViewModels/Converters/BooleanToNavButtonVisibleConverter.cs +++ b/src/HyPlayer.App/ViewModels/Converters/BooleanToNavButtonVisibleConverter.cs @@ -1,24 +1,16 @@ using CommunityToolkit.WinUI.UI.Converters; using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Data; -using Microsoft.UI.Xaml.Media; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace HyPlayer.ViewModels.Converters { internal class BooleanToNavButtonVisibleConverter : BoolToObjectConverter { - public BooleanToNavButtonVisibleConverter() + public BooleanToNavButtonVisibleConverter() { base.TrueValue = NavigationViewBackButtonVisible.Visible; base.FalseValue = NavigationViewBackButtonVisible.Collapsed; } } - + } diff --git a/src/HyPlayer.App/ViewModels/Converters/BrushToColorConverter.cs b/src/HyPlayer.App/ViewModels/Converters/BrushToColorConverter.cs index 850a107..cf25ba4 100644 --- a/src/HyPlayer.App/ViewModels/Converters/BrushToColorConverter.cs +++ b/src/HyPlayer.App/ViewModels/Converters/BrushToColorConverter.cs @@ -1,7 +1,7 @@ -using System; -using System.Drawing; -using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Media; +using System; +using System.Drawing; namespace HyPlayer.ViewModels.Converters; diff --git a/src/HyPlayer.App/ViewModels/Converters/CountHumanizerConverter.cs b/src/HyPlayer.App/ViewModels/Converters/CountHumanizerConverter.cs index 17b97d0..6c4d1f9 100644 --- a/src/HyPlayer.App/ViewModels/Converters/CountHumanizerConverter.cs +++ b/src/HyPlayer.App/ViewModels/Converters/CountHumanizerConverter.cs @@ -1,7 +1,5 @@ -using System; -using System.Numerics; -using Humanizer; using Microsoft.UI.Xaml.Data; +using System; namespace HyPlayer.ViewModels.Converters; @@ -10,48 +8,48 @@ public class CountHumanizerConverter : IValueConverter public object Convert(object value, Type targetType, object parameter, string language) { return value switch - { - int numInt => ParseInt(numInt), - long numLong => ParseLong(numLong), - double numDouble => ParseDouble(numDouble), - _ => value.ToString() ?? string.Empty - }; + { + int numInt => ParseInt(numInt), + long numLong => ParseLong(numLong), + double numDouble => ParseDouble(numDouble), + _ => value.ToString() ?? string.Empty + }; } private static string ParseInt(int value) { return value switch - { - < 10000 => value.ToString("D"), - >= 10000 and < 100000000 => (value / 10000).ToString() + " 万", - > 100000000 => (value / 10000000).ToString() + " 亿", - _ => value.ToString() - }; + { + < 10000 => value.ToString("D"), + >= 10000 and < 100000000 => (value / 10000).ToString() + " 万", + > 100000000 => (value / 10000000).ToString() + " 亿", + _ => value.ToString() + }; } - + private static string ParseLong(long value) { return value switch - { - < 10000 => value.ToString("D"), - >= 10000 and < 100000000 => (value / 10000).ToString() + " 万", - > 100000000 => (value / 10000000).ToString() + " 亿", - _ => value.ToString() - }; + { + < 10000 => value.ToString("D"), + >= 10000 and < 100000000 => (value / 10000).ToString() + " 万", + > 100000000 => (value / 10000000).ToString() + " 亿", + _ => value.ToString() + }; } - + private static string ParseDouble(double val) { var value = (long)val; return value switch - { - < 10000 => value.ToString("D"), - >= 10000 and < 100000000 => (value / 10000).ToString() + " 万", - > 100000000 => (value / 10000000).ToString() + " 亿", - _ => value.ToString() - }; + { + < 10000 => value.ToString("D"), + >= 10000 and < 100000000 => (value / 10000).ToString() + " 万", + > 100000000 => (value / 10000000).ToString() + " 亿", + _ => value.ToString() + }; } - + public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); diff --git a/src/HyPlayer.App/ViewModels/Converters/CoverToImageSourceConverter.cs b/src/HyPlayer.App/ViewModels/Converters/CoverToImageSourceConverter.cs index 4a34c7b..5874d84 100644 --- a/src/HyPlayer.App/ViewModels/Converters/CoverToImageSourceConverter.cs +++ b/src/HyPlayer.App/ViewModels/Converters/CoverToImageSourceConverter.cs @@ -1,10 +1,9 @@ -using System; using HyPlayer.Extensions; using HyPlayer.PlayCore.Abstraction.Interfaces.ProvidableItem; -using HyPlayer.PlayCore.Abstraction.Models.Resources; using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media.Imaging; +using System; namespace HyPlayer.ViewModels.Converters; @@ -12,7 +11,7 @@ public class CoverToImageSourceConverter : IValueConverter { private ImageSource? _defaultImage; - + public object Convert(object value, Type targetType, object parameter, string language) { if (value is IHasCover hasCover) @@ -22,7 +21,7 @@ public object Convert(object value, Type targetType, object parameter, string la var size = System.Convert.ToInt32(sizeStr); var result = hasCover.GetCoverUrl(size, size); if (result is not null) - return new BitmapImage(new Uri(result)); + return new BitmapImage(result); } // TODO: Change the default Image Here diff --git a/src/HyPlayer.App/ViewModels/Converters/StringListToStringConverter.cs b/src/HyPlayer.App/ViewModels/Converters/StringListToStringConverter.cs index 0c5d7a6..1ffad70 100644 --- a/src/HyPlayer.App/ViewModels/Converters/StringListToStringConverter.cs +++ b/src/HyPlayer.App/ViewModels/Converters/StringListToStringConverter.cs @@ -1,6 +1,6 @@ -using System; +using Microsoft.UI.Xaml.Data; +using System; using System.Collections.Generic; -using Microsoft.UI.Xaml.Data; namespace HyPlayer.ViewModels.Converters; diff --git a/src/HyPlayer.App/ViewModels/Converters/StringToImageSourceConverter.cs b/src/HyPlayer.App/ViewModels/Converters/StringToImageSourceConverter.cs index 1978365..ffff2d3 100644 --- a/src/HyPlayer.App/ViewModels/Converters/StringToImageSourceConverter.cs +++ b/src/HyPlayer.App/ViewModels/Converters/StringToImageSourceConverter.cs @@ -1,13 +1,7 @@ -using HyPlayer.PlayCore.Abstraction.Interfaces.ProvidableItem; -using Microsoft.UI.Xaml.Data; -using Microsoft.UI.Xaml.Media.Imaging; +using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Imaging; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Humanizer; namespace HyPlayer.ViewModels.Converters { @@ -17,7 +11,7 @@ class StringToImageSourceConverter : IValueConverter public object Convert(object value, Type targetType, object parameter, string language) { - return new BitmapImage(new Uri((string)value)); + return new BitmapImage(new Uri((string)value)); } public object ConvertBack(object value, Type targetType, object parameter, string language) diff --git a/src/HyPlayer.App/ViewModels/Converters/TimeStampToDateConverter.cs b/src/HyPlayer.App/ViewModels/Converters/TimeStampToDateConverter.cs index 43d638f..34e60ee 100644 --- a/src/HyPlayer.App/ViewModels/Converters/TimeStampToDateConverter.cs +++ b/src/HyPlayer.App/ViewModels/Converters/TimeStampToDateConverter.cs @@ -1,9 +1,5 @@ using Microsoft.UI.Xaml.Data; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace HyPlayer.ViewModels.Converters { @@ -12,7 +8,7 @@ class TimeStampToDateConverter : IValueConverter public object Convert(object value, Type targetType, object parameter, string language) { - if (value is not long timeStamp) return null; + if (value is not long timeStamp) throw new ArgumentException(); var localDateTime = (new DateTime(1970, 1, 1).AddMilliseconds(timeStamp)).ToLocalTime(); var now = DateTime.Now; var timeSpan = now - localDateTime; @@ -21,7 +17,8 @@ public object Convert(object value, Type targetType, if (timeSpan.TotalHours >= 1) { return $"{(int)timeSpan.TotalHours} 小时之前"; - }if (timeSpan.TotalMinutes >= 1) + } + if (timeSpan.TotalMinutes >= 1) { return $"{(int)timeSpan.TotalMinutes} 分钟之前"; } diff --git a/src/HyPlayer.App/ViewModels/CurrentPlayingViewModel.cs b/src/HyPlayer.App/ViewModels/CurrentPlayingViewModel.cs index ff48d4b..e3a6b02 100644 --- a/src/HyPlayer.App/ViewModels/CurrentPlayingViewModel.cs +++ b/src/HyPlayer.App/ViewModels/CurrentPlayingViewModel.cs @@ -1,14 +1,10 @@ -using System.Threading; -using System.Threading.Tasks; -using Windows.System; using CommunityToolkit.Mvvm.ComponentModel; -using Depository.Abstraction.Interfaces; +using Depository.Abstraction.Interfaces.NotificationHub; using HyPlayer.Interfaces.ViewModels; -using HyPlayer.NeteaseProvider.Models; -using HyPlayer.PlayCore.Abstraction; using HyPlayer.PlayCore.Abstraction.Models.Notifications; using HyPlayer.PlayCore.Abstraction.Models.SingleItems; -using Depository.Abstraction.Interfaces.NotificationHub; +using System.Threading; +using System.Threading.Tasks; namespace HyPlayer.ViewModels; @@ -16,11 +12,11 @@ public partial class CurrentPlayingViewModel : ObservableObject, ISingletonViewM { [ObservableProperty] private SingleSongBase? _song; - + public Task HandleNotificationAsync(CurrentSongChangedNotification notification, CancellationToken ctk = new CancellationToken()) { - App.GetDispatcherQueue().TryEnqueue(() => + App.GetDispatcherQueue()?.TryEnqueue(() => { Song = notification.CurrentPlayingSong; }); diff --git a/src/HyPlayer.App/ViewModels/HomeViewModel.cs b/src/HyPlayer.App/ViewModels/HomeViewModel.cs index 90436b5..fd8a7e5 100644 --- a/src/HyPlayer.App/ViewModels/HomeViewModel.cs +++ b/src/HyPlayer.App/ViewModels/HomeViewModel.cs @@ -1,19 +1,11 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; -using HyPlayer.Interfaces; using HyPlayer.Interfaces.ViewModels; -using HyPlayer.NeteaseApi; -using HyPlayer.NeteaseApi.ApiContracts; -using HyPlayer.NeteaseProvider.Mappers; using HyPlayer.NeteaseProvider.Models; -using HyPlayer.PlayCore.Abstraction; using HyPlayer.PlayCore.Abstraction.Models; -using HyPlayer.PlayCore.Abstraction.Models.Containers; -using HyPlayer.PlayCore.Abstraction.Models.Resources; -using HyPlayer.NeteaseApi.Models.ResponseModels; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; namespace HyPlayer.ViewModels; @@ -48,35 +40,41 @@ public async Task GetSongsAsync() // 仅在登录后加载 if (AccountViewModel.IsLogin) { - if((await ((await _provider.GetRecommendationAsync("pl")) as NeteaseActionGettableContainer)?.GetAllItemsAsync()) is not null) + var recommendPlayLists = await _provider.GetRecommendationAsync("pl") as NeteaseActionGettableContainer; + if (recommendPlayLists != null) { - // 推荐歌单 - PlayLists = - (await ((await _provider.GetRecommendationAsync("pl")) as NeteaseActionGettableContainer)?.GetAllItemsAsync()) - .Select(t => (NeteasePlaylist)t).ToList(); + if (await recommendPlayLists.GetAllItemsAsync() is List providableItems) + { + // 推荐歌单 + PlayLists = providableItems.Select(t => (NeteasePlaylist)t).ToList(); + + } } - - - if((await ((await _provider.GetRecommendationAsync("sg")) as NeteaseActionGettableContainer)?.GetAllItemsAsync()) is not null) + + + var recommendedSongs = await _provider.GetRecommendationAsync("sg") as NeteaseActionGettableContainer; + if (recommendedSongs != null) { - // 推荐歌曲 - RecommendedSongs = - (await ((await _provider.GetRecommendationAsync("sg")) as NeteaseActionGettableContainer)?.GetAllItemsAsync()) - .Select(t => (NeteaseSong)t).ToList(); + if (await recommendedSongs.GetAllItemsAsync() is List providableItems) + { + // 推荐歌曲 + RecommendedSongs = providableItems.Select(t => (NeteaseSong)t).ToList(); + } } - - + + } // 不登录加载 // 排行榜 - if((await ((await _provider.GetRecommendationAsync("ct")) as NeteaseActionGettableContainer)?.GetAllItemsAsync()) is not null) + var topLists = await _provider.GetRecommendationAsync("ct") as NeteaseActionGettableContainer; + if (topLists != null) { - TopLists = - (await ((await _provider?.GetRecommendationAsync("ct")) as NeteaseActionGettableContainer)?.GetAllItemsAsync())? - .Select(t => (NeteasePlaylist)t).ToList(); + if (await topLists.GetAllItemsAsync() is List providableItems) + { + TopLists = providableItems.Select(t => (NeteasePlaylist)t).ToList(); + } } - } } diff --git a/src/HyPlayer.App/ViewModels/NeteasePlaylistViewModel.cs b/src/HyPlayer.App/ViewModels/NeteasePlaylistViewModel.cs index 14c04e7..4a59ea7 100644 --- a/src/HyPlayer.App/ViewModels/NeteasePlaylistViewModel.cs +++ b/src/HyPlayer.App/ViewModels/NeteasePlaylistViewModel.cs @@ -2,7 +2,6 @@ using CommunityToolkit.Mvvm.Input; using HyPlayer.Interfaces.ViewModels; using HyPlayer.NeteaseProvider.Models; -using HyPlayer.PlayCore.Abstraction.Models.SingleItems; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -12,8 +11,8 @@ namespace HyPlayer.ViewModels; public partial class NeteasePlaylistViewModel : ObservableObject, IScrollableViewModel, IConnectedViewModel, IScopedViewModel { - public double? ScrollValue { get; set ; } - public int? ConnectedItemIndex { get ; set; } + public double? ScrollValue { get; set; } + public int? ConnectedItemIndex { get; set; } public string? ConnectedElementName { get; set; } private readonly NeteaseProvider.NeteaseProvider _provider; @@ -28,33 +27,36 @@ public partial class NeteasePlaylistViewModel : ObservableObject, IScrollableVie public ObservableCollection? _songsList; public int SortOrder = 0; // 0: 不排序, 1: 升序, 2: 降序 public string SortTypes = "SongName"; - private ObservableCollection tempSong; + private ObservableCollection? tempSong; public NeteasePlaylistViewModel(NeteaseProvider.NeteaseProvider provider) { - _provider = provider; + _provider = provider; } [RelayCommand] public async Task GetSongsAsync() { - if(PlayList is not null) + if (PlayList is not null) { - SongsList = new ObservableCollection((await PlayList.GetAllItemsAsync())?.Select(t => (NeteaseSong)t)); - tempSong = SongsList; + if ((await PlayList.GetAllItemsAsync())?.Select(t => (NeteaseSong)t) is IEnumerable songs) + { + SongsList = new ObservableCollection(songs); + tempSong = SongsList; + } } } [RelayCommand] public async Task SubscribePlaylistAsync() { - if (PlayList.Subscribed==false) + if (PlayList?.Subscribed == false) { await _provider.LikeProvidableItemAsync($"pl{PlayList.ActualId}", null); } else { - await _provider.UnlikeProvidableItemAsync($"pl{PlayList.ActualId}", null); + await _provider.UnlikeProvidableItemAsync($"pl{PlayList?.ActualId}", null); } OnPropertyChanged(nameof(PlayList)); } @@ -70,7 +72,7 @@ public void SortSongListOrder(bool reload = false) { if (SortOrder == 0) { - if(!reload) return; + if (!reload) return; SongsList = tempSong; OnPropertyChanged(nameof(SongsList)); return; @@ -78,13 +80,13 @@ public void SortSongListOrder(bool reload = false) switch (SortTypes) { case "SongName": - SongsList = new ObservableCollection(SortOrder == 1 ? SongsList.OrderBy(song => song.Name) : SongsList.OrderByDescending(song => song.Name)); + SongsList = new ObservableCollection(SortOrder == 1 ? SongsList!.OrderBy(song => song!.Name) : SongsList!.OrderByDescending(song => song.Name)); break; case "Artist": - SongsList = new ObservableCollection(SortOrder == 1 ? SongsList.OrderBy(song => song.Artists.FirstOrDefault()?.Name) : SongsList.OrderByDescending(song => song.Artists.FirstOrDefault()?.Name)); + SongsList = new ObservableCollection(SortOrder == 1 ? SongsList!.OrderBy(song => song!.Artists?.FirstOrDefault()?.Name) : SongsList!.OrderByDescending(song => song!.Artists?.FirstOrDefault()?.Name)); break; case "Album": - SongsList = new ObservableCollection(SortOrder == 1 ? SongsList.OrderBy(song => song.Album?.Name) : SongsList.OrderByDescending(song => song.Album?.Name)); + SongsList = new ObservableCollection(SortOrder == 1 ? SongsList!.OrderBy(song => song!.Album?.Name) : SongsList!.OrderByDescending(song => song.Album?.Name)); break; default: SongsList = tempSong; diff --git a/src/HyPlayer.App/ViewModels/SearchViewModel.cs b/src/HyPlayer.App/ViewModels/SearchViewModel.cs index 4bc4b16..a6c0d73 100644 --- a/src/HyPlayer.App/ViewModels/SearchViewModel.cs +++ b/src/HyPlayer.App/ViewModels/SearchViewModel.cs @@ -6,10 +6,10 @@ namespace HyPlayer.ViewModels; public class SearchViewModel : ObservableObject, IViewModel, IScopedViewModel { private readonly NeteaseProvider.NeteaseProvider _provider; - + public SearchViewModel(NeteaseProvider.NeteaseProvider provider) { _provider = provider; } - + } \ No newline at end of file diff --git a/src/HyPlayer.App/ViewModels/ShellViewModel.cs b/src/HyPlayer.App/ViewModels/ShellViewModel.cs index 78c14dc..9cf6445 100644 --- a/src/HyPlayer.App/ViewModels/ShellViewModel.cs +++ b/src/HyPlayer.App/ViewModels/ShellViewModel.cs @@ -2,11 +2,6 @@ using CommunityToolkit.Mvvm.Input; using HyPlayer.Interfaces.ViewModels; using HyPlayer.Interfaces.Views; -using HyPlayer.Views.Controls.Dialogs; -using HyPlayer.Views.Pages; -using Microsoft.UI.Xaml.Controls; -using System; -using System.Threading.Tasks; namespace HyPlayer.ViewModels { @@ -14,8 +9,8 @@ public partial class ShellViewModel : ObservableObject, IScopedViewModel { [ObservableProperty] private AccountViewModel _accountViewModel; - public ShellViewModel(AccountViewModel accountViewModel) - { + public ShellViewModel(AccountViewModel accountViewModel) + { _accountViewModel = accountViewModel; } @@ -23,14 +18,14 @@ public ShellViewModel(AccountViewModel accountViewModel) public void GoBack() { var canGoBack = App.GetService().CanGoBack; - if(canGoBack) + if (canGoBack) { App.GetService().GoBack(); } } - - + + public bool CanBack => App.GetService().CanGoBack; } diff --git a/src/HyPlayer.App/ViewModels/UserViewModel.cs b/src/HyPlayer.App/ViewModels/UserViewModel.cs index eb0a9b4..d47b229 100644 --- a/src/HyPlayer.App/ViewModels/UserViewModel.cs +++ b/src/HyPlayer.App/ViewModels/UserViewModel.cs @@ -1,7 +1,6 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using HyPlayer.Interfaces.ViewModels; -using HyPlayer.NeteaseProvider; using HyPlayer.NeteaseProvider.Models; namespace HyPlayer.ViewModels @@ -10,12 +9,12 @@ public partial class UserViewModel : ObservableObject, IScopedViewModel { private readonly NeteaseProvider.NeteaseProvider _provider; - [ObservableProperty] public NeteaseUser _ncmUser; + [ObservableProperty] public NeteaseUser? _ncmUser; [ObservableProperty] private string? _userName; [ObservableProperty] private string? _description; [ObservableProperty] private int? _vipType; - public UserViewModel(NeteaseProvider.NeteaseProvider provider) + public UserViewModel(NeteaseProvider.NeteaseProvider provider) { _provider = provider; } @@ -23,7 +22,7 @@ public UserViewModel(NeteaseProvider.NeteaseProvider provider) [RelayCommand] public void GetUserInfo() { - if (NcmUser == null) + if (NcmUser == null) { UserName = "HyPlayer"; Description = "A Third-party Netease Music Cilent"; diff --git a/src/HyPlayer.App/Views/Controls/App/DesktopNavigationView.xaml.cs b/src/HyPlayer.App/Views/Controls/App/DesktopNavigationView.xaml.cs index 9afaab2..f873e94 100644 --- a/src/HyPlayer.App/Views/Controls/App/DesktopNavigationView.xaml.cs +++ b/src/HyPlayer.App/Views/Controls/App/DesktopNavigationView.xaml.cs @@ -1,19 +1,7 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; +using HyPlayer.Interfaces.Views; +using HyPlayer.Views.Controls.Base; 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 HyPlayer.Views.Controls.Base; -using HyPlayer.Interfaces.Views; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -37,11 +25,13 @@ public DesktopNavigationView() HyPlayer.App.contentFrame = contentFrame; } - + private void NavView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args) { - var invokedItemTag = HyPlayer.App.GetService().GetPageType((args.InvokedItemContainer as NavigationViewItem)?.Tag?.ToString()); + var invokedItem = (args.InvokedItemContainer as NavigationViewItem)?.Tag?.ToString(); + if (invokedItem == null) return; + var invokedItemTag = HyPlayer.App.GetService().GetPageType(invokedItem); var invokedItemName = (args.InvokedItemContainer as NavigationViewItem)?.Content?.ToString(); diff --git a/src/HyPlayer.App/Views/Controls/App/HomePageHeaderImage.xaml.cs b/src/HyPlayer.App/Views/Controls/App/HomePageHeaderImage.xaml.cs index 0f8448b..42edf38 100644 --- a/src/HyPlayer.App/Views/Controls/App/HomePageHeaderImage.xaml.cs +++ b/src/HyPlayer.App/Views/Controls/App/HomePageHeaderImage.xaml.cs @@ -1,15 +1,16 @@ -using System.Numerics; +using CommunityToolkit.WinUI.UI; +using CommunityToolkit.WinUI.UI.Animations; +using CommunityToolkit.WinUI.UI.Animations.Expressions; using Microsoft.Graphics.Canvas.Effects; +using Microsoft.UI; +using Microsoft.UI.Composition; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Hosting; using Microsoft.UI.Xaml.Media.Animation; -using Microsoft.UI.Composition; -using Microsoft.UI; -using CommunityToolkit.WinUI.UI.Animations; -using Windows.UI; using System; -using CommunityToolkit.WinUI.UI; +using System.Numerics; +using Windows.UI; namespace HyPlayer.Views.Controls.App { @@ -51,10 +52,16 @@ private void OnLoaded(object sender, RoutedEventArgs e) _imageGridBottomGradientBrush = _compositor.CreateLinearGradientBrush(); _imageGridBottomGradientBrush.MappingMode = CompositionMappingMode.Absolute; - _imageGridBottomGradientBrush.StartAnimation(_bottomGradientStartPointAnimation); - _imageGridBottomGradientBrush.StartAnimation(CreateExpressionAnimation(nameof(CompositionLinearGradientBrush.EndPoint), "Vector2(0.5, Visual.Size.Y)")); + if (_bottomGradientStartPointAnimation is not null) + { + _imageGridBottomGradientBrush.StartAnimation(_bottomGradientStartPointAnimation); + } + var animation = CreateExpressionAnimation(nameof(CompositionLinearGradientBrush.EndPoint), "Vector2(0.5, Visual.Size.Y)"); + if (animation is not null) + { + _imageGridBottomGradientBrush.StartAnimation(animation); + } _imageGridBottomGradientBrush.CreateColorStopsWithEasingFunction(EasingType.Sine, EasingMode.EaseInOut, 0f, 1f); - var alphaMask = new AlphaMaskEffect { Source = new CompositionEffectSourceParameter("ImageGrid"), @@ -121,11 +128,14 @@ private void AnimateImage() } - private ExpressionAnimation CreateExpressionAnimation(string target, string expression) + private ExpressionAnimation? CreateExpressionAnimation(string target, string expression) { var ani = _compositor?.CreateExpressionAnimation(expression); - ani.SetReferenceParameter("Visual", _imageGridVisual); - ani.Target = target; + if (ani != null) + { + ani.SetReferenceParameter("Visual", _imageGridVisual); + ani.Target = target; + } return ani; } } diff --git a/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotEx.xaml.cs b/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotEx.xaml.cs index 5a9cc48..b20911a 100644 --- a/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotEx.xaml.cs +++ b/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotEx.xaml.cs @@ -1,11 +1,11 @@ -using System; -using System.Threading; -using System.Threading.Tasks; using CommunityToolkit.WinUI.UI; using Microsoft.UI.Composition; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Hosting; +using System; +using System.Threading; +using System.Threading.Tasks; namespace HyPlayer.Views.Controls.App.PivotExtensions; @@ -118,8 +118,11 @@ private async Task UpdateCurrentScrollViewer() cts = _cts; currentScrollViewer.ViewChanging += CurrentScrollViewer_ViewChanging; - - var offsetY = await TryScrollVerticalOffsetAsync(currentScrollViewer); + var task = TryScrollVerticalOffsetAsync(currentScrollViewer); + if (task is not null) + { + var offsetY = await task; + } if (cts.IsCancellationRequested) return; @@ -151,7 +154,7 @@ private async Task UpdateCurrentScrollViewer() } } - private void CurrentScrollViewer_ViewChanging(object sender, ScrollViewerViewChangingEventArgs e) + private void CurrentScrollViewer_ViewChanging(object? sender, ScrollViewerViewChangingEventArgs e) { UpdateHeaderScrollOffset(e.NextView.VerticalOffset); } @@ -207,7 +210,7 @@ private void PivotEx_PivotItemLoaded(Pivot sender, PivotItemEventArgs args) return tcs.Task; - void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e) + void ScrollViewer_ViewChanged(object? sender, ScrollViewerViewChangedEventArgs e) { scrollViewer.ViewChanged -= ScrollViewer_ViewChanged; tcs.SetResult(scrollViewer.VerticalOffset); diff --git a/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotExHeaderView.xaml.cs b/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotExHeaderView.xaml.cs index 0848caa..5e60deb 100644 --- a/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotExHeaderView.xaml.cs +++ b/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotExHeaderView.xaml.cs @@ -1,9 +1,9 @@ -using System; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using System; using System.ComponentModel; using System.Linq; using Windows.Foundation.Collections; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; namespace HyPlayer.Views.Controls.App.PivotExtensions; diff --git a/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotView.xaml.cs b/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotView.xaml.cs index 71d48ba..6e76cad 100644 --- a/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotView.xaml.cs +++ b/src/HyPlayer.App/Views/Controls/App/PivotExtensions/PivotView.xaml.cs @@ -1,11 +1,11 @@ -using System; -using Windows.Foundation; using Microsoft.UI.Composition; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Hosting; using Microsoft.UI.Xaml.Markup; using Microsoft.UI.Xaml.Media; +using System; +using Windows.Foundation; namespace HyPlayer.Views.Controls.App.PivotExtensions; @@ -253,7 +253,7 @@ private void HeaderContainer_SizeChanged(object sender, SizeChangedEventArgs e) UpdateHeaderHeight(); } - private void Pivot_HeaderScrollOffsetChanged(object sender, EventArgs e) + private void Pivot_HeaderScrollOffsetChanged(object? sender, EventArgs e) { UpdatePivotMaxHeaderScrollOffset(); UpdateScrollProgress(); diff --git a/src/HyPlayer.App/Views/Controls/App/TopChartButton/TopChartButton.cs b/src/HyPlayer.App/Views/Controls/App/TopChartButton/TopChartButton.cs index ebed876..6559b20 100644 --- a/src/HyPlayer.App/Views/Controls/App/TopChartButton/TopChartButton.cs +++ b/src/HyPlayer.App/Views/Controls/App/TopChartButton/TopChartButton.cs @@ -1,12 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Data; -using Microsoft.UI.Xaml.Documents; -using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Media; // To learn more about WinUI, the WinUI project structure, @@ -37,13 +30,13 @@ public string PlayCount get => (string)GetValue(PlayCountProperty); set => SetValue(PlayCountProperty, value); } - + public string LeaderBoardName { get => (string)GetValue(LeaderBoardNameProperty); set => SetValue(LeaderBoardNameProperty, value); } - + public TopChartButton() { this.DefaultStyleKey = typeof(TopChartButton); diff --git a/src/HyPlayer.App/Views/Controls/Base/NavigationViewBase.cs b/src/HyPlayer.App/Views/Controls/Base/NavigationViewBase.cs index ca1083c..819f4a1 100644 --- a/src/HyPlayer.App/Views/Controls/Base/NavigationViewBase.cs +++ b/src/HyPlayer.App/Views/Controls/Base/NavigationViewBase.cs @@ -1,10 +1,5 @@ -using HyPlayer.ViewModels; -using HyPlayer.Interfaces.Views; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using HyPlayer.Interfaces.Views; +using HyPlayer.ViewModels; namespace HyPlayer.Views.Controls.Base { diff --git a/src/HyPlayer.App/Views/Controls/CoolControls/AutoScrollView.cs b/src/HyPlayer.App/Views/Controls/CoolControls/AutoScrollView.cs index 7d43b85..07472e2 100644 --- a/src/HyPlayer.App/Views/Controls/CoolControls/AutoScrollView.cs +++ b/src/HyPlayer.App/Views/Controls/CoolControls/AutoScrollView.cs @@ -2,11 +2,6 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Hosting; using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; namespace CoolControls.WinUI3.Controls { diff --git a/src/HyPlayer.App/Views/Controls/CoolControls/ButtonContentSnapBehavior.cs b/src/HyPlayer.App/Views/Controls/CoolControls/ButtonContentSnapBehavior.cs index db6e471..57e3b94 100644 --- a/src/HyPlayer.App/Views/Controls/CoolControls/ButtonContentSnapBehavior.cs +++ b/src/HyPlayer.App/Views/Controls/CoolControls/ButtonContentSnapBehavior.cs @@ -6,13 +6,8 @@ using Microsoft.UI.Xaml.Media; using Microsoft.Xaml.Interactivity; using System; -using System.Collections.Generic; using System.Linq; using System.Numerics; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Windows.UI.Core.AnimationMetrics; namespace CoolControls.WinUI3.Controls { diff --git a/src/HyPlayer.App/Views/Controls/CoolControls/OpacityMaskView.cs b/src/HyPlayer.App/Views/Controls/CoolControls/OpacityMaskView.cs index 0032988..d37432d 100644 --- a/src/HyPlayer.App/Views/Controls/CoolControls/OpacityMaskView.cs +++ b/src/HyPlayer.App/Views/Controls/CoolControls/OpacityMaskView.cs @@ -1,16 +1,9 @@ using Microsoft.UI.Composition; using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Hosting; -using Microsoft.UI.Xaml.Markup; using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; using System.Numerics; -using System.Text; -using System.Threading.Tasks; using Windows.UI; namespace CoolControls.WinUI3.Controls diff --git a/src/HyPlayer.App/Views/Controls/CoolControls/RedirectVisualView.cs b/src/HyPlayer.App/Views/Controls/CoolControls/RedirectVisualView.cs index d586998..fd5399d 100644 --- a/src/HyPlayer.App/Views/Controls/CoolControls/RedirectVisualView.cs +++ b/src/HyPlayer.App/Views/Controls/CoolControls/RedirectVisualView.cs @@ -3,14 +3,7 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Hosting; using Microsoft.UI.Xaml.Markup; -using Microsoft.UI.Xaml.Media; -using Microsoft.UI.Xaml.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; using System.Numerics; -using System.Text; -using System.Threading.Tasks; namespace CoolControls.WinUI3.Controls { diff --git a/src/HyPlayer.App/Views/Controls/Dialogs/SignInDialog.xaml.cs b/src/HyPlayer.App/Views/Controls/Dialogs/SignInDialog.xaml.cs index aa91a37..7fe79b8 100644 --- a/src/HyPlayer.App/Views/Controls/Dialogs/SignInDialog.xaml.cs +++ b/src/HyPlayer.App/Views/Controls/Dialogs/SignInDialog.xaml.cs @@ -1,11 +1,9 @@ using Depository.Abstraction.Interfaces; using Depository.Core; using Depository.Extensions; -using HyPlayer.Interfaces.ViewModels; using HyPlayer.Interfaces.Views; using HyPlayer.ViewModels; using Microsoft.UI.Xaml.Controls; -using System.Threading.Tasks; // To learn more about WinUI, the WinUI project structure, @@ -54,7 +52,7 @@ public async void Login() private void ContentDialog_KeyDown(object sender, Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e) { - if(TextBoxAccount.Text == "") + if (TextBoxAccount.Text == "") { TextBoxAccount.Focus(Microsoft.UI.Xaml.FocusState.Programmatic); return; diff --git a/src/HyPlayer.App/Views/Controls/Netease/SongListView/SongListView.xaml.cs b/src/HyPlayer.App/Views/Controls/Netease/SongListView/SongListView.xaml.cs index 86bf6f2..5f97b33 100644 --- a/src/HyPlayer.App/Views/Controls/Netease/SongListView/SongListView.xaml.cs +++ b/src/HyPlayer.App/Views/Controls/Netease/SongListView/SongListView.xaml.cs @@ -1,24 +1,9 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Collections.ObjectModel; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -using System.Runtime.InteropServices; using CommunityToolkit.WinUI.UI; using HyPlayer.NeteaseProvider.Models; using HyPlayer.ViewModels; 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.Diagnostics; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -38,7 +23,7 @@ public sealed partial class SongListView : UserControl public static readonly DependencyProperty FooterProperty = DependencyProperty.Register( "Footer", typeof(UIElement), typeof(SongListView), new PropertyMetadata(default(UIElement))); - public NeteasePlaylistViewModel ViewModel; + public NeteasePlaylistViewModel? ViewModel; public string ListSource { get => (string)GetValue(ListSourceProperty); @@ -81,8 +66,11 @@ private void SongItemOnClick(object sender, ItemClickEventArgs e) public async void ScrollToIndex(int index) { - SongContainer.SelectedItem = ViewModel.SongsList[index]; - await SongContainer.SmoothScrollIntoViewWithIndexAsync(index, ScrollItemPlacement.Top, false, true); + if (ViewModel?.SongsList != null) + { + SongContainer.SelectedItem = ViewModel.SongsList[index]; + await SongContainer.SmoothScrollIntoViewWithIndexAsync(index, ScrollItemPlacement.Top, false, true); + } } } } diff --git a/src/HyPlayer.App/Views/Controls/Search/SearchBox.xaml.cs b/src/HyPlayer.App/Views/Controls/Search/SearchBox.xaml.cs index f82f450..793c711 100644 --- a/src/HyPlayer.App/Views/Controls/Search/SearchBox.xaml.cs +++ b/src/HyPlayer.App/Views/Controls/Search/SearchBox.xaml.cs @@ -1,20 +1,7 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; using HyPlayer.Interfaces.Views; using HyPlayer.ViewModels; -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 HyPlayer.Views.Pages; +using Microsoft.UI.Xaml.Input; namespace HyPlayer.Views.Controls.Search { @@ -36,6 +23,6 @@ private void AppSearchBox_KeyDown(object sender, KeyRoutedEventArgs e) public class SearchBoxBase : ReactiveControlBase { - + } } diff --git a/src/HyPlayer.App/Views/Pages/ErrorPage.xaml.cs b/src/HyPlayer.App/Views/Pages/ErrorPage.xaml.cs index 40d4738..e1b2e6a 100644 --- a/src/HyPlayer.App/Views/Pages/ErrorPage.xaml.cs +++ b/src/HyPlayer.App/Views/Pages/ErrorPage.xaml.cs @@ -1,17 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -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; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. diff --git a/src/HyPlayer.App/Views/Pages/HomePage.xaml.cs b/src/HyPlayer.App/Views/Pages/HomePage.xaml.cs index 7ebf2f6..ccb575e 100644 --- a/src/HyPlayer.App/Views/Pages/HomePage.xaml.cs +++ b/src/HyPlayer.App/Views/Pages/HomePage.xaml.cs @@ -1,30 +1,13 @@ -using Depository.Abstraction.Interfaces; -using Depository.Core; +using AsyncAwaitBestPractices; +using HyPlayer.Interfaces.Views; +using HyPlayer.NeteaseProvider.Models; 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.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; -using Windows.Foundation; -using Windows.Foundation.Collections; -using AsyncAwaitBestPractices; -using Depository.Abstraction.Models.Options; -using Depository.Extensions; using HomeViewModel = HyPlayer.ViewModels.HomeViewModel; -using App = HyPlayer.App; -using HyPlayer.Interfaces.Views; -using HyPlayer.PlayCore.Abstraction.Models; -using HyPlayer.NeteaseProvider.Models; namespace HyPlayer.Views.Pages { @@ -45,12 +28,12 @@ protected override void OnNavigatedTo(NavigationEventArgs e) ViewModel.GetSongsAsync().SafeFireAndForget(); DateTime currentTime = DateTime.Now; int hour = currentTime.Hour; - if (hour < 11 && hour>=6) + if (hour < 11 && hour >= 6) { - Greetings.Text=Windows.ApplicationModel.Resources.Core.ResourceManager.Current.MainResourceMap.GetValue("Resources/HomePage_GreetingPrefix_Morning").ValueAsString; + Greetings.Text = Windows.ApplicationModel.Resources.Core.ResourceManager.Current.MainResourceMap.GetValue("Resources/HomePage_GreetingPrefix_Morning").ValueAsString; GreetingsText.Text = Windows.ApplicationModel.Resources.Core.ResourceManager.Current.MainResourceMap.GetValue("Resources/HomePage_GreetingSuffix_Morning").ValueAsString; } - else if(hour>=11 && hour<13) + else if (hour >= 11 && hour < 13) { Greetings.Text = Windows.ApplicationModel.Resources.Core.ResourceManager.Current.MainResourceMap.GetValue("Resources/HomePage_GreetingPrefix_Noon").ValueAsString; GreetingsText.Text = Windows.ApplicationModel.Resources.Core.ResourceManager.Current.MainResourceMap.GetValue("Resources/HomePage_GreetingSuffix_Noon").ValueAsString; @@ -85,7 +68,7 @@ private void HomePageTopChart_OnClick(object sender, RoutedEventArgs e) var button = sender as Button; if (button == null) return; var playlist = button.CommandParameter as NeteasePlaylist; - Debug.WriteLine($"Clicking on {playlist.Name}"); + Debug.WriteLine($"Clicking on {playlist!.Name}"); App.GetService().NavigateTo(typeof(PlaylistPage), playlist); } diff --git a/src/HyPlayer.App/Views/Pages/PlaylistPage.xaml.cs b/src/HyPlayer.App/Views/Pages/PlaylistPage.xaml.cs index 6627920..c3f5043 100644 --- a/src/HyPlayer.App/Views/Pages/PlaylistPage.xaml.cs +++ b/src/HyPlayer.App/Views/Pages/PlaylistPage.xaml.cs @@ -1,23 +1,10 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; +using HyPlayer.Interfaces.Views; +using HyPlayer.NeteaseProvider.Models; +using HyPlayer.ViewModels; 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 HyPlayer.Interfaces.Views; -using HyPlayer.ViewModels; -using System.Threading.Tasks; -using HyPlayer.NeteaseProvider.Models; -using HyPlayer.PlayCore.Abstraction; -using AsyncAwaitBestPractices; +using System.Linq; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -48,22 +35,26 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) private async void LikeBtnClick(object sender, RoutedEventArgs e) { await ViewModel.SubscribePlaylistAsync(); - ViewModel.PlayList.Subscribed = !ViewModel.PlayList.Subscribed; + if (ViewModel.PlayList is not null) + ViewModel.PlayList.Subscribed = !ViewModel.PlayList.Subscribed; } private void AutoSuggestBox_OnTextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) { - var suggestions = ViewModel.SongsList.Where(t => t.Name.Contains(sender.Text)).Select(t => t.Name).ToList(); + var suggestions = ViewModel.SongsList?.Where(t => t.Name.Contains(sender.Text)).Select(t => t.Name).ToList(); sender.ItemsSource = suggestions; } } - private async void AutoSuggestBox_OnSuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args) + private void AutoSuggestBox_OnSuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args) { - var song = ViewModel.SongsList.First(t => t.Name == args.SelectedItem.ToString()); - SongsListView.ScrollToIndex(ViewModel.SongsList.IndexOf(song)); + var song = ViewModel.SongsList?.First(t => t.Name == args.SelectedItem.ToString()); + if (song != null) + { + SongsListView.ScrollToIndex(ViewModel.SongsList!.IndexOf(song)); + } } private void SortButton_Click(SplitButton sender, SplitButtonClickEventArgs args) @@ -76,7 +67,7 @@ private void SortButton_Click(SplitButton sender, SplitButtonClickEventArgs args switch (ViewModel.SortOrder) { case 1: // 升序 - sortToolTip.Content="升序"; + sortToolTip.Content = "升序"; fontIcon.Glyph = "\uE74A"; splitButton.IsChecked = true; break; @@ -95,13 +86,17 @@ private void SortButton_Click(SplitButton sender, SplitButtonClickEventArgs args private void SortRadioButton_OnChecked(object sender, RoutedEventArgs e) { - ViewModel.SortTypes = (sender as RadioButton).Tag.ToString(); - ViewModel.SortSongListOrder(); + var sortType = (sender as RadioButton)?.Tag?.ToString(); + if (sortType is not null) + { + ViewModel.SortTypes = sortType; + ViewModel.SortSongListOrder(); + } } } public class PlaylistPageBase : AppPageWithScopedViewModelBase { - + } } diff --git a/src/HyPlayer.App/Views/Pages/SearchPage.xaml.cs b/src/HyPlayer.App/Views/Pages/SearchPage.xaml.cs index d9ff2af..7d4dccd 100644 --- a/src/HyPlayer.App/Views/Pages/SearchPage.xaml.cs +++ b/src/HyPlayer.App/Views/Pages/SearchPage.xaml.cs @@ -1,17 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -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; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. diff --git a/src/HyPlayer.App/Views/Pages/ShellPage.xaml.cs b/src/HyPlayer.App/Views/Pages/ShellPage.xaml.cs index 451324d..b947cb8 100644 --- a/src/HyPlayer.App/Views/Pages/ShellPage.xaml.cs +++ b/src/HyPlayer.App/Views/Pages/ShellPage.xaml.cs @@ -1,17 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -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; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. diff --git a/src/HyPlayer.App/Views/Pages/UserPage.xaml.cs b/src/HyPlayer.App/Views/Pages/UserPage.xaml.cs index dff78fa..9e93354 100644 --- a/src/HyPlayer.App/Views/Pages/UserPage.xaml.cs +++ b/src/HyPlayer.App/Views/Pages/UserPage.xaml.cs @@ -1,20 +1,7 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -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 HyPlayer.Interfaces.Views; -using HyPlayer.ViewModels; using HyPlayer.NeteaseProvider.Models; +using HyPlayer.ViewModels; +using Microsoft.UI.Xaml.Navigation; namespace HyPlayer.Views.Pages @@ -26,17 +13,17 @@ public sealed partial class UserPage : UserPageBase { public UserPage() { - this.InitializeComponent(); + this.InitializeComponent(); } protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - ViewModel.NcmUser = (NeteaseUser) e.Parameter; - if(ViewModel.NcmUser != null) + ViewModel.NcmUser = (NeteaseUser)e.Parameter; + if (ViewModel.NcmUser != null) { - + ViewModel.GetUserInfo(); } } diff --git a/src/HyPlayer.App/Views/Window/MainWindow.xaml.cs b/src/HyPlayer.App/Views/Window/MainWindow.xaml.cs index dc8c3e2..0b9151b 100644 --- a/src/HyPlayer.App/Views/Window/MainWindow.xaml.cs +++ b/src/HyPlayer.App/Views/Window/MainWindow.xaml.cs @@ -1,27 +1,20 @@ +using Depository.Abstraction.Interfaces; +using Depository.Core; +using Depository.Extensions; +using HyPlayer.Interfaces.Views; +using HyPlayer.ViewModels; +using HyPlayer.Views.Controls.Dialogs; +using HyPlayer.Views.Pages; using Microsoft.UI; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; -using System.Collections.Generic; using System; +using System.Collections.Generic; using System.Runtime.InteropServices; using WinRT.Interop; using WinUIEx; - using AppWindow = Microsoft.UI.Windowing.AppWindow; using AppWindowTitleBar = Microsoft.UI.Windowing.AppWindowTitleBar; -using Microsoft.UI.Xaml.Controls; -using Windows.UI.WindowManagement; -using HyPlayer.Interfaces.Views; -using HyPlayer.ViewModels; -using Depository.Abstraction.Interfaces; -using Depository.Abstraction.Models.Options; -using Depository.Core; -using Depository.Extensions; -using HyPlayer.Interfaces.ViewModels; -using HyPlayer.Views.Controls.Dialogs; -using HyPlayer.Views.Pages; -using HyPlayer.Views.Controls.App; -using System.Runtime.CompilerServices; namespace HyPlayer.Views.Window { @@ -67,7 +60,7 @@ public MainWindow() // A taller title bar is only supported when drawing a fully custom title bar if (AppWindowTitleBar.IsCustomizationSupported() && titleBar.ExtendsContentIntoTitleBar) { - + // Recalculate the drag region for the custom title bar // if you explicitly defined new draggable areas. SetDragRegionForCustomTitleBar(AppWindow); @@ -188,7 +181,7 @@ private void SetDragRegionForCustomTitleBar(AppWindow appWindow) List dragRectsList = new(); Windows.Graphics.RectInt32 dragRectL; - dragRectL.X = (int)((LeftPaddingColumn.ActualWidth) * scaleAdjustment)+48; + dragRectL.X = (int)((LeftPaddingColumn.ActualWidth) * scaleAdjustment) + 48; dragRectL.Y = 0; dragRectL.Height = (int)(AppTitleBar.ActualHeight * scaleAdjustment); dragRectL.Width = (int)((IconColumn.ActualWidth @@ -213,11 +206,11 @@ private void SetDragRegionForCustomTitleBar(AppWindow appWindow) } } - + private async void UserButton_Click(object sender, RoutedEventArgs e) { - if(!_shellViewModel.AccountViewModel.IsLogin) + if (!_shellViewModel.AccountViewModel.IsLogin) { var signin_dialog = new SignInDialog(); signin_dialog.XamlRoot = this.Content.XamlRoot; @@ -229,6 +222,6 @@ private async void UserButton_Click(object sender, RoutedEventArgs e) } } - + } } diff --git a/src/HyPlayer.App/Views/Window/SmallWindow.xaml.cs b/src/HyPlayer.App/Views/Window/SmallWindow.xaml.cs index 6aade0e..814dc67 100644 --- a/src/HyPlayer.App/Views/Window/SmallWindow.xaml.cs +++ b/src/HyPlayer.App/Views/Window/SmallWindow.xaml.cs @@ -1,23 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -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 XamlWindow = Microsoft.UI.Xaml.Window; using Windows.UI.WindowManagement; using WinUIEx; -using Microsoft.UI; -using Microsoft.UI.Xaml.Markup; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -34,8 +17,8 @@ public SmallWindow() { this.InitializeComponent(); this.AppWindow.SetPresenter((Microsoft.UI.Windowing.AppWindowPresenterKind)AppWindowPresentationKind.CompactOverlay); - - + + this.SetTitleBar(AppTitleBar); Content = contentFrame;