LookupById() public static method

public static LookupById ( int id ) : ControlType
id int
return ControlType
Exemplo n.º 1
0
        internal override bool AppliesTo(AutomationElement element)
        {
            // TODO: Test caching behavior
            object currentVal   = element.GetCurrentPropertyValue(property);
            object conditionVal = val;

            if (currentVal == null || conditionVal == null)
            {
                return(currentVal == conditionVal);
            }

            // Compare AutomationElements against Condition's
            // stored runtime ID array
            if (property == AEIds.LabeledByProperty ||
                property == GridItemPatternIdentifiers.ContainingGridProperty ||
                property == SelectionItemPatternIdentifiers.SelectionContainerProperty)
            {
                AutomationElement elementVal =
                    currentVal as AutomationElement;
                int [] conditionId = conditionVal as int [];
                return(currentVal != null &&
                       conditionId != null &&
                       Automation.Compare(conditionId,
                                          elementVal.GetRuntimeId()));
            }

            // For some other properties, need to reconstruct proper
            // object for comparison
            if (property == AEIds.BoundingRectangleProperty)
            {
                double [] rectArray = (double [])val;
                conditionVal = new Rect(rectArray [0],
                                        rectArray [1],
                                        rectArray [2],
                                        rectArray [3]);
            }
            else if (property == AEIds.ClickablePointProperty)
            {
                double [] pointArray = (double [])val;
                conditionVal = new Point(pointArray [0],
                                         pointArray [1]);
            }
            else if (property == AEIds.ControlTypeProperty)
            {
                conditionVal = ControlType.LookupById((int)val);
            }
            else if (property == AEIds.CultureProperty)
            {
                conditionVal = new CultureInfo((int)val);
            }

            return(ArePropertyValuesEqual(conditionVal, currentVal));
        }
Exemplo n.º 2
0
        void Init(AutomationProperty property, object value)
        {
            if (property == AutomationElement.ControlTypeProperty)
            {
                switch (value)
                {
                case ControlType controlType2:
                    this._condition = Automation.AutomationClass.CreatePropertyCondition(propertyId: property.Id, value: controlType2.Id.ToVariant());
                    break;

                case int _:
                    var controlType1 = ControlType.LookupById(id: int.Parse(s: value.ToString()));
                    this._condition = controlType1 == null ? null : Automation.AutomationClass.CreatePropertyCondition(propertyId: property.Id, value: controlType1.Id.ToVariant());
                    break;
                }
            }
            else
            {
                var variant = value.ToVariant();
                this._condition = Automation.AutomationClass.CreatePropertyCondition(propertyId: property.Id, value: variant);
                variant.Free();
            }
        }