コード例 #1
0
        public SetResult TrySet(string value)
        {
            if (!DoesApply())
            {
                return(SetResult.NotApplicable);
            }
            _element.ExpandAll(_automation, 0);

            if (string.IsNullOrWhiteSpace(value))
            {
                DeselectAll(_selectionPattern.GetCurrentSelection());
                return(SetResult.Success);
            }

            var condition = _automation.CreatePropertyCondition(UIA_PropertyIds.UIA_NamePropertyId, value);
            var item      = _element.FindFirst(TreeScope.TreeScope_Descendants, condition);

            return(item == null
                ? SetResult.Failure
                : new SelectionItemPattern(item, _selectionPattern.CurrentCanSelectMultiple != 0).TrySet(SelectionItemPattern
                                                                                                         .SelectValue));
        }