コード例 #1
0
 public static int GetSelectedIndex(IntPtr controlHandle)
 {
     try
     {
         AutomationElement   control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
         AutomationElement[] element = SelectionPatternHelper.GetSelection(control);
         int ret = SelectionItemPatternHelper.FindIndexByItem(control, element[0].Current.Name);
         if (ret == -1)
         {
             /* Call native function */
             ret = ProdListBoxNative.GetSelectedIndexNative(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
        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));
        }