Exemple #1
0
        private void FindMatchingDescendants(AutomationElement element, AutomationSearchCondition automationSearchCondition,
                                             ElementSearchResult elementSearchResult, int depth)
        {
            if (depth == 0)
            {
                return;
            }
            logger.DebugFormat("[RawSearch] Finding descendants of: ({0})", element.Display());
            AutomationElement current = RawViewWalker.GetFirstChild(element);

            while (current != null)
            {
                MatchElement(current, automationSearchCondition, elementSearchResult);
                if (elementSearchResult.AllResultsFound)
                {
                    return;
                }
                FindMatchingDescendants(current, automationSearchCondition, elementSearchResult, depth - 1);
                if (elementSearchResult.AllResultsFound)
                {
                    return;
                }
                current = RawViewWalker.GetNextSibling(current);
            }
        }
 private void MatchElement(AutomationElement current, AutomationSearchCondition automationSearchCondition, ElementSearchResult elementSearchResult)
 {
     logger.DebugFormat("[RawSearch] Matching: ({0})", current.Display());
     if (automationSearchCondition.Satisfies(current))
     {
         logger.DebugFormat("[RawSearch] Matched: ({0})", current.Display());
         elementSearchResult.Add(current);
     }
 }
 private void FindMatchingDescendants(AutomationElement element, AutomationSearchCondition automationSearchCondition,
     ElementSearchResult elementSearchResult, int depth)
 {
     if (depth == 0)
     {
         return;
     }
     logger.DebugFormat("[RawSearch] Finding descendants of: ({0})", element.Display());
     AutomationElement current = RawViewWalker.GetFirstChild(element);
     while (current != null)
     {
         MatchElement(current, automationSearchCondition, elementSearchResult);
         if (elementSearchResult.AllResultsFound) return;
         FindMatchingDescendants(current, automationSearchCondition, elementSearchResult, depth - 1);
         if (elementSearchResult.AllResultsFound) return;
         current = RawViewWalker.GetNextSibling(current);
     }
 }
Exemple #4
0
 private void MatchElement(AutomationElement current, AutomationSearchCondition automationSearchCondition, ElementSearchResult elementSearchResult)
 {
     logger.DebugFormat("[RawSearch] Matching: ({0})", current.Display());
     if (automationSearchCondition.Satisfies(current))
     {
         logger.DebugFormat("[RawSearch] Matched: ({0})", current.Display());
         elementSearchResult.Add(current);
     }
 }
Exemple #5
0
 private ElementSearchResult FindAll(AutomationSearchCondition automationSearchCondition, ElementSearchResult elementSearchResult, int depth)
 {
     logger.DebugFormat("[RawSearch] Finding in: ({0})", automationElement.Display());
     FindMatchingDescendants(automationElement, automationSearchCondition, elementSearchResult, depth);
     return(elementSearchResult);
 }
Exemple #6
0
 public virtual List <AutomationElement> Descendants(AutomationSearchCondition automationSearchCondition)
 {
     return(FindAll(automationSearchCondition, ElementSearchResult.ForMany(), CoreAppXmlConfiguration.Instance.MaxElementSearchDepth).Elements);
 }
Exemple #7
0
 public virtual AutomationElement Descendant(AutomationSearchCondition automationSearchCondition)
 {
     return
         (FindAll(automationSearchCondition, ElementSearchResult.ForOne(), CoreAppXmlConfiguration.Instance.MaxElementSearchDepth).Elements.FirstOrDefault
              ());
 }
Exemple #8
0
 public virtual AutomationElement Child(AutomationSearchCondition automationSearchCondition)
 {
     return(FindAll(automationSearchCondition, ElementSearchResult.ForOne(), 1).Elements.FirstOrDefault());
 }
 private ElementSearchResult FindAll(AutomationSearchCondition automationSearchCondition, ElementSearchResult elementSearchResult, int depth)
 {
     logger.DebugFormat("[RawSearch] Finding in: ({0})", automationElement.Display());
     FindMatchingDescendants(automationElement, automationSearchCondition, elementSearchResult, depth);
     return elementSearchResult;
 }