-
Notifications
You must be signed in to change notification settings - Fork 1
/
BluetoothDevicePicker.cs
31 lines (26 loc) · 983 Bytes
/
BluetoothDevicePicker.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
using RemoteController.Bluetooth;
using RemoteController.Win32;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace RemoteController
{
public sealed partial class BluetoothDevicePicker
{
public Task<BluetoothDeviceInfo> PickSingleDeviceAsync()
{
BluetoothDeviceInfo info = null;
BLUETOOTH_SELECT_DEVICE_PARAMS p = new BLUETOOTH_SELECT_DEVICE_PARAMS();
p.Reset();
p.SetClassOfDevices(ClassOfDevices.ToArray());
p.fForceAuthentication = RequireAuthentication;
p.hwndParent = NativeMethods.GetActiveWindow();
if (NativeMethods.BluetoothSelectDevices(ref p))
{
info = new BluetoothDeviceInfo(p.Device);
}
return Task.FromResult(info);
}
public List<ClassOfDevice> ClassOfDevices { get; } = new List<ClassOfDevice>();
public bool RequireAuthentication { get; set; }
}
}