private void Init(AutomationProperty property, object val, PropertyConditionFlags flags) { Utility.ValidateArgumentNonNull(property, "property"); this._obj = (UIAutomationClient.IUIAutomationPropertyCondition) Automation.Factory.CreatePropertyConditionEx( property.Id, Utility.UnwrapObject(val), (UIAutomationClient.PropertyConditionFlags)flags); }
private System.Windows.Automation.Condition BuildPropertyCondition(XmlNode xnPropCondition) { System.Windows.Automation.Condition condition = null; PropertyConditionFlags none = PropertyConditionFlags.None; string str = string.Empty; if (xnPropCondition.InnerText == null) { return(condition); } str = UIAHelperMethods.GetXmlAttribute(xnPropCondition, "Name").Value; Type type = AutomationPropReturnTypes[str]; if (type.Equals(typeof(string))) { none = PropertyConditionFlags.IgnoreCase; } return(new PropertyCondition(AutomationProperties[str], this.ConvertStringtoObject(xnPropCondition.InnerText, AutomationPropReturnTypes[str]), none)); }
public PropertyCondition(AutomationProperty property, object value, PropertyConditionFlags flags) : base() { if (property == null) { throw new ArgumentNullException("property"); } this.property = property; // NotSupported is handled the same way for all properties if (value == AutomationElement.NotSupported) { if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } this.val = value; this.flags = flags; return; } if (property == AEIds.AcceleratorKeyProperty || property == AEIds.AccessKeyProperty || property == AEIds.AutomationIdProperty || property == AEIds.ClassNameProperty || property == AEIds.HelpTextProperty || property == AEIds.ItemStatusProperty || property == AEIds.ItemTypeProperty || property == AEIds.LocalizedControlTypeProperty || property == AEIds.NameProperty || property == AEIds.FrameworkIdProperty || property == ValuePatternIdentifiers.ValueProperty) { if (value != null && !(value is string)) { throw new ArgumentException("value"); } if (value == null && (flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = value; } else if (property == AEIds.BoundingRectangleProperty) { Rect?rect = null; if (value == null || !(rect = value as Rect?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = new double [] { rect.Value.X, rect.Value.Y, rect.Value.Width, rect.Value.Height }; } else if (property == AEIds.ClickablePointProperty) { Point?point = null; if (value == null || !(point = value as Point?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = new double [] { point.Value.X, point.Value.Y }; } else if (property == AEIds.ControlTypeProperty) { ControlType controlType = null; if (value != null && (controlType = value as ControlType) == null) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } if (controlType != null) { val = controlType.Id; } } else if (property == AEIds.CultureProperty) { CultureInfo culture = null; if (value != null && (culture = value as CultureInfo) == null) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } if (culture != null) { val = culture.LCID; } } else if (property == AEIds.HasKeyboardFocusProperty || property == AEIds.IsContentElementProperty || property == AEIds.IsControlElementProperty || property == AEIds.IsDockPatternAvailableProperty || property == AEIds.IsEnabledProperty || property == AEIds.IsExpandCollapsePatternAvailableProperty || property == AEIds.IsGridItemPatternAvailableProperty || property == AEIds.IsGridPatternAvailableProperty || property == AEIds.IsInvokePatternAvailableProperty || property == AEIds.IsKeyboardFocusableProperty || property == AEIds.IsMultipleViewPatternAvailableProperty || property == AEIds.IsOffscreenProperty || property == AEIds.IsPasswordProperty || property == AEIds.IsRangeValuePatternAvailableProperty || property == AEIds.IsRequiredForFormProperty || property == AEIds.IsScrollItemPatternAvailableProperty || property == AEIds.IsScrollPatternAvailableProperty || property == AEIds.IsSelectionItemPatternAvailableProperty || property == AEIds.IsSelectionPatternAvailableProperty || property == AEIds.IsTableItemPatternAvailableProperty || property == AEIds.IsTablePatternAvailableProperty || property == AEIds.IsTextPatternAvailableProperty || property == AEIds.IsTogglePatternAvailableProperty || property == AEIds.IsTransformPatternAvailableProperty || property == AEIds.IsValuePatternAvailableProperty || property == AEIds.IsWindowPatternAvailableProperty || property == RangeValuePatternIdentifiers.IsReadOnlyProperty || property == ScrollPatternIdentifiers.HorizontallyScrollableProperty || property == ScrollPatternIdentifiers.VerticallyScrollableProperty || property == SelectionItemPatternIdentifiers.IsSelectedProperty || property == SelectionPatternIdentifiers.CanSelectMultipleProperty || property == SelectionPatternIdentifiers.IsSelectionRequiredProperty || property == TransformPatternIdentifiers.CanMoveProperty || property == TransformPatternIdentifiers.CanResizeProperty || property == TransformPatternIdentifiers.CanRotateProperty || property == ValuePatternIdentifiers.IsReadOnlyProperty || property == WindowPatternIdentifiers.CanMaximizeProperty || property == WindowPatternIdentifiers.CanMinimizeProperty || property == WindowPatternIdentifiers.IsModalProperty || property == WindowPatternIdentifiers.IsTopmostProperty) { bool?boolVal = null; if (value == null || !(boolVal = value as bool?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = boolVal.Value; } else if (property == AEIds.LabeledByProperty || property == GridItemPatternIdentifiers.ContainingGridProperty || property == SelectionItemPatternIdentifiers.SelectionContainerProperty) { AutomationElement element = null; if (value != null && (element = value as AutomationElement) == null) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } if (element != null) { val = element.GetRuntimeId(); } } else if (property == AEIds.NativeWindowHandleProperty || property == AEIds.ProcessIdProperty || property == GridItemPatternIdentifiers.ColumnProperty || property == GridItemPatternIdentifiers.ColumnSpanProperty || property == GridItemPatternIdentifiers.RowProperty || property == GridItemPatternIdentifiers.RowSpanProperty || property == GridPatternIdentifiers.ColumnCountProperty || property == GridPatternIdentifiers.RowCountProperty || property == MultipleViewPatternIdentifiers.CurrentViewProperty) { int?intVal = null; if (value == null || !(intVal = value as int?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = intVal.Value; } else if (property == AEIds.OrientationProperty) { OrientationType?orientation = null; if (value == null || !(orientation = value as OrientationType?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = orientation.Value; } else if (property == AEIds.RuntimeIdProperty || property == MultipleViewPatternIdentifiers.SupportedViewsProperty) { int [] runtimeId = null; if (value != null && (runtimeId = value as int []) == null) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } if (runtimeId != null) { val = runtimeId; } } else if (property == DockPatternIdentifiers.DockPositionProperty) { DockPosition?position = null; if (value == null || !(position = value as DockPosition?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = position.Value; } else if (property == ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty) { ExpandCollapseState?state = null; if (value == null || !(state = value as ExpandCollapseState?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = state.Value; } else if (property == RangeValuePatternIdentifiers.LargeChangeProperty || property == RangeValuePatternIdentifiers.SmallChangeProperty || property == RangeValuePatternIdentifiers.ValueProperty || property == ScrollPatternIdentifiers.HorizontalScrollPercentProperty || property == ScrollPatternIdentifiers.HorizontalViewSizeProperty || property == ScrollPatternIdentifiers.VerticalScrollPercentProperty || property == ScrollPatternIdentifiers.VerticalViewSizeProperty) { double?doubleVal = null; if (value == null || !(doubleVal = value as double?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = doubleVal.Value; } else if (property == RangeValuePatternIdentifiers.MaximumProperty || property == RangeValuePatternIdentifiers.MinimumProperty) { if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase && !(value is string)) { throw new ArgumentException("flags"); } val = value; } else if (property == SelectionPatternIdentifiers.SelectionProperty || property == TableItemPatternIdentifiers.ColumnHeaderItemsProperty || property == TableItemPatternIdentifiers.RowHeaderItemsProperty || property == TablePatternIdentifiers.ColumnHeadersProperty || property == TablePatternIdentifiers.RowHeadersProperty) { AutomationElement [] elements = null; if (value != null && (elements = value as AutomationElement []) == null) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } if (elements != null) { val = elements; } } else if (property == TablePatternIdentifiers.RowOrColumnMajorProperty) { RowOrColumnMajor?state = null; if (value == null || !(state = value as RowOrColumnMajor?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = state.Value; } else if (property == TogglePatternIdentifiers.ToggleStateProperty) { ToggleState?state = null; if (value == null || !(state = value as ToggleState?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = state.Value; } else if (property == WindowPatternIdentifiers.WindowInteractionStateProperty) { WindowInteractionState?state = null; if (value == null || !(state = value as WindowInteractionState?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = state.Value; } else if (property == WindowPatternIdentifiers.WindowVisualStateProperty) { WindowVisualState?state = null; if (value == null || !(state = value as WindowVisualState?).HasValue) { throw new ArgumentException("value"); } if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) { throw new ArgumentException("flags"); } val = state.Value; } this.flags = flags; }
public PropertyCondition(PropertyId property, object value, PropertyConditionFlags propertyConditionFlags) { Property = property; Value = value; PropertyConditionFlags = propertyConditionFlags; }
public PropertyCondition(AutomationProperty property, object value, PropertyConditionFlags flags) { this.Init(property, value, flags); }
public PropertyCondition2(AutomationProperty property, object value, PropertyConditionFlags flags) : base(property, value, flags) { realValue = value; }
internal static PropertyCondition FromId(string id, PropertyConditionFlags propertyConditionFlags = PropertyConditionFlags.None) { return(FromProperty(AutomationElementIdentifiers.AutomationIdProperty, id, propertyConditionFlags)); }
internal static PropertyCondition FromName(string name, PropertyConditionFlags propertyConditionFlags = PropertyConditionFlags.None) { return(FromProperty(AutomationElementIdentifiers.NameProperty, name, propertyConditionFlags)); }
/// <summary> /// Creates a condition to search by a name. /// </summary> public PropertyCondition ByName(string name, PropertyConditionFlags conditionFlags = PropertyConditionFlags.None) { return(new PropertyCondition(_propertyLibrary.Element.Name, name, conditionFlags)); }
/// <summary> /// Constructor to create a condition that checks whether a property has the specified value /// </summary> /// <param name="property">The property to check</param> /// <param name="value">The value to check the property for</param> /// <param name="flags">Flags that affect the comparison</param> public PropertyCondition( AutomationProperty property, object value, PropertyConditionFlags flags ) { Init(property, value, flags); }
/// <summary> /// Creates a condition to search by a value. /// </summary> public PropertyCondition ByValue(string value, PropertyConditionFlags conditionFlags = PropertyConditionFlags.None) { return(new PropertyCondition(_propertyLibrary.Value.Value, value, conditionFlags)); }
/// <summary> /// Creates a condition to search by an automation id. /// </summary> public PropertyCondition ByAutomationId(string automationId, PropertyConditionFlags conditionFlags = PropertyConditionFlags.None) { return(new PropertyCondition(_propertyLibrary.Element.AutomationId, automationId, conditionFlags)); }
private void VerifyPropertyConditionConstructor (AutomationProperty property, object val, object expectedPropVal, PropertyConditionFlags? flags) { bool exceptionRaised = false; bool ignoreCaseAllowed = val is string; bool exceptionExpected = flags.HasValue && flags.Value == PropertyConditionFlags.IgnoreCase && !ignoreCaseAllowed; try { PropertyCondition cond; if (flags.HasValue) cond = new PropertyCondition (property, val, flags.Value); else cond = new PropertyCondition (property, val); Assert.AreEqual (property, cond.Property, "PropertyCondition.Property"); Assert.AreEqual (expectedPropVal, cond.Value, "PropertyCondition.Value for " + property.ProgrammaticName); Assert.AreEqual (flags.HasValue ? flags.Value : PropertyConditionFlags.None, cond.Flags, "PropertyCondition.Flags"); } catch (ArgumentException) { exceptionRaised = true; } Assert.AreEqual (exceptionExpected, exceptionRaised, string.Format ("For {0} expected '{1}' with {2} to be a {3}", property.ProgrammaticName, val ?? "(null)", flags.HasValue ? flags.Value.ToString () : "no flag specified", exceptionExpected ? "bad value" : "good value, but instead received ArgumentException")); }
public virtual extern IUIAutomationCondition IUIAutomation3_CreatePropertyConditionEx( [In] int propertyId, [MarshalAs(unmanagedType: UnmanagedType.Struct), In] Variant value, [In] PropertyConditionFlags flags);
public static AutomationElement GetControlElement(this AutomationElement parentElement, object value, AutomationProperty property = null, PropertyConditionFlags flags = PropertyConditionFlags.IgnoreCase, TreeScope treeScope = TreeScope.Descendants) { if (property == null) { property = AutomationElement.AutomationIdProperty; } Condition condition = new PropertyCondition(property, value, flags); AutomationElement controlElement = parentElement.FindFirst(treeScope, condition); return(controlElement); }
/// <summary> /// Creates a condition to search by a text (same as <see cref="ByName"/>). /// </summary> public PropertyCondition ByText(string text, PropertyConditionFlags conditionFlags = PropertyConditionFlags.None) { return(ByName(text, conditionFlags)); }
//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods void Init(AutomationProperty property, object val, PropertyConditionFlags flags ) { Misc.ValidateArgumentNonNull(property, "property"); AutomationPropertyInfo info; if (!Schema.GetPropertyInfo(property, out info)) { throw new ArgumentException(SR.Get(SRID.UnsupportedProperty)); } // Check type is appropriate: NotSupported is allowed against any property, // null is allowed for any reference type (ie not for value types), otherwise // type must be assignable from expected type. Type expectedType = info.Type; if (val != AutomationElement.NotSupported && ((val == null && expectedType.IsValueType) || (val != null && !expectedType.IsAssignableFrom(val.GetType())))) { throw new ArgumentException(SR.Get(SRID.PropertyConditionIncorrectType, property.ProgrammaticName, expectedType.Name)); } if ((flags & PropertyConditionFlags.IgnoreCase) != 0) { Misc.ValidateArgument(val is string, SRID.IgnoreCaseRequiresString); } // Some types are handled differently in managed vs unmanaged - handle those here... if (val is AutomationElement) { // If this is a comparison against a Raw/LogicalElement, // save the runtime ID instead of the element so that we // can take it cross-proc if needed. val = ((AutomationElement)val).GetRuntimeId(); } else if (val is ControlType) { // If this is a control type, use the ID, not the CLR object val = ((ControlType)val).Id; } else if (val is Rect) { Rect rc = (Rect)val; val = new double[] { rc.Left, rc.Top, rc.Width, rc.Height }; } else if (val is Point) { Point pt = (Point)val; val = new double[] { pt.X, pt.Y }; } else if (val is CultureInfo) { val = ((CultureInfo)val).LCID; } _property = property; _val = val; _flags = flags; SetMarshalData(new UiaCoreApi.UiaPropertyCondition(_property.Id, _val, _flags)); }
/// <summary> /// Creates a condition to search by a Framework Id. /// </summary> public PropertyCondition ByFrameworkId(string frameworkId, PropertyConditionFlags conditionFlags = PropertyConditionFlags.None) { return(new PropertyCondition(_propertyLibrary.Element.FrameworkId, frameworkId, conditionFlags)); }
//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods void Init(AutomationProperty property, object val, PropertyConditionFlags flags) { Misc.ValidateArgumentNonNull(property, "property"); AutomationPropertyInfo info; if (!Schema.GetPropertyInfo(property, out info)) { throw new ArgumentException(SR.Get(SRID.UnsupportedProperty)); } // Check type is appropriate: NotSupported is allowed against any property, // null is allowed for any reference type (ie not for value types), otherwise // type must be assignable from expected type. Type expectedType = info.Type; if (val != AutomationElement.NotSupported && ((val == null && expectedType.IsValueType) || (val != null && !expectedType.IsAssignableFrom(val.GetType())))) { throw new ArgumentException(SR.Get(SRID.PropertyConditionIncorrectType, property.ProgrammaticName, expectedType.Name)); } if ((flags & PropertyConditionFlags.IgnoreCase) != 0) { Misc.ValidateArgument(val is string, SRID.IgnoreCaseRequiresString); } // Some types are handled differently in managed vs unmanaged - handle those here... if (val is AutomationElement) { // If this is a comparison against a Raw/LogicalElement, // save the runtime ID instead of the element so that we // can take it cross-proc if needed. val = ((AutomationElement)val).GetRuntimeId(); } else if (val is ControlType) { // If this is a control type, use the ID, not the CLR object val = ((ControlType)val).Id; } else if (val is Rect) { Rect rc = (Rect)val; val = new double[] { rc.Left, rc.Top, rc.Width, rc.Height }; } else if (val is Point) { Point pt = (Point)val; val = new double[] { pt.X, pt.Y }; } else if (val is CultureInfo) { val = ((CultureInfo)val).LCID; } else if (val is AutomationHeadingLevel) { AutomationHeadingLevel automationHeadingLevel = (AutomationHeadingLevel)(val); switch (automationHeadingLevel) { case AutomationHeadingLevel.None: val = HeadingLevel.None; break; case AutomationHeadingLevel.Level1: val = HeadingLevel.Level1; break; case AutomationHeadingLevel.Level2: val = HeadingLevel.Level2; break; case AutomationHeadingLevel.Level3: val = HeadingLevel.Level3; break; case AutomationHeadingLevel.Level4: val = HeadingLevel.Level4; break; case AutomationHeadingLevel.Level5: val = HeadingLevel.Level5; break; case AutomationHeadingLevel.Level6: val = HeadingLevel.Level6; break; case AutomationHeadingLevel.Level7: val = HeadingLevel.Level7; break; case AutomationHeadingLevel.Level8: val = HeadingLevel.Level8; break; case AutomationHeadingLevel.Level9: val = HeadingLevel.Level9; break; default: val = HeadingLevel.None; break; } } _property = property; _val = val; _flags = flags; SetMarshalData(new UiaCoreApi.UiaPropertyCondition(_property.Id, _val, _flags)); }
/// <summary> /// Creates a condition to search by a localized control type. /// </summary> public PropertyCondition ByLocalizedControlType(string localizedControlType, PropertyConditionFlags conditionFlags = PropertyConditionFlags.None) { return(new PropertyCondition(_propertyLibrary.Element.LocalizedControlType, localizedControlType, conditionFlags)); }
internal static PropertyCondition FromProperty(AutomationProperty property, object value, PropertyConditionFlags propertyConditionFlags = PropertyConditionFlags.None) { return(new PropertyCondition(property, value, propertyConditionFlags)); }
public PropertyCondition(PropertyId property, object value, PropertyConditionFlags propertyConditionFlags) { this.Property = property; this.Value = value; this.PropertyConditionFlags = propertyConditionFlags; }
/// <summary> /// Optional. Specify <see cref="PropertyConditionFlags"/> to use when performing <see cref="Condition"/> comparison. /// </summary> /// <param name="propertyConditionFlags"></param> /// <returns></returns> public WrappedPropertyCondition <T> WithFlags(PropertyConditionFlags propertyConditionFlags) { _propertyConditionFlags = propertyConditionFlags; return(this); }
/// <summary> /// Creates a condition to search by a help text. /// </summary> public PropertyCondition ByHelpText(string helpText, PropertyConditionFlags conditionFlags = PropertyConditionFlags.None) { return(new PropertyCondition(_propertyLibrary.Element.HelpText, helpText, conditionFlags)); }
public PropertyCondition (AutomationProperty property, object value, PropertyConditionFlags flags) : base () { if (property == null) throw new ArgumentNullException ("property"); this.property = property; // NotSupported is handled the same way for all properties if (value == AutomationElement.NotSupported) { if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); this.val = value; this.flags = flags; return; } if (property == AEIds.AcceleratorKeyProperty || property == AEIds.AccessKeyProperty || property == AEIds.AutomationIdProperty || property == AEIds.ClassNameProperty || property == AEIds.HelpTextProperty || property == AEIds.ItemStatusProperty || property == AEIds.ItemTypeProperty || property == AEIds.LocalizedControlTypeProperty || property == AEIds.NameProperty || property == AEIds.FrameworkIdProperty || property == ValuePatternIdentifiers.ValueProperty) { if (value != null && !(value is string)) throw new ArgumentException ("value"); if (value == null && (flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = value; } else if (property == AEIds.BoundingRectangleProperty) { Rect? rect = null; if (value == null || !(rect = value as Rect?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = new double [] { rect.Value.X, rect.Value.Y, rect.Value.Width, rect.Value.Height }; } else if (property == AEIds.ClickablePointProperty) { Point? point = null; if (value == null || !(point = value as Point?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = new double [] { point.Value.X, point.Value.Y }; } else if (property == AEIds.ControlTypeProperty) { ControlType controlType = null; if (value != null && (controlType = value as ControlType) == null) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); if (controlType != null) val = controlType.Id; } else if (property == AEIds.CultureProperty) { CultureInfo culture = null; if (value != null && (culture = value as CultureInfo) == null) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); if (culture != null) val = culture.LCID; } else if (property == AEIds.HasKeyboardFocusProperty || property == AEIds.IsContentElementProperty || property == AEIds.IsControlElementProperty || property == AEIds.IsDockPatternAvailableProperty || property == AEIds.IsEnabledProperty || property == AEIds.IsExpandCollapsePatternAvailableProperty || property == AEIds.IsGridItemPatternAvailableProperty || property == AEIds.IsGridPatternAvailableProperty || property == AEIds.IsInvokePatternAvailableProperty || property == AEIds.IsKeyboardFocusableProperty || property == AEIds.IsMultipleViewPatternAvailableProperty || property == AEIds.IsOffscreenProperty || property == AEIds.IsPasswordProperty || property == AEIds.IsRangeValuePatternAvailableProperty || property == AEIds.IsRequiredForFormProperty || property == AEIds.IsScrollItemPatternAvailableProperty || property == AEIds.IsScrollPatternAvailableProperty || property == AEIds.IsSelectionItemPatternAvailableProperty || property == AEIds.IsSelectionPatternAvailableProperty || property == AEIds.IsTableItemPatternAvailableProperty || property == AEIds.IsTablePatternAvailableProperty || property == AEIds.IsTextPatternAvailableProperty || property == AEIds.IsTogglePatternAvailableProperty || property == AEIds.IsTransformPatternAvailableProperty || property == AEIds.IsValuePatternAvailableProperty || property == AEIds.IsWindowPatternAvailableProperty || property == RangeValuePatternIdentifiers.IsReadOnlyProperty || property == ScrollPatternIdentifiers.HorizontallyScrollableProperty || property == ScrollPatternIdentifiers.VerticallyScrollableProperty || property == SelectionItemPatternIdentifiers.IsSelectedProperty || property == SelectionPatternIdentifiers.CanSelectMultipleProperty || property == SelectionPatternIdentifiers.IsSelectionRequiredProperty || property == TransformPatternIdentifiers.CanMoveProperty || property == TransformPatternIdentifiers.CanResizeProperty || property == TransformPatternIdentifiers.CanRotateProperty || property == ValuePatternIdentifiers.IsReadOnlyProperty || property == WindowPatternIdentifiers.CanMaximizeProperty || property == WindowPatternIdentifiers.CanMinimizeProperty || property == WindowPatternIdentifiers.IsModalProperty || property == WindowPatternIdentifiers.IsTopmostProperty) { bool? boolVal = null; if (value == null || !(boolVal = value as bool?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = boolVal.Value; } else if (property == AEIds.LabeledByProperty || property == GridItemPatternIdentifiers.ContainingGridProperty || property == SelectionItemPatternIdentifiers.SelectionContainerProperty) { AutomationElement element = null; if (value != null && (element = value as AutomationElement) == null) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); if (element != null) val = element.GetRuntimeId (); } else if (property == AEIds.NativeWindowHandleProperty || property == AEIds.ProcessIdProperty || property == GridItemPatternIdentifiers.ColumnProperty || property == GridItemPatternIdentifiers.ColumnSpanProperty || property == GridItemPatternIdentifiers.RowProperty || property == GridItemPatternIdentifiers.RowSpanProperty || property == GridPatternIdentifiers.ColumnCountProperty || property == GridPatternIdentifiers.RowCountProperty || property == MultipleViewPatternIdentifiers.CurrentViewProperty) { int? intVal = null; if (value == null || !(intVal = value as int?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = intVal.Value; } else if (property == AEIds.OrientationProperty) { OrientationType? orientation = null; if (value == null || !(orientation = value as OrientationType?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = orientation.Value; } else if (property == AEIds.RuntimeIdProperty || property == MultipleViewPatternIdentifiers.SupportedViewsProperty) { int [] runtimeId = null; if (value != null && (runtimeId = value as int []) == null) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); if (runtimeId != null) val = runtimeId; } else if (property == DockPatternIdentifiers.DockPositionProperty) { DockPosition? position = null; if (value == null || !(position = value as DockPosition?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = position.Value; } else if (property == ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty) { ExpandCollapseState? state = null; if (value == null || !(state = value as ExpandCollapseState?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = state.Value; } else if (property == RangeValuePatternIdentifiers.LargeChangeProperty || property == RangeValuePatternIdentifiers.SmallChangeProperty || property == RangeValuePatternIdentifiers.ValueProperty || property == ScrollPatternIdentifiers.HorizontalScrollPercentProperty || property == ScrollPatternIdentifiers.HorizontalViewSizeProperty || property == ScrollPatternIdentifiers.VerticalScrollPercentProperty || property == ScrollPatternIdentifiers.VerticalViewSizeProperty) { double? doubleVal = null; if (value == null || !(doubleVal = value as double?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = doubleVal.Value; } else if (property == RangeValuePatternIdentifiers.MaximumProperty || property == RangeValuePatternIdentifiers.MinimumProperty) { if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase && !(value is string)) throw new ArgumentException ("flags"); val = value; } else if (property == SelectionPatternIdentifiers.SelectionProperty || property == TableItemPatternIdentifiers.ColumnHeaderItemsProperty || property == TableItemPatternIdentifiers.RowHeaderItemsProperty || property == TablePatternIdentifiers.ColumnHeadersProperty || property == TablePatternIdentifiers.RowHeadersProperty) { AutomationElement [] elements = null; if (value != null && (elements = value as AutomationElement []) == null) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); if (elements != null) val = elements; } else if (property == TablePatternIdentifiers.RowOrColumnMajorProperty) { RowOrColumnMajor? state = null; if (value == null || !(state = value as RowOrColumnMajor?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = state.Value; } else if (property == TogglePatternIdentifiers.ToggleStateProperty) { ToggleState? state = null; if (value == null || !(state = value as ToggleState?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = state.Value; } else if (property == WindowPatternIdentifiers.WindowInteractionStateProperty) { WindowInteractionState? state = null; if (value == null || !(state = value as WindowInteractionState?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = state.Value; } else if (property == WindowPatternIdentifiers.WindowVisualStateProperty) { WindowVisualState? state = null; if (value == null || !(state = value as WindowVisualState?).HasValue) throw new ArgumentException ("value"); if ((flags & PropertyConditionFlags.IgnoreCase) == PropertyConditionFlags.IgnoreCase) throw new ArgumentException ("flags"); val = state.Value; } this.flags = flags; }