/// <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 "SaveFile": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.S); //DialogUtils.Toast("Saved"); break; case "CmdFind": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.F); break; case "NotepadLectureManager": if (TextControlAgent != null) { String text = TextControlAgent.GetText(); if (String.IsNullOrEmpty(text.Trim())) { DialogUtils.ShowTimedDialog(PanelManager.Instance.GetCurrentPanel() as Form, R.GetString("LectureManager"), R.GetString("DocumentIsEmpty")); break; } if (DialogUtils.ConfirmScanner(R.GetString("LoadThisDocIntoLM"))) { #pragma warning disable 4014 launchLectureManager(); #pragma warning restore 4014 } } break; case "SwitchAppWindow": DialogUtils.ShowTaskSwitcher(_notepadProcessName); break; case "CmdSnapMaxDockWindowToggle": if (snapWindowDockAlphabetScanner) { Windows.ToggleForegroundWindowMaximizeDock(Context.AppPanelManager.GetCurrentForm() as Form, Context.AppWindowPosition, true); } else { Windows.ToggleSnapForegroundWindow(Context.AppWindowPosition, Common.AppPreferences.WindowSnapSizePercent); } break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }
/// <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 "FoxitZoomMenu": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var panelArg = new PanelRequestEventArgs("FoxitReaderZoomMenu", "Foxit", 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> /// 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 "SaveFile": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.S); //DialogUtils.Toast("Saved"); break; case "CmdFind": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.F); break; case "NotepadLectureManager": if (TextControlAgent != null) { String text = TextControlAgent.GetText(); if (String.IsNullOrEmpty(text.Trim())) { DialogUtils.ShowTimedDialog(PanelManager.Instance.GetCurrentPanel() as Form, R.GetString("LectureManager"), R.GetString("DocumentIsEmpty")); break; } if (DialogUtils.ConfirmScanner(R.GetString("LoadThisDocIntoLM"))) { #pragma warning disable 4014 launchLectureManager(); #pragma warning restore 4014 } } break; case "SwitchAppWindow": DialogUtils.ShowTaskSwitcher(_notepadProcessName); break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }
/// <summary> /// Launches lecture manager with text from the wordpad window. This /// function returns only after lecture manager has exited /// </summary> /// <returns>task</returns> private async Task launchLectureManager() { IApplicationAgent agent = Context.AppAgentMgr.GetAgentByCategory("LectureManagerAgent"); if (agent != null) { IExtension extension = agent; extension.GetInvoker().SetValue("LoadFromFile", false); String fileName = getFileNameFromWindow(); if (!String.IsNullOrEmpty(fileName)) { extension.GetInvoker().SetValue("LectureFile", fileName); } extension.GetInvoker().SetValue("LectureText", TextControlAgent.GetText()); await Context.AppAgentMgr.ActivateAgent(agent as IFunctionalAgent); } }
/// <summary> /// Invoked to set the 'enabled' state of a widget. This /// will depend on the current context. /// </summary> /// <param name="arg">contains info about the widget</param> public override void CheckWidgetEnabled(CheckEnabledArgs arg) { arg.Handled = true; switch (arg.Widget.SubClass) { case "ShowWindowPosSizeMenu": arg.Enabled = !Context.AppTalkWindowManager.IsTalkWindowVisible; arg.Handled = true; break; case "ClearTalkWindowText": arg.Enabled = !Context.AppTalkWindowManager.IsTalkWindowEmpty(); break; case "ContextualMenu": arg.Enabled = true; break; case "SpeechControl": if (_ttsEngineSupportsSpeechControl) { String word; TextControlAgent.GetWordAtCaret(out word); object ret = Context.AppTTSManager.ActiveEngine.GetInvoker().InvokeExtensionMethod("IsValidSpeechControlSequence", word); if (ret is bool) { arg.Enabled = (bool)ret; } } break; case "QuickSearch": case "GoogleSearch": case "WikiSearch": arg.Enabled = !String.IsNullOrEmpty(getTalkWindowSelectedTextOrPara().Trim()); break; default: arg.Handled = false; break; } }
/// <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(WordPadProcessName); break; case "WordPadLectureManager": if (TextControlAgent != null) { String text = TextControlAgent.GetText(); if (String.IsNullOrEmpty(text.Trim())) { DialogUtils.ShowTimedDialog(PanelManager.Instance.GetCurrentPanel() as Form, "Lecture Manager", "Document is empty"); break; } if (DialogUtils.ConfirmScanner("Load this document into Lecture Manager?")) { #pragma warning disable 4014 launchLectureManager(); #pragma warning restore 4014 } } break; case "CmdParitalMaximizeWindow": Windows.SetForegroundWindowSizePercent(Context.AppWindowPosition, Common.AppPreferences.WindowMaximizeSizePercent); break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }
/// <summary> /// Returns text from the notepad window /// </summary> /// <returns></returns> private String getNotepadText() { var retVal = TextControlAgent.GetText(); return(Regex.Replace(retVal, "\r\r\n", "")); }
/// <summary> /// Addes text from the WordPad window to the word prediction context /// </summary> private void addWordPredictionContext() { _wordPredictionContext = Context.AppWordPredictionManager.ActiveWordPredictor.LoadContext(TextControlAgent.GetText()); }
/// <summary> /// Executes the specified 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(ChromeProcessName); break; case "ChromeAddressBar": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.L); break; case "ChromeZoomMenu": { var monitorInfo = WindowActivityMonitor.GetForegroundWindowInfo(); var panelArg = new PanelRequestEventArgs("ChromeBrowserZoomMenu", "Chrome", 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.D0); TextControlAgent.Resume(); break; case "CmdFind": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.F); break; case "ChromeGoBackward": AgentManager.Instance.Keyboard.Send(Keys.BrowserBack); break; case "ChromeGoForward": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.Right); break; case "NewTab": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.T); break; case "NextTab": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Tab); break; case "CloseTab": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.W); break; case "ChromeFavorites": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.LShiftKey, Keys.O); break; case "ChromeHistory": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.H); break; case "ChromeAddFavorites": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D); break; case "ChromeRefreshPage": AgentManager.Instance.Keyboard.Send(Keys.BrowserRefresh); break; case "ChromeHomePage": AgentManager.Instance.Keyboard.Send(Keys.BrowserHome); break; case "ChromeBrowserMenu": showPanel(this, new PanelRequestEventArgs("ChromeBrowserMenu", "Chrome", WindowActivityMonitor.GetForegroundWindowInfo(), true)); break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }