Exemple #1
0
        internal EgsDevicesWindowMessageReceivingForm()
        {
            InitializeComponent();
            this.Visible            = false;
            IsToUseActiveWindowHWnd = EgsDevice.IsToUseActiveWindowHWnd;

            IntPtr monitoringHWnd = IntPtr.Zero;

            if (IsToUseActiveWindowHWnd)
            {
                IntPtr hWnd = NativeMethods.GetActiveWindow();
                hMainWindow   = NativeMethods.GetForegroundWindow();
                newWndProc    = new WndProcDelegate(WndProc);
                newWndProcPtr = Marshal.GetFunctionPointerForDelegate(newWndProc);
                oldWndProcPtr = NativeMethods.SetWindowLong(hMainWindow, -4, newWndProcPtr);
                if (true)
                {
                    if (ApplicationCommonSettings.IsDebugging)
                    {
                        Console.WriteLine("Use HWND of the result of GetForegroundWindow()");
                    }
                    monitoringHWnd = hMainWindow;
                }
                else
                {
                    if (ApplicationCommonSettings.IsDebugging)
                    {
                        Console.WriteLine("Use HWND of the result of GetActiveWindow()");
                    }
                    monitoringHWnd = hWnd;
                }
            }
            else
            {
                if (ApplicationCommonSettings.IsDebugging)
                {
                    Console.WriteLine("Use HWND of this Form");
                }
                monitoringHWnd = this.Handle;
            }

            deviceNotification = new Win32DeviceNotification(monitoringHWnd);
            SetupDi            = new Win32SetupDiForEgsDevice();

            deviceNotification.RegisterForDeviceNotificationsByUsbGuid();
#if USE_OLD_HID
            HidReportsUpdateByWin32RawInput = new EgsDeviceHidReportsUpdateByWin32RawInput();
            touchRawInputDevices            = new Win32RegisterRawInputDevices(monitoringHWnd);
            touchRawInputDevices.RegisterRawInputDevices();
#endif
        }
        internal EgsDevicesManager()
        {
            DeviceList = new List <EgsDevice>();

            SetupDi = new Win32SetupDiForEgsDevice();

#if false
            EachDeviceStatusMonitoringTimer = new System.Windows.Forms.Timer()
            {
                Interval = ApplicationCommonSettings.IsDebugging ? 1000 : 5000
            };
            EachDeviceStatusMonitoringTimer.Tick += delegate
            {
                foreach (var device in DeviceList)
                {
                    device.UpdateTemperatureProperties();
                }
            };
            EachDeviceStatusMonitoringTimer.Start();
#endif
        }