// Creates new header for specified row AutomationElement (use only when no Header is available) private static ListViewHeader GetHeader(AutomationElement automationElement, IActionListener actionListener) { var parentGrid = TreeWalker.ControlViewWalker.GetParent(automationElement); if (parentGrid == null) { throw new UIItemSearchException("Can't find parent DataGrid element"); } if (parentGrid.Current.ControlType != ControlType.DataGrid) { throw new UIItemSearchException("Parent of specified element is not DataGrid"); } var parentGridFinder = new AutomationElementFinder(parentGrid); var factory = new ListViewFactory(parentGridFinder, actionListener); return(factory.Header); }
public ListView(AutomationElement automationElement, IActionListener actionListener) : base(automationElement, actionListener) { listViewFactory = new ListViewFactory(new AutomationElementFinder(automationElement), this); }
/// <summary> /// Tworzy widok listy /// </summary> /// <typeparam name="T"></typeparam> /// <param name="title"></param> /// <param name="description"></param> /// <returns></returns> public virtual ListViewFactory <T> CreateGrid <T>(string title = null, string description = null) { var view = new ListViewFactory <T>(); var visibleProperty = new List <VisibleProperty>(); var type = typeof(T); var properties = type.GetProperties(); foreach (var propertyInfo in properties) { var scaffoldColumns = propertyInfo.GetCustomAttributes(typeof(GridViewAttribute)); if (scaffoldColumns.Any()) { var scaffoldColumn = scaffoldColumns.First() as GridViewAttribute; if (scaffoldColumn != null) { var vp = new VisibleProperty() { ListView = scaffoldColumn, PropertyInfo = propertyInfo }; if (propertyInfo.PropertyType == typeof(bool)) { vp.ListView.ColumnType = GridColumnType.CheckboxColumn; } visibleProperty.Add(vp); } } } var df = view.AddDataForm(); if (title != null) { df.AddLabel(title); } if (description != null) { df.AddLabel(description); } var grid = df.AddGridView(); grid.GridView.GroupingEnabled = true; grid.GridView.AllowFilteringByColumn = true; grid.GridView.AllowSorting = true; grid.GridView.AggregateEnabled = true; foreach (var property in visibleProperty) { var column = grid.Column(property.PropertyInfo.Name).Label(property.ListView.Label ?? property.PropertyInfo.Name); column.Column.FilterFunction = property.ListView.FilterFunction; column.Column.FilterDefaultValue = property.ListView.FilterDefaultValue; column.Column.ColumnType = property.ListView.ColumnType; if (property.ListView.FilterFunction != GridKnownFunction.NoFilter) { column.ShowColumnFilter(); } column.Column.Width = property.ListView.Width; column.Column.DataFormatString = property.ListView.DataFormatString; column.Column.Aggregate = property.ListView.Aggregate; column.Column.DataTypeName = property.ListView.ColumnDataType?.AssemblyQualifiedName; //property.PropertyInfo.PropertyType.AssemblyQualifiedName; } view.Grid = grid; return(view); }