Esempio n. 1
0
        /// <summary>
        /// Call this method about all registered devices, after calling MessageReceivingForm.SetupDi.Update(); in EgsDevicesManagers
        /// </summary>
        internal void UpdateHidDeviceConnectionStatus()
        {
            // TODO: It should be able to use multiple devices, even if "ProductId" is changed in future.  If the app checks them, the place may be here.
            var newDevicePath = refToSetupDi.GetHidDevicePath(IndexInHidDevicePathList);

            if (string.IsNullOrEmpty(newDevicePath))
            {
                _HidDeviceDevicePath = "";
                // NOTE: When the device is disconnected, the ReportMonitoringThread must be completed.
                if (HidReportsUpdate != null)
                {
                    HidReportsUpdate.OnDisable();
                }
                _IsHidDeviceConnected = false;
            }
            else
            {
                _HidDeviceDevicePath = newDevicePath;
                if (HidReportsUpdate != null)
                {
                    HidReportsUpdate.Start(_HidDeviceDevicePath);
                }
                _IsHidDeviceConnected = true;
                SetAllSettingsToDeviceAndReadStatusFromDevice();
            }

            OnHidDeviceDevicePathChanged(EventArgs.Empty);
            OnIsHidDeviceConnectedChanged(EventArgs.Empty);
        }
        /// <summary>
        /// Call this method about all registered devices, after calling MessageReceivingForm.SetupDi.Update(); in EgsDevicesManagers
        /// </summary>
        internal void UpdateHidDeviceConnectionStatus()
        {
            // TODO: It should be able to use multiple devices, even if "ProductId" is changed in future.  If the app checks them, the place may be here.
            var newDevicePath = DefaultEgsDevicesManager.SetupDi.GetHidDevicePath(IndexInHidDevicePathList);

            if (string.IsNullOrEmpty(newDevicePath))
            {
                _HidDeviceDevicePath  = "";
                _IsHidDeviceConnected = false;
            }
            else
            {
                _HidDeviceDevicePath = newDevicePath;
                HidReportsUpdate.Start(_HidDeviceDevicePath);
                _IsHidDeviceConnected = true;
                SetAllSettingsToDeviceAndReadStatusFromDevice();
            }

            OnHidDeviceDevicePathChanged(EventArgs.Empty);
            OnIsHidDeviceConnectedChanged(EventArgs.Empty);
        }