Пример #1
0
 public void OnUpdateConnectedDevices(object sender, UpdateConnectedDevicesEventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         if (e.Add != null && !this.connectedDevices.Contains(e.Add))
         {
             this.connectedDevices.Add(e.Add);
         }
         if (e.Remove != null && this.connectedDevices.Contains(e.Remove))
         {
             this.connectedDevices.Remove(e.Remove);
         }
     });
 }
        protected virtual void UpdateConnectedDevices(string deviceAddress, bool add)
        {
            UpdateConnectedDevicesEventArgs args = new UpdateConnectedDevicesEventArgs();

            if (add)
            {
                args.Add = deviceAddress;
                this.ConnectedDevices.Add(deviceAddress);
            }
            else
            {
                args.Remove = deviceAddress;
                this.ConnectedDevices.Remove(deviceAddress);
            }
            UpdateConnectedDevicesEventHandler?.Invoke(this, args);
        }