private static int UiaGetItemCount(BaseProdControl control)
        {
            AutomationElementCollection convRet = SelectionItemPatternHelper.GetListItems(control.UIAElement);

            LogController.ReceiveLogMessage(new LogMessage("Items: " + convRet.Count));
            return(convRet.Count);
        }
Пример #2
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);
            }
        }
        public static Collection <object> GetItems(IntPtr controlHandle)
        {
            try
            {
                AutomationElement           control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
                AutomationElementCollection convRet = SelectionItemPatternHelper.GetListItems(control);

                Collection <object> ret = InternalUtilities.AutomationCollToObjectList(convRet);

                if (ret == null)
                {
                    ProdListBoxNative.GetItemsNative(controlHandle);
                }

                LogController.ReceiveLogMessage(new LogMessage(control.Current.Name, ret));
                return(ret);
            }
            catch (InvalidOperationException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ArgumentException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
        private static Collection <object> UiaGetItems(BaseProdControl control)
        {
            AutomationElementCollection convRet = SelectionItemPatternHelper.GetListItems(control.UIAElement);

            Collection <object> retVal = InternalUtilities.AutomationCollToObjectList(convRet);

            LogController.ReceiveLogMessage(new LogMessage("List Items: ", retVal));
            return(retVal);
        }
        private static void UiaSelectAll(BaseProdControl control)
        {
            if (!UiaCanSelectMultiple(control))
            {
                throw new ProdOperationException("Does not support multiple selection");
            }

            foreach (AutomationElement item in SelectionItemPatternHelper.GetListItems(control.UIAElement))
            {
                SelectionItemPatternHelper.AddToSelection(control.UIAElement, item.Current.Name);
            }
        }
Пример #6
0
 /// <summary>
 /// Gets a collection of all items in the list control
 /// </summary>
 /// <param name="controlHandle">The target controls handle.</param>
 /// <returns>
 /// list containing all items
 /// </returns>
 /// <exception cref="ProdOperationException">Examine inner exception</exception>
 public static Collection <object> TabsGet(IntPtr controlHandle)
 {
     try
     {
         AutomationElement           control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
         AutomationElementCollection aec     = SelectionItemPatternHelper.GetListItems(control);
         LogController.ReceiveLogMessage(new LogMessage(control.Current.Name));
         return(InternalUtilities.AutomationCollToObjectList(aec));
     }
     catch (InvalidOperationException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
     catch (ElementNotAvailableException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
     catch (ArgumentException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
 }