Example #1
0
        /// <summary>
        /// Closes the talk window.  Unsubscribe from events.  Set
        /// force to true to close the window even if it was not
        /// previously active
        /// </summary>
        /// <param name="force"></param>
        public void CloseTalkWindow(bool force = false)
        {
            if ((IsTalkWindowActive || force) && _talkWindow != null)
            {
                IsPaused = false;

                _fontSize = _talkWindow.FontSize;

                Log.Debug("_fontsize: " + _fontSize);

                IsTalkWindowActive = false;

                _zoomModeTalkWindowEmpty = false;

                TTSManager.Instance.ActiveEngine.Stop();

                PanelManagement.Glass.HideGlass();

                unsubscribeEvents();

                if (CoreGlobals.AppPreferences.RetainTalkWindowContentsOnHide)
                {
                    _talkWindowText = _talkWindow.TalkWindowText;
                }

                Windows.CloseForm(_talkWindowForm);

                _talkWindowForm = null;
                _talkWindow     = null;

                AuditLog.Audit(new AuditEventTalkWindow("close"));
            }
        }
Example #2
0
        /// <summary>
        /// Activates the functional agent.
        /// The caller should to an 'await'
        /// on this to wait for it to complete.  This is because some
        /// functional agents return data and the caller has to wait
        /// for the functional agent to exit so it can get the data. Eg
        /// FileBrowser agent that returns a filename
        /// </summary>
        /// <param name="agent"></param>
        /// <returns></returns>
        private async Task activateAgent(IFunctionalAgent agent)
        {
            var form = new Form {
                WindowState = FormWindowState.Minimized, Visible = false, ShowInTaskbar = false
            };

            form.Load += form_Load;
            form.Show();

            if (agent is FunctionalAgentBase)
            {
                var  funcAgent = (FunctionalAgentBase)agent;
                Task t         = Task.Factory.StartNew(() =>
                {
                    Log.Debug("Calling funcAgent.activate: " + agent.Name);
                    funcAgent.IsClosing   = false;
                    funcAgent.ExitCommand = null;
                    form.Invoke(new MethodInvoker(() => funcAgent.Activate()));

                    // This event is triggered by the functional agent when
                    // it exits
                    Log.Debug("Waiting on CloseEvent...: " + agent.Name);
                    funcAgent.CloseEvent.WaitOne();
                    Log.Debug("Returned from CloseEvent: " + agent.Name);
                });
                await t;
            }

            Windows.CloseForm(form);
        }
Example #3
0
        /// <summary>
        /// Handle quit by asking the user if there is a need
        /// to ask.  Close forms
        /// </summary>
        /// <param name="showPrompt">Should we prompt the user?</param>
        private void handleQuit(bool showPrompt = true)
        {
            bool confirmQuit = true;

            if (showPrompt)
            {
                confirmQuit = confirm(Resources.ExitWithoutCreating);
                if (confirmQuit)
                {
                    ExitCode = CompletionCode.None;
                }
            }

            if (confirmQuit)
            {
                if (_newFileNameForm != null)
                {
                    _newFileNameForm.EvtDone -= _newFileNameForm_EvtDone;
                    Windows.CloseForm(_newFileNameForm);
                }

                _fileChoiceMenu = null;
                _scannerShown   = false;
                CreateTextFile  = false;
                CreateWordDoc   = false;

                Close();
            }
        }
Example #4
0
        /// <summary>
        /// User pressed OK.  Check the pin is valid, and quit
        /// </summary>
        private void onOK()
        {
            var pin = Windows.GetText(tbPINCode).Trim();

            var errorMessage = String.Empty;
            var hasValidPin  = CheckPINCode(pin, Windows.GetText(svalMaxDigit)[0], ref errorMessage);

            if (hasValidPin == false)
            {
                DialogUtils.ShowTimedDialog(this, errorMessage);
                return;
            }

            if (DialogUtils.Confirm(this, "Your new PIN is " + pin + "\nSave changes?"))
            {
                var prefs = updateSettingsFromUI();
                if (prefs != null)
                {
                    prefs.Save();
                }

                isDirty = false;
                Common.AppPreferences.NotifyPreferencesChanged();
            }

            Windows.CloseForm(this);
        }
Example #5
0
 /// <summary>
 /// Thread proc to fade out the form
 /// </summary>
 private void fadeOutProc()
 {
     while (!_quit)
     {
         try
         {
             double opacity = Windows.GetOpacity(this);
             opacity -= 0.05;
             Windows.SetOpacity(this, opacity);
             if (opacity > 0.0)
             {
                 Thread.Sleep(50);
             }
             else
             {
                 Windows.CloseForm(this);
                 break;
             }
         }
         catch (Exception ex)
         {
             Log.Exception(ex);
         }
     }
 }
Example #6
0
        /// <summary>
        /// User pressed OK.  Check the pin is valid, and quit
        /// </summary>
        private void onOK()
        {
            var pin = Windows.GetText(tbPINCode).Trim();

            var errorMessage = String.Empty;
            var hasValidPin  = checkPINCode(pin, Windows.GetText(svalMaxDigit)[0], ref errorMessage);

            if (hasValidPin == false)
            {
                showTimedDialog(errorMessage);
                return;
            }

            var str    = R.GetString("NewPinSaveChanges").Replace("\\n", Environment.NewLine);
            var prompt = String.Format(str, pin);

            if (DialogUtils.Confirm(this, prompt))
            {
                var prefs = updateSettingsFromUI();
                if (prefs != null)
                {
                    prefs.Save();
                }

                _isDirty = false;
                Common.AppPreferences.NotifyPreferencesChanged();
            }

            Windows.CloseForm(this);
        }
Example #7
0
 /// <summary>
 /// Closes the abbreviations scanner
 /// </summary>
 private void closeScanner()
 {
     if (_abbrForm != null)
     {
         Windows.CloseForm(_abbrForm);
         _abbrForm = null;
     }
 }
Example #8
0
 /// <summary>
 /// Closes the file browser scanner
 /// </summary>
 private void closeScanner()
 {
     if (_fileBrowserScanner != null)
     {
         Windows.CloseForm(_fileBrowserScanner);
         _fileBrowserScanner = null;
     }
 }
Example #9
0
 /// <summary>
 /// Closes all the scanners
 /// </summary>
 private void closeScanner()
 {
     if (_volumeSettingsScanner != null)
     {
         Windows.CloseForm(_volumeSettingsScanner);
         _volumeSettingsScanner = null;
     }
 }
Example #10
0
 /// <summary>
 /// Closes the Phrases scanner
 /// </summary>
 private void closeScanner()
 {
     if (_phraseSpeakScanner != null)
     {
         Windows.CloseForm(_phraseSpeakScanner);
         _phraseSpeakScanner = null;
     }
 }
Example #11
0
 /// <summary>
 /// Closes the abbreviations scanner
 /// </summary>
 private void closeScanner()
 {
     if (_form != null)
     {
         Windows.CloseForm(_form);
         _form         = null;
         _scannerShown = false;
     }
 }
Example #12
0
 /// <summary>
 /// Invoked when the scanner is closed
 /// </summary>
 /// <param name="panelClass">name of scanner being closed</param>
 /// <param name="monitorInfo">foreground window info</param>
 public override void OnPanelClosed(String panelClass, WindowActivityMonitorInfo monitorInfo)
 {
     if (panelClass == PanelClasses.AlphabetMinimal)
     {
         if (_newFileNameForm != null)
         {
             Windows.CloseForm(_newFileNameForm);
         }
     }
 }
Example #13
0
        /// <summary>
        /// Closes the scanner that confirms whether the
        /// user wants to delete or edit an abbreviation
        /// </summary>
        private void closeEditDeleteConfirmScanner()
        {
            _editDeleteMenuShown = false;

            if (_editDeleteConfirmScanner != null)
            {
                Windows.CloseForm(_editDeleteConfirmScanner);
                _editDeleteConfirmScanner = null;
            }
        }
Example #14
0
 /// <summary>
 /// Closes the form
 /// </summary>
 private void closeDrawForm()
 {
     if (_drawForm != null)
     {
         _drawFormClosing = true;
         _drawForm.Paint -= formPaint;
         Windows.CloseForm(_drawForm);
         _drawForm = null;
     }
 }
Example #15
0
        /// <summary>
        /// Handler for when the abbr scanner is closing. Close
        /// the alphabet scanner as well
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event arg</param>
        private void _form_FormClosing(object sender, FormClosingEventArgs e)
        {
            _form.EvtDone             -= _form_EvtDone;
            _form.EvtAddAbbreviation  -= _form_EvtAddAbbreviation;
            _form.EvtEditAbbreviation -= _form_EvtEditAbbreviation;

            if (Context.AppPanelManager.GetCurrentPanel() != null)
            {
                Windows.CloseForm(Context.AppPanelManager.GetCurrentPanel() as Form);
            }
        }
Example #16
0
        /// <summary>
        /// User is done. Confirm, perform validation and check
        /// that everything is OK and then quit.
        /// </summary>
        private void finish()
        {
            var quit = !_isDirty || DialogUtils.Confirm(R.GetString("SaveAndQuit"));

            if (quit)
            {
                Cancel = false;
                updateAndSaveList();
                Windows.CloseForm(this);
            }
        }
Example #17
0
        /// <summary>
        /// Saves the settings and quits the dialog
        /// </summary>
        private void saveSettingsAndQuit()
        {
            if (_isDirty && DialogUtils.Confirm(this, R.GetString("SaveSettings")))
            {
                getSettingsFromUI().Save();

                _isDirty = false;
                Common.AppPreferences.NotifyPreferencesChanged();
            }

            Windows.CloseForm(this);
        }
Example #18
0
        /// <summary>
        /// Saves changes and closes the dialog
        /// </summary>
        private void saveSettingsAndQuit()
        {
            if (DialogUtils.Confirm(this, Resources.SaveSettings))
            {
                getAppPreferencesFromUI().Save();

                _isDirty = false;
                Common.AppPreferences.NotifyPreferencesChanged();
            }

            Windows.CloseForm(this);
        }
Example #19
0
        /// <summary>
        /// Save settings and close the dialog. Confirm with the user first
        /// </summary>
        private void saveSettingsAndQuit()
        {
            if (isDirty && DialogUtils.Confirm(this, "Save settings?"))
            {
                updateSettingsFromUI().Save();

                isDirty = false;
                Common.AppPreferences.NotifyPreferencesChanged();
            }

            Windows.CloseForm(this);
        }
Example #20
0
        /// <summary>
        /// User wants to cancel out of the dialog box
        /// </summary>
        private void cancel()
        {
            Log.Debug();

            if (DialogUtils.Confirm("Cancel and Quit?"))
            {
                Invoke(new MethodInvoker(delegate()
                {
                    Cancel = true;
                    Windows.CloseForm(this);
                }));
            }
        }