Exemplo n.º 1
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_APPCOMMAND = 0x319;

            if (msg == WM_APPCOMMAND)
            {
                if (_appCommand != null)
                {
                    var appCommandEventArgs = new AppCommandEventArgs { Cmd = (lParam.ToInt32() / 65536) };
                 
                    _appCommand.Invoke(null, appCommandEventArgs);
                    handled = appCommandEventArgs.Handled;
                }
            }

            return IntPtr.Zero;
        }
Exemplo n.º 2
0
        public void input_AppCommand(object sender, AppCommandEventArgs appCommandEventArgs)
        {
            var appCommand = MapAppCommand(appCommandEventArgs.Cmd);
            _logger.Debug("input_AppCommand: {0} {1}", appCommandEventArgs.Cmd, appCommand == null ? "null" : appCommand.ToString());

            if (appCommand != null)
            {
                if (IsDuplicateMediaKeyEvent(appCommand.Value))
                {
                    _logger.Debug("input_AppCommand: IsDuplicate - cmd {0} after key {1}", appCommand, _lastKeyDown);
                    appCommandEventArgs.Handled = false;
                }
                else if (!appCommandEventArgs.Handled) 
                {
                    var command = _inputCommandMaps.GetMappedCommand(appCommand.Value);
                    appCommandEventArgs.Handled = SendCommandEvents(command, null);
                }

                if (appCommandEventArgs.Handled)
                {
                    _lastCmd = appCommand.Value;
                    _lastCmdTime = DateTime.Now;
                }
                else
                {
                    _logger.Debug("input_AppCommand {0}, command not handled", appCommand);
                }
            }
        }