internal void InstallEvents()
 {
     Dispatch.Install <HTML_BrowserReady_t>(x => OnBrowserReady?.Invoke(new Browser(x.UnBrowserHandle)));
     Dispatch.Install <HTML_StartRequest_t>(x => OnStartRequest?.Invoke(new Browser(x.UnBrowserHandle), x.PchURL, x.PchTarget, x.PchPostData, x.BIsRedirect));
     Dispatch.Install <HTML_JSAlert_t>(x => OnJSAlert?.Invoke(new Browser(x.UnBrowserHandle), x.PchMessage));
     Dispatch.Install <HTML_JSConfirm_t>(x => OnJSConfirm?.Invoke(new Browser(x.UnBrowserHandle), x.PchMessage));
     Dispatch.Install <HTML_FileOpenDialog_t>(x => OnFileOpenDialog?.Invoke(new Browser(x.UnBrowserHandle), x.PchTitle, x.PchInitialFile));
     Dispatch.Install <HTML_FinishedRequest_t>(x => OnFinishedLoading?.Invoke(new Browser(x.UnBrowserHandle), x.PchURL, x.PchPageTitle));
     Dispatch.Install <HTML_NeedsPaint_t>(x => OnNeedsPaint?.Invoke(new Browser(x.UnBrowserHandle), new BrowserPaint(x)));
     Dispatch.Install <HTML_NewWindow_t>(x => OnNewWindow?.Invoke(new Browser(x.UnBrowserHandle), new BrowserNewWindow(x)));
     Dispatch.Install <HTML_OpenLinkInNewTab_t>(x => OnNewTab?.Invoke(new Browser(x.UnBrowserHandle), x.PchURL));
     Dispatch.Install <HTML_StatusText_t>(x => OnStatusText?.Invoke(new Browser(x.UnBrowserHandle), x.PchMsg));
 }
Esempio n. 2
0
        private void OnHidEvent(object sender, SharpLib.Hid.Event hidEvent)
        {
            try
            {
                if (hidEvent.IsButtonDown)
                {
                    if (hidEvent.IsGeneric)
                    {
                        var id = hidEvent.Usages.FirstOrDefault();
                        if (hidEvent.UsagePageEnum == UsagePage.WindowsMediaCenterRemoteControl && !_currentCodes[REMOTE_INPUT_TYPE].Contains(id.ToString()))
                        {
                            _currentCodes[REMOTE_INPUT_TYPE].Add(id.ToString());
                        }
                        if (hidEvent.UsagePageEnum == UsagePage.Consumer && !_currentCodes[CONSUMER_INPUT_TYPE].Contains(id.ToString()))
                        {
                            _currentCodes[CONSUMER_INPUT_TYPE].Add(id.ToString());
                        }
                    }
                    else if (hidEvent.IsKeyboard)
                    {
                        int key = (int)hidEvent.VirtualKey;
                        if (!_currentCodes[KEYBOARD_INPUT_TYPE].Contains(key.ToString()))
                        {
                            _currentCodes[KEYBOARD_INPUT_TYPE].Add(key.ToString());
                        }
                    }
                    _resetTimer.Enabled = true;
                }
                if (hidEvent.IsButtonUp)
                {
                    if (hidEvent.IsGeneric)
                    {
                        var id = hidEvent.Usages.FirstOrDefault();
                        if (hidEvent.UsagePageEnum == UsagePage.WindowsMediaCenterRemoteControl)
                        {
                            if (IsCombinationMatch(REMOTE_INPUT_TYPE))
                            {
                                OnStartRequest?.Invoke(this, EventArgs.Empty);
                            }

                            if (_currentCodes[REMOTE_INPUT_TYPE].Contains(id.ToString()))
                            {
                                _currentCodes[REMOTE_INPUT_TYPE].Remove(id.ToString());
                            }
                        }
                        else if (hidEvent.UsagePageEnum == UsagePage.Consumer)
                        {
                            if (IsCombinationMatch(CONSUMER_INPUT_TYPE))
                            {
                                OnStartRequest?.Invoke(this, EventArgs.Empty);
                            }

                            if (_currentCodes[CONSUMER_INPUT_TYPE].Contains(id.ToString()))
                            {
                                _currentCodes[CONSUMER_INPUT_TYPE].Remove(id.ToString());
                            }
                        }
                    }
                    else if (hidEvent.IsKeyboard)
                    {
                        if (IsCombinationMatch(KEYBOARD_INPUT_TYPE))
                        {
                            OnStartRequest?.Invoke(this, EventArgs.Empty);
                        }

                        int key = (int)hidEvent.VirtualKey;
                        if (_currentCodes[KEYBOARD_INPUT_TYPE].Contains(key.ToString()))
                        {
                            _currentCodes[KEYBOARD_INPUT_TYPE].Remove(key.ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("HID event failed", ex);
            }
        }