Esempio n. 1
0
        private async void Added(DeviceWatcher sender, DeviceInformation deviceInformation)
        {
            if (await IsDeviceCompatible(deviceInformation.Id))
            {
                // Protect against race condition if the task runs after the app stopped the deviceWatcher.
                if (sender == _deviceWatcher)
                {
                    var args = new Events.DeviceAddedEventArgs()
                    {
                        Device = new Schema.WatcherDevice()
                        {
                            Id         = deviceInformation.Id,
                            IsDefault  = deviceInformation.IsDefault,
                            IsEnabled  = deviceInformation.IsEnabled,
                            Name       = deviceInformation.Name,
                            IsPaired   = deviceInformation.Pairing.IsPaired,
                            Kind       = deviceInformation.Kind.ToString(),
                            Properties = deviceInformation.Properties.ToDictionary(pair => pair.Key, pair => pair.Value)
                        }
                    };

                    OnDeviceAdded(args);
                }
            }
        }
Esempio n. 2
0
 protected virtual void OnDeviceAdded(Events.DeviceAddedEventArgs e)
 {
     DeviceAdded?.Invoke(this, e);
 }