添加了处理中的对话框
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using HandyControl.Tools.Extension;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using PMSWPF.Models;
|
||||
using PMSWPF.ViewModels.Dialogs;
|
||||
@@ -119,4 +120,14 @@ public class DialogService :IDialogService
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ContentDialog ShowProcessingDialog(string title, string message)
|
||||
{
|
||||
ProcessingDialogViewModel vm = new ProcessingDialogViewModel();
|
||||
vm.Title = title;
|
||||
vm.Message = message;
|
||||
var dialog = new ProcessingDialog(vm);
|
||||
_ = dialog.ShowAsync(); // 不await,让它在后台显示
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using PMSWPF.Models;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using PMSWPF.Models;
|
||||
|
||||
namespace PMSWPF.Services;
|
||||
|
||||
@@ -16,4 +17,5 @@ public interface IDialogService
|
||||
void ShowMessageDialog(string title, string message);
|
||||
Task<VariableData> ShowEditVarDataDialog(VariableData variableData);
|
||||
Task<string> ShowImportExcelDialog();
|
||||
ContentDialog ShowProcessingDialog(string title, string message);
|
||||
}
|
||||
9
ViewModels/Dialogs/ProcessingDialogViewModel.cs
Normal file
9
ViewModels/Dialogs/ProcessingDialogViewModel.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace PMSWPF.ViewModels.Dialogs;
|
||||
|
||||
public partial class ProcessingDialogViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private string _title;
|
||||
[ObservableProperty] private string _message;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using PMSWPF.Data.Repositories;
|
||||
@@ -142,6 +143,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
[RelayCommand]
|
||||
private async void ImprotFromTiaVarTable()
|
||||
{
|
||||
ContentDialog processingDialog = null;
|
||||
try
|
||||
{
|
||||
// 让用户选择导入的Excel文件
|
||||
@@ -152,6 +154,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
var importVarDataList = ExcelHelper.ImprotFromTiaVariableTable(filePath);
|
||||
if (importVarDataList.Count == 0)
|
||||
return;
|
||||
processingDialog= _dialogService.ShowProcessingDialog("正在处理...", "正在导入变量,请稍等片刻....");
|
||||
|
||||
foreach (var variableData in importVarDataList)
|
||||
{
|
||||
@@ -167,7 +170,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
variableTable.DataVariables.Add(variableData);
|
||||
}
|
||||
DataVariables=new ObservableCollection<VariableData>(resVarDataList);
|
||||
|
||||
processingDialog?.Hide();
|
||||
string msgSuccess = $"成功导入变量:{resVarDataList.Count}个。";
|
||||
Logger.Info(msgSuccess);
|
||||
NotificationHelper.ShowMessage(msgSuccess, NotificationType.Success);
|
||||
|
||||
34
Views/Dialogs/ProcessingDialog.xaml
Normal file
34
Views/Dialogs/ProcessingDialog.xaml
Normal file
@@ -0,0 +1,34 @@
|
||||
<ui:ContentDialog x:Class="PMSWPF.Views.Dialogs.ProcessingDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:vmd="clr-namespace:PMSWPF.ViewModels.Dialogs"
|
||||
Title="{Binding Title}"
|
||||
Background="#fff"
|
||||
d:DataContext="{d:DesignInstance vmd:ProcessingDialogViewModel}"
|
||||
mc:Ignorable="d">
|
||||
<Grid Width="360"
|
||||
Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="0,0,0,20"
|
||||
FontSize="14"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding Message}"
|
||||
HorizontalAlignment="Center" />
|
||||
|
||||
<ui:ProgressRing Grid.Row="1"
|
||||
IsActive="True"
|
||||
Width="50"
|
||||
Height="50"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</ui:ContentDialog>
|
||||
13
Views/Dialogs/ProcessingDialog.xaml.cs
Normal file
13
Views/Dialogs/ProcessingDialog.xaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using PMSWPF.ViewModels.Dialogs;
|
||||
|
||||
namespace PMSWPF.Views.Dialogs;
|
||||
|
||||
public partial class ProcessingDialog : ContentDialog
|
||||
{
|
||||
public ProcessingDialog(ProcessingDialogViewModel viewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = viewModel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user