private void InitDeviceList() { SelectedDevInfo selectedDevInfo = _nemo.GetSelectedDevInfo(); _deviceInfoList.Clear(); foreach (var item in _nemo.GetCameraDevices()) { SettingsDeviceInfo info = new SettingsDeviceInfo(); info.NemoDevInfoConverter(item, MediaDeviceType.Camera, 0 == string.CompareOrdinal(selectedDevInfo.CameraDevId, item.devId), 0 == string.CompareOrdinal(selectedDevInfo.SecondCameraDevId, item.devId)); SettingsDeviceListItemInfo itemDev = new SettingsDeviceListItemInfo(info); _deviceInfoList.Add(itemDev); } InitCameraDeviceList(_deviceInfoList); ThreadPool.QueueUserWorkItem(delegate { SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Application.Current.Dispatcher)); SynchronizationContext.Current.Post(pl => { PopMessage = "正在加载设备列表,轻稍后"; PopVisibility = Visibility.Visible; InitMicrophoneDeviceList(_nemo.GetMicrophoneDevices(), selectedDevInfo.MicrophoneDevId); InitSpeakerDeviceList(_nemo.GetSpeakerDevices(), selectedDevInfo.SpeakerDevId); PopVisibility = Visibility.Collapsed; }, null); }); }
private void OnGaopaiCheckBoxClick(ExCommandParameter e) { string currentDeviceID = e.Parameter as string; SettingsDeviceListItemInfo device = DeviceCameraList.FirstOrDefault(x => x.DevId != currentDeviceID && x.IsChecked && x.DevType == MediaDeviceType.SubCamera); if (device != null) { device.IsChecked = false; } }
private void OnCameraCheckBoxClick(ExCommandParameter e) { //Click事件在Checked&UnChecked之后触发 string currentDeviceID = e.Parameter as string; if (DeviceCameraList.Where(x => x.DevType == MediaDeviceType.Camera && x.IsChecked).Count() < 1) { SetPopMessage("摄像头必须保持一个为开启状态!"); DeviceCameraList.FirstOrDefault(x => x.DevId == currentDeviceID).IsChecked = true; return; } else { SettingsDeviceListItemInfo device = DeviceCameraList.FirstOrDefault(x => x.DevId != currentDeviceID && x.IsChecked && x.DevType == MediaDeviceType.Camera); if (device != null) { device.IsChecked = false; } } }
private void OnMicrophoneCheckBoxClick(ExCommandParameter e) { string currentDeviceID = e.Parameter as string; CheckBox sender = e.Sender as CheckBox; if (DeviceMicrophoneList.Where(x => x.IsChecked == true).Count() < 1) { SetPopMessage("麦克风至少保持一个为开启状态!"); DeviceMicrophoneList.FirstOrDefault(x => x.DevId == currentDeviceID).IsChecked = true; return; } else { SettingsDeviceListItemInfo device = DeviceMicrophoneList.FirstOrDefault(x => x.DevId != currentDeviceID && x.IsChecked); if (device != null) { device.IsChecked = false; } } }
private void OnSpeakerCheckBoxClick(ExCommandParameter e) { string currentDeviceID = e.Parameter as string; CheckBox sender = e.Sender as CheckBox; //扬声器只能开一个,也可以全关,只用UAS-1000时,默认全关 if (DeviceSpeakerList.Where(x => x.IsChecked == true).Count() < 1) { //SetPopMessage("扬声器必须且只能保持一个为开启状态!"); //DeviceSpeakerList.FirstOrDefault(x => x.DevId == currentDeviceID).IsChecked = true; //return; } else { SettingsDeviceListItemInfo device = DeviceSpeakerList.FirstOrDefault(x => x.DevId != currentDeviceID && x.IsChecked); if (device != null) { device.IsChecked = false; } } }
/// <summary> /// 初始化麦克风设备列表 /// </summary> /// <param name="devInfos"></param> /// <param name="selectedDevId"></param> private void InitMicrophoneDeviceList(SDKMediaDevInfo[] devInfos, string selectedDevId) { if (0 >= devInfos.Length) { return; } foreach (SDKMediaDevInfo devInfo in devInfos) { SettingsDeviceInfo info = new SettingsDeviceInfo(); if (0 == string.CompareOrdinal(selectedDevId, devInfo.devId)) { info.NemoDevInfoConverter(devInfo, MediaDeviceType.Microphone, true); } else { info.NemoDevInfoConverter(devInfo, MediaDeviceType.Microphone, false); } SettingsDeviceListItemInfo itemDev = new SettingsDeviceListItemInfo(info); DeviceMicrophoneList.Add(itemDev); } DeviceMicrophoneList = new ObservableCollection <SettingsDeviceListItemInfo>(DeviceMicrophoneList.OrderBy(x => x.DevName).ToList()); }