Exemple #1
0
        public object GetCachedPropertyValue(AutomationProperty property, bool ignoreDefaultValue)
        {
            Validate.ArgumentNotNull(parameter: property, parameterName: nameof(property));
            var cachedPropertyValueEx = IUIAutomationElement.GetCachedPropertyValueEx(propertyId: property.Id, ignoreDefaultValue: Convert.ToInt32(value: ignoreDefaultValue));

            return(UiaConvert.ConvertPropertyValue(property: property, propertyValueVariant: cachedPropertyValueEx));
        }
Exemple #2
0
        public AutomationElement FindFirst(TreeScope scope, Condition condition)
        {
            Validate.ArgumentNotNull(parameter: condition, parameterName: nameof(condition));
            var firstBuildCache = IUIAutomationElement.FindFirstBuildCache(scope: UiaConvert.Convert(treeScope: scope), condition: condition.IUIAutomationCondition, cacheRequest: DefaultCacheRequest.IUIAutomationCacheRequest);

            return(firstBuildCache != null ? new AutomationElement(autoElement: firstBuildCache) : null);
        }
Exemple #3
0
        public AutomationElementCollection FindAll(
            TreeScope scope,
            Condition condition)
        {
            Validate.ArgumentNotNull(parameter: condition, parameterName: nameof(condition));
            var allBuildCache = IUIAutomationElement.FindAllBuildCache(scope: UiaConvert.Convert(treeScope: scope), condition: condition.IUIAutomationCondition, cacheRequest: DefaultCacheRequest.IUIAutomationCacheRequest);

            return(allBuildCache != null ? new AutomationElementCollection(elementArray: allBuildCache) : null);
        }
Exemple #4
0
        public object GetCurrentPropertyValue(AutomationProperty property, bool ignoreDefaultValue)
        {
            Validate.ArgumentNotNull(parameter: property, parameterName: nameof(property));
            var propertyValueVariant = new Variant();

            try {
                propertyValueVariant = IUIAutomationElement.GetCurrentPropertyValueEx(propertyId: property.Id, ignoreDefaultValue: Convert.ToInt32(value: ignoreDefaultValue));
            } catch (COMException ex) {
            }

            return(UiaConvert.ConvertPropertyValue(property: property, propertyValueVariant: propertyValueVariant));
        }
Exemple #5
0
 public AutomationElement GetUpdatedCache(CacheRequest request)
 {
     try {
         return(new AutomationElement(autoElement: IUIAutomationElement.BuildUpdatedCache(cacheRequest: request.IUIAutomationCacheRequest)));
     } catch (COMException ex) {
         Exception exception = null;
         if (UiaConvert.ConvertException(e: ex, newException: out exception))
         {
             throw exception;
         }
         throw;
     }
 }
Exemple #6
0
 internal static R UIAutomation <R>(Func <R> f)
 {
     try {
         return(f());
     } catch (COMException ex) {
         Exception exception;
         if (UiaConvert.ConvertException(e: ex, newException: out exception))
         {
             throw exception;
         }
         throw;
     }
 }
Exemple #7
0
 internal static void UIAutomation(Action a)
 {
     try {
         a();
     } catch (COMException ex) {
         Exception exception;
         if (UiaConvert.ConvertException(e: ex, newException: out exception))
         {
             throw exception;
         }
         throw;
     }
 }
        internal static void Add(
            AutomationElement element,
            TreeScope scope,
            StructureChangedEventHandler handlingDelegate)
        {
            var e            = new StructureChangedEventHandlerImpl(uiAutomationElement: element.IUIAutomationElement, handlingDelegate: handlingDelegate);
            var cacheRequest = AutomationElement.DefaultCacheRequest.IUIAutomationCacheRequest;

            Boundary.UIAutomation(a: () => Automation.AutomationClass.AddStructureChangedEventHandler(element: e._uiAutomationElement, scope: UiaConvert.Convert(treeScope: scope), cacheRequest: cacheRequest, handler: e));
            Add(instance: e);
        }
        void IUIAutomationStructureChangedEventHandler.HandleStructureChangedEvent(
            IUIAutomationElement sender,
            UIAutomationClient.StructureChangeType changeType,
            int[] runtimeId)
        {
            AutomationElement automationElement = null;

            if (sender != null)
            {
                automationElement = new AutomationElement(autoElement: sender);
            }
            this._handlingDelegate(sender: automationElement, e: new StructureChangedEventArgs(structureChangeType: UiaConvert.Convert(structureChangeType: changeType), runtimeId: runtimeId));
        }
Exemple #10
0
 public void ScrollVertical(ScrollAmount amount)
 {
     this._scrollPattern.Scroll(horizontalAmount: UiaConvert.Convert(scrollAmount: ScrollAmount.NoAmount), verticalAmount: UiaConvert.Convert(scrollAmount: amount));
 }
Exemple #11
0
 public void Scroll(ScrollAmount horizontalAmount, ScrollAmount verticalAmount)
 {
     this._scrollPattern.Scroll(horizontalAmount: UiaConvert.Convert(scrollAmount: horizontalAmount), verticalAmount: UiaConvert.Convert(scrollAmount: verticalAmount));
 }
Exemple #12
0
 public void SetDockPosition(DockPosition dockPosition)
 {
     this._dockPattern.SetDockPosition(dockPos: UiaConvert.Convert(position: dockPosition));
 }
Exemple #13
0
 public void SetWindowVisualState(WindowVisualState state)
 {
     this._windowPattern.SetWindowVisualState(state: UiaConvert.Convert(state: state));
 }
        internal static void Add(
            AutomationElement element,
            TreeScope scope,
            AutomationPropertyChangedEventHandler handlingDelegate,
            AutomationProperty[] properties)
        {
            var e               = new AutomationPropertyChangedEventHandlerImpl(uiAutomationElement: element.IUIAutomationElement, handlingDelegate: handlingDelegate);
            var cacheRequest    = AutomationElement.DefaultCacheRequest.IUIAutomationCacheRequest;
            var propertiesArray = properties.Select(selector: p => p.Id).ToArray();

            Boundary.UIAutomation(a: () => Automation.AutomationClass.AddPropertyChangedEventHandler(element: e._uiAutomationElement, scope: UiaConvert.Convert(treeScope: scope), cacheRequest: cacheRequest, handler: e, propertyArray: propertiesArray));
            Add(instance: e);
        }