From 37f2d8eb8191bb399f689f24db2d6e2f16f8519e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E5=BD=AA?= <1315508912@qq.com> Date: Thu, 21 Dec 2023 23:07:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96dialog=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=92=8C=E4=BF=AE=E5=A4=8Ddialog=E7=9A=84=E7=9B=B8?= =?UTF-8?q?=E5=85=B3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi/App.axaml.cs | 6 +- DownKyi/DownKyi.csproj | 8 ++ DownKyi/PrismExtension/Common/MvvmHelpers.cs | 77 +++++++++++ DownKyi/PrismExtension/Dialog/Dialog.cs | 30 +++++ .../PrismExtension/Dialog/DialogService.cs | 124 ++++++++++++++++++ .../PrismExtension/Dialog/DialogWindow.axaml | 12 ++ .../Dialog/DialogWindow.axaml.cs | 14 ++ .../Dialog}/IDialogService.cs | 2 +- .../PrismExtension/Dialog/IDialogWindow.cs | 8 ++ DownKyi/Services/AlertService.cs | 1 + DownKyi/Services/DialogService.cs | 58 -------- .../Services/Download/AddToDownloadService.cs | 1 + .../Services/Download/AriaDownloadService.cs | 2 +- .../Download/BuiltinDownloadService.cs | 2 +- .../Download/CustomAriaDownloadService.cs | 2 +- DownKyi/Services/Download/DownloadService.cs | 1 + DownKyi/Themes/Styles/StyleSystemBtn.axaml | 60 +++++++++ DownKyi/Themes/ThemeDefault.axaml | 2 +- .../DownloadManager/DownloadBaseItem.cs | 2 +- .../DownloadManager/DownloadedItem.cs | 2 +- .../DownloadManager/DownloadingItem.cs | 2 +- .../ViewDownloadFinishedViewModel.cs | 2 +- .../ViewDownloadingViewModel.cs | 19 +-- .../ViewModels/Settings/ViewAboutViewModel.cs | 2 +- .../Settings/ViewNetworkViewModel.cs | 2 +- DownKyi/ViewModels/ViewModelBase.cs | 2 +- .../ViewMyBangumiFollowViewModel.cs | 3 +- .../ViewModels/ViewMyFavoritesViewModel.cs | 3 +- DownKyi/ViewModels/ViewMyHistoryViewModel.cs | 3 +- .../ViewModels/ViewMyToViewVideoViewModel.cs | 3 +- .../ViewPublicFavoritesViewModel.cs | 3 +- .../ViewModels/ViewPublicationViewModel.cs | 1 + .../ViewModels/ViewSeasonsSeriesViewModel.cs | 3 +- .../ViewModels/ViewVideoDetailViewModel.cs | 2 +- DownKyi/Views/Dialogs/ViewAlertDialog.axaml | 25 +++- .../Views/Dialogs/ViewDownloadSetter.axaml | 11 +- .../Views/Dialogs/ViewParsingSelector.axaml | 41 ++++-- 37 files changed, 430 insertions(+), 111 deletions(-) create mode 100644 DownKyi/PrismExtension/Common/MvvmHelpers.cs create mode 100644 DownKyi/PrismExtension/Dialog/Dialog.cs create mode 100644 DownKyi/PrismExtension/Dialog/DialogService.cs create mode 100644 DownKyi/PrismExtension/Dialog/DialogWindow.axaml create mode 100644 DownKyi/PrismExtension/Dialog/DialogWindow.axaml.cs rename DownKyi/{Services => PrismExtension/Dialog}/IDialogService.cs (88%) create mode 100644 DownKyi/PrismExtension/Dialog/IDialogWindow.cs delete mode 100644 DownKyi/Services/DialogService.cs create mode 100644 DownKyi/Themes/Styles/StyleSystemBtn.axaml diff --git a/DownKyi/App.axaml.cs b/DownKyi/App.axaml.cs index b966394..8b131ba 100644 --- a/DownKyi/App.axaml.cs +++ b/DownKyi/App.axaml.cs @@ -10,7 +10,7 @@ using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; using Avalonia.Threading; using DownKyi.Core.Settings; -using DownKyi.Services; +using DownKyi.PrismExtension.Dialog; using DownKyi.Services.Download; using DownKyi.ViewModels; using DownKyi.ViewModels.Dialogs; @@ -61,6 +61,7 @@ public partial class App : PrismApplication protected override void RegisterTypes(IContainerRegistry containerRegistry) { containerRegistry.RegisterSingleton(); + containerRegistry.Register(); // pages containerRegistry.RegisterForNavigation(ViewIndexViewModel.Tag); containerRegistry.RegisterForNavigation(ViewLoginViewModel.Tag); @@ -105,8 +106,7 @@ public partial class App : PrismApplication // UserSpace containerRegistry.RegisterForNavigation(ViewArchiveViewModel.Tag); // containerRegistry.RegisterForNavigation(ViewModels.UserSpace.ViewChannelViewModel.Tag); - containerRegistry.RegisterForNavigation(ViewModels.UserSpace - .ViewSeasonsSeriesViewModel.Tag); + containerRegistry.RegisterForNavigation(ViewModels.UserSpace.ViewSeasonsSeriesViewModel.Tag); // dialogs containerRegistry.RegisterDialog(ViewAlertDialogViewModel.Tag); diff --git a/DownKyi/DownKyi.csproj b/DownKyi/DownKyi.csproj index c0c3cef..b8c9ba6 100644 --- a/DownKyi/DownKyi.csproj +++ b/DownKyi/DownKyi.csproj @@ -35,4 +35,12 @@ + + + + + DialogWindow.axaml + Code + + diff --git a/DownKyi/PrismExtension/Common/MvvmHelpers.cs b/DownKyi/PrismExtension/Common/MvvmHelpers.cs new file mode 100644 index 0000000..5810995 --- /dev/null +++ b/DownKyi/PrismExtension/Common/MvvmHelpers.cs @@ -0,0 +1,77 @@ +using System; +using Avalonia.Controls; +using Prism.Mvvm; + +namespace DownKyi.PrismExtension.Common; + +/// + /// Helper class for MVVM. + /// + public static class MvvmHelpers + { + /// + /// Sets the AutoWireViewModel property to true for the . + /// + /// + /// The AutoWireViewModel property will only be set to true if the view + /// is a , the DataContext of the view is null, and + /// the AutoWireViewModel property of the view is null. + /// + /// The View or ViewModel. + internal static void AutowireViewModel(object viewOrViewModel) + { + if (viewOrViewModel is Control view && + view.DataContext is null && + ViewModelLocator.GetAutoWireViewModel(view) is null) + { + ViewModelLocator.SetAutoWireViewModel(view, true); + } + } + + ////#endif + + /// + /// Perform an on a view and viewmodel. + /// + /// + /// The action will be performed on the view and its viewmodel if they implement . + /// + /// The parameter type. + /// The view to perform the on. + /// The to perform. + public static void ViewAndViewModelAction(object view, Action action) where T : class + { + if (view is T viewAsT) + action(viewAsT); + + if (view is Control element && element.DataContext is T viewModelAsT) + { + action(viewModelAsT); + } + } + + /// + /// Get an implementer from a view or viewmodel. + /// + /// + /// If the view implements it will be returned. + /// Otherwise if the view's implements it will be returned instead. + /// + /// The implementer type to get. + /// The view to get from. + /// view or viewmodel as . + public static T GetImplementerFromViewOrViewModel(object view) where T : class + { + if (view is T viewAsT) + { + return viewAsT; + } + + if (view is Control element && element.DataContext is T vmAsT) + { + return vmAsT; + } + + return null; + } + } \ No newline at end of file diff --git a/DownKyi/PrismExtension/Dialog/Dialog.cs b/DownKyi/PrismExtension/Dialog/Dialog.cs new file mode 100644 index 0000000..4ed3742 --- /dev/null +++ b/DownKyi/PrismExtension/Dialog/Dialog.cs @@ -0,0 +1,30 @@ +using Avalonia; +using Avalonia.Styling; + +namespace DownKyi.PrismExtension.Dialog; + +public class Dialog : Prism.Services.Dialogs.Dialog +{ + public static readonly AvaloniaProperty ThemeProperty = + AvaloniaProperty.RegisterAttached("Theme", typeof(Dialog)); + + /// + /// Gets the value for the attached property. + /// + /// The target element. + /// The attached to the element. + public static ControlTheme? GetTheme(AvaloniaObject obj) + { + return (ControlTheme?)obj.GetValue(ThemeProperty); + } + + /// + /// Sets the attached property. + /// + /// The target element. + /// The Style to attach. + public static void SetTheme(AvaloniaObject obj, ControlTheme value) + { + obj.SetValue(ThemeProperty, value); + } +} \ No newline at end of file diff --git a/DownKyi/PrismExtension/Dialog/DialogService.cs b/DownKyi/PrismExtension/Dialog/DialogService.cs new file mode 100644 index 0000000..40c3dd9 --- /dev/null +++ b/DownKyi/PrismExtension/Dialog/DialogService.cs @@ -0,0 +1,124 @@ +using System; +using System.Threading.Tasks; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.ApplicationLifetimes; +using DownKyi.PrismExtension.Common; +using Prism.Ioc; +using Prism.Services.Dialogs; + +namespace DownKyi.PrismExtension.Dialog; + +public class DialogService : Prism.Services.Dialogs.DialogService, IDialogService +{ + private readonly IContainerExtension _containerExtension; + + /// Initializes a new instance of the class. + /// The + public DialogService(IContainerExtension containerExtension) : base(containerExtension) + { + _containerExtension = containerExtension; + } + + public Task ShowDialogAsync(string name, IDialogParameters parameters, Action? callback = null, + string? windowName = null) + { + return ShowDialogInternal(name, parameters, callback, true, windowName); + } + + private Task ShowDialogInternal(string name, IDialogParameters parameters, Action? callback, + bool isModal, string? windowName = null, Window? parentWindow = null) + { + if (parameters == null) + parameters = new DialogParameters(); + + IDialogWindow dialogWindow = CreateDialogWindow(windowName); + ConfigureDialogWindowEvents(dialogWindow, callback); + ConfigureDialogWindowContent(name, dialogWindow, parameters); + + return ShowDialogWindow(dialogWindow, isModal, parentWindow); + } + + protected virtual IDialogWindow CreateDialogWindow(string name) + { + if (string.IsNullOrWhiteSpace(name)) + return _containerExtension.Resolve(); + else + return _containerExtension.Resolve(name); + } + + protected new virtual Task ShowDialogWindow(IDialogWindow dialogWindow, bool isModal, Window? owner = null) + { + if (isModal && + Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime deskLifetime) + { + // Ref: + // - https://docs.avaloniaui.net/docs/controls/window#show-a-window-as-a-dialog + // - https://github.com/AvaloniaUI/Avalonia/discussions/7924 + // (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) + + if (owner != null) + return dialogWindow.ShowDialog(owner); + else + return dialogWindow.ShowDialog(deskLifetime.MainWindow); + } + else + { + dialogWindow.Show(); + } + + return Task.CompletedTask; + } + + /// + /// Configure content. + /// + /// The name of the dialog to show. + /// The hosting window. + /// The parameters to pass to the dialog. + protected virtual void ConfigureDialogWindowContent(string dialogName, IDialogWindow window, + IDialogParameters parameters) + { + var content = _containerExtension.Resolve(dialogName); + if (!(content is Control dialogContent)) + throw new NullReferenceException("A dialog's content must be a FrameworkElement"); + + MvvmHelpers.AutowireViewModel(dialogContent); + + if (!(dialogContent.DataContext is IDialogAware viewModel)) + throw new NullReferenceException("A dialog's ViewModel must implement the IDialogAware interface"); + + ConfigureDialogWindowProperties(window, dialogContent, viewModel); + + MvvmHelpers.ViewAndViewModelAction(viewModel, d => d.OnDialogOpened(parameters)); + } + + protected void ConfigureDialogWindowProperties(IDialogWindow window, Control dialogContent, + IDialogAware viewModel) + { + // Avalonia returns 'null' for Dialog.GetWindowStyle(dialogContent); + // WPF: Window > ContentControl > FrameworkElement + // Ava: Window > WindowBase > TopLevel > Control > InputElement > Interactive > Layoutable > Visual > StyledElement.Styles (collection) + + var windowTheme = Dialog.GetTheme(dialogContent); + if (windowTheme != null) + { + window.Theme = windowTheme; + } + + window.Content = dialogContent; + window.DataContext = viewModel; + + + // WPF + //// var windowStyle = Dialog.GetWindowStyle(dialogContent); + //// if (windowStyle != null) + //// window.Style = windowStyle; + //// + //// window.Content = dialogContent; + //// window.DataContext = viewModel; //we want the host window and the dialog to share the same data context + //// + //// if (window.Owner == null) + // window.Owner = Application.Current?.Windows.OfType().FirstOrDefault(x => x.IsActive); + } +} \ No newline at end of file diff --git a/DownKyi/PrismExtension/Dialog/DialogWindow.axaml b/DownKyi/PrismExtension/Dialog/DialogWindow.axaml new file mode 100644 index 0000000..23e1873 --- /dev/null +++ b/DownKyi/PrismExtension/Dialog/DialogWindow.axaml @@ -0,0 +1,12 @@ + + + + + diff --git a/DownKyi/PrismExtension/Dialog/DialogWindow.axaml.cs b/DownKyi/PrismExtension/Dialog/DialogWindow.axaml.cs new file mode 100644 index 0000000..5c834b9 --- /dev/null +++ b/DownKyi/PrismExtension/Dialog/DialogWindow.axaml.cs @@ -0,0 +1,14 @@ +using Avalonia.Controls; +using Prism.Services.Dialogs; + +namespace DownKyi.PrismExtension.Dialog; + +public partial class DialogWindow : Window, IDialogWindow +{ + public DialogWindow() + { + InitializeComponent(); + } + + public IDialogResult? Result { get; set; } +} \ No newline at end of file diff --git a/DownKyi/Services/IDialogService.cs b/DownKyi/PrismExtension/Dialog/IDialogService.cs similarity index 88% rename from DownKyi/Services/IDialogService.cs rename to DownKyi/PrismExtension/Dialog/IDialogService.cs index ccc3562..80357b0 100644 --- a/DownKyi/Services/IDialogService.cs +++ b/DownKyi/PrismExtension/Dialog/IDialogService.cs @@ -2,7 +2,7 @@ using System; using System.Threading.Tasks; using Prism.Services.Dialogs; -namespace DownKyi.Services; +namespace DownKyi.PrismExtension.Dialog; public interface IDialogService : Prism.Services.Dialogs.IDialogService { diff --git a/DownKyi/PrismExtension/Dialog/IDialogWindow.cs b/DownKyi/PrismExtension/Dialog/IDialogWindow.cs new file mode 100644 index 0000000..fb02b02 --- /dev/null +++ b/DownKyi/PrismExtension/Dialog/IDialogWindow.cs @@ -0,0 +1,8 @@ +using Avalonia.Styling; + +namespace DownKyi.PrismExtension.Dialog; + +public interface IDialogWindow: Prism.Services.Dialogs.IDialogWindow +{ + ControlTheme? Theme { get; set; } +} \ No newline at end of file diff --git a/DownKyi/Services/AlertService.cs b/DownKyi/Services/AlertService.cs index bfb4b90..f97ca21 100644 --- a/DownKyi/Services/AlertService.cs +++ b/DownKyi/Services/AlertService.cs @@ -3,6 +3,7 @@ using DownKyi.Images; using DownKyi.Utils; using DownKyi.ViewModels.Dialogs; using Prism.Services.Dialogs; +using IDialogService = DownKyi.PrismExtension.Dialog.IDialogService; namespace DownKyi.Services; diff --git a/DownKyi/Services/DialogService.cs b/DownKyi/Services/DialogService.cs deleted file mode 100644 index 02b6f10..0000000 --- a/DownKyi/Services/DialogService.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Threading.Tasks; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Controls.ApplicationLifetimes; -using Prism.Ioc; -using Prism.Services.Dialogs; - -namespace DownKyi.Services; - -public class DialogService : Prism.Services.Dialogs.DialogService, IDialogService -{ - public DialogService(IContainerExtension containerExtension) : base(containerExtension) - { - } - - public Task ShowDialogAsync(string name, IDialogParameters parameters, Action? callback = null, - string? windowName = null) - { - return ShowDialogInternal(name, parameters, callback, true, windowName); - } - - private Task ShowDialogInternal(string name, IDialogParameters parameters, Action? callback, - bool isModal, string? windowName = null, Window? parentWindow = null) - { - if (parameters == null) - parameters = new DialogParameters(); - - IDialogWindow dialogWindow = CreateDialogWindow(windowName); - ConfigureDialogWindowEvents(dialogWindow, callback); - ConfigureDialogWindowContent(name, dialogWindow, parameters); - - return ShowDialogWindow(dialogWindow, isModal, parentWindow); - } - - protected new virtual Task ShowDialogWindow(IDialogWindow dialogWindow, bool isModal, Window? owner = null) - { - if (isModal && - Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime deskLifetime) - { - // Ref: - // - https://docs.avaloniaui.net/docs/controls/window#show-a-window-as-a-dialog - // - https://github.com/AvaloniaUI/Avalonia/discussions/7924 - // (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) - - if (owner != null) - return dialogWindow.ShowDialog(owner); - else - return dialogWindow.ShowDialog(deskLifetime.MainWindow); - } - else - { - dialogWindow.Show(); - } - - return Task.CompletedTask; - } -} \ No newline at end of file diff --git a/DownKyi/Services/Download/AddToDownloadService.cs b/DownKyi/Services/Download/AddToDownloadService.cs index a3b2e56..6bac1f3 100644 --- a/DownKyi/Services/Download/AddToDownloadService.cs +++ b/DownKyi/Services/Download/AddToDownloadService.cs @@ -20,6 +20,7 @@ using DownKyi.ViewModels.DownloadManager; using DownKyi.ViewModels.PageViewModels; using Prism.Events; using Prism.Services.Dialogs; +using IDialogService = DownKyi.PrismExtension.Dialog.IDialogService; namespace DownKyi.Services.Download; diff --git a/DownKyi/Services/Download/AriaDownloadService.cs b/DownKyi/Services/Download/AriaDownloadService.cs index a2b89ea..63177f2 100644 --- a/DownKyi/Services/Download/AriaDownloadService.cs +++ b/DownKyi/Services/Download/AriaDownloadService.cs @@ -15,9 +15,9 @@ using DownKyi.Core.Settings; using DownKyi.Core.Utils; using DownKyi.Images; using DownKyi.Models; +using DownKyi.PrismExtension.Dialog; using DownKyi.Utils; using DownKyi.ViewModels.DownloadManager; -using Prism.Services.Dialogs; namespace DownKyi.Services.Download; diff --git a/DownKyi/Services/Download/BuiltinDownloadService.cs b/DownKyi/Services/Download/BuiltinDownloadService.cs index 38ef0da..842b1f2 100644 --- a/DownKyi/Services/Download/BuiltinDownloadService.cs +++ b/DownKyi/Services/Download/BuiltinDownloadService.cs @@ -14,7 +14,7 @@ using DownKyi.Core.Utils; using DownKyi.Models; using DownKyi.Utils; using DownKyi.ViewModels.DownloadManager; -using Prism.Services.Dialogs; +using DownKyi.PrismExtension.Dialog; using Console = DownKyi.Core.Utils.Debugging.Console; namespace DownKyi.Services.Download; diff --git a/DownKyi/Services/Download/CustomAriaDownloadService.cs b/DownKyi/Services/Download/CustomAriaDownloadService.cs index 0ced738..d47689d 100644 --- a/DownKyi/Services/Download/CustomAriaDownloadService.cs +++ b/DownKyi/Services/Download/CustomAriaDownloadService.cs @@ -15,7 +15,7 @@ using DownKyi.Core.Utils; using DownKyi.Models; using DownKyi.Utils; using DownKyi.ViewModels.DownloadManager; -using Prism.Services.Dialogs; +using DownKyi.PrismExtension.Dialog; namespace DownKyi.Services.Download; diff --git a/DownKyi/Services/Download/DownloadService.cs b/DownKyi/Services/Download/DownloadService.cs index ed733ff..4e9a5d3 100644 --- a/DownKyi/Services/Download/DownloadService.cs +++ b/DownKyi/Services/Download/DownloadService.cs @@ -16,6 +16,7 @@ using DownKyi.Core.Storage; using DownKyi.Core.Utils; using DownKyi.Images; using DownKyi.Models; +using DownKyi.PrismExtension.Dialog; using DownKyi.Utils; using DownKyi.ViewModels.DownloadManager; using Console = DownKyi.Core.Utils.Debugging.Console; diff --git a/DownKyi/Themes/Styles/StyleSystemBtn.axaml b/DownKyi/Themes/Styles/StyleSystemBtn.axaml new file mode 100644 index 0000000..7aa851c --- /dev/null +++ b/DownKyi/Themes/Styles/StyleSystemBtn.axaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DownKyi/Themes/ThemeDefault.axaml b/DownKyi/Themes/ThemeDefault.axaml index 86d80f7..ab11f5e 100644 --- a/DownKyi/Themes/ThemeDefault.axaml +++ b/DownKyi/Themes/ThemeDefault.axaml @@ -7,7 +7,7 @@ - + diff --git a/DownKyi/ViewModels/DownloadManager/DownloadBaseItem.cs b/DownKyi/ViewModels/DownloadManager/DownloadBaseItem.cs index c1f6d7f..726d837 100644 --- a/DownKyi/ViewModels/DownloadManager/DownloadBaseItem.cs +++ b/DownKyi/ViewModels/DownloadManager/DownloadBaseItem.cs @@ -2,7 +2,7 @@ using DownKyi.Core.BiliApi.BiliUtils; using DownKyi.Core.BiliApi.Zone; using DownKyi.Models; -using DownKyi.Services; +using DownKyi.PrismExtension.Dialog; using DownKyi.Utils; using Prism.Mvvm; diff --git a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs index df6c229..c73264c 100644 --- a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs +++ b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs @@ -6,7 +6,7 @@ using DownKyi.Services; using DownKyi.Utils; using Prism.Commands; using Prism.Services.Dialogs; -using IDialogService = DownKyi.Services.IDialogService; +using IDialogService = DownKyi.PrismExtension.Dialog.IDialogService; namespace DownKyi.ViewModels.DownloadManager { diff --git a/DownKyi/ViewModels/DownloadManager/DownloadingItem.cs b/DownKyi/ViewModels/DownloadManager/DownloadingItem.cs index 3932d53..f11fbbe 100644 --- a/DownKyi/ViewModels/DownloadManager/DownloadingItem.cs +++ b/DownKyi/ViewModels/DownloadManager/DownloadingItem.cs @@ -5,7 +5,7 @@ using DownKyi.Services; using DownKyi.Utils; using Prism.Commands; using Prism.Services.Dialogs; -using IDialogService = DownKyi.Services.IDialogService; +using IDialogService = DownKyi.PrismExtension.Dialog.IDialogService; namespace DownKyi.ViewModels.DownloadManager { diff --git a/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs b/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs index 37f5d3a..feee46c 100644 --- a/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs +++ b/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs @@ -13,7 +13,7 @@ using Prism.Events; using Prism.Regions; using Prism.Services.Dialogs; using Console = DownKyi.Core.Utils.Debugging.Console; -using IDialogService = DownKyi.Services.IDialogService; +using IDialogService = DownKyi.PrismExtension.Dialog.IDialogService; namespace DownKyi.ViewModels.DownloadManager { diff --git a/DownKyi/ViewModels/DownloadManager/ViewDownloadingViewModel.cs b/DownKyi/ViewModels/DownloadManager/ViewDownloadingViewModel.cs index b9cf421..8503709 100644 --- a/DownKyi/ViewModels/DownloadManager/ViewDownloadingViewModel.cs +++ b/DownKyi/ViewModels/DownloadManager/ViewDownloadingViewModel.cs @@ -1,4 +1,10 @@ -using DownKyi.Core.Logging; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.Linq; +using System.Threading.Tasks; +using DownKyi.Core.Logging; using DownKyi.Images; using DownKyi.Models; using DownKyi.Services; @@ -7,13 +13,8 @@ using Prism.Commands; using Prism.Events; using Prism.Regions; using Prism.Services.Dialogs; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Collections.Specialized; -using System.Linq; -using System.Threading.Tasks; -using IDialogService = DownKyi.Services.IDialogService; +using Console = DownKyi.Core.Utils.Debugging.Console; +using IDialogService = DownKyi.PrismExtension.Dialog.IDialogService; namespace DownKyi.ViewModels.DownloadManager { @@ -199,7 +200,7 @@ namespace DownKyi.ViewModels.DownloadManager } catch (Exception e) { - Core.Utils.Debugging.Console.PrintLine("SetDialogService()发生异常: {0}", e); + Console.PrintLine("SetDialogService()发生异常: {0}", e); LogManager.Error($"{Tag}.SetDialogService()", e); } } diff --git a/DownKyi/ViewModels/Settings/ViewAboutViewModel.cs b/DownKyi/ViewModels/Settings/ViewAboutViewModel.cs index 94e108b..22b4154 100644 --- a/DownKyi/ViewModels/Settings/ViewAboutViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewAboutViewModel.cs @@ -1,7 +1,7 @@ using DownKyi.Core.Settings; using DownKyi.Events; using DownKyi.Models; -using DownKyi.Services; +using DownKyi.PrismExtension.Dialog; using DownKyi.Utils; using Prism.Commands; using Prism.Events; diff --git a/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs b/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs index 8f97df6..e0af7f0 100644 --- a/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs @@ -11,7 +11,7 @@ using Prism.Commands; using Prism.Events; using Prism.Regions; using Prism.Services.Dialogs; -using IDialogService = DownKyi.Services.IDialogService; +using IDialogService = DownKyi.PrismExtension.Dialog.IDialogService; namespace DownKyi.ViewModels.Settings; diff --git a/DownKyi/ViewModels/ViewModelBase.cs b/DownKyi/ViewModels/ViewModelBase.cs index 2e0e020..763dfe4 100644 --- a/DownKyi/ViewModels/ViewModelBase.cs +++ b/DownKyi/ViewModels/ViewModelBase.cs @@ -1,6 +1,6 @@ using System; using Avalonia.Threading; -using DownKyi.Services; +using DownKyi.PrismExtension.Dialog; using Prism.Events; using Prism.Mvvm; using Prism.Regions; diff --git a/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs b/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs index e9cb67a..c9bbd47 100644 --- a/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs +++ b/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs @@ -19,8 +19,7 @@ using DownKyi.ViewModels.PageViewModels; using Prism.Commands; using Prism.Events; using Prism.Regions; -using Prism.Services.Dialogs; -using IDialogService = DownKyi.Services.IDialogService; +using IDialogService = DownKyi.PrismExtension.Dialog.IDialogService; namespace DownKyi.ViewModels; diff --git a/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs b/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs index 8b10d50..31b6750 100644 --- a/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs +++ b/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs @@ -10,6 +10,7 @@ using DownKyi.Core.BiliApi.VideoStream; using DownKyi.CustomControl; using DownKyi.Events; using DownKyi.Images; +using DownKyi.PrismExtension.Dialog; using DownKyi.Services; using DownKyi.Services.Download; using DownKyi.Utils; @@ -17,8 +18,6 @@ using DownKyi.ViewModels.PageViewModels; using Prism.Commands; using Prism.Events; using Prism.Regions; -using Prism.Services.Dialogs; -using IDialogService = DownKyi.Services.IDialogService; namespace DownKyi.ViewModels; diff --git a/DownKyi/ViewModels/ViewMyHistoryViewModel.cs b/DownKyi/ViewModels/ViewMyHistoryViewModel.cs index d8a1ee2..568fa72 100644 --- a/DownKyi/ViewModels/ViewMyHistoryViewModel.cs +++ b/DownKyi/ViewModels/ViewMyHistoryViewModel.cs @@ -11,6 +11,7 @@ using DownKyi.Core.Storage; using DownKyi.Core.Utils; using DownKyi.Events; using DownKyi.Images; +using DownKyi.PrismExtension.Dialog; using DownKyi.Services; using DownKyi.Services.Download; using DownKyi.Utils; @@ -18,8 +19,6 @@ using DownKyi.ViewModels.PageViewModels; using Prism.Commands; using Prism.Events; using Prism.Regions; -using Prism.Services.Dialogs; -using IDialogService = DownKyi.Services.IDialogService; namespace DownKyi.ViewModels; diff --git a/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs b/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs index f04c7ba..47b0886 100644 --- a/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs +++ b/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs @@ -10,6 +10,7 @@ using DownKyi.Core.BiliApi.VideoStream; using DownKyi.Core.Storage; using DownKyi.Events; using DownKyi.Images; +using DownKyi.PrismExtension.Dialog; using DownKyi.Services; using DownKyi.Services.Download; using DownKyi.Utils; @@ -17,8 +18,6 @@ using DownKyi.ViewModels.PageViewModels; using Prism.Commands; using Prism.Events; using Prism.Regions; -using Prism.Services.Dialogs; -using IDialogService = DownKyi.Services.IDialogService; namespace DownKyi.ViewModels; diff --git a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs index 8820451..89380b1 100644 --- a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs @@ -9,6 +9,7 @@ using DownKyi.Core.BiliApi.VideoStream; using DownKyi.Core.Logging; using DownKyi.Events; using DownKyi.Images; +using DownKyi.PrismExtension.Dialog; using DownKyi.Services; using DownKyi.Services.Download; using DownKyi.Utils; @@ -16,8 +17,6 @@ using DownKyi.ViewModels.PageViewModels; using Prism.Commands; using Prism.Events; using Prism.Regions; -using Prism.Services.Dialogs; -using IDialogService = DownKyi.Services.IDialogService; namespace DownKyi.ViewModels; diff --git a/DownKyi/ViewModels/ViewPublicationViewModel.cs b/DownKyi/ViewModels/ViewPublicationViewModel.cs index f84760c..7a700be 100644 --- a/DownKyi/ViewModels/ViewPublicationViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicationViewModel.cs @@ -12,6 +12,7 @@ using DownKyi.Core.Utils; using DownKyi.CustomControl; using DownKyi.Events; using DownKyi.Images; +using DownKyi.PrismExtension.Dialog; using DownKyi.Services; using DownKyi.Services.Download; using DownKyi.Utils; diff --git a/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs b/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs index 0e46420..2e42b3c 100644 --- a/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs +++ b/DownKyi/ViewModels/ViewSeasonsSeriesViewModel.cs @@ -12,6 +12,7 @@ using DownKyi.Core.Utils; using DownKyi.CustomControl; using DownKyi.Events; using DownKyi.Images; +using DownKyi.PrismExtension.Dialog; using DownKyi.Services; using DownKyi.Services.Download; using DownKyi.Utils; @@ -19,8 +20,6 @@ using DownKyi.ViewModels.PageViewModels; using Prism.Commands; using Prism.Events; using Prism.Regions; -using Prism.Services.Dialogs; -using IDialogService = DownKyi.Services.IDialogService; namespace DownKyi.ViewModels; diff --git a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs index 1231e45..75045d6 100644 --- a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs +++ b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs @@ -22,7 +22,7 @@ using Prism.Events; using Prism.Regions; using Prism.Services.Dialogs; using Console = DownKyi.Core.Utils.Debugging.Console; -using IDialogService = DownKyi.Services.IDialogService; +using IDialogService = DownKyi.PrismExtension.Dialog.IDialogService; namespace DownKyi.ViewModels; diff --git a/DownKyi/Views/Dialogs/ViewAlertDialog.axaml b/DownKyi/Views/Dialogs/ViewAlertDialog.axaml index a6ec635..99a9529 100644 --- a/DownKyi/Views/Dialogs/ViewAlertDialog.axaml +++ b/DownKyi/Views/Dialogs/ViewAlertDialog.axaml @@ -4,7 +4,20 @@ xmlns:prism="http://prismlibrary.com/" prism:ViewModelLocator.AutoWireViewModel="True" xmlns:vmd="clr-namespace:DownKyi.ViewModels.Dialogs" - x:DataType="vmd:ViewAlertDialogViewModel"> + xmlns:prismExtension="clr-namespace:DownKyi.PrismExtension.Dialog" + x:DataType="vmd:ViewAlertDialogViewModel" + xmlns:i="using:Avalonia.Xaml.Interactivity" + xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"> + + + + + + + + + + @@ -18,7 +31,9 @@ Margin="10,0" VerticalAlignment="Center" Orientation="Horizontal"> - + diff --git a/DownKyi/Views/Dialogs/ViewDownloadSetter.axaml b/DownKyi/Views/Dialogs/ViewDownloadSetter.axaml index 295a8bb..6c6f280 100644 --- a/DownKyi/Views/Dialogs/ViewDownloadSetter.axaml +++ b/DownKyi/Views/Dialogs/ViewDownloadSetter.axaml @@ -1,10 +1,17 @@  + + + + + + + + diff --git a/DownKyi/Views/Dialogs/ViewParsingSelector.axaml b/DownKyi/Views/Dialogs/ViewParsingSelector.axaml index 8e22e35..b58f687 100644 --- a/DownKyi/Views/Dialogs/ViewParsingSelector.axaml +++ b/DownKyi/Views/Dialogs/ViewParsingSelector.axaml @@ -4,24 +4,45 @@ prism:ViewModelLocator.AutoWireViewModel="True" x:Class="DownKyi.Views.Dialogs.ViewParsingSelector" xmlns:vmd="clr-namespace:DownKyi.ViewModels.Dialogs" + xmlns:prismExtension="clr-namespace:DownKyi.PrismExtension.Dialog" x:DataType="vmd:ViewParsingSelectorViewModel"> - + + + - - + + + + +