private void ConnectUsbDevice() { _usbDevice = UsbDevice.OpenUsbDevice(_myUsbFinder); if (_usbDevice != null) { IsAvailable = true; if (ArduinoUsbDeviceChangeNotifier != null) { ArduinoUsbDeviceChangeNotifier.Invoke(true, null); } } else { IsAvailable = false; } }
private void OnDeviceNotifyEvent(object sender, DeviceNotifyEventArgs e) { if (e.Device.IdVendor == _vendorId && e.Device.IdProduct == _productId) { if (e.EventType == EventType.DeviceArrival) { ConnectUsbDevice(); } else if (e.EventType == EventType.DeviceRemoveComplete) { _usbDevice = null; IsAvailable = false; if (ArduinoUsbDeviceChangeNotifier != null) { ArduinoUsbDeviceChangeNotifier.Invoke(false, null); } } } }