public DeviceNotifyHook(USBNotifier notifier, Guid guid)
        {
            // _parent = parent;
            _guid = guid;
            // _parent.HandleCreated += new EventHandler(this.OnHandleCreated);
            // _parent.HandleDestroyed += new EventHandler(this.OnHandleDestroyed);
            _notifier = notifier;

            IntPtr hWnd = IntPtr.Zero;

            if (Application.Current.MainWindow != null)
            {
                hWnd = new WindowInteropHelper(Application.Current.MainWindow).Handle;
            }

            if (hWnd == IntPtr.Zero)
            {
                throw new USBException("Main window not loaded yet. Cannot connect with USB yet.");
            }

            API.DeviceManagement.RegisterForDeviceNotifications(hWnd, _guid, ref _notifyHandle);

            HwndSource source = PresentationSource.FromVisual(Application.Current.MainWindow) as HwndSource;

            source.AddHook(WndProc);
        }
Esempio n. 2
0
 public DeviceNotifyHook(USBNotifier notifier, Control parent, Guid guid)
 {
     _guid = guid;
     parent.HandleCreated   += new EventHandler(this.OnHandleCreated);
     parent.HandleDestroyed += new EventHandler(this.OnHandleDestroyed);
     _notifier = notifier;
 }
Esempio n. 3
0
 public DeviceNotifyHook(USBNotifier notifier, Control parent, Guid guid)
 {
     _parent = parent;
     _guid = guid;
     _parent.HandleCreated += new EventHandler(this.OnHandleCreated);
     _parent.HandleDestroyed += new EventHandler(this.OnHandleDestroyed);
     _notifier = notifier;
 }
Esempio n. 4
0
 public DeviceNotifyHook(USBNotifier notifier, IntPtr windowHandle, Guid guid)
 {
     _guid = guid;
     RegisterNotify(windowHandle);   // TODO handle StopNotify on handle destroy
     _notifier = notifier;
 }