Ejemplo n.º 1
0
        public static void TabSelect(IntPtr controlHandle, int index)
        {
            try
            {
                AutomationElement           control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
                AutomationElementCollection aec     = SelectionItemPatternHelper.GetListItems(control);

                /* When using the GetListItems() methods, item index 0 is the tab control itself, so add on to get to correct TabItem */
                if (index >= int.MaxValue)
                {
                    throw new ProdOperationException("input must be less than Int32.MaxValue");
                }

                int    adjustedIndex = index + 1;
                string itemText      = aec[adjustedIndex].Current.Name;

                StaticEvents.RegisterEvent(SelectionItemPattern.ElementSelectedEvent, control);
                SelectionItemPatternHelper.SelectItem(SelectionItemPatternHelper.FindItemByText(control, itemText));

                LogController.ReceiveLogMessage(new LogMessage(control.Current.Name));
            }
            catch (InvalidOperationException)
            {
                /* Call native function */
                ProdTabNative.SetSelectedTab(controlHandle, index);
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ArgumentException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
Ejemplo n.º 2
0
        public static void SetSelectedItem(IntPtr controlHandle, string itemText)
        {
            try
            {
                AutomationElement control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
                StaticEvents.RegisterEvent(SelectionItemPattern.ElementSelectedEvent, control);

                AutomationElement indexedItem = SelectionItemPatternHelper.FindItemByText(control, itemText);
                SelectionItemPatternHelper.SelectItem(indexedItem);

                LogController.ReceiveLogMessage(new LogMessage(itemText));
            }
            catch (InvalidOperationException)
            {
                ProdListBoxNative.SelectItemNative(controlHandle, itemText);
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ArgumentException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
        private static void UiaSetSelectedItem(BaseProdControl control, string itemText)
        {
            LogController.ReceiveLogMessage(new LogMessage("Selecting " + itemText));

            AutomationEventVerifier.Register(new EventRegistrationMessage(control, SelectionItemPattern.ElementSelectedEvent));
            AutomationElement element = SelectionItemPatternHelper.FindItemByText(control.UIAElement, itemText);

            SelectionItemPatternHelper.SelectItem(element);
        }
        private static void UiaSetSelectedIndex(BaseProdControl control, int index)
        {
            LogController.ReceiveLogMessage(new LogMessage("Selecting " + index));

            AutomationEventVerifier.Register(new EventRegistrationMessage(control, SelectionItemPattern.ElementSelectedEvent));
            AutomationElement indexedItem = SelectionItemPatternHelper.FindItemByIndex(control.UIAElement, index);

            SelectionItemPatternHelper.SelectItem(indexedItem);
        }