// Get a cached property value for this custom property protected object GetCachedPropertyValue(UiaPropertyInfoHelper propInfo) { var param = new UiaParameterHelper(propInfo.UiaType); PatternInstance.GetProperty(propInfo.Index, 1 /* fCached */, param.GetUiaType(), param.Data); return(param.Value); }
private void SetPropertyRegistrationInfo(UiaPropertyInfoHelper prop) { var propFieldName = prop.Data.pProgrammaticName + "Property"; var field = GetType().GetField(propFieldName, BindingFlags.Static | BindingFlags.Public); if (field == null) { throw new ArgumentException(string.Format("Field {0} not found on the type", propFieldName)); } if (field.FieldType == typeof(int)) { field.SetValue(null, prop.PropertyId); } else if (field.FieldType == typeof(AutomationProperty)) { if (!_usedInWpf) { throw new ArgumentException("You can't use AutomationPattern registration info because you passed usedInWpf: false in constructor"); } field.SetValue(null, AutomationProperty.LookupById(prop.PropertyId)); } else { throw new ArgumentException("Fields for properties should be either of type int of AutomationProperty"); } }
private static AutomationProperty RegisterProperty(UiaPropertyInfoHelper property) { var automationPropertyType = typeof(AutomationProperty); var registerMethod = automationPropertyType.GetMethod("Register", BindingFlags.NonPublic | BindingFlags.Static); using (Dispatcher.CurrentDispatcher.DisableProcessing()) return((AutomationProperty)registerMethod.Invoke(null, new object[] { property.Guid, property.Data.pProgrammaticName })); }
private void CallProperty(IInvocation invocation, UiaPropertyInfoHelper propHelper, bool cached) { // it is call for CurrentXxx property var param = new UiaParameterHelper(propHelper.UiaType); NativeMethods.WrapUiaComCall(() => _patternInstance.GetProperty(propHelper.Index, cached ? 1 : 0, propHelper.UiaType, param.Data)); object value = param.Value; if (invocation.Method.ReturnType == typeof(AutomationElement)) { value = AutomationElement.Wrap((IUIAutomationElement)value); } invocation.ReturnValue = value; }
private static AutomationProperty RegisterProperty(UiaPropertyInfoHelper property) { var automationPropertyType = typeof(AutomationProperty); var registerMethod = automationPropertyType.GetMethod("Register", BindingFlags.NonPublic | BindingFlags.Static); using (Dispatcher.CurrentDispatcher.DisableProcessing()) return (AutomationProperty)registerMethod.Invoke(null, new object[] { property.Guid, property.Data.pProgrammaticName }); }
/// <summary> /// Add a property to this pattern /// </summary> /// <param name="property"></param> public void AddProperty(UiaPropertyInfoHelper property) { _properties.Add(property); }
// Get a current property value for this custom property protected object GetCurrentPropertyValue(UiaPropertyInfoHelper propInfo) { var param = new UiaParameterHelper(propInfo.UiaType); PatternInstance.GetProperty(propInfo.Index, 0 /* fCached */, param.GetUiaType(), param.Data); return param.Value; }
private void CallProperty(IInvocation invocation, UiaPropertyInfoHelper propHelper, bool cached) { // it is call for CurrentXxx property var param = new UiaParameterHelper(propHelper.UiaType); NativeMethods.WrapUiaComCall(() => _patternInstance.GetProperty(propHelper.Index, cached ? 1 : 0, propHelper.UiaType, param.Data)); object value = param.Value; if (invocation.Method.ReturnType == typeof(AutomationElement)) value = AutomationElement.Wrap((IUIAutomationElement)value); invocation.ReturnValue = value; }