示例#1
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 /// <param name="monitorInfo">Active window info</param>
 /// <param name="widget">Scanner button that needs to be enabled/disabled</param>
 public CheckEnabledArgs(WindowActivityMonitorInfo monitorInfo, Widget widget)
 {
     Handled = false;
     Enabled = false;
     Widget = widget;
     MonitorInfo = monitorInfo;
 }
示例#2
0
        /// <summary>
        /// The animation sequence can contain wildcard names for the
        /// UI widgets or even references (such as @SelectedWidget for the
        /// currently selected widget).  Resolves all these referneces to their
        /// actual names and adds the actual widgets to the child list
        /// </summary>
        internal void ResolveUIWidgetsReferences(Widget rootWidget, Variables variables)
        {
            clearAnimationWidgetList();

            Log.Debug(rootWidget.Name + ". widgetXMLNodeList count: " + _widgetXMLNodeList.Count);

            foreach (XmlNode xmlNode in _widgetXMLNodeList)
            {
                resolveWildCardReferences(rootWidget, variables, xmlNode);
                resolveNonWildCardReferences(rootWidget, variables, xmlNode);
            }
        }
示例#3
0
 /// <summary>
 /// Stores widget objects from the form
 /// </summary>
 private void getWidgets()
 {
     _sortOrderWidget = _scannerCommon.GetRootWidget().Finder.FindChild("SortOrderIcon");
     _pageNumberWidget = _scannerCommon.GetRootWidget().Finder.FindChild("PageNumber");
     _sortButton = _scannerCommon.GetRootWidget().Finder.FindChild("ButtonSort");
 }
示例#4
0
 /// <summary>
 /// Not used
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="widget"></param>
 public void SetTargetControl(Form parent, Widget widget)
 {
 }
示例#5
0
文件: AboutBoxForm.cs 项目: glwu/acat
        /// <summary>
        /// Triggered when a widget is actuated.
        /// </summary>
        /// <param name="widget">Which one triggered?</param>
        public void OnButtonActuated(Widget widget)
        {
            var value = widget.Value;
            if (String.IsNullOrEmpty(value))
            {
                return;
            }

            Log.Debug("**Actuate** " + widget.Name + " Value: " + value);

            switch (value)
            {
                case "ok":
                    Windows.CloseForm(this);
                    break;
            }
        }
示例#6
0
        /// <summary>
        /// Event handler for when button is highlighted.
        /// Update tooltip
        /// </summary>
        /// <param name="widget">widget that was highlighted</param>
        /// <param name="handled">was it handled?</param>
        private void widget_EvtHighlightOn(Widget widget, out bool handled)
        {
            handled = false;
            var help = String.Empty;
            var buttonWidget = widget as IButtonWidget;
            if (buttonWidget != null)
            {
                help = buttonWidget.GetWidgetAttribute().ToolTip;
            }

            Windows.SetText(labelToolTip, help);
        }
示例#7
0
        /// <summary>
        /// Triggered when a widget is actuated.
        /// </summary>
        /// <param name="widget">Which one triggered?</param>
        public void OnButtonActuated(Widget widget)
        {
            Log.Debug("**Actuate** " + widget.UIControl.Name + " Value: " + widget.Value);

            var value = widget.Value;

            if (String.IsNullOrEmpty(value))
            {
                Log.Debug("OnButtonActuated() -- received actuation from empty widget!");
                return;
            }

            Invoke(new MethodInvoker(delegate()
            {
                switch (value)
                {
                    case "goBack":
                        onBack();
                        break;

                    case "ScannerZoomOut":
                        onZoomOut();
                        break;

                    case "ScannerZoomIn":
                        onZoomIn();
                        break;

                    case "ScannerRestoreDefaults":
                        onRestoreDefaults();
                        break;

                    case "ScannerMove":
                        onRepositionScanner();
                        break;

                    default:
                        Log.Debug("OnButtonActuated() -- unhandled widget actuation!");
                        break;
                }
            }));
        }
示例#8
0
 /// <summary>
 /// Called when the user clicks on a item that holds
 /// an abbreviation
 /// </summary>
 /// <param name="widget">widget</param>
 /// <param name="handled">true</param>
 public void OnWidgetActuated(Widget widget, ref bool handled)
 {
     if (widget is TabStopScannerButton)
     {
         handled = true;
     }
 }
示例#9
0
 /// <summary>
 /// Activates the button that was triggered by
 /// a switch actuator. 'command' is the character associated
 /// with the button. For eg, if 'command' is the letter 'a',
 /// the letter a will be sent to the application window
 /// </summary>
 /// <param name="widget">widget to activate</param>
 /// <param name="value">char associated with the button</param>
 public void ActuateButton(Widget widget, char value)
 {
     if (widget is IButtonWidget)
     {
         var button = (IButtonWidget)widget;
         actuateNormalKey(button.GetWidgetAttribute().Modifiers, value);
     }
 }
示例#10
0
        /// <summary>
        /// Create the widget manager. Load all the widgets
        /// from the config file
        /// </summary>
        /// <param name="configFileName">name of the animation file</param>
        /// <returns></returns>
        private bool initWidgetManager(String configFileName)
        {
            _widgetManager = new WidgetManager(ScannerForm);
            _widgetManager.Layout.SetColorScheme(ColorSchemes.ScannerSchemeName);
            _widgetManager.Layout.SetDisabledButtonColorScheme(ColorSchemes.DisabledScannerButtonSchemeName);
            bool retVal = _widgetManager.Initialize(configFileName);
            if (!retVal)
            {
                Log.Error("Unable to initialize widget manager");
            }
            else
            {
                _rootWidget = _widgetManager.RootWidget;
                if (String.IsNullOrEmpty(_rootWidget.SubClass))
                {
                    _rootWidget.SubClass = (ScannerForm is ContextualMenuBase) ?
                                            PanelClasses.PanelCategory.ContextualMenu.ToString() :
                                            PanelClasses.PanelCategory.Scanner.ToString();
                }
            }

            return retVal;
        }
 /// <summary>
 /// Triggered when the user actuates a widget
 /// </summary>
 /// <param name="widget">widget actuated</param>
 /// <param name="handled">was this handled?</param>
 public void OnWidgetActuated(Widget widget, ref bool handled)
 {
     switch (widget.Value)
     {
         case "@Phrase1":
         case "@Phrase2":
         case "@Phrase3":
         case "@Phrase4":
         case "@Phrase5":
         case "@Phrase6":
         case "@Phrase7":
         case "@Phrase8":
         case "@Phrase9":
             handled = true;
             String text = widget.GetText().Trim();
             if (!String.IsNullOrEmpty(text))
             {
                 Context.AppTTSManager.ActiveEngine.Speak(text);
             }
             break;
     }
     _alphabetScannerCommon.OnWidgetActuated(widget, ref handled);
 }
示例#12
0
        /// <summary>
        /// Resolves all widgets with wild card references (ends with an asterisk).
        /// The format for a wild card reference is <widgetname>/* where widgnetname
        /// is the parent widget and * represents all its children
        /// Eg.  Box1/* would resolve to Row1, Row2, Row3 and Row4
        /// </summary>
        /// <param name="rootWidget">The root widget of the scanner</param>
        /// <param name="variables">variable references to resolve</param>
        /// <param name="xmlNode">the xmlNode to parse</param>
        private void resolveWildCardReferences(Widget rootWidget, Variables variables, XmlNode xmlNode)
        {
            var name = XmlUtils.GetXMLAttrString(xmlNode, "name");

            if (name.Contains("*"))
            {
                Log.Debug("name=" + name);

                var containerWidget = getContainerWidget(rootWidget, variables, name);
                if (containerWidget != null)
                {
                    Log.Debug("containerWidget: " + containerWidget.Name);

                    if (EvtResolveWidgetChildren != null)
                    {
                        EvtResolveWidgetChildren(this, new ResolveWidgetChildrenEventArgs(rootWidget, containerWidget, xmlNode));
                    }

                    foreach (var childWidget in containerWidget.Children)
                    {
                        Log.Debug("Found child name : " + childWidget.Name);
                        var animationWidget = createAndAddAnimationWidget(childWidget);
                        if (animationWidget != null)
                        {
                            animationWidget.Load(xmlNode);
                        }
                    }
                }
            }
        }
