diff --git a/DownKyi/DownKyi.csproj b/DownKyi/DownKyi.csproj
index 2cf609b..f59c457 100644
--- a/DownKyi/DownKyi.csproj
+++ b/DownKyi/DownKyi.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/DownKyi/Services/AlertService.cs b/DownKyi/Services/AlertService.cs
index 69f9d43..ae9f564 100644
--- a/DownKyi/Services/AlertService.cs
+++ b/DownKyi/Services/AlertService.cs
@@ -1,4 +1,5 @@
-using DownKyi.Images;
+using System.Threading.Tasks;
+using DownKyi.Images;
using DownKyi.Utils;
using DownKyi.ViewModels.Dialogs;
using Prism.Services.Dialogs;
@@ -20,11 +21,11 @@ public class AlertService
///
///
///
- public ButtonResult ShowInfo(string message, int buttonNumber = 2)
+ public async Task ShowInfo(string message, int buttonNumber = 2)
{
VectorImage image = SystemIcon.Instance().Info;
string title = DictionaryResource.GetString("Info");
- return ShowMessage(image, title, message, buttonNumber);
+ return await ShowMessage(image, title, message, buttonNumber);
}
///
@@ -33,11 +34,11 @@ public class AlertService
///
///
///
- public ButtonResult ShowWarning(string message, int buttonNumber = 1)
+ public async Task ShowWarning(string message, int buttonNumber = 1)
{
VectorImage image = SystemIcon.Instance().Warning;
string title = DictionaryResource.GetString("Warning");
- return ShowMessage(image, title, message, buttonNumber);
+ return await ShowMessage(image, title, message, buttonNumber);
}
///
@@ -45,30 +46,43 @@ public class AlertService
///
///
///
- public ButtonResult ShowError(string message)
+ public async Task ShowError(string message)
{
VectorImage image = SystemIcon.Instance().Error;
string title = DictionaryResource.GetString("Error");
- return ShowMessage(image, title, message, 1);
+ return await ShowMessage(image, title, message, 1);
}
- public ButtonResult ShowMessage(VectorImage image, string type, string message, int buttonNumber)
+ public async Task ShowMessage(VectorImage image, string type, string message, int buttonNumber)
{
- ButtonResult result = ButtonResult.None;
+ var result = ButtonResult.None;
if (dialogService == null)
{
return result;
}
- DialogParameters param = new DialogParameters
+ var param = new DialogParameters
{
{ "image", image },
{ "title", type },
{ "message", message },
{ "button_number", buttonNumber }
};
+
+ var isEnd = false;
dialogService.ShowDialog(ViewAlertDialogViewModel.Tag, param,
- buttonResult => { result = buttonResult.Result; });
+ buttonResult =>
+ {
+ result = buttonResult.Result;
+ isEnd = true;
+ });
+ await Task.Run(() =>
+ {
+ while (true)
+ {
+ if (isEnd) break;
+ }
+ });
return result;
}
}
\ No newline at end of file
diff --git a/DownKyi/Services/Download/DownloadService.cs b/DownKyi/Services/Download/DownloadService.cs
index 2807126..ad8c33b 100644
--- a/DownKyi/Services/Download/DownloadService.cs
+++ b/DownKyi/Services/Download/DownloadService.cs
@@ -487,7 +487,7 @@ public abstract class DownloadService
AlertService alertService = new AlertService(dialogService);
ButtonResult result =
- alertService.ShowError($"{path}{DictionaryResource.GetString("DirectoryError")}");
+ await alertService.ShowError($"{path}{DictionaryResource.GetString("DirectoryError")}");
return;
}
diff --git a/DownKyi/ViewModels/Dialogs/BaseDialogViewModel.cs b/DownKyi/ViewModels/Dialogs/BaseDialogViewModel.cs
index 28d3135..5ba2d8d 100644
--- a/DownKyi/ViewModels/Dialogs/BaseDialogViewModel.cs
+++ b/DownKyi/ViewModels/Dialogs/BaseDialogViewModel.cs
@@ -1,5 +1,6 @@
using System;
using DownKyi.Images;
+using DownKyi.Models;
using DownKyi.Utils;
using Prism.Commands;
using Prism.Mvvm;
@@ -15,16 +16,16 @@ public class BaseDialogViewModel : BindableBase, IDialogAware
public string Title
{
- get { return title; }
- set { SetProperty(ref title, value); }
+ get => title;
+ set => SetProperty(ref title, value);
}
private VectorImage closeIcon;
public VectorImage CloseIcon
{
- get { return closeIcon; }
- set { SetProperty(ref closeIcon, value); }
+ get => closeIcon;
+ set => SetProperty(ref closeIcon, value);
}
#endregion
@@ -33,14 +34,14 @@ public class BaseDialogViewModel : BindableBase, IDialogAware
{
#region 属性初始化
- // Title = new AppInfo().Name;
- // CloseIcon = new VectorImage
- // {
- // Height = SystemIcon.Instance().Close.Height,
- // Width = SystemIcon.Instance().Close.Width,
- // Data = SystemIcon.Instance().Close.Data,
- // Fill = SystemIcon.Instance().Close.Fill
- // };
+ Title = new AppInfo().Name;
+ CloseIcon = new VectorImage
+ {
+ Height = SystemIcon.Instance().Close.Height,
+ Width = SystemIcon.Instance().Close.Width,
+ Data = SystemIcon.Instance().Close.Data,
+ Fill = SystemIcon.Instance().Close.Fill
+ };
#endregion
}
diff --git a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
index cc5324d..3304e5a 100644
--- a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
+++ b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
@@ -160,10 +160,10 @@ namespace DownKyi.ViewModels.DownloadManager
///
/// 删除事件
///
- private void ExecuteRemoveVideoCommand()
+ private async void ExecuteRemoveVideoCommand()
{
AlertService alertService = new AlertService(DialogService);
- ButtonResult result = alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"), 2);
+ ButtonResult result = await alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"), 2);
if (result != ButtonResult.OK)
{
return;
diff --git a/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs b/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs
index 90c8a21..379ed01 100644
--- a/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs
+++ b/DownKyi/ViewModels/DownloadManager/ViewDownloadFinishedViewModel.cs
@@ -111,7 +111,7 @@ namespace DownKyi.ViewModels.DownloadManager
private async void ExecuteClearAllDownloadedCommand()
{
AlertService alertService = new AlertService(dialogService);
- ButtonResult result = alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"));
+ ButtonResult result = await alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"));
if (result != ButtonResult.OK)
{
return;
diff --git a/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs b/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs
index 15b1b65..3f08cc2 100644
--- a/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs
+++ b/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs
@@ -440,7 +440,7 @@ public class ViewNetworkViewModel : ViewModelBase
/// 下载器选择事件
///
///
- private void ExecuteSelectDownloaderCommand(string parameter)
+ private async void ExecuteSelectDownloaderCommand(string parameter)
{
Downloader downloader;
switch (parameter)
@@ -463,7 +463,7 @@ public class ViewNetworkViewModel : ViewModelBase
PublishTip(isSucceed);
AlertService alertService = new AlertService(dialogService);
- ButtonResult result = alertService.ShowInfo(DictionaryResource.GetString("ConfirmReboot"));
+ ButtonResult result = await alertService.ShowInfo(DictionaryResource.GetString("ConfirmReboot"));
if (result == ButtonResult.OK)
{
(App.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).Shutdown(0);