private void afterRenewElementsByAncestorEventHander(object source, ElementsBuilderEventArgs args) { _clickedElement = args.element; _ancestorElements = args.ancestorElements; _childElements = args.childElements; this.BeginInvoke(new Action(() => { this.Hide(); GetDesktopSnapshot(); BuildListviewControl(_childElements, lapListViewObjects, lvItem_lnLinkItemClick); this.Show(); })); }
private void afterPointToElementsEventHander(object source, ElementsBuilderEventArgs args) { _clickedElement = args.element; _ancestorElements = args.ancestorElements; _childElements = args.childElements; //this form hasn't been created, therefore call the parent form's invoke function this.Owner.BeginInvoke(new Action(() => { this.Hide(); GetDesktopSnapshot(); BuildListviewControl(_childElements, lapListViewObjects, lvItem_lnLinkItemClick); BuildBreadcrumbControl(_ancestorElements, breadcrumbControl1); this.Visible = true; })); }
public void PointToElements(Point point) { AutomationElementCollection aeCollection = null; AutomationElement menuAe = null; using (_generalCacheReq.Activate()) { _element = AutomationElement.FromPoint(point); UIAHighlight.HighlightThread_Spy(_element); if (_element.Current.ControlType == ControlType.MenuItem) { if (UIAUtility.ExpandMenuItem(_element) && _element.FindFirst(TreeScope.Children, _propertyMenuItemCondition) == null) { menuAe = RetrieveMenuElement(_element); } } if (menuAe == null) { if (_element.FindFirst(TreeScope.Children, Condition.TrueCondition) == null) { _element = TreeWalker.ControlViewWalker.GetParent(_element); } aeCollection = _element.FindAll(TreeScope.Children, Condition.TrueCondition); } else { aeCollection = menuAe.FindAll(TreeScope.Descendants, _menuCondition); } _ancestorElements.Clear(); _ancestorElements = UIAUtility.GetAutomationElementsLine(_element); _childElements.Clear(); _childElements = aeCollection.Cast <AutomationElement>().ToList(); } Console.WriteLine("childrenelement count {0}, ancestorelement count {1}", _childElements.Count, _ancestorElements.Count); if (null != afterPointToElementsEventHander) { ElementsBuilderEventArgs e = new ElementsBuilderEventArgs(this, _ancestorElements, _childElements, _element); afterPointToElementsEventHander(this, e); } }
public void RenewElementsByAncestor(AutomationElement element) { int indexofAncestor = 0; int AncestorCount = this._ancestorElements.Count; AutomationElementCollection aeCollection = null; AutomationElement menuItemAe = null; AutomationElement menuAe = null; using (_generalCacheReq.Activate()) { for (indexofAncestor = 0; indexofAncestor < AncestorCount; ++indexofAncestor) { if (_ancestorElements[indexofAncestor].Cached.ControlType == ControlType.MenuItem) { menuItemAe = _ancestorElements[indexofAncestor]; using (_generalCacheReq.Activate()) { if (UIAUtility.ExpandMenuItem(menuItemAe) && menuItemAe.FindFirst(TreeScope.Children, _propertyMenuItemCondition) == null) { menuAe = RetrieveMenuElement(menuItemAe); if (menuAe != null) { if (indexofAncestor + 1 < AncestorCount) { _ancestorElements[indexofAncestor + 1] = getChildMenuItemByNameType(menuAe, _ancestorElements[indexofAncestor + 1].Cached.Name); } else { element = getChildMenuItemByNameType(menuAe, element.Cached.Name); } } else { Console.WriteLine("not find menu element {0}", menuItemAe.Cached.Name); } } } } if (UIAUtility.AreEqual3(_ancestorElements[indexofAncestor], element)) //found { element = _ancestorElements[indexofAncestor]; break; } } if (element.Current.ControlType == ControlType.MenuItem) { aeCollection = element.FindAll(TreeScope.Descendants, _menuCondition); } else { if (element.FindFirst(TreeScope.Children, Condition.TrueCondition) == null) { element = UIAUtility.GetParentElement(element); } aeCollection = element.FindAll(TreeScope.Children, Condition.TrueCondition); } _ancestorElements.Clear(); _ancestorElements = UIAUtility.GetAutomationElementsLine(element); _childElements.Clear(); _childElements = aeCollection.Cast <AutomationElement>().ToList(); this._element = element; } Console.WriteLine("childrenelement count {0}, ancestorelement count {1}", _childElements.Count, _ancestorElements.Count); if (null != afterReNewElementsByAncestorEventHander) { ElementsBuilderEventArgs e = new ElementsBuilderEventArgs(this, _ancestorElements, _childElements, _element); afterReNewElementsByAncestorEventHander(this, e); } }