Description of SingleControlSearcherData.
Inheritance: ControlSearcherTemplateData
Exemple #1
0
        public virtual List <IUiElement> GetElements(ControlSearcherTemplateData data)
        {
            ResultCollection = new List <IUiElement>();

            SingleControlSearcherData controlSearcherData = null;

            if (null != data)
            {
                controlSearcherData = data.ConvertControlSearcherTemplateDataToSingleControlSearcherData();
                SearchData          = data;
            }
            if (null == controlSearcherData)
            {
                controlSearcherData = SearchData.ConvertControlSearcherTemplateDataToSingleControlSearcherData();
            }
            if (null == controlSearcherData)
            {
                return(ResultCollection);
            }

            if (!string.IsNullOrEmpty(controlSearcherData.ContainsText))
            {
                controlSearcherData.Name = controlSearcherData.Value = controlSearcherData.ContainsText;
            }

            ResultCollection = FilterElements(controlSearcherData, LoadElements(controlSearcherData));

            return(ResultCollection);
        }
 internal override List<IUiElement> FilterElements(SingleControlSearcherData controlSearcherData, List<IUiElement> initialCollection)
 {
     const WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled;
     var wildcardName = new WildcardPattern(controlSearcherData.Name ?? "*", options);
     var wildcardValue = new WildcardPattern(controlSearcherData.Value ?? "*", options);
     
     foreach (IUiElement element in initialCollection) {
         if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, element.GetCurrent().Name))
             continue;
         if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, element.GetCurrent().AutomationId))
             continue;
         if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, element.GetCurrent().ClassName))
             continue;
         try {
             string elementValue = element.GetCurrentPattern<IValuePattern>(classic.ValuePattern.Pattern).Current.Value;
             if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, elementValue))
                 continue;
             if (element.IsMatchWildcardPattern(ResultCollection, wildcardValue, elementValue))
                 continue;
         } catch {
         }
     }
     
     return ResultCollection;
 }
Exemple #3
0
 public static List<IUiElement> SearchByContainsTextViaWin32(
 	IUiElement inputObject,
     string containsText,
     string[] controlTypeNames,
     IEnumerable<IUiElement> collection,
     IEnumerable<int> handles)
 {
 	var singleControlSearcherData = new SingleControlSearcherData { Name = containsText, ControlType = controlTypeNames };
 	var controlProvider = FakeFactory.GetControlFromWin32Provider_old(collection, singleControlSearcherData);
 	
 	controlProvider.HandleCollector = FakeFactory.GetHandleCollector(inputObject, new int[] {}, collection.ToArray());
 	return ControlSearcher.SearchByContainsTextViaWin32(inputObject, controlProvider).ToList();
 }
        internal override List <IUiElement> FilterElements(SingleControlSearcherData controlSearcherData, List <IUiElement> initialCollection)
        {
            const WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled;
            var wildcardName  = new WildcardPattern(controlSearcherData.Name ?? "*", options);
            var wildcardValue = new WildcardPattern(controlSearcherData.Value ?? "*", options);

            foreach (IUiElement element in initialCollection)
            {
                if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, element.GetCurrent().Name))
                {
                    continue;
                }
                if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, element.GetCurrent().AutomationId))
                {
                    continue;
                }
                if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, element.GetCurrent().ClassName))
                {
                    continue;
                }
                try {
                    string elementValue = element.GetCurrentPattern <IValuePattern>(classic.ValuePattern.Pattern).Current.Value;
                    if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, elementValue))
                    {
                        continue;
                    }
                    if (element.IsMatchWildcardPattern(ResultCollection, wildcardValue, elementValue))
                    {
                        continue;
                    }
                } catch {
                }
            }

            return(ResultCollection);
        }
 internal override List<IUiElement> LoadElements(SingleControlSearcherData controlSearcherData)
 {
     return ResultCollection;
 }
//        public override List<IUiElement> GetElements(ControlSearcherTemplateData data)
//        {
//            return new List<IUiElement>();
//        }
        
        internal override List<IUiElement> FilterElements(SingleControlSearcherData controlSearcherData, List<IUiElement> initialCollection)
        {
            return ResultCollection;
        }
Exemple #7
0
 internal IEnumerable<IUiElement> SearchByWildcardViaWin32(
     IUiElement inputObject,
     ControlSearcherData data,
     HandleCollector handleCollector)
 {
     var tempListWin32 = new List<IUiElement>();
     
     if (!string.IsNullOrEmpty(data.Name) || !string.IsNullOrEmpty(data.Value)) {
         
         var controlFrom32Provider = AutomationFactory.GetObject<ControlFromWin32Provider>();
         
         var singleControlSearcherData = new SingleControlSearcherData {
             InputObject = inputObject,
             Name = data.Name,
             Value = data.Value,
             AutomationId = data.AutomationId,
             Class = data.Class
         };
         
         controlFrom32Provider.HandleCollector = handleCollector;
         
         tempListWin32.AddRange(
             controlFrom32Provider.GetElements(
                 singleControlSearcherData.ConvertSingleControlSearcherDataToControlSearcherTemplateData()));
     }
     
     var resultList = new List<IUiElement>();
     
     foreach (IUiElement tempElement3 in tempListWin32) {
         
         bool goFurther = true;
         
         if (null != data.ControlType && 0 < data.ControlType.Length) {
             
             // 20140312
             // goFurther &= !data.ControlType.Any(controlTypeName => String.Equals(tempElement3.Current.ControlType.ProgrammaticName.Substring(12), controlTypeName, StringComparison.CurrentCultureIgnoreCase));
             goFurther &= !data.ControlType.Any(controlTypeName => String.Equals(tempElement3.GetCurrent().ControlType.ProgrammaticName.Substring(12), controlTypeName, StringComparison.CurrentCultureIgnoreCase));
             
         } else {
             goFurther = false;
         }
         
         if (goFurther) continue;
         
         if (null == data.SearchCriteria || 0 == data.SearchCriteria.Length) {
             
             resultList.Add(tempElement3);
         } else {
             
             if (!TestControlWithAllSearchCriteria(data.SearchCriteria, tempElement3)) continue;
             resultList.Add(tempElement3);
         }
     }
     
     if (null != tempListWin32) {
         tempListWin32.Clear();
         tempListWin32 = null;
     }
     
     return resultList;
 }
Exemple #8
0
 internal static ControlSearcherTemplateData ConvertSingleControlSearcherDataToControlSearcherTemplateData(this SingleControlSearcherData data)
 {
     return(new ControlSearcherTemplateData {
         InputObject = new IUiElement[] { data.InputObject },
         Name = data.Name,
         AutomationId = data.AutomationId,
         Class = data.Class,
         Value = data.Value,
         ControlType = data.ControlType,
         ContainsText = data.ContainsText,
         Win32 = data.Win32,
         CaseSensitive = data.CaseSensitive,
         Regex = data.Regex,
         SearchCriteria = data.SearchCriteria
     });
 }
 internal override List<IUiElement> LoadElements(SingleControlSearcherData controlSearcherData)
 {
     return HandleCollector.GetElementsFromHandles(HandleCollector.CollectRecursively(controlSearcherData.InputObject, controlSearcherData.Name, 1));
 }
Exemple #10
0
 internal abstract List <IUiElement> LoadElements(SingleControlSearcherData controlSearcherData);
Exemple #11
0
 internal abstract List <IUiElement> FilterElements(SingleControlSearcherData controlSearcherData, List <IUiElement> initialCollection);
 internal override List <IUiElement> LoadElements(SingleControlSearcherData controlSearcherData)
 {
     return(ResultCollection);
 }
//        public override List<IUiElement> GetElements(ControlSearcherTemplateData data)
//        {
//            return new List<IUiElement>();
//        }

        internal override List <IUiElement> FilterElements(SingleControlSearcherData controlSearcherData, List <IUiElement> initialCollection)
        {
            return(ResultCollection);
        }
Exemple #14
0
        internal IEnumerable <IUiElement> SearchByWildcardViaWin32(
            IUiElement inputObject,
            ControlSearcherData data,
            HandleCollector handleCollector)
        {
            var tempListWin32 = new List <IUiElement>();

            if (!string.IsNullOrEmpty(data.Name) || !string.IsNullOrEmpty(data.Value))
            {
                var controlFrom32Provider = AutomationFactory.GetObject <ControlFromWin32Provider>();

                var singleControlSearcherData = new SingleControlSearcherData {
                    InputObject  = inputObject,
                    Name         = data.Name,
                    Value        = data.Value,
                    AutomationId = data.AutomationId,
                    Class        = data.Class
                };

                controlFrom32Provider.HandleCollector = handleCollector;

                tempListWin32.AddRange(
                    controlFrom32Provider.GetElements(
                        singleControlSearcherData.ConvertSingleControlSearcherDataToControlSearcherTemplateData()));
            }

            var resultList = new List <IUiElement>();

            foreach (IUiElement tempElement3 in tempListWin32)
            {
                bool goFurther = true;

                if (null != data.ControlType && 0 < data.ControlType.Length)
                {
                    // 20140312
                    // goFurther &= !data.ControlType.Any(controlTypeName => String.Equals(tempElement3.Current.ControlType.ProgrammaticName.Substring(12), controlTypeName, StringComparison.CurrentCultureIgnoreCase));
                    goFurther &= !data.ControlType.Any(controlTypeName => String.Equals(tempElement3.GetCurrent().ControlType.ProgrammaticName.Substring(12), controlTypeName, StringComparison.CurrentCultureIgnoreCase));
                }
                else
                {
                    goFurther = false;
                }

                if (goFurther)
                {
                    continue;
                }

                if (null == data.SearchCriteria || 0 == data.SearchCriteria.Length)
                {
                    resultList.Add(tempElement3);
                }
                else
                {
                    if (!TestControlWithAllSearchCriteria(data.SearchCriteria, tempElement3))
                    {
                        continue;
                    }
                    resultList.Add(tempElement3);
                }
            }

            if (null != tempListWin32)
            {
                tempListWin32.Clear();
                tempListWin32 = null;
            }

            return(resultList);
        }
 internal override List <IUiElement> LoadElements(SingleControlSearcherData controlSearcherData)
 {
     return(HandleCollector.GetElementsFromHandles(HandleCollector.CollectRecursively(controlSearcherData.InputObject, controlSearcherData.Name, 1)));
 }