Ejemplo n.º 1
0
 /// <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;
 }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 /// <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;
 }
Ejemplo n.º 4
0
 /// <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;
 }
Ejemplo n.º 5
0
        /// <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;
        }
Ejemplo n.º 6
0
        /// <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);
        }