-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeviceWrapper.cs
46 lines (41 loc) · 1.21 KB
/
DeviceWrapper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using CSCore.CoreAudioAPI;
using System;
using System.Windows.Forms;
namespace VoiceMod
{
public class DeviceWrapper
{
public MMDevice Device { get; private set; }
public DeviceWrapper(MMDevice device)
{
this.Device = device;
}
public override string ToString()
{
return Device.FriendlyName;
}
public static void AudioDevicesUpdate(MMDeviceCollection devices, ComboBox comboBox, MMDevice selectedDevice)
{
if (devices == null)
{
throw new ArgumentNullException("devices");
}
if (comboBox == null)
{
throw new ArgumentNullException("comboBox");
}
comboBox.BeginUpdate();
comboBox.Items.Clear();
foreach (var device in devices)
{
var wrapper = new DeviceWrapper(device);
comboBox.Items.Add(wrapper);
if (selectedDevice != null && device.DeviceID == selectedDevice.DeviceID)
{
comboBox.SelectedItem = wrapper;
}
}
comboBox.EndUpdate();
}
}
}