| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Services.Dialogs;
- using System;
- using TeamAAS_VP.Core.Lights;
- using TeamAAS_VP.Models.Lights;
- using TeamAAS_VP.Resources.Languages;
- namespace TeamAAS_VP.ViewModels.Setting
- {
- public class AddLightControllerViewModel : BindableBase, IDialogAware
- {
- private LightControllerConfig _LightController;
- public LightControllerConfig LightController
- {
- get => _LightController; set => SetProperty(ref _LightController, value);
- }
- private DelegateCommand _ConfirmCommand;
- public DelegateCommand ConfirmCommand => _ConfirmCommand ?? (_ConfirmCommand = new DelegateCommand(ExecuteConfirmCommand, CanExecuteConfirmCommand).ObservesProperty(() => LightController.Name));
- private DelegateCommand _CancelCommand;
- public DelegateCommand CancelCommand => _CancelCommand ?? (_CancelCommand = new DelegateCommand(ExecuteCancelCommand));
- public AddLightControllerViewModel()
- {
- }
- public string Title { get; set; } = "Ìí¼Ó¹âÔ´¿ØÖÆÆ÷";
- public event Action<IDialogResult> RequestClose;
- public bool CanCloseDialog() => true;
- public void OnDialogClosed() { }
- public void OnDialogOpened(IDialogParameters parameters)
- {
- LightController = new LightControllerConfig() { Id = 0, Name = "New Controller", LightModel = TeamAAS_VP.Core.Lights.LightModel.KCS_KDC_12V60W_4T };
- }
- bool CanExecuteConfirmCommand()
- {
- return LightController != null && !string.IsNullOrEmpty(LightController.Name);
- }
- void ExecuteConfirmCommand()
- {
- var p = new DialogParameters();
- LightController.Init();
- p.Add("LightController", LightController);
- RequestClose?.Invoke(new DialogResult(ButtonResult.OK, p));
- }
- void ExecuteCancelCommand()
- {
- RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
- }
- }
- }
|