/// <summary> /// Creates the form requested in eventArg /// </summary> /// <param name="eventArg">info about panel to create</param> /// <returns>created form</returns> private Form createPanel(PanelRequestEventArgs eventArg) { String panelClass = eventArg.PanelClass; Form form = CreatePanel( ref panelClass, eventArg.Title, eventArg.MonitorInfo.FgHwnd, eventArg.MonitorInfo.FocusedElement); eventArg.PanelClass = panelClass; return(form); }
/// <summary> /// Initialzies the specified scanner panel /// </summary> /// <param name="scannerPanel">panel to initialize</param> /// <param name="arg">panel arguments</param> /// <returns>true on success</returns> private bool initializePanel(IScannerPanel scannerPanel, PanelRequestEventArgs arg) { var startupArg = new StartupArg { FocusedElement = arg.MonitorInfo.FocusedElement, PanelClass = arg.PanelClass, ConfigFileName = PanelConfigMap.GetConfigFileForPanel(arg.PanelClass), Arg = arg.RequestArg }; Log.Debug("panelClass: " + arg.PanelClass + ", ConfigFIle: " + startupArg.ConfigFileName); return(scannerPanel.Initialize(startupArg)); }
/// <summary> /// Initialzies the specified scanner panel /// </summary> /// <param name="scannerPanel">panel to initialize</param> /// <param name="arg">panel arguments</param> /// <returns>true on success</returns> private bool initializePanel(IScannerPanel scannerPanel, PanelRequestEventArgs arg) { var startupArg = new StartupArg { FocusedElement = arg.MonitorInfo.FocusedElement, PanelClass = arg.PanelClass, Arg = arg.RequestArg }; var panelConfigMapEntry = PanelConfigMap.GetPanelConfigMapEntry(arg.PanelClass); Log.Debug("panelClass: " + arg.PanelClass + ", ConfigFIle: " + ((panelConfigMapEntry != null) ? panelConfigMapEntry.ConfigFileName : String.Empty)); return(scannerPanel.Initialize(startupArg)); }
/// <summary> /// Switches the currently active scanner to the one specified /// in eventArg. Closes the current panel, creates nand shows /// the specified one. /// </summary> /// <param name="eventArg">Info about which scanner to display</param> private void switchCurrentPanel(PanelRequestEventArgs eventArg) { Log.Debug(); Log.Debug(eventArg.ToString()); if (!eventArg.UseCurrentScreenAsParent) { Log.Debug("UseCurrentScreenAsParent is false. closing current panel " + ((_currentPanel != null) ? _currentPanel.Name : "<null>")); CloseCurrentPanel(); } Log.Debug("Creating panel ..." + eventArg.PanelClass); Form form = createPanel(eventArg); Log.Debug("Calling show for ..." + eventArg.PanelClass); if (form == null) { Log.Debug("createPanel returned null!!"); } else { initializePanel(form as IScannerPanel, eventArg); Log.Debug("Calling show for ..." + eventArg.PanelClass); if (eventArg.UseCurrentScreenAsParent && _currentForm is IPanel) { Log.Debug("Showing form " + form.Name + ", parent " + _currentForm.Name); Show((IPanel)_currentForm, (IPanel)form); } else { Log.Debug("Showing form " + form.Name + " without parent."); Show(null, (IPanel)form); } } }
/// <summary> /// Invoked to run a command /// </summary> /// <param name="command">The command to execute</param> /// <param name="commandArg">Optional arguments for the command</param> /// <param name="handled">set this to true if handled</param> public override void OnRunCommand(String command, object commandArg, ref bool handled) { handled = true; switch (command) { case "CmdThreeFourthMaximizeWindow": Windows.SetForegroundWindowSizePercent(Context.AppWindowPosition, 75); break; case "SwitchAppWindow": DialogUtils.ShowTaskSwitcher(IEProcessName); break; case "CmdZoomIn": appTextInterface.Pause(); AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Add); appTextInterface.Resume(); break; case "CmdZoomOut": appTextInterface.Pause(); AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Subtract); appTextInterface.Resume(); break; case "CmdZoomFit": appTextInterface.Pause(); AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D0); appTextInterface.Resume(); break; case "CmdFind": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.F); break; case "IEGoBackward": AgentManager.Instance.Keyboard.Send(Keys.BrowserBack); break; case "IEGoForward": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.Right); break; case "IEHomePage": AgentManager.Instance.Keyboard.Send(Keys.BrowserHome); break; case "IEWebSearch": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.E); break; case "IEFavorites": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.I); //AgentController.Instance.Send(Keys.BrowserFavorites); break; case "IEHistory": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.H); break; case "IEAddFavorites": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D); break; case "IERefreshPage": AgentManager.Instance.Keyboard.Send(Keys.BrowserRefresh); break; case "IEAddressBar": AgentManager.Instance.Keyboard.Send(Keys.F4); break; case "IEZoomMenu": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var panelArg = new PanelRequestEventArgs("InternetExplorerZoomMenu", "IExplorer", monitorInfo) { UseCurrentScreenAsParent = true }; showPanel(this, panelArg); } break; case "IEEmailLink": _explorerElements.EmailPageAsLink(); break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }
/// <summary> /// Event handler for request to display a scanner. The /// arg parameter contains information about which scanner /// to display /// </summary> /// <param name="sender">event sender</param> /// <param name="arg">event arg</param> private void AppAgent_EvtPanelRequest(object sender, PanelRequestEventArgs arg) { getTopOfStack().AppAgent_EvtPanelRequest(sender, arg); }
/// <summary> /// Invoked when there is a request to run a command. This /// could as a result of the user activating a button on the /// scanner and there is a command associated with the button /// </summary> /// <param name="command">command to run</param> /// <param name="commandArg">any optional arguments</param> /// <param name="handled">was this handled?</param> public override void OnRunCommand(String command, object commandArg, ref bool handled) { handled = true; switch (command) { case "SpeakMenu": if (isMainFormActive()) { if (Confirm("Speak now?")) { PanelRequestEventArgs speakArg; if (_lectureMgrForm.Mode == LectureManagerMainForm.SpeechMode.All) { speakArg = new PanelRequestEventArgs( SpeakAllMenuPanel, Title, WindowActivityMonitor.GetForegroundWindowInfo()) { UseCurrentScreenAsParent = true }; showPanel(this, speakArg); } else { speakArg = new PanelRequestEventArgs( SpeakMenuPanel, Title, WindowActivityMonitor.GetForegroundWindowInfo()) { UseCurrentScreenAsParent = true }; showPanel(this, speakArg); } } } break; case "LMTopOfDoc": if (isMainFormActive()) { _lectureMgrForm.GoToTop(); } break; case "LMForward": if (isMainFormActive()) { _lectureMgrForm.NavigateForward(); } break; case "LMBackward": if (isMainFormActive()) { _lectureMgrForm.NavigateBackward(); } break; case "SpeechModeParagraph": if (isMainFormActive()) { if (Confirm("Set Paragraph Mode?")) { _lectureMgrForm.Mode = LectureManagerMainForm.SpeechMode.Paragraph; closeCurrentPanel(); } } break; case "SpeechModeSentence": if (isMainFormActive()) { if (Confirm("Set Sentence Mode?")) { _lectureMgrForm.Mode = LectureManagerMainForm.SpeechMode.Sentence; closeCurrentPanel(); } } break; case "SpeechModeAll": if (isMainFormActive()) { if (Confirm("Set All?")) { _lectureMgrForm.Mode = LectureManagerMainForm.SpeechMode.All; closeCurrentPanel(); } } break; case "SpeakNext": if (isMainFormActive()) { _lectureMgrForm.ProcessSpeakNext(); } break; case "SpeakAll": if (isMainFormActive()) { if (_lectureMgrForm.Speaking) { _lectureMgrForm.PauseSpeaking(); } else { _lectureMgrForm.ProcessReadAllSpeech(); } } break; case "leaveSpeak": if (Confirm("Speaking. Leave?")) { closeCurrentPanel(); if (isMainFormActive()) { _lectureMgrForm.StopIfSpeaking(); } } break; case "exitLectureManager": if (Confirm("Exit Lecture Manager?")) { closeCurrentPanel(); if (_lectureMgrForm != null) { Windows.CloseForm(_lectureMgrForm); _lectureMgrForm = null; } Context.AppWindowPosition = _prevScannerPosition; Close(); Log.Debug("setting _menushown to false "); _menuShown = false; } break; case "ToggleMode": var toggleModeArg = new PanelRequestEventArgs("LectureManagerToggleModeMenu", Title, WindowActivityMonitor.GetForegroundWindowInfo()) { UseCurrentScreenAsParent = true }; showPanel(this, toggleModeArg); break; case "NavigateMenu": var navigateMenuArg = new PanelRequestEventArgs("LectureManagerNavigationMenu", Title, WindowActivityMonitor.GetForegroundWindowInfo()) { UseCurrentScreenAsParent = true }; showPanel(this, navigateMenuArg); break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }
/// <summary> /// Invoked when there is a request to display a contextual /// menu /// </summary> /// <param name="monitorInfo">foreground window info</param> public override void OnContextMenuRequest(WindowActivityMonitorInfo monitorInfo) { var arg = new PanelRequestEventArgs(PanelClasses.None, monitorInfo); getLectureManagerPanel(arg); showPanel(this, arg); }
/// <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; }
/// <summary> /// Event handler for when the file browser scanner requests for an /// alphabet scanner to be displayed. /// </summary> /// <param name="sender">event sender</param> /// <param name="eventArgs">event args</param> private void _fileBrowserScanner_EvtShowScanner(object sender, EventArgs eventArgs) { if (_fileBrowserScanner != null) { var arg = new PanelRequestEventArgs(PanelClasses.AlphabetMinimal, WindowActivityMonitor.GetForegroundWindowInfo()) { TargetPanel = _fileBrowserScanner, RequestArg = _fileBrowserScanner, UseCurrentScreenAsParent = true }; showPanel(this, arg); } }
/// <summary> /// Show the contexual menus for menus /// </summary> /// <param name="monitorInfo">Foreground menu window information</param> private void showMenuContextMenu(WindowActivityMonitorInfo monitorInfo) { var args = new PanelRequestEventArgs(PanelClasses.MenuContextMenu, monitorInfo) { UseCurrentScreenAsParent = true, Title = "Menu" }; showPanel(this, args); scannerShown = true; }
/// <summary> /// Invoked to run a command /// </summary> /// <param name="command">The command to execute</param> /// <param name="commandArg">Optional arguments for the command</param> /// <param name="handled">set this to true if handled</param> public override void OnRunCommand(String command, object commandArg, ref bool handled) { handled = true; Log.Debug(command); switch (command) { case "EmailOpenOrInbox": handleCmdEmailOpenOrInbox(); break; case "EmailNew": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.N); break; case "EmailOpen": AgentManager.Instance.Keyboard.Send(Keys.Enter); break; case "EmailNext": AgentManager.Instance.Keyboard.Send(Keys.Down); break; case "EmailPrevious": AgentManager.Instance.Keyboard.Send(Keys.Up); break; case "EmailNextSimple": handleCmdEmailNextSimple(); break; case "EmailPreviousSimple": handleCmdEmailPreviousSimple(); break; case "EmailReply": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.R); break; case "EmailReplyAll": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.LShiftKey, Keys.R); break; case "EmailForward": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.M, Keys.F); break; case "EmailBrowseDelete": if (DialogUtils.ConfirmScanner("Confirm Delete?")) { AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D); } break; case "EmailInboxDelete": if (DialogUtils.ConfirmScanner("Confirm Delete?")) { AgentManager.Instance.Keyboard.Send(Keys.Delete); } break; case "EmailEnterText": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); showPanel(this, new PanelRequestEventArgs("Alphabet", monitorInfo)); break; } case "EmailNextField": handleCmdEmailNextField(); break; case "EmailPreviousField": handleCmdEmailPreviousField(); break; case "EmailAttachFile": attachFile(); break; case "EmailAttachments": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.A); break; case "EmailSend": if (DialogUtils.ConfirmScanner("Confirm Send?")) { AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.E); } break; case "EmailBrowseNext": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.Down); break; case "EmailBrowsePrevious": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.Up); break; case "EmailClose": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.W); break; case "EmailInbox": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D1); break; case "EmailOutbox": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D0); break; case "EmailJunkbox": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.X); AgentManager.Instance.Keyboard.Send(Keys.J); break; case "EmailTrashbox": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.X); AgentManager.Instance.Keyboard.Send(Keys.T); break; case "Top": AgentManager.Instance.Keyboard.Send(Keys.Home); break; case "MailBoxes": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var arg = new PanelRequestEventArgs("EudoraMailBoxesContextMenu", "Eudora", monitorInfo) { UseCurrentScreenAsParent = true }; showPanel(this, arg); } break; case "EmailAction": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var arg = new PanelRequestEventArgs("EudoraMailActionContextMenu", "Eudora", monitorInfo) { UseCurrentScreenAsParent = true }; showPanel(this, arg); } break; case "EmailAddToContacts": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.K); break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }
/// <summary> /// Raises an event to indicate that there was a request to /// display a scanner. The arg parameter contains info about /// which scanner to display /// </summary> /// <param name="sender">event sender</param> /// <param name="arg">panel request info</param> private void triggerPanelRequest(object sender, PanelRequestEventArgs arg) { Log.Debug("PanelClass: " + arg.PanelClass); if (_panelChangeNotifications.OnHold()) { Log.Debug("Panel change request paused. will not change panel"); return; } if (EvtPanelRequest != null) { EvtPanelRequest(sender, arg); } else { Log.Debug("EvtPanelrequest is null"); } }
/// <summary> /// Dispays the menu indicated by the menu name /// </summary> /// <param name="menuName">name of the menu</param> /// <param name="title">Title of the menu</param> private void showMenu(String menuName, String title) { var panelArg = new PanelRequestEventArgs(menuName, title, WindowActivityMonitor.GetForegroundWindowInfo()) { UseCurrentScreenAsParent = true }; showPanel(this, panelArg); }
/// <summary> /// Event handler for request to display a scanner /// </summary> /// <param name="sender">event sender</param> /// <param name="arg">event arg</param> private void agent_EvtPanelRequest(object sender, PanelRequestEventArgs arg) { Log.Debug("Panel request for " + arg.PanelClass); triggerPanelRequest(sender, arg); }
/// <summary> /// Event handler for request to display a scanner. The /// arg parameter contains information about which scanner /// to display /// </summary> /// <param name="sender">event sender</param> /// <param name="arg">event arg</param> private void AppAgent_EvtPanelRequest(object sender, PanelRequestEventArgs arg) { Log.Debug("A request came in for panel " + arg.PanelClass + ". NewWindow is " + arg.MonitorInfo.IsNewWindow); if (_currentForm != null) { Log.Debug("_currentForm is " + _currentForm.Name + ", type: " + _currentForm.GetType() + ", IsModal: " + _currentForm.Modal); Form owner = _currentForm.Owner; if (owner != null) { Log.Debug("owner is : " + owner.Name + ", type: " + owner.GetType() + ", is owner ipanel? " + (_currentForm.Owner is IPanel)); } else { Log.Debug("_currentForm.Owner is null"); } // if a modal dialog is currently open, don't honor the request. // the modal dialog has to be closed first. if (arg.TargetPanel == null || arg.TargetPanel != _currentForm) { if (_currentForm.Modal || (_currentForm.Owner != null && _currentForm.Owner.Modal)) { Log.Debug("A modal dialog is open. Will not honor panel request"); return; } } } // if no panel type, use the alphabet scanner as the String requestedPanelClass = arg.PanelClass; if (PanelConfigMap.AreEqual(arg.PanelClass, PanelClasses.None)) { requestedPanelClass = PanelClasses.Alphabet; } IScannerPanel currentScanner = _currentPanel as IScannerPanel; if (arg.MonitorInfo.IsNewWindow) { Log.Debug("This is a new window. winHandle: " + arg.MonitorInfo.FgHwnd); if (currentScanner != null) { Log.Debug("currentpanel: " + currentScanner.PanelClass + ", requested: " + requestedPanelClass); } else { Log.Debug("_currentPanel is null or not IScannerPanel. Activate alphabet scanner"); requestedPanelClass = PanelClasses.Alphabet; } // if the current scanner is the same as the requested one, just show it if (currentScanner != null && PanelConfigMap.AreEqual(currentScanner.PanelClass, requestedPanelClass) && _currentPanel.Owner == null) { Log.Debug("Current panel is already " + requestedPanelClass + ", calling Show()"); _currentPanel.TopMost = true; Show(null, (IPanel)_currentPanel); } else { // check with the agent if it is OK to switch panels. if ((currentScanner == null) || currentScanner.OnQueryPanelChange(arg)) { switchCurrentPanel(arg); } } } else { if (currentScanner == null) { Log.Debug("CurrentPanel is null. returning"); return; } Log.Debug("**** Not a new window. CurrentPanel is " + currentScanner.PanelClass + " requested panel is " + requestedPanelClass); // if the current panel is not the same as the requested one, query the // agent if it is OK to switch and then do the switch if (!PanelConfigMap.AreEqual(currentScanner.PanelClass, requestedPanelClass) && currentScanner.OnQueryPanelChange(arg)) { switchCurrentPanel(arg); } else { Log.Debug("Will not switch panels. Current: " + currentScanner.PanelClass + ", requested: " + requestedPanelClass); } } }
/// <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); setTextInterface(textInterface); if (_menuShown) { return; } var arg = new PanelRequestEventArgs(PanelClasses.None, monitorInfo); handled = getLectureManagerPanel(arg); Log.Debug("handled: " + handled); if (handled) { _menuShown = true; Log.Debug("calling showpanel for : " + arg.PanelClass); showPanel(this, arg); } }
/// <summary> /// Creates the form requested in eventArg /// </summary> /// <param name="eventArg">info about panel to create</param> /// <returns>created form</returns> private Form createPanel(PanelRequestEventArgs eventArg) { String panelClass = eventArg.PanelClass; Form form = CreatePanel( ref panelClass, eventArg.Title, eventArg.MonitorInfo.FgHwnd, eventArg.MonitorInfo.FocusedElement); eventArg.PanelClass = panelClass; return form; }
/// <summary> /// Depending on the context, returns the appropriate scanner /// to activate /// </summary> /// <param name="arg">contextual info</param> /// <returns>true on success</returns> private bool getLectureManagerPanel(PanelRequestEventArgs arg) { arg.PanelClass = "LectureManagerContextMenuSimple"; arg.Title = "Lecture Mgr"; return true; }
/// <summary> /// Initialzies the specified scanner panel /// </summary> /// <param name="scannerPanel">panel to initialize</param> /// <param name="arg">panel arguments</param> /// <returns>true on success</returns> private bool initializePanel(IScannerPanel scannerPanel, PanelRequestEventArgs arg) { var startupArg = new StartupArg { FocusedElement = arg.MonitorInfo.FocusedElement, PanelClass = arg.PanelClass, ConfigFileName = PanelConfigMap.GetConfigFileForPanel(arg.PanelClass), Arg = arg.RequestArg }; Log.Debug("panelClass: " + arg.PanelClass + ", ConfigFIle: " + startupArg.ConfigFileName); return scannerPanel.Initialize(startupArg); }
/// <summary> /// Should we allow ACAT to switch this scanner out when /// there is a application context switch. /// </summary> /// <param name="arg">contextual info</param> /// <returns>true</returns> public virtual bool OnQueryPanelChange(PanelRequestEventArgs arg) { return(true); }
/// <summary> /// Switches the currently active scanner to the one specified /// in eventArg. Closes the current panel, creates nand shows /// the specified one. /// </summary> /// <param name="eventArg">Info about which scanner to display</param> private void switchCurrentPanel(PanelRequestEventArgs eventArg) { Log.Debug(); Log.Debug(eventArg.ToString()); if (!eventArg.UseCurrentScreenAsParent) { Log.Debug("UseCurrentScreenAsParent is false. closing current panel " + ((_currentPanel != null) ? _currentPanel.Name : "<null>")); CloseCurrentPanel(); } Log.Debug("Creating panel ..." + eventArg.PanelClass); Form form = createPanel(eventArg); Log.Debug("Calling show for ..." + eventArg.PanelClass); if (form == null) { Log.Debug("FORM IS NULL!!"); } else { initializePanel(form as IScannerPanel, eventArg); Log.Debug("Calling show for ..." + eventArg.PanelClass); if (eventArg.UseCurrentScreenAsParent && _currentForm is IPanel) { Log.Debug("Showing form " + form.Name + ", parent " + _currentForm.Name); Show((IPanel)_currentForm, (IPanel)form); } else { Log.Debug("Showing form " + form.Name + " without parent."); Show(null, (IPanel)form); } } }
/// <summary> /// Event handler for request to display a scanner. The /// arg parameter contains information about which scanner /// to display /// </summary> /// <param name="sender">event sender</param> /// <param name="arg">event arg</param> public void AppAgent_EvtPanelRequest(object sender, PanelRequestEventArgs arg) { Log.Debug("A request came in for panel " + arg.PanelClass + ". NewWindow is " + arg.MonitorInfo.IsNewWindow); if (_currentForm != null) { Log.Debug("_currentForm is " + _currentForm.Name + ", type: " + _currentForm.GetType() + ", IsModal: " + _currentForm.Modal); Form owner = _currentForm.Owner; if (owner != null) { Log.Debug("owner is : " + owner.Name + ", type: " + owner.GetType() + ", is owner ipanel? " + (_currentForm.Owner is IPanel)); } else { Log.Debug("_currentForm.Owner is null"); } // if a modal dialog is currently open, don't honor the request. // the modal dialog has to be closed first. if (arg.TargetPanel == null || arg.TargetPanel != _currentForm) { if (_currentForm.Modal || (_currentForm.Owner != null && _currentForm.Owner.Modal)) { Log.Debug("A modal dialog is open. Will not honor panel request"); return; } } } // if no panel type, use the alphabet scanner as the String requestedPanelClass = arg.PanelClass; if (PanelConfigMap.AreEqual(arg.PanelClass, PanelClasses.None)) { requestedPanelClass = PanelClasses.Alphabet; } IScannerPanel currentScanner = _currentPanel as IScannerPanel; if (arg.MonitorInfo.IsNewWindow) { Log.Debug("This is a new window. winHandle: " + arg.MonitorInfo.FgHwnd); if (currentScanner != null) { Log.Debug("currentpanel: " + currentScanner.PanelClass + ", requested: " + requestedPanelClass); } else { Log.Debug("_currentPanel is null or not IScannerPanel. Activate alphabet scanner"); requestedPanelClass = PanelClasses.Alphabet; } // if the current scanner is the same as the requested one, just show it if (currentScanner != null && PanelConfigMap.AreEqual(currentScanner.PanelClass, requestedPanelClass) && _currentPanel.Owner == null) { Log.Debug("Current panel is already " + requestedPanelClass + ", calling Show()"); _currentPanel.TopMost = true; if (_currentPanel is MenuPanelBase) { (_currentPanel as MenuPanelBase).SetTitle(arg.Title); } Show(null, (IPanel)_currentPanel); } else { // check with the agent if it is OK to switch panels. if ((currentScanner == null) || currentScanner.OnQueryPanelChange(arg)) { switchCurrentPanel(arg); } } } else { if (currentScanner == null) { Log.Debug("_currentPanel is null. returning"); return; } Log.Debug("Not a new window. _currentPanel is " + currentScanner.PanelClass + " requested panel is " + requestedPanelClass); // if the current panel is not the same as the requested one, query the // agent if it is OK to switch and then do the switch if (!PanelConfigMap.AreEqual(currentScanner.PanelClass, requestedPanelClass) && currentScanner.OnQueryPanelChange(arg)) { switchCurrentPanel(arg); } else { Log.Debug("Will not switch panels. Current: " + currentScanner.PanelClass + ", requested: " + requestedPanelClass); if (currentScanner is MenuPanelBase) { (currentScanner as MenuPanelBase).SetTitle(arg.Title); } } } }
/// <summary> /// Should we allow ACAT to switch this scanner out when /// there is a application context switch. /// </summary> /// <param name="arg">contextual info</param> /// <returns>true</returns> public virtual bool OnQueryPanelChange(PanelRequestEventArgs arg) { return true; }
public virtual void OnRunCommand(String command, object arg, ref bool handled) { handled = true; switch (command) { case "OpenFile": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.O); break; case "NewFile": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.N); break; case "SaveFile": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.S); break; case "SaveFileAs": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.F); AgentManager.Instance.Keyboard.Send(Keys.A); break; case "CmdFind": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.H); break; case "DesktopSearch": AgentManager.Instance.Keyboard.Send(Keys.LWin, Keys.F); break; case "WindowsStartMenu": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Escape); break; case "PageUp": AgentManager.Instance.Keyboard.Send(Keys.PageUp); break; case "PageDown": AgentManager.Instance.Keyboard.Send(Keys.PageDown); break; case "Up": AgentManager.Instance.Keyboard.Send(Keys.Up); break; case "Down": AgentManager.Instance.Keyboard.Send(Keys.Down); break; case "Left": AgentManager.Instance.Keyboard.Send(Keys.Left); break; case "Right": AgentManager.Instance.Keyboard.Send(Keys.Right); break; case "CmdMouseScanner": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var panelArg = new PanelRequestEventArgs(PanelClasses.Mouse, monitorInfo) { UseCurrentScreenAsParent = true }; showPanel(this, panelArg); } break; case "CmdCursorScanner": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var panelArg = new PanelRequestEventArgs(PanelClasses.Cursor, monitorInfo) { UseCurrentScreenAsParent = true }; showPanel(this, panelArg); } break; default: handled = false; break; } }
/// <summary> /// Raises an event to request for displaying the specified /// scanner in 'arg'. /// </summary> /// <param name="sender">event source</param> /// <param name="arg">event arg</param> protected void showPanel(object sender, PanelRequestEventArgs arg) { if (EvtPanelRequest != null) { EvtPanelRequest.Invoke(this, arg); } }
/// <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() + ", menushown: " + _scannerShown); base.OnFocusChanged(monitorInfo, ref handled); if (!_scannerShown && _launchAppScanner != null) { var arg = new PanelRequestEventArgs(PanelClasses.AlphabetMinimal, monitorInfo) { TargetPanel = _launchAppScanner, RequestArg = _launchAppScanner, UseCurrentScreenAsParent = true }; showPanel(this, arg); _scannerShown = true; } handled = true; }
/// <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); Log.Debug("menuShown: " + _scannerShown + ", title: " + monitorInfo.Title); if (!_scannerShown && monitorInfo.Title == "Create New File") { var arg = new PanelRequestEventArgs("Alphabet", monitorInfo); _scannerShown = true; showPanel(this, arg); } handled = true; }
/// <summary> /// Displays the scanner that is appropriate for the element in focus /// </summary> /// <param name="monitorInfo">Foreground window info</param> /// <param name="handled">set to true if handled</param> private void autoDisplayScanner(WindowActivityMonitorInfo monitorInfo, ref bool handled) { handled = true; if (_explorerElements.IsFavoritesWindow(monitorInfo.FocusedElement) || _explorerElements.IsHistoryWindow(monitorInfo.FocusedElement) || _explorerElements.IsFeedsWindow(monitorInfo.FocusedElement)) { if (!_scannerType.HasFlag(ScannerType.Favorites)) { var args = new PanelRequestEventArgs(PanelClasses.MenuContextMenu, ScannerTitle, monitorInfo) { UseCurrentScreenAsParent = true }; showPanel(this, args); _scannerType = ScannerType.Favorites; } } else if (_explorerElements.IsSearchControl(monitorInfo.FocusedElement) || _explorerElements.IsFindControl(monitorInfo.FocusedElement) || _explorerElements.IsAddressWindow(monitorInfo.FocusedElement)) { if (!_scannerType.HasFlag(ScannerType.Address)) { showPanel(this, new PanelRequestEventArgs(PanelClasses.Alphabet, monitorInfo)); _scannerType = ScannerType.Address; } } else if (!_scannerType.HasFlag(ScannerType.Other)) { showPanel(this, new PanelRequestEventArgs("InternetExplorerContextMenu", ScannerTitle, monitorInfo)); _scannerType = ScannerType.Other; } }
/// <summary> /// Invoked to run a command /// </summary> /// <param name="command">The command to execute</param> /// <param name="commandArg">Optional arguments for the command</param> /// <param name="handled">set this to true if handled</param> public override void OnRunCommand(String command, object commandArg, ref bool handled) { handled = true; switch (command) { case "SwitchAppWindow": DialogUtils.ShowTaskSwitcher(ReaderProcessName); break; case "AcrobatZoomMenu": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var panelArg = new PanelRequestEventArgs("AcrobatReaderZoomMenu", "Acrobat", monitorInfo) { UseCurrentScreenAsParent = true }; showPanel(this, panelArg); } break; case "SaveFile": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.F); AgentManager.Instance.Keyboard.Send(Keys.A); break; case "CmdZoomIn": TextControlAgent.Pause(); AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Add); TextControlAgent.Resume(); break; case "CmdZoomOut": TextControlAgent.Pause(); AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Subtract); TextControlAgent.Resume(); break; case "CmdZoomFit": TextControlAgent.Pause(); AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D2); TextControlAgent.Resume(); break; case "CmdFind": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.F); break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }
/// <summary> /// Not used /// </summary> /// <param name="eventArg">event arguments</param> /// <returns>true always</returns> public bool OnQueryPanelChange(PanelRequestEventArgs eventArg) { return true; }
/// <summary> /// Invoked when the user selects something in the scanner that /// corresponds to a mapped functionality. For now we only /// support photo viewer. Extend this to support other /// functionalities /// </summary> /// <param name="command">the command</param> /// <param name="commandArg">any optional arguments</param> /// <param name="handled">was it handled?</param> public override void OnRunCommand(String command, object commandArg, ref bool handled) { handled = true; switch (command) { case "NextPhoto": Context.AppAgentMgr.Keyboard.Send(Keys.Right); break; case "PreviousPhoto": Context.AppAgentMgr.Keyboard.Send(Keys.Left); break; case "PhotoDelete": Context.AppAgentMgr.Keyboard.Send(Keys.Delete); break; case "PhotoViewerZoomMenu": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var panelArg = new PanelRequestEventArgs("PhotoViewerZoomMenu", PhotoViewerTitle, monitorInfo) { UseCurrentScreenAsParent = true }; showPanel(this, panelArg); } break; case "PhotoViewerRotateMenu": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var panelArg = new PanelRequestEventArgs("PhotoViewerRotateMenu", PhotoViewerTitle, monitorInfo) { UseCurrentScreenAsParent = true }; showPanel(this, panelArg); } break; case "CmdZoomIn": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Add); break; case "CmdZoomOut": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Subtract); break; case "CmdZoomFit": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D0); break; case "RotateRight": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.OemPeriod); break; case "RotateLeft": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Oemcomma); break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }