public string GetValueNew(int row, int column) { string somenonsense = ""; if (PElementPattern) { TablePattern gridItem = (BasePattern)basePattern2 as TablePattern; if (gridItem != null) { var tableitem = gridItem.GetItem(row, column); somenonsense = tableitem.Current.Name; } } return(somenonsense); }
public void TableItemPatternTest() { var pattern = (TableItemPattern)tablePattern.GetItem(1, 2). GetCurrentPattern(TableItemPattern.Pattern); Assert.AreEqual(2, pattern.Current.Column, "Column"); Assert.AreEqual(1, pattern.Current.Row, "Row"); Assert.AreEqual(1, pattern.Current.ColumnSpan, "ColumnSpan"); Assert.AreEqual(1, pattern.Current.RowSpan, "RowSpan"); //todo comment below line to make following code run //Assert.AreEqual (table1Element, pattern.Current.ContainingGrid, // "ContainingGrid"); Assert.AreEqual(0, pattern.Current.GetRowHeaderItems().Length, "row headers"); VerifyTableColumnHeaders(pattern.Current.GetColumnHeaderItems()); }
public string GetValue(int row, int column) { string somenonsense = ""; object basePattern; if (PurpleElement.TryGetCurrentPattern(TablePattern.Pattern, out basePattern)) { TablePattern gridItem = (BasePattern)basePattern as TablePattern; if (gridItem != null) { var tableitem = gridItem.GetItem(row, column); somenonsense = tableitem.Current.Name; } } return(somenonsense); }
public void TablePatternCachedTest() { CacheRequest req = new CacheRequest(); req.Add(TablePattern.Pattern); req.Add(TableItemPattern.Pattern); req.Add(GridPattern.Pattern); req.Add(GridItemPattern.Pattern); req.Add(GridPattern.RowCountProperty); req.Add(GridPattern.ColumnCountProperty); req.Add(GridItemPattern.RowProperty); req.Add(GridItemPattern.ColumnProperty); req.Add(GridItemPattern.ContainingGridProperty); req.Add(TablePattern.RowHeadersProperty); req.Add(TablePattern.ColumnHeadersProperty); req.Add(TableItemPattern.RowHeaderItemsProperty); req.Add(TableItemPattern.ColumnHeaderItemsProperty); using (req.Activate()) { AutomationElement itemsView = ExplorerTargetTests.explorerHost.Element.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.ClassNameProperty, "UIItemsView")); Assert.IsNotNull(itemsView); // TablePattern test TablePattern table = (TablePattern)itemsView.GetCachedPattern(TablePattern.Pattern); Assert.IsTrue(table.Cached.ColumnCount > 0); Assert.IsTrue(table.Cached.RowCount > 0); Assert.IsTrue(table.Cached.GetRowHeaders().Length == 0); Assert.IsTrue(table.Cached.GetColumnHeaders().Length > 0); AutomationElement tableItemElement = table.GetItem(0, 0); TableItemPattern tableItem = (TableItemPattern)tableItemElement.GetCachedPattern(TableItemPattern.Pattern); Assert.AreEqual(tableItem.Cached.Row, 0); Assert.AreEqual(tableItem.Cached.Column, 0); Assert.AreEqual(tableItem.Cached.ContainingGrid, itemsView); Assert.IsTrue(tableItem.Cached.GetColumnHeaderItems().Length == 1); Assert.IsTrue(tableItem.Cached.GetRowHeaderItems().Length == 0); } }
public void TablePatternTest() { AutomationElement itemsView = ExplorerTargetTests.explorerHost.Element.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.ClassNameProperty, "UIItemsView")); Assert.IsNotNull(itemsView); // TablePattern test TablePattern table = (TablePattern)itemsView.GetCurrentPattern(TablePattern.Pattern); Assert.IsTrue(table.Current.ColumnCount > 0); Assert.IsTrue(table.Current.RowCount > 0); Assert.IsTrue(table.Current.GetRowHeaders().Length == 0); Assert.IsTrue(table.Current.GetColumnHeaders().Length > 0); AutomationElement tableItemElement = table.GetItem(0, 0); TableItemPattern tableItem = (TableItemPattern)tableItemElement.GetCurrentPattern(TableItemPattern.Pattern); Assert.AreEqual(tableItem.Current.Row, 0); Assert.AreEqual(tableItem.Current.Column, 0); Assert.AreEqual(tableItem.Current.ContainingGrid, itemsView); Assert.IsTrue(tableItem.Current.GetColumnHeaderItems().Length == 1); Assert.IsTrue(tableItem.Current.GetRowHeaderItems().Length == 0); }
// </Snippet102> // <Snippet103> ///-------------------------------------------------------------------- /// <summary> /// Event handler for table item focus change. /// Can be used to track traversal of individual table items /// within a table. /// </summary> /// <param name="src">Object that raised the event.</param> /// <param name="e">Event arguments.</param> ///-------------------------------------------------------------------- private void OnTableItemFocusChange( object src, AutomationFocusChangedEventArgs e) { // Make sure the element still exists. Elements such as tooltips // can disappear before the event is processed. AutomationElement sourceElement; try { sourceElement = src as AutomationElement; } catch (ElementNotAvailableException) { return; } // Get a TableItemPattern from the source of the event. TableItemPattern tableItemPattern = GetTableItemPattern(sourceElement); if (tableItemPattern == null) { return; } // Get a TablePattern from the container of the current element. TablePattern tablePattern = GetTablePattern(tableItemPattern.Current.ContainingGrid); if (tablePattern == null) { return; } AutomationElement tableItem = null; try { tableItem = tablePattern.GetItem( tableItemPattern.Current.Row, tableItemPattern.Current.Column); } catch (ArgumentOutOfRangeException) { // If the requested row coordinate is larger than the RowCount // or the column coordinate is larger than the ColumnCount. // -- OR -- // If either of the requested row or column coordinates // is less than zero. // TO DO: error handling. } // Further event processing can be done at this point. // For the purposes of this sample we can just record item properties. string controlType = tableItem.Current.ControlType.LocalizedControlType; AutomationElement[] columnHeaders = tableItemPattern.Current.GetColumnHeaderItems(); AutomationElement[] rowHeaders = tableItemPattern.Current.GetRowHeaderItems(); int itemRow = tableItemPattern.Current.Row; int itemColumn = tableItemPattern.Current.Column; int itemRowSpan = tableItemPattern.Current.RowSpan; int itemColumnSpan = tableItemPattern.Current.ColumnSpan; }
public string TextAt(int column, int row) { return(Pattern.GetItem(row, column).GetCurrentPropertyValue(AutomationElement.NameProperty).ToString()); }
/// <summary> /// Gets the item at the specified cell. /// </summary> /// <param name="control">The UI Automation element</param> /// <param name="row">The row of the item to retrieve.</param> /// <param name="column">The column of the item to retrieve.</param> /// <returns> /// The Automation Element at the supplied row/column intersection /// </returns> internal static AutomationElement GetItem(AutomationElement control, int row, int column) { TablePattern pat = (TablePattern)CommonUIAPatternHelpers.CheckPatternSupport(TablePattern.Pattern, control); return(pat.GetItem(row, column)); }