2025-07-01 21:34:20 +08:00
|
|
|
|
using iNKORE.UI.WPF.Modern.Controls;
|
2025-06-12 18:56:25 +08:00
|
|
|
|
using PMSWPF.Models;
|
2025-06-12 13:15:55 +08:00
|
|
|
|
using PMSWPF.ViewModels.Dialogs;
|
|
|
|
|
|
using PMSWPF.Views.Dialogs;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PMSWPF.Services;
|
|
|
|
|
|
|
2025-06-26 19:36:27 +08:00
|
|
|
|
public class DialogService :IDialogService
|
2025-06-12 13:15:55 +08:00
|
|
|
|
{
|
2025-06-25 22:33:57 +08:00
|
|
|
|
public DialogService()
|
|
|
|
|
|
{
|
2025-06-26 19:36:27 +08:00
|
|
|
|
|
2025-06-25 22:33:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-12 18:56:25 +08:00
|
|
|
|
public async Task<Device> ShowAddDeviceDialog()
|
2025-06-12 13:15:55 +08:00
|
|
|
|
{
|
2025-06-23 17:01:06 +08:00
|
|
|
|
var device = new Device();
|
2025-07-01 21:34:20 +08:00
|
|
|
|
DeviceDialogViewModel vm = new DeviceDialogViewModel(device);
|
|
|
|
|
|
vm.Title = "添加设备";
|
|
|
|
|
|
vm.PrimaryButContent = "添加设备";
|
|
|
|
|
|
return await ShowConentDialog(vm,device);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static async Task<Device> ShowConentDialog(DeviceDialogViewModel viewModel,Device device)
|
|
|
|
|
|
{
|
|
|
|
|
|
var dialog = new DeviceDialog(viewModel);
|
2025-06-23 17:01:06 +08:00
|
|
|
|
var res = await dialog.ShowAsync();
|
2025-06-26 19:36:27 +08:00
|
|
|
|
if (res == ContentDialogResult.Primary)
|
|
|
|
|
|
{
|
|
|
|
|
|
return device;
|
|
|
|
|
|
}
|
2025-06-23 17:01:06 +08:00
|
|
|
|
return null;
|
2025-06-12 13:15:55 +08:00
|
|
|
|
}
|
2025-06-13 18:54:17 +08:00
|
|
|
|
|
2025-07-01 21:34:20 +08:00
|
|
|
|
public async Task<Device> ShowEditDeviceDialog(Device device)
|
|
|
|
|
|
{
|
|
|
|
|
|
DeviceDialogViewModel vm = new DeviceDialogViewModel(device);
|
|
|
|
|
|
vm.Title = "编辑设备";
|
|
|
|
|
|
vm.PrimaryButContent = "编辑设备";
|
|
|
|
|
|
return await ShowConentDialog(vm,device);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<bool> ShowConfrimeDialog(string title, string message,string buttonText="确认")
|
|
|
|
|
|
{
|
|
|
|
|
|
ConfrimDialogViewModel vm = new ConfrimDialogViewModel();
|
|
|
|
|
|
vm.Title = title;
|
|
|
|
|
|
vm.Message = message;
|
|
|
|
|
|
vm.PrimaryButtonText = buttonText;
|
|
|
|
|
|
var dialog = new ConfirmDialog(vm);
|
|
|
|
|
|
var res = await dialog.ShowAsync();
|
|
|
|
|
|
if (res == ContentDialogResult.Primary)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-13 18:54:17 +08:00
|
|
|
|
public void ShowMessageDialog(string title, string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(message);
|
|
|
|
|
|
}
|
2025-06-25 22:33:57 +08:00
|
|
|
|
|
2025-06-12 13:15:55 +08:00
|
|
|
|
}
|