LookupById() публичный статический Метод

public static LookupById ( int id ) : AutomationProperty
id int
Результат AutomationProperty
Пример #1
0
        public AutomationProperty[] GetSupportedProperties()
        {
            int[] propertyIds;
            Automation.AutomationClass.PollForPotentialSupportedProperties(pElement: IUIAutomationElement, propertyIds: out propertyIds, propertyNames: out var _);
            var automationPropertyList = new List <AutomationProperty>();

            for (var index = 0; index < propertyIds.Length; ++index)
            {
                if (propertyIds[index] != 0)
                {
                    try {
                        var automationProperty = AutomationProperty.LookupById(id: propertyIds[index]);
                        automationPropertyList.Add(item: automationProperty);
                    } catch (KeyNotFoundException ex) {
                    }
                }
            }

            return(automationPropertyList.ToArray());
        }
Пример #2
0
        public Condition[] GetConditions()
        {
            if (!(IUIAutomationCondition is IUIAutomationAndCondition automationCondition))
            {
                return(null);
            }
            var typedArray     = automationCondition.GetChildren().ToTypedArray <IUIAutomationCondition>();
            var conditionArray = new Condition[typedArray.Length];

            for (var index = 0; index < conditionArray.Length; ++index)
            {
                if (typedArray[index] is IUIAutomationPropertyCondition)
                {
                    var propertyCondition = typedArray[index] as IUIAutomationPropertyCondition;
                    conditionArray[index] = new PropertyCondition(property: AutomationProperty.LookupById(id: propertyCondition.propertyId), value: propertyCondition.PropertyValue);
                }
                else if (typedArray[index] is IUIAutomationAndCondition)
                {
                    var automationAndCondition = typedArray[index] as IUIAutomationAndCondition;
                    conditionArray[index] = new AndCondition(iUIAConditions: automationAndCondition.GetChildren().ToTypedArray <IUIAutomationCondition>());
                }
                else if (typedArray[index] is IUIAutomationOrCondition)
                {
                    var automationOrCondition = typedArray[index] as IUIAutomationOrCondition;
                    conditionArray[index] = new OrCondition(iUIAConditions: automationOrCondition.GetChildren().ToTypedArray <IUIAutomationCondition>());
                }
                else if (typedArray[index] is IUIAutomationNotCondition)
                {
                    conditionArray[index] = new NotCondition(condition: new Condition(condition: typedArray[index]));
                }
                else if (typedArray[index] != null)
                {
                    conditionArray[index] = new Condition(condition: typedArray[index]);
                }
            }

            return(conditionArray);
        }
Пример #3
0
        public AutomationProperty[] GetSupportedProperties()
        {
            Array rawPropertyIds;
            Array rawPropertyNames;

            try
            {
                Automation.Factory.PollForPotentialSupportedProperties(this._obj, out rawPropertyIds, out rawPropertyNames);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx))
                {
                    throw newEx;
                }
                else
                {
                    throw;
                }
            }
            int[] propertyIds = (int[])rawPropertyIds;

            // This element may support properties that are not registered for this
            // client.  Filter them out.
            List <AutomationProperty> properties = new List <AutomationProperty>();

            foreach (int propertyId in propertyIds)
            {
                AutomationProperty property = AutomationProperty.LookupById(propertyId);
                if (property != null)
                {
                    properties.Add(property);
                }
            }
            return(properties.ToArray());
        }
        void IUIAutomationPropertyChangedEventHandler.HandlePropertyChangedEvent(
            IUIAutomationElement sender,
            int propertyId,
            Variant newValue)
        {
            AutomationElement automationElement = null;

            if (sender != null)
            {
                automationElement = new AutomationElement(autoElement: sender);
            }
            this._handlingDelegate(sender: automationElement, e: new AutomationPropertyChangedEventArgs(property: AutomationProperty.LookupById(id: propertyId), oldValue: null, newValue: newValue));
        }