/// <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() && Confirm("Speak now?"))
{
var panel = (_lectureMgrForm.Mode == LectureManagerMainForm.SpeechMode.All) ?
SpeakAllMenu :
SpeakMenu;
showPanel(this, new PanelRequestEventArgs(
panel,
Title,
WindowActivityMonitor.GetForegroundWindowInfo(), true));
}
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("Close 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":
showPanel(this, new PanelRequestEventArgs("LectureManagerToggleModeMenu",
Title,
WindowActivityMonitor.GetForegroundWindowInfo(),
true));
break;
case "NavigateMenu":
showPanel(this, new PanelRequestEventArgs("LectureManagerNavigationMenu",
Title,
WindowActivityMonitor.GetForegroundWindowInfo(),
true));
break;
default:
base.OnRunCommand(command, commandArg, ref handled);
break;
}
}