65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using HandyControl.Tools.Extension;
|
|
using iNKORE.UI.WPF.Modern.Controls;
|
|
using PMSWPF.Message;
|
|
using PMSWPF.Models;
|
|
using PMSWPF.ViewModels.Dialogs;
|
|
using PMSWPF.Views.Dialogs;
|
|
|
|
namespace PMSWPF.Services;
|
|
|
|
public class DialogService :IDialogService
|
|
{
|
|
public DialogService()
|
|
{
|
|
|
|
}
|
|
|
|
public async Task<Device> ShowAddDeviceDialog()
|
|
{
|
|
var device = new Device();
|
|
var dialog = new DeviceDialog(device);
|
|
var res = await dialog.ShowAsync();
|
|
if (res == ContentDialogResult.Primary)
|
|
{
|
|
return device;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void ShowMessageDialog(string title, string message)
|
|
{
|
|
MessageBox.Show(message);
|
|
}
|
|
|
|
|
|
public void Receive(OpenDialogMessage message)
|
|
{
|
|
// DialogMessage response = new DialogMessage();
|
|
// Device device = new Device();
|
|
// if (message.Message! != null && message.Message.Request != null && message.Message.Request is Device)
|
|
// {
|
|
// device = message.Message.Request as Device;
|
|
// }
|
|
// else
|
|
// {
|
|
// var ddvm = new DeviceDialogViewModel(device)
|
|
// {
|
|
// Title = "添加设备"
|
|
// };
|
|
// var dialog = new DeviceDialog(ddvm);
|
|
// var res = dialog.ShowAsync().GetAwaiter().GetResult();
|
|
// if (res == ContentDialogResult.Primary)
|
|
// {
|
|
// response.IsConfirm = true;
|
|
// response.Response = device;
|
|
// }
|
|
// else
|
|
// {
|
|
// response.IsCancel = true;
|
|
// }
|
|
// }
|
|
// message.Reply(response);
|
|
}
|
|
} |