/// <summary> /// Remove a device from the Set. /// </summary> /// <param name="device"></param> /// <returns> /// true if the element is successfully found and removed; otherwise, false. This method returns false if /// <paramref name="deviceName" /> is not found in the <see cref="T:System.Collections.Generic.HashSet`1" /> object. /// </returns> public bool UnselectDevice(IAudioDevice device) { var result = false; DeviceListChanged eventChanged = null; switch (device.Type) { case AudioDeviceType.Playback: result = SelectedPlaybackDevicesList.Remove(device.FriendlyName); eventChanged = new DeviceListChanged(SelectedPlaybackDevicesList, device.Type); break; case AudioDeviceType.Recording: result = SelectedRecordingDevicesList.Remove(device.FriendlyName); eventChanged = new DeviceListChanged(SelectedRecordingDevicesList, device.Type); break; default: throw new ArgumentOutOfRangeException(); } if (result) { SelectedDeviceChanged?.Invoke(this, eventChanged); AppConfigs.Configuration.Save(); } return(result); }
private void MigrateSelectedDeviceLists() { using (AppLogger.Log.InfoCall()) { if (AppConfigs.Configuration.MigratedSelectedDeviceLists) { AppLogger.Log.Info("Already migrated the device lists"); return; } var audioDeviceLister = new AudioDeviceLister(DeviceState.All); using (AppLogger.Log.InfoCall()) { if (AppConfigs.Configuration.SelectedRecordingDeviceList != null) { foreach (var audioDevice in audioDeviceLister.GetRecordingDevices() .Join(AppConfigs.Configuration.SelectedRecordingDeviceList, a => a.FriendlyName, selected => selected, (a, selected) => a)) { SelectedRecordingDevicesList.Add(audioDevice.Id); AppLogger.Log.Info("Migrating Device: ", audioDevice); } } } using (AppLogger.Log.InfoCall()) { if (AppConfigs.Configuration.SelectedPlaybackDeviceList != null) { foreach (var audioDevice in audioDeviceLister.GetPlaybackDevices() .Join(AppConfigs.Configuration.SelectedPlaybackDeviceList, a => a.FriendlyName, selected => selected, (a, selected) => a)) { SelectedPlaybackDevicesList.Add(audioDevice.Id); AppLogger.Log.Info("Migrating Device: ", audioDevice); } } } AppConfigs.Configuration.MigratedSelectedDeviceLists = true; AppConfigs.Configuration.SelectedPlaybackDeviceList = null; AppConfigs.Configuration.SelectedRecordingDeviceList = null; AppConfigs.Configuration.Save(); } }