12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System.ComponentModel;
- using Windows.Devices.Enumeration;
- namespace BluetoothLENet.Classes
- {
- /// <summary>
- /// Display class used to represent a BluetoothLEDevice in the Device list
- /// </summary>
- public class BluetoothLEDeviceDisplay : INotifyPropertyChanged
- {
- public BluetoothLEDeviceDisplay(DeviceInformation deviceInfoIn)
- {
- DeviceInformation = deviceInfoIn;
- }
- public DeviceInformation DeviceInformation { get; private set; }
- public string Id => DeviceInformation.Id;
- public string Name => DeviceInformation.Name;
- public bool IsPaired => DeviceInformation.Pairing.IsPaired;
- public bool IsConnected => (bool?)DeviceInformation.Properties["System.Devices.Aep.IsConnected"] == true;
- public bool IsConnectable => (bool?)DeviceInformation.Properties["System.Devices.Aep.Bluetooth.Le.IsConnectable"] == true;
- public IReadOnlyDictionary<string, object> Properties => DeviceInformation.Properties;
- public event PropertyChangedEventHandler PropertyChanged;
- public void Update(DeviceInformationUpdate deviceInfoUpdate)
- {
- DeviceInformation.Update(deviceInfoUpdate);
- OnPropertyChanged("Id");
- OnPropertyChanged("Name");
- OnPropertyChanged("DeviceInformation");
- OnPropertyChanged("IsPaired");
- OnPropertyChanged("IsConnected");
- OnPropertyChanged("Properties");
- OnPropertyChanged("IsConnectable");
- }
- protected void OnPropertyChanged(string name)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
- }
- }
- }
|