コード例 #1
0
        public static void SetSelectedItems(IntPtr controlHandle, Collection <string> items)
        {
            try
            {
                CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
                if (!CanSelectMultiple(controlHandle))
                {
                    return;
                }

                foreach (string item in items)
                {
                    AddToSelection(controlHandle, item);
                }
                List <object>       itemList = new List <object>(items);
                Collection <object> retList  = new Collection <object>(itemList);
                LogController.ReceiveLogMessage(new LogMessage("List items Selected: ", retList));
            }
            catch (InvalidOperationException)
            {
                /* Call native function */
                foreach (string item in items)
                {
                    ProdListBoxNative.AddSelectedItemNative(controlHandle, item);
                }
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ArgumentException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
コード例 #2
0
        public static void AddToSelection(IntPtr controlHandle, int index)
        {
            try
            {
                AutomationElement control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);

                StaticEvents.RegisterEvent(SelectionItemPattern.ElementAddedToSelectionEvent, control);
                SelectionItemPatternHelper.AddToSelection(control, index);

                LogController.ReceiveLogMessage(new LogMessage(control.Current.Name));
            }
            catch (InvalidOperationException)
            {
                /* Call native function */
                ProdListBoxNative.AddSelectedItemNative(controlHandle, index);
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ArgumentException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
コード例 #3
0
        public static void SetSelectedIndexes(IntPtr controlHandle, Collection <int> indexes)
        {
            if (!CanSelectMultiple(controlHandle))
            {
                return;
            }

            try
            {
                AutomationElement control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
                if (!CanSelectMultiple((IntPtr)control.Current.NativeWindowHandle))
                {
                    return;
                }

                foreach (int index in indexes)
                {
                    AddToSelection(controlHandle, index);
                }

                Collection <object> retList = new Collection <object> {
                    indexes
                };
                LogController.ReceiveLogMessage(new LogMessage("List items Selected: ", retList));
            }
            catch (InvalidOperationException)
            {
                /* Call native function */
                foreach (int item in indexes)
                {
                    ProdListBoxNative.AddSelectedItemNative(controlHandle, item);
                }
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ArgumentException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
コード例 #4
0
 /// <summary>
 /// Adds the list item to the current selection using SendMessage
 /// </summary>
 /// <param name="control">The base ProdUI control.</param>
 /// <param name="index">Zero based index of the item.</param>
 private static void NativeAddToSelection(BaseProdControl control, int index)
 {
     ProdListBoxNative.AddSelectedItemNative((IntPtr)control.UIAElement.Current.NativeWindowHandle, index);
 }