Inheritance: System.Windows.Forms.Form, IExtension, IPanel
示例#1
0
        /// <summary>
        /// Release resources
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void form_FormClosing(object sender, FormClosingEventArgs e)
        {
            Log.Debug("setting _menushown to false ");

            _menuShown      = false;
            _lectureMgrForm = null;
        }
示例#2
0
        /// <summary>
        /// Invoked when the Functional agent is activated.  This is
        /// the entry point.  Displays the lecture manager form and
        /// sets the file name to read from.
        /// </summary>
        /// <returns>true on success</returns>
        public override bool Activate()
        {
            IsClosing = false;

            _title = R.GetString("LectureMgr");

            _menuShown                = false;
            ExitCode                  = CompletionCode.None;
            _prevScannerPosition      = Context.AppWindowPosition;
            Context.AppWindowPosition = Windows.WindowPosition.TopRight;
            var form = new LectureManagerMainForm
            {
                LoadFromFile = this.LoadFromFile,
                LectureFile  = this.LectureFile,
                LectureText  = this.LectureText
            };

            form.FormClosing += form_FormClosing;

            _lectureMgrForm = form;

            IsActive = true;

            Windows.ShowForm(form);

            return(true);
        }
示例#3
0
        /// <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;
            }
        }
        /// <summary>
        /// Release resources
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void form_FormClosing(object sender, FormClosingEventArgs e)
        {
            Log.Debug("setting _menushown to false ");

            _menuShown = false;
            _lectureMgrForm = null;
        }
        /// <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(Resources.SpeakNow))
                    {
                        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(Resources.SetParagraphMode))
                        {
                            _lectureMgrForm.Mode = LectureManagerMainForm.SpeechMode.Paragraph;
                            closeCurrentPanel();
                        }
                    }

                    break;

                case "SpeechModeSentence":
                    if (isMainFormActive())
                    {
                        if (Confirm(Resources.SetSentenceMode))
                        {
                            _lectureMgrForm.Mode = LectureManagerMainForm.SpeechMode.Sentence;
                            closeCurrentPanel();
                        }
                    }

                    break;

                case "SpeechModeAll":
                    if (isMainFormActive())
                    {
                        if (Confirm(Resources.SetAll))
                        {
                            _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(Resources.SpeakingLeave))
                    {
                        closeCurrentPanel();
                        if (isMainFormActive())
                        {
                            _lectureMgrForm.StopIfSpeaking();
                        }
                    }

                    break;

                case "exitLectureManager":
                    if (Confirm(Resources.CloseLectureManager))
                    {
                        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;
            }
        }
        /// <summary>
        /// Invoked when the Functional agent is activated.  This is
        /// the entry point.  Displays the lecture manager form and 
        /// sets the file name to read from.
        /// </summary>
        /// <returns>true on success</returns>
        public override bool Activate()
        {
            _menuShown = false;
            ExitCode = CompletionCode.None;
            _prevScannerPosition = Context.AppWindowPosition;
            Context.AppWindowPosition = Windows.WindowPosition.TopRight;
            var form = new LectureManagerMainForm
            {
                LoadFromFile = this.LoadFromFile,
                LectureFile = this.LectureFile,
                LectureText = this.LectureText
            };

            form.FormClosing += form_FormClosing;

            _lectureMgrForm = form;
            Windows.ShowForm(form);

            return true;
        }