2025-06-12 13:15:55 +08:00
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2025-06-12 18:41:46 +08:00
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2025-07-26 10:05:43 +08:00
|
|
|
|
using DMS.WPF.ViewModels.Items;
|
2025-07-27 21:08:58 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2025-06-12 13:15:55 +08:00
|
|
|
|
|
2025-07-19 09:25:01 +08:00
|
|
|
|
namespace DMS.WPF.ViewModels.Dialogs;
|
2025-06-12 13:15:55 +08:00
|
|
|
|
|
2025-07-27 21:08:58 +08:00
|
|
|
|
public partial class DeviceDialogViewModel : DialogViewModelBase<DeviceItemViewModel>
|
2025-06-12 13:15:55 +08:00
|
|
|
|
{
|
2025-07-29 20:02:09 +08:00
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
private bool _isAddMode;
|
2025-07-27 21:08:58 +08:00
|
|
|
|
|
2025-06-26 19:36:27 +08:00
|
|
|
|
[ObservableProperty]
|
2025-07-26 10:05:43 +08:00
|
|
|
|
private DeviceItemViewModel _device;
|
2025-06-20 18:53:29 +08:00
|
|
|
|
|
2025-07-29 20:02:09 +08:00
|
|
|
|
public DeviceDialogViewModel(DeviceItemViewModel device=null)
|
2025-06-12 18:41:46 +08:00
|
|
|
|
{
|
2025-07-29 20:02:09 +08:00
|
|
|
|
if (device==null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_device = new DeviceItemViewModel();
|
|
|
|
|
|
IsAddMode=true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_device=device;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-12 18:41:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[RelayCommand]
|
2025-07-27 21:08:58 +08:00
|
|
|
|
private async Task Save()
|
2025-06-12 13:15:55 +08:00
|
|
|
|
{
|
2025-07-27 21:08:58 +08:00
|
|
|
|
// Here you can add validation logic before closing.
|
|
|
|
|
|
await Close(Device);
|
|
|
|
|
|
}
|
2025-06-26 19:36:27 +08:00
|
|
|
|
|
2025-07-27 21:08:58 +08:00
|
|
|
|
[RelayCommand]
|
|
|
|
|
|
private async Task Cancel()
|
|
|
|
|
|
{
|
|
|
|
|
|
await Close(null);
|
2025-06-12 13:15:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|