/// <summary> /// This will AssignHandle to nativeWindow and register for device notifications. /// </summary> /// <param name="usbDeviceWatcher"> /// The usb Device Watcher. /// </param> /// <returns> /// The <see cref="IProcessHandleResult"/>. /// </returns> public IProcessHandleResult ProcessFor(IUsbDeviceWatcher usbDeviceWatcher) { usbDeviceWatcher.AssignHandle(Handle); var processHandleResult = _deviceNotifications.Register(Handle); DeviceNotificationHandle = processHandleResult.Handle; return processHandleResult; }
/// <summary> /// This will AssignHandle to nativeWindow and register for device notifications. /// </summary> /// <param name="usbDeviceWatcher"> /// The usb Device Watcher. /// </param> /// <returns> /// The <see cref="IProcessHandleResult"/>. /// </returns> public IProcessHandleResult ProcessFor(IUsbDeviceWatcher usbDeviceWatcher) { usbDeviceWatcher.AssignHandle(Handle); var processHandleResult = _deviceNotifications.Register(Handle); DeviceNotificationHandle = processHandleResult.Handle; return(processHandleResult); }
/// <summary> /// Initializes a new instance of the <see cref="UsbDevice"/> class. /// </summary> /// <param name="path"> /// The path. /// </param> /// <param name="usbDeviceWatcher"> /// The usb Device Watcher. /// </param> public UsbDevice(string path, IUsbDeviceWatcher usbDeviceWatcher) { _disposable = usbDeviceWatcher.ArrivedDeviceNotificationsOnly() .Select(x => x.Name) .Where(x => x == Path) .StartWith(path) .Subscribe(Connect, Error, Completed); _usbDeviceWatcher = usbDeviceWatcher; Path = path; }
/// <summary> /// This will unregister the device from being watched. /// </summary> /// <param name="usbDeviceWatcher"> /// The usb device watcher. /// </param> /// <returns> /// The <see cref="IProcessHandleResult"/>. /// </returns> public IProcessHandleResult ProcessFor(IUsbDeviceWatcher usbDeviceWatcher) { var registeredCreatedHandle = usbDeviceWatcher.RegisteredCreatedHandle; if (registeredCreatedHandle == null) { return new ProcessHandleResult(Handle, new MarshalWrapper()); } var processHandleResult = _deviceNotifications.UnRegister(registeredCreatedHandle.DeviceNotificationHandle); usbDeviceWatcher.ReleaseHandle(); return processHandleResult; }
/// <summary> /// This will unregister the device from being watched. /// </summary> /// <param name="usbDeviceWatcher"> /// The usb device watcher. /// </param> /// <returns> /// The <see cref="IProcessHandleResult"/>. /// </returns> public IProcessHandleResult ProcessFor(IUsbDeviceWatcher usbDeviceWatcher) { var registeredCreatedHandle = usbDeviceWatcher.RegisteredCreatedHandle; if (registeredCreatedHandle == null) { return(new ProcessHandleResult(Handle, new MarshalWrapper())); } var processHandleResult = _deviceNotifications.UnRegister(registeredCreatedHandle.DeviceNotificationHandle); usbDeviceWatcher.ReleaseHandle(); return(processHandleResult); }