示例#13
0
        /// <summary>
        /// Resolves non-wild card entries to their acutal names.  For instance,
        /// a @SelectedWidget would get resolved to the name of the widget that
        /// is currently selected
        /// </summary>
        /// <param name="rootWidget">The root widget of the scanner</param>
        /// <param name="variables">variable references to resolve</param>
        /// <param name="xmlNode">the xmlNode to parse</param>
        private void resolveNonWildCardReferences(Widget rootWidget, Variables variables, XmlNode xmlNode)
        {
            var name = XmlUtils.GetXMLAttrString(xmlNode, "name");

            Log.Debug("name=" + name);
            if (!String.IsNullOrEmpty(name) && !name.Contains("*"))
            {
                var widgetName = resolveName(variables, name);
                Log.Debug("Resolved name : " + widgetName);

                var uiWidget = rootWidget.Finder.FindChild(widgetName);
                if (uiWidget != null)
                {
                    Log.Debug("Found child name : " + widgetName);
                    var animationWidget = createAndAddAnimationWidget(uiWidget);
                    if (animationWidget != null)
                    {
                        animationWidget.Load(xmlNode);
                    }
                }
                else
                {
                    Log.Debug("Did not find child " + widgetName);
                }
            }

            return;
        }
示例#14
0
        /// <summary>
        /// Wild card names can be @variablename/* or widgetname/*. Parses
        /// the string and returns the name of the container widget
        /// </summary>
        /// <param name="rootWidget">root widget of the scanner</param>
        /// <param name="wildCard">wildcard to resolve</param>
        /// <returns>container widget</returns>
        private Widget getContainerWidget(Widget rootWidget, Variables variables, string wildCard)
        {
            Widget retVal = null;
            String[] wildCardPatterns =
            {
                "\\@[a-zA-Z0-9]*/\\*",      // @variablename/*
                "[a-zA-Z0-9]*/\\*",         // widgename/*"
                "\\*"                       // *
            };

            String[] extractPatterns =
            {
                "\\@[a-zA-Z0-9]*",
                "[a-zA-Z0-9]*",
                "\\*"
            };

            bool done = false;
            for (int ii = 0; !done && ii < wildCardPatterns.Length; ii++)
            {
                if (!Regex.IsMatch(wildCard, wildCardPatterns[ii]))
                {
                    continue;
                }

                Match match = Regex.Match(wildCard, extractPatterns[ii]);
                if (String.IsNullOrEmpty(match.Value))
                {
                    continue;
                }

                done = true;
                String widgetName;
                switch (ii)
                {
                    case 0:
                        widgetName = match.Value.Substring(1);
                        if (String.Compare(widgetName, Variables.SelectedWidget) == 0)
                        {
                            retVal = (Widget)variables.Get(Variables.SelectedWidget);
                        }

                        break;

                    case 1:
                        widgetName = match.Value;
                        if (String.Compare(widgetName, rootWidget.Name, true) == 0)
                        {
                            retVal = rootWidget;
                        }
                        else
                        {
                            retVal = rootWidget.Finder.FindChild(widgetName);
                        }

                        break;

                    case 2:
                        retVal = (Widget)variables.Get(Variables.SelectedWidget);
                        break;
                }
            }

            return retVal;
        }
示例#15
0
        /// <summary>
        /// Creates and adds an animation widget entry that will contain the
        /// specified ui widget.  UI widget represents a windows control
        /// such as a button in the scanner.  Raises an event that the
        /// widget was added
        /// </summary>
        /// <param name="uiWidget">the ui widget</param>
        /// <returns>animation widget</returns>
        private AnimationWidget createAndAddAnimationWidget(Widget uiWidget)
        {
            var retVal = new AnimationWidget { UIWidget = uiWidget };
            AnimationWidgetList.Add(retVal);
            if (EvtAnimationWidgetAdded != null)
            {
                EvtAnimationWidgetAdded(this, new AnimationWidgetAddedEventArgs(retVal));
            }

            return retVal;
        }
示例#16
0
        /// <summary>
        /// Triggered when a widget is triggered
        /// </summary>
        /// <param name="widget">Which one triggered?</param>
        public void OnButtonActuated(Widget widget)
        {
            Log.Debug("**Actuate** " + widget.UIControl.Name + " Value: " + widget.Value);

            var value = widget.Value;

            if (String.IsNullOrEmpty(value))
            {
                Log.Debug("received actuation from empty widget!");
                return;
            }

            Invoke(new MethodInvoker(delegate()
            {
                switch (value)
                {
                    case "valButtonOK":
                        onOK();
                        break;

                    case "valButtonCancel":
                        onCancel();
                        break;

                    default:
                        Log.Warn("unhandled widget actuation! value=" + value);
                        break;
                }
            }));
        }
