/// <summary>
        /// Triggered when a widget is actuated. Call this in the OnWidgetActuated
        /// function in the Alphabet scanner.
        /// </summary>
        /// <param name="widget">widget that was actuated</param>
        /// <param name="handled">set to true if handled</param>
        public virtual void OnWidgetActuated(Widget widget, ref bool handled)
        {
            if (widget is WordListItemWidget)
            {
                _form.Invoke(new MethodInvoker(delegate
                {
                    Log.Debug("wordListItemName : " + widget.Name);
                    var item = widget as WordListItemWidget;
                    Log.Debug("Value: " + item.Value);
                    var wordSelected = item.Value.Trim();

                    if (!String.IsNullOrEmpty(wordSelected))
                    {
                        KeyStateTracker.ClearAlt();
                        KeyStateTracker.ClearCtrl();

                        _scannerCommon.AutoCompleteWord(wordSelected);
                        AuditLog.Audit(new AuditEventAutoComplete(widget.Name));
                    }
                }));
                handled = true;
            }
            else
            {
                handled = false;
            }
        }
Esempio n. 2
0
        private void autoComplete(WordListItemWidget wordListWidget)
        {
            Log.Debug("wordListItemName : " + wordListWidget.Name + ", value: " + wordListWidget.Value);

            var wordSelected = wordListWidget.Value.Trim();

            if (!String.IsNullOrEmpty(wordSelected))
            {
                KeyStateTracker.ClearAlt();
                KeyStateTracker.ClearCtrl();

                _scannerCommon.AutoCompleteWord(wordSelected);
                AuditLog.Audit(new AuditEventAutoComplete(wordListWidget.Name));
            }
        }
Esempio n. 3
0
            /// <summary>
            /// Executes the command
            /// </summary>
            /// <param name="handled">true if handled</param>
            /// <returns>true on success</returns>
            public override bool Execute(ref bool handled)
            {
                var form = Dispatcher.Scanner.Form as PunctuationsScanner;

                switch (Command)
                {
                case "1":
                case "2":
                case "3":
                case "4":
                case "5":
                case "6":
                case "7":
                case "8":
                case "9":
                case "0":
                    if (KeyStateTracker.IsFuncOn())
                    {
                        sendFunctionKey("F" + Command);

                        KeyStateTracker.ClearFunc();
                        KeyStateTracker.ClearShift();
                        KeyStateTracker.ClearAlt();
                        KeyStateTracker.ClearCtrl();
                    }
                    else
                    {
                        if (form._scannerCommon.ActuatedWidget != null)
                        {
                            form._scannerCommon.ActuateButton(form._scannerCommon.ActuatedWidget, Command[0]);
                        }
                    }

                    handled = true;
                    break;

                default:
                    handled = false;
                    break;
                }

                return(true);
            }
Esempio n. 4
0
        /// <summary>
        /// Handles actuation of a button representation a punctuation
        /// </summary>
        /// <param name="modifiers">Any modfiers (shift, alt, ctrl)</param>
        /// <param name="punctuation">the punctuation</param>
        /// <returns>true on success</returns>
        public bool HandlePunctuation(ArrayList modifiers, char punctuation)
        {
            Log.Debug();

            try
            {
                if (!isPunctuation(punctuation))
                {
                    return(false);
                }

                // turn off extended keys such as alt, ctrl.  This causes problems when space
                // is inserted after puncuation and alt+space causes the system menu to show up.

                KeyStateTracker.ClearAlt();
                KeyStateTracker.ClearCtrl();
                KeyStateTracker.ClearFunc();

                using (AgentContext context = Context.AppAgentMgr.ActiveContext())
                {
                    int offset;
                    int count;

                    // delete any spaces before the punctuation
                    context.TextAgent().GetPrecedingWhiteSpaces(out offset, out count);
                    Log.Debug("Preceding whitespace count: " + count);
                    if (count > 0)
                    {
                        Log.Debug("Deleting whitespaces from offset " + offset);
                        context.TextAgent().Delete(offset, count);
                    }

                    Log.Debug("Sending punctuation");
                    Context.AppAgentMgr.Keyboard.Send((modifiers != null) ? modifiers.Cast <Keys>().ToList() : KeyStateTracker.GetExtendedKeys(), punctuation);

                    // if this is a sentence terminator, add spaces
                    // after the punctuation.

                    if ("})]".LastIndexOf(punctuation) >= 0)
                    {
                        Context.AppAgentMgr.Keyboard.Send(KeyStateTracker.GetExtendedKeys(), ' ');
                    }
                    else if (TextUtils.IsTerminator(punctuation))
                    {
                        for (int ii = 0; ii < CoreGlobals.AppPreferences.SpacesAfterPunctuation; ii++)
                        {
                            Context.AppAgentMgr.Keyboard.Send(KeyStateTracker.GetExtendedKeys(), ' ');
                        }
                    }

                    // this is important.  The ACAT talk window caretpos doesn't update until this we exit
                    // this function.  DoEvents give a chance to the talk window to update its caret position.
                    //Application.DoEvents();

                    _autoCompleteCaretPos = context.TextAgent().GetCaretPos();
                    Log.Debug("after actuating, caretpos is " + _autoCompleteCaretPos);

                    KeyStateTracker.KeyTriggered(punctuation);

                    _lastAction = LastAction.Punctuation;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }

            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// Handles actuation of a button representation a punctuation
        /// </summary>
        /// <param name="modifiers">Any modfiers (shift, alt, ctrl)</param>
        /// <param name="punctuation">the punctuation</param>
        /// <returns>true on success</returns>
        public bool HandlePunctuation(ArrayList modifiers, char punctuation)
        {
            Log.Debug();

            try
            {
                Context.AppAgentMgr.TextChangedNotifications.Hold();

                if (!ResourceUtils.LanguageSettings().IsInsertSpaceAfterChar(punctuation) &&
                    !ResourceUtils.LanguageSettings().IsDeletePrecedingSpacesChar(punctuation))
                {
                    return(false);
                }

                // turn off extended keys such as alt, ctrl.  This causes problems when space
                // is inserted after puncuation and alt+space causes the system menu to show up.

                KeyStateTracker.ClearAlt();
                KeyStateTracker.ClearCtrl();

                using (AgentContext context = Context.AppAgentMgr.ActiveContext())
                {
                    if (!context.TextAgent().EnableSmartPunctuations())
                    {
                        Context.AppAgentMgr.Keyboard.Send((modifiers != null) ?
                                                          modifiers.Cast <Keys>().ToList() :
                                                          KeyStateTracker.GetExtendedKeys(),
                                                          punctuation);
                        _lastAction = LastAction.AlphaNumeric;
                        return(true);
                    }

                    if (ResourceUtils.LanguageSettings().IsDeletePrecedingSpacesChar(punctuation))
                    {
                        // delete any spaces before the punctuation
                        int offset;
                        int count;
                        context.TextAgent().GetPrecedingWhiteSpaces(out offset, out count);
                        Log.Debug("Preceding whitespace count: " + count);
                        if (count > 0)
                        {
                            Log.Debug("Deleting whitespaces from offset " + offset);
                            context.TextAgent().Delete(offset, count);
                        }
                    }

                    Log.Debug("Sending punctuation");
                    Context.AppAgentMgr.Keyboard.Send((modifiers != null) ?
                                                      modifiers.Cast <Keys>().ToList() :
                                                      KeyStateTracker.GetExtendedKeys(), punctuation);

                    if (ResourceUtils.LanguageSettings().IsInsertSpaceAfterChar(punctuation))
                    {
                        Context.AppAgentMgr.Keyboard.Send(KeyStateTracker.GetExtendedKeys(), ' ');
                    }

                    _autoCompleteCaretPos = context.TextAgent().GetCaretPos();

                    Log.Debug("after actuating, caretpos is " + _autoCompleteCaretPos);

                    KeyStateTracker.KeyTriggered(punctuation);

                    _lastAction = LastAction.Punctuation;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            finally
            {
                Context.AppAgentMgr.TextChangedNotifications.Release();
            }

            return(true);
        }