private void OnDevicesChanged(DeviceList removed, DeviceList added) { try { foreach (var d in added) { Debug.LogFormat("{0} {1}", d.Info[CameraInfo.Name], d.Info[CameraInfo.SerialNumber]); } m_removed.Clear(); foreach (var d in m_added) { if (removed.Contains(d)) { m_removed.Add(d); } } m_added.Clear(); m_added.AddRange(added); e.Set(); } catch (Exception e) { Debug.LogException(e); } }
private void UpdateDeviceList() { List <ObservableBluetoothLEDevice> toRemove = new List <ObservableBluetoothLEDevice>(); lock (deviceListLock) { foreach (ObservableBluetoothLEDevice dev in DeviceList) { if (ShouldShow(dev) == false) { toRemove.Add(dev); } } foreach (ObservableBluetoothLEDevice dev in toRemove) { DeviceList.Remove(dev); } foreach (ObservableBluetoothLEDevice dev in Context.BluetoothLEDevices) { if (ShouldShow(dev) && DeviceList.Contains(dev) == false) { DeviceList.Add(dev); } } } }
internal void RemoveDeviceFromDeviceList(EgsDevice device) { if (DeviceList.Contains(device) == false) { return; } device.Close(); DeviceList.Remove(device); // TODO: MUSTDO: delete MessageReceivingForm.CurrentDevice itself MessageReceivingForm.CurrentDevice = null; }
public async void StartRefreshingAsync() { if (!_bluetooth.IsBluetoothAvailable) { ShowMessage(TextConstants.BluetoothUnavailable, TextConstants.ButtonClose); return; } if (_bluetooth.IsDiscovering) { return; } ButtonText = TextConstants.ButtonStopRefreshing; await _bluetooth.TurnOnBluetoothAsync(1000, 25); await _bluetooth.StartDeviceDiscoveryAsync(1000, 25); await Task.Run(async() => { while (_bluetooth.IsDiscovering) { if (SelectedDevice == null || !DeviceList.Contains(SelectedDevice)) { foreach (var item in DeviceList) { if ((_user.SavedAddress == "" && item.Name == TextConstants.DefaultDeviceName) || item.Address == _user.SavedAddress) { SelectedDevice = item; break; } } } await Task.Delay(25); } }); ButtonText = TextConstants.ButtonStartRefreshing; }