Beispiel #1
0
 internal AutomationElement(IElement sourceElement)
 {
     this.sourceElement = sourceElement;
     current            = new AutomationElementInformation(this, false);
     cached             = new AutomationElementInformation(this, true);
     propertyCache      = new Dictionary <int, CachedValue> ();
     mode = AutomationElementMode.Full;
 }
Beispiel #2
0
        private List <AutomationElement> Find(TreeScope scope, Condition condition, bool findFirst)
        {
            // Parent and Ancestors scopes are not supported on
            // Windows (this is specified in MSDN, too).
            if ((scope & TreeScope.Parent) == TreeScope.Parent ||
                (scope & TreeScope.Ancestors) == TreeScope.Ancestors)
            {
                throw new ArgumentException("scope");
            }

            List <AutomationElement> found = new List <AutomationElement> ();

            if ((!findFirst || found.Count == 0) &&
                (scope & TreeScope.Element) == TreeScope.Element &&
                condition.AppliesTo(this) &&
                (CacheRequest.Current == CacheRequest.DefaultRequest || CacheRequest.Current.TreeFilter.AppliesTo(this)))
            {
                // TODO: Need to check request's TreeScope, too?
                found.Add(GetUpdatedCache(CacheRequest.Current));
            }

            if ((!findFirst || found.Count == 0) &&
                ((scope & TreeScope.Children) == TreeScope.Children ||
                 (scope & TreeScope.Descendants) == TreeScope.Descendants))
            {
                TreeScope childScope = TreeScope.Element;
                if ((scope & TreeScope.Descendants) == TreeScope.Descendants)
                {
                    childScope = TreeScope.Subtree;
                }
                AutomationElement current =
                    TreeWalker.RawViewWalker.GetFirstChild(this);
                while (current != null)
                {
                    //Log.Debug ("Inspecting child: " + current.Current.Name);
                    found.AddRange(current.Find(childScope, condition, findFirst));
                    if (findFirst && found.Count > 0)
                    {
                        break;
                    }
                    current = TreeWalker.RawViewWalker.GetNextSibling(current);
                }
            }

            return(found);
        }
Beispiel #3
0
		private List<AutomationElement> Find (TreeScope scope, Condition condition, bool findFirst)
		{
			// Parent and Ancestors scopes are not supported on
			// Windows (this is specified in MSDN, too).
			if ((scope & TreeScope.Parent) == TreeScope.Parent ||
			    (scope & TreeScope.Ancestors) == TreeScope.Ancestors)
				throw new ArgumentException ("scope");

			List<AutomationElement> found = new List<AutomationElement> ();

			if ((!findFirst || found.Count == 0) &&
			    (scope & TreeScope.Element) == TreeScope.Element &&
			    condition.AppliesTo (this) &&
			    (CacheRequest.Current == CacheRequest.DefaultRequest || CacheRequest.Current.TreeFilter.AppliesTo (this))) {
				// TODO: Need to check request's TreeScope, too?
				found.Add (GetUpdatedCache (CacheRequest.Current));
			}

			if ((!findFirst || found.Count == 0) &&
			    ((scope & TreeScope.Children) == TreeScope.Children ||
			    (scope & TreeScope.Descendants) == TreeScope.Descendants)) {
				TreeScope childScope = TreeScope.Element;
				if ((scope & TreeScope.Descendants) == TreeScope.Descendants)
					childScope = TreeScope.Subtree;
				AutomationElement current =
					TreeWalker.RawViewWalker.GetFirstChild (this);
				while (current != null) {
					//Log.Debug ("Inspecting child: " + current.Current.Name);
					found.AddRange (current.Find (childScope, condition, findFirst));
					if (findFirst && found.Count > 0)
						break;
					current = TreeWalker.RawViewWalker.GetNextSibling (current);
				}
			}

			return found;
		}
Beispiel #4
0
		internal AutomationElement (IElement sourceElement)
		{
			this.sourceElement = sourceElement;
			current = new AutomationElementInformation (this, false);
			cached = new AutomationElementInformation (this, true);
			propertyCache = new Dictionary<int, CachedValue> ();
			mode = AutomationElementMode.Full;
		}