TableCollectionNavigator.cs 874 B

1234567891011121314151617181920212223242526272829303132333435
  1. namespace Terminal.Gui {
  2. /// <summary>
  3. /// Collection navigator for cycling selections in a <see cref="TableView"/>.
  4. /// </summary>
  5. public class TableCollectionNavigator : CollectionNavigatorBase {
  6. readonly TableView tableView;
  7. /// <summary>
  8. /// Creates a new instance for navigating the data in the wrapped <paramref name="tableView"/>.
  9. /// </summary>
  10. public TableCollectionNavigator (TableView tableView)
  11. {
  12. this.tableView = tableView;
  13. }
  14. /// <inheritdoc/>
  15. protected override object ElementAt (int idx)
  16. {
  17. var col = tableView.SelectedColumn;
  18. var rawValue = tableView.Table [idx, col];
  19. var style = this.tableView.Style.GetColumnStyleIfAny (col);
  20. return style?.RepresentationGetter?.Invoke (rawValue) ?? rawValue;
  21. }
  22. /// <inheritdoc/>
  23. protected override int GetCollectionLength ()
  24. {
  25. return tableView.Table.Rows;
  26. }
  27. }
  28. }