示例#17
0
        /// <summary>
        /// Triggered when a widget is actuated.
        /// </summary>
        /// <param name="widget">Which one triggered?</param>
        ///
        public void OnButtonActuated(Widget widget)
        {
            Log.Debug("**Actuate** " + widget.Name + " Value: " + widget.Value);

            var value = widget.Value;
            if (String.IsNullOrEmpty(value))
            {
                return;
            }

            Invoke(new MethodInvoker(delegate()
            {
                switch (value)
                {
                    case "valButtonBack":
                        quit();
                        break;

                    case "valButtonSave":
                        saveSettingsAndQuit();
                        break;

                    case "valButtonRestoreDefaults":
                        loadDefaultSettings();
                        break;
                }
            }));
        }
示例#18
0
        /// <summary>
        /// User actuated a button on the form.  Handle the event.
        /// </summary>
        /// <param name="widget">Widget to acutate</param>
        private void actuateButton(Widget widget)
        {
            ActuatedWidget = null;

            if (widget is WordListItemWidget)
            {
                return;
            }

            if (String.IsNullOrEmpty(widget.Value) || !(widget is IButtonWidget))
            {
                return;
            }

            var button = (IButtonWidget)widget;

            ActuatedWidget = widget;

            // If the first letter of text is '@', this is a special key.
            if (widget.Value[0] != '@')
            {
                actuateNormalKey(button.GetWidgetAttribute().Modifiers, widget.Value[0]);
            }
            else
            {
                actuateSpecialKey(button.GetWidgetAttribute().Modifiers, widget.Value, button.GetWidgetAttribute().IsVirtualKey);
            }

            ActuatedWidget = null;
        }
示例#19
0
        /// <summary>
        /// Initilaze. Load the abbreviations, populate list and
        /// dock the form to the active scanner
        /// </summary>
        private void AbbreviationsScanner_Load(object sender, EventArgs e)
        {
            enableWatchdogs();

            _scannerCommon.OnLoad();

            var list = new List<Widget>();
            _scannerCommon.GetRootWidget().Finder.FindChild(typeof(TabStopScannerButton), list);

            foreach (var widget in list)
            {
                widget.EvtMouseClicked += widget_EvtMouseClicked;
            }

            _sortOrderWidget = _scannerCommon.GetRootWidget().Finder.FindChild("SortOrderIcon");
            _pageNumberWidget = _scannerCommon.GetRootWidget().Finder.FindChild("PageNumber");

            SearchFilter.TextChanged += SearchFilter_TextChanged;
            SortOrderIcon.Click += SortOrderIcon_Click;
            Shown += AbbreviationsScanner_Shown;

            LoadAbbreviations();

            highlightOff();

            var panel = PanelManager.Instance.GetCurrentPanel();
            if (panel != null)
            {
                dockToScanner(panel as Form);
            }
        }
示例#20
0
        /// <summary>
        /// Call this in the Initialize function of the Alphabet scanner
        /// </summary>
        /// <param name="startupArg">startup arguments</param>
        /// <returns>true on success</returns>
        public bool Initialize(StartupArg startupArg)
        {
            PanelClass = startupArg.PanelClass;

            _scannerCommon = new ScannerCommon(_scannerPanel);
            _scannerHelper = new ScannerHelper(_scannerPanel, startupArg);

            if (!_scannerCommon.Initialize(startupArg))
            {
                Log.Debug("Could not initialize form " + _form.Name);
                return false;
            }

            _rootWidget = _scannerCommon.GetRootWidget();

            return true;
        }
示例#21
0
 /// <summary>
 /// Handler for highlight off. Update the tooltip
 /// </summary>
 /// <param name="widget">Widget</param>
 /// <param name="handled">was it handled</param>
 private void widget_EvtHighlightOff(Widget widget, out bool handled)
 {
     handled = false;
     Windows.SetText(labelToolTip, String.Empty);
 }
示例#22
0
        /// <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;
            }
        }
示例#23
0
        /// <summary>
        /// Called when a widget on the scanner is activated
        /// </summary>
        /// <param name="widget">widget activated</param>
        /// <param name="handled">true if handled</param>
        public override void OnWidgetActuated(Widget widget, ref bool handled)
        {
            handled = true;
            switch (widget.Value)
            {
                case "@TextFile":
                    Choice = "TextFile";
                    DialogResult = DialogResult.OK;
                    break;

                case "@WordDoc":
                    Choice = "WordDoc";
                    DialogResult = DialogResult.OK;
                    break;

                case "@exitFileTypeMenu":
                    Choice = String.Empty;
                    DialogResult = DialogResult.Cancel;
                    break;
            }
        }
示例#24
0
        /// <summary>
        /// Initialize the class
        /// </summary>
        /// <param name="arg">startup arg</param>
        /// <returns>true on success</returns>
        public bool Initialize(StartupArg arg)
        {
            Log.Debug();

            PanelClass = arg.PanelClass;
            startupCommandArg = arg.Arg;
            startupArg = arg;

            _scannerHelper = new ScannerHelper(this, startupArg);
            scannerCommon = new ScannerCommon(this);

            if (!scannerCommon.Initialize(startupArg))
            {
                Log.Debug("Could not initialize form " + Name);
                return false;
            }

            rootWidget = scannerCommon.GetRootWidget();
            return true;
        }
示例#25
0
 /// <summary>
 /// Called when widget is actuated
 /// </summary>
 /// <param name="widget">which one</param>
 /// <param name="handled">are we handling it?</param>
 public void OnWidgetActuated(Widget widget, ref bool handled)
 {
     actuateWidget(widget, ref handled);
 }
示例#26
0
 /// <summary>
 /// Invoked when a widget is actuated
 /// </summary>
 /// <param name="widget">widget</param>
 /// <param name="handled">was this handled</param>
 public virtual void OnWidgetActuated(Widget widget, ref bool handled)
 {
     handled = false;
 }
示例#27
0
 /// <summary>
 /// Find the widget that was actuated and act on it
 /// </summary>
 /// <param name="widgetName">name of the widget</param>
 private void actuateWidget(Widget widget, ref bool handled)
 {
     handleWidgetSelection(widget, ref handled);
     highlightOff();
 }
示例#28
0
 /// <summary>
 /// Triggered when the user actuates a widget
 /// </summary>
 /// <param name="widget">widget actuated</param>
 /// <param name="handled">was this handled?</param>
 public void OnWidgetActuated(Widget widget, ref bool handled)
 {
     _alphabetScannerCommon.OnWidgetActuated(widget, ref handled);
 }
示例#29
0
        /// <summary>
        /// Handle the selection - navigate, launch app etc
        /// </summary>
        /// <param name="itemTag">item tag of selected item</param>
        private void handleWidgetSelection(Widget widget, ref bool handled)
        {
            if (widget.UserData is AppInfo)
            {
                handleAppSelect((AppInfo)widget.UserData);
                handled = true;
            }
            else
            {
                handled = true;
                switch (widget.Value)
                {
                    case "@Quit":
                        if (EvtQuit != null)
                        {
                            EvtQuit.BeginInvoke(null, null, null, null);
                        }
                        break;

                    case "@AppListSort":
                        switchSortOrder();
                        break;

                    case "@AppListNextPage":
                        gotoNextPage();
                        break;

                    case "@AppListPrevPage":
                        gotoPreviousPage();
                        break;

                    case "@AppListSearch":
                        if (EvtShowScanner != null)
                        {
                            EvtShowScanner.BeginInvoke(null, null, null, null);
                        }
                        break;

                    case "@AppListClearFilter":
                        ClearFilter();
                        break;

                    default:
                        handled = false;
                        break;
                }
            }
        }
示例#30
0
        /// <summary>
        /// Triggered when a widget is actuated.
        /// </summary>
        /// <param name="widget">Which one triggered?</param>
        public void OnButtonActuated(Widget widget)
        {
            bool quit = false;

            Log.Debug();

            Invoke(new MethodInvoker(delegate()
            {
                switch (widget.Name)
                {
                    case "B1":
                        textBoxEntry.Text = textBoxEntry.Text + widget.Value;
                        break;

                    case "B2":
                        textBoxEntry.Text = textBoxEntry.Text + widget.Value;
                        break;

                    case "B3":
                        textBoxEntry.Text = textBoxEntry.Text + widget.Value;
                        break;

                    case "B4":
                        textBoxEntry.Text = textBoxEntry.Text + widget.Value;
                        break;

                    case "buttonBackspace": // delete last letter
                        if (textBoxEntry.Text.Length == 1)
                        {
                            textBoxEntry.Text = string.Empty;
                        }
                        else if (textBoxEntry.Text.Length > 1)
                        {
                            textBoxEntry.Text = textBoxEntry.Text.Substring(0, textBoxEntry.Text.Length - 1);
                        }

                        break;

                    case "buttonReset":
                        clearTextBox();
                        break;

                    case "buttonExit":
                        quit = true;
                        break;
                }

                if (quit)
                {
                    if (DialogUtils.Confirm("Exit?"))
                    {
                        Context.AppQuit = true;
                        Windows.CloseForm(this);
                    }
                }
            }));
        }