private void CreateDeviceList() { int hr; int selectedIndex = -1; if (0 < listBoxDevices.Items.Count) { selectedIndex = listBoxDevices.SelectedIndex; } listBoxDevices.Items.Clear(); hr = wasapi.DoDeviceEnumeration(WasapiCS.DeviceType.Rec); textBoxLog.Text += string.Format("wasapi.DoDeviceEnumeration(Rec) {0:X8}\r\n", hr); int nDevices = wasapi.GetDeviceCount(); for (int i = 0; i < nDevices; ++i) { listBoxDevices.Items.Add(wasapi.GetDeviceName(i)); } buttonDeviceSelect.IsEnabled = true; buttonDeselect.IsEnabled = false; buttonRec.IsEnabled = false; buttonStop.IsEnabled = false; groupBoxWasapiSettings.IsEnabled = true; buttonInspectDevice.IsEnabled = false; if (0 < nDevices) { if (0 <= selectedIndex && selectedIndex < listBoxDevices.Items.Count) { listBoxDevices.SelectedIndex = selectedIndex; } else { listBoxDevices.SelectedIndex = 0; } if (mWavData != null) { buttonDeviceSelect.IsEnabled = true; } buttonInspectDevice.IsEnabled = true; } }