Ejemplo n.º 1
0
        /// <summary>
        /// Invoked when the focus changes either in the active window or when the
        /// active window itself changes.
        /// </summary>
        /// <param name="monitorInfo">Info about focused element</param>
        /// <param name="handled">was this handled</param>
        public override void OnFocusChanged(WindowActivityMonitorInfo monitorInfo, ref bool handled)
        {
            Log.Debug("OnFocus: " + monitorInfo.ToString());

            base.OnFocusChanged(monitorInfo, ref handled);

            var handle = IntPtr.Zero;

            if (_form != null)
            {
                _form.Invoke(new MethodInvoker(delegate()
                {
                    handle = _form.Handle;
                }));
            }

            // if the abbreviations scanner is up, display the
            // alphabet scanner
            if (handle != IntPtr.Zero && monitorInfo.FgHwnd == handle)
            {
                if (!_scannerShown)
                {
                    var arg = new PanelRequestEventArgs(PanelClasses.AlphabetMinimal, monitorInfo)
                    {
                        RequestArg  = _form,
                        TargetPanel = _form,
                        UseCurrentScreenAsParent = true
                    };
                    showPanel(this, arg);
                    _scannerShown = true;
                }
            }

            handled = true;
        }