From 0f2e51fe96cf6a409430bff48b1244933ffe4076 Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Sat, 18 Feb 2023 13:16:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=B9=E5=87=BA=E6=A1=86?= =?UTF-8?q?=E7=9A=84UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi/Services/AlertService.cs | 14 ++++++----- .../Services/Download/AriaDownloadService.cs | 3 ++- .../Dialogs/ViewAlertDialogViewModel.cs | 22 ++++++++++------- DownKyi/Views/Dialogs/ViewAlertDialog.xaml | 24 +++++++++++-------- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/DownKyi/Services/AlertService.cs b/DownKyi/Services/AlertService.cs index 5302459..4b46ecf 100644 --- a/DownKyi/Services/AlertService.cs +++ b/DownKyi/Services/AlertService.cs @@ -18,12 +18,13 @@ namespace DownKyi.Services /// 显示一个信息弹窗 /// /// + /// /// - public ButtonResult ShowInfo(string message) + public ButtonResult ShowInfo(string message, int buttonNumber = 2) { VectorImage image = SystemIcon.Instance().Info; string title = DictionaryResource.GetString("Info"); - return ShowMessage(image, title, message); + return ShowMessage(image, title, message, buttonNumber); } /// @@ -35,7 +36,7 @@ namespace DownKyi.Services { VectorImage image = SystemIcon.Instance().Warning; string title = DictionaryResource.GetString("Warning"); - return ShowMessage(image, title, message); + return ShowMessage(image, title, message, 1); } /// @@ -47,10 +48,10 @@ namespace DownKyi.Services { VectorImage image = SystemIcon.Instance().Error; string title = DictionaryResource.GetString("Error"); - return ShowMessage(image, title, message); + return ShowMessage(image, title, message, 1); } - public ButtonResult ShowMessage(VectorImage image, string type, string message) + public ButtonResult ShowMessage(VectorImage image, string type, string message, int buttonNumber) { ButtonResult result = ButtonResult.None; if (dialogService == null) @@ -62,7 +63,8 @@ namespace DownKyi.Services { { "image", image }, { "title", type }, - { "message", message } + { "message", message }, + { "button_number", buttonNumber } }; dialogService.ShowDialog(ViewAlertDialogViewModel.Tag, param, buttonResult => { diff --git a/DownKyi/Services/Download/AriaDownloadService.cs b/DownKyi/Services/Download/AriaDownloadService.cs index 3847787..460ae98 100644 --- a/DownKyi/Services/Download/AriaDownloadService.cs +++ b/DownKyi/Services/Download/AriaDownloadService.cs @@ -347,7 +347,8 @@ namespace DownKyi.Services.Download AlertService alertService = new AlertService(dialogService); ButtonResult result = alertService.ShowMessage(SystemIcon.Instance().Error, $"Aria2 {DictionaryResource.GetString("Error")}", - errorMessage); + errorMessage, + 1); return; } diff --git a/DownKyi/ViewModels/Dialogs/ViewAlertDialogViewModel.cs b/DownKyi/ViewModels/Dialogs/ViewAlertDialogViewModel.cs index 4bd897f..02ba1ee 100644 --- a/DownKyi/ViewModels/Dialogs/ViewAlertDialogViewModel.cs +++ b/DownKyi/ViewModels/Dialogs/ViewAlertDialogViewModel.cs @@ -73,16 +73,22 @@ namespace DownKyi.ViewModels.Dialogs Image = parameters.GetValue("image"); Title = parameters.GetValue("title"); Message = parameters.GetValue("message"); + int number = parameters.GetValue("button_number"); - if (Image == SystemIcon.Instance().Error) + switch (number) { - AloneButton = Visibility.Visible; - TwoButton = Visibility.Collapsed; - } - else - { - AloneButton = Visibility.Collapsed; - TwoButton = Visibility.Visible; + case 1: + AloneButton = Visibility.Visible; + TwoButton = Visibility.Collapsed; + break; + case 2: + AloneButton = Visibility.Collapsed; + TwoButton = Visibility.Visible; + break; + default: + AloneButton = Visibility.Collapsed; + TwoButton = Visibility.Visible; + break; } } diff --git a/DownKyi/Views/Dialogs/ViewAlertDialog.xaml b/DownKyi/Views/Dialogs/ViewAlertDialog.xaml index becee3e..17eb4b3 100644 --- a/DownKyi/Views/Dialogs/ViewAlertDialog.xaml +++ b/DownKyi/Views/Dialogs/ViewAlertDialog.xaml @@ -90,24 +90,28 @@ - + - + Padding="15,0" + VerticalScrollBarVisibility="Auto"> + +