コード例 #1
0
        public static int GetItemCount(IntPtr controlHandle)
        {
            try
            {
                AutomationElement control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
                int ret = SelectionItemPatternHelper.GetListItemCount(control);

                if (ret == -1)
                {
                    if (control.Current.ControlType == ControlType.ComboBox)
                    {
                        ProdComboBoxNative.GetItemCountNative(controlHandle);
                    }
                    else
                    {
                        ProdListBoxNative.GetItemCountNative(controlHandle);
                    }
                }

                LogController.ReceiveLogMessage(new LogMessage(ret.ToString(CultureInfo.InvariantCulture)));
                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);
            }
        }
コード例 #2
0
        /// <summary>
        /// Natives the get items.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private static Collection <object> NativeGetItems(BaseProdControl control)
        {
            if (control.UIAElement.Current.ControlType == ControlType.ComboBox)
            {
                return(ProdComboBoxNative.GetItemsNative((IntPtr)control.UIAElement.Current.NativeWindowHandle));
            }

            return(ProdListBoxNative.GetItemsNative((IntPtr)control.UIAElement.Current.NativeWindowHandle));
        }
コード例 #3
0
        private static void NativeSetSelectedItem(BaseProdControl control, string itemText)
        {
            if (control.UIAElement.Current.ControlType == ControlType.ComboBox)
            {
                ProdComboBoxNative.SelectItemNative((IntPtr)control.UIAElement.Current.NativeWindowHandle, itemText);
            }

            ProdListBoxNative.SelectItemNative((IntPtr)control.UIAElement.Current.NativeWindowHandle, itemText);
        }
コード例 #4
0
        private static int NativeSelectedIndex(BaseProdControl control)
        {
            if (control.UIAElement.Current.ControlType == ControlType.ComboBox)
            {
                return(ProdComboBoxNative.GetSelectedIndexNative((IntPtr)control.UIAElement.Current.NativeWindowHandle));
            }

            return(ProdListBoxNative.GetSelectedIndexNative((IntPtr)control.UIAElement.Current.NativeWindowHandle));
        }
コード例 #5
0
        private static int NativeGetItemCount(BaseProdControl control)
        {
            if (control.UIAElement.Current.ControlType == ControlType.Tab)
            {
                return(ProdTabNative.GetTabCount((IntPtr)control.UIAElement.Current.NativeWindowHandle));
            }
            if (control.UIAElement.Current.ControlType == ControlType.ComboBox)
            {
                ProdComboBoxNative.GetItemCountNative((IntPtr)control.UIAElement.Current.NativeWindowHandle);
            }

            return(ProdListBoxNative.GetItemCountNative((IntPtr)control.UIAElement.Current.NativeWindowHandle));
        }
コード例 #6
0
        private static bool NativeIsItemSelected(BaseProdControl control, int index)
        {
            int selectedIndex;

            if (control.UIAElement.Current.ControlType == ControlType.ComboBox)
            {
                selectedIndex = ProdComboBoxNative.GetSelectedIndexNative((IntPtr)control.UIAElement.Current.NativeWindowHandle);
            }
            else
            {
                selectedIndex = ProdTabNative.GetSelectedTab((IntPtr)control.UIAElement.Current.NativeWindowHandle);
            }

            return(selectedIndex == index);
        }