ACAT.Lib.Extension.AppAgents.MSWord.MSWordAgentBase.OnFocusChanged C# (CSharp) Method

OnFocusChanged() public method

Invoked when the foreground window focus changes. Displays the scanner depending on the context. Also, if this is a new window that has come into focus, adds its contents to the word prediction temporary batch model for more contextual prediction of words
public OnFocusChanged ( ACAT.Lib.Core.Utility.WindowActivityMonitorInfo monitorInfo, bool &handled ) : void
monitorInfo ACAT.Lib.Core.Utility.WindowActivityMonitorInfo Foreground window info
handled bool set to true if handled
return void
        public override void OnFocusChanged(WindowActivityMonitorInfo monitorInfo, ref bool handled)
        {
            Log.Debug();

            if (String.Compare(monitorInfo.FocusedElement.Current.ClassName, DocClassName, true) == 0)
            {
                createMSWordTextInterface();
                if (monitorInfo.IsNewFocusedElement)
                {
                    showPanel(this, new PanelRequestEventArgs(PanelClasses.Alphabet, monitorInfo));
                }

                if (monitorInfo.IsNewWindow)
                {
                    loadWordPredictionContext();
                }
            }
            else if (autoSwitchScanners)
            {
                if (isRecentDocuments(monitorInfo.FocusedElement))
                {
                    showPanel(this, new PanelRequestEventArgs(PanelClasses.DialogContextMenu, ScannerTitle, monitorInfo));
                }
                else if (String.Compare(monitorInfo.FocusedElement.Current.ClassName, "NetUIToolWindow") == 0)
                {
                    showPanel(this, new PanelRequestEventArgs(PanelClasses.MenuContextMenu, ScannerTitle, monitorInfo));
                }
                else
                {
                    handled = false;
                    return;
                }
            }
            else if (!_scannerShown)
            {
                showPanel(this, new PanelRequestEventArgs(PanelClasses.Alphabet, monitorInfo));
                _scannerShown = true;
            }

            handled = true;
        }