private void CreateTree(IUIItem parent, Element parentElement) { var types = (from c in parent.GetMultiple(SearchCriteria.All) select c.GetType()).Distinct(); var items = from c in parent.GetMultiple(SearchCriteria.All) select c; foreach (var type in types) { var elementType = new Element { Text = type.ToString().Split('.').Last() }; var index = 0; IEnumerable<IUIItem> final; if (type == typeof(CustomUIItem)) { final = items.Where(n => n.GetType() == type); } else { final = parent.GetMultiple(SearchCriteria.ByControlType(type, parent.Framework)); } foreach (var control in final) { var childElement = new Element { Text = "[Index: " + index + "] - [ID: " + control.Id + "] - [Coordinates: " + control.Bounds + "]", Target = control }; elementType.Elements.Add(childElement); if (type == typeof(Panel) || type == typeof(CustomUIItem)) { CreateTree(control, childElement); } index++; } parentElement.Elements.Add(elementType); } }
/// <summary> /// Get multiple UI Items /// </summary> /// <typeparam name="T">Type of Item</typeparam> /// <param name="uiItem">The root UI Item from were to start searching</param> /// <param name="searchCriteria">The Search Criteria to use for the Search</param> /// <returns>Located UI Items</returns> public static T[] GetMultiple <T>(this IUIItem uiItem, SearchCriteria searchCriteria) where T : IUIItem { return(searchCriteria == null ? uiItem.GetMultiple <T>() : GetUiItemContainer(uiItem).GetMultiple <T>(searchCriteria)); }
/// <summary> /// Get multiple UI Items by a specific Search Critera /// </summary> /// <param name="uiItem">The root UI Item from were to start searching</param> /// <param name="searchCriteria">The Search Criteria to use for the Search</param> /// <returns>Located UI Items</returns> public static IUIItem[] GetMultiple(this IUIItem uiItem, SearchCriteria searchCriteria) { return(searchCriteria == null ? uiItem.GetMultiple() : GetUiItemContainer(uiItem).GetMultiple(searchCriteria)); }
private TreeViewItem CreateTreeItem(IUIItem control, int index) { var item = new TreeViewItem(); item.Header = "[Index: " + index + "] - [ID: " + control.Id + "] - [Coordinates: " + control.Bounds + "]"; item.Tag = control; try { switch (control.Framework) { case WindowsFramework.None: case WindowsFramework.Silverlight: case WindowsFramework.Swt: case WindowsFramework.Win32: case WindowsFramework.WinForms: case WindowsFramework.Wpf: var types = (from c in control.GetMultiple(SearchCriteria.All) select c.GetType()).Distinct(); foreach (var type in types) { item.Items.Add(CreateTreeItem(type.ToString().Split('.').LastOrDefault(), type)); } break; default: break; } } catch { } return item; }