using MvCamCtrl.NET; using Prism.Commands; using Prism.Mvvm; using Prism.Services.Dialogs; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using TeamAAS_VP.Enums; using TeamAAS_VP.Models; using TeamAAS_VP.Resources.Languages; namespace TeamAAS_VP.ViewModels.Setting { public class SelectCameraBrandViewModel : BindableBase, IDialogAware { private CameraBrand _CameraBrand; /// /// 相机品牌 /// public CameraBrand CameraBrand { get { return _CameraBrand; } set { SetProperty(ref _CameraBrand, value); } } private DelegateCommand _ConfirmCommand; public DelegateCommand ConfirmCommand => _ConfirmCommand ?? (_ConfirmCommand = new DelegateCommand(ExecuteConfirmCommand)); void ExecuteConfirmCommand() { IDialogParameters parameters = new DialogParameters(); parameters.Add("CameraBrand", CameraBrand); RequestClose?.Invoke(new DialogResult(ButtonResult.OK, parameters)); } private DelegateCommand _CancelCommand; public DelegateCommand CancelCommand => _CancelCommand ?? (_CancelCommand = new DelegateCommand(ExecuteCancelCommand)); void ExecuteCancelCommand() { IDialogParameters parameters = new DialogParameters(); parameters.Add("CameraBrand", CameraBrand); RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel, parameters)); } public SelectCameraBrandViewModel() { } public string Title { get; set; } = "Select Camera Brand"; public event Action RequestClose; public bool CanCloseDialog() { return true; } public void OnDialogClosed() { } public void OnDialogOpened(IDialogParameters parameters) { Title = Lang.添加相机; if (parameters.TryGetValue("CameraBrand",out CameraBrand brand)) { CameraBrand = brand; } else { CameraBrand = CameraBrand.HikRobot_MVS; } } } }