2
0

TableCollectionNavigator.cs 942 B

12345678910111213141516171819202122232425
  1. #nullable disable
  2. namespace Terminal.Gui.Views;
  3. /// <summary>Collection navigator for cycling selections in a <see cref="TableView"/>.</summary>
  4. internal class TableCollectionNavigator : CollectionNavigatorBase
  5. {
  6. private readonly TableView _tableView;
  7. /// <summary>Creates a new instance for navigating the data in the wrapped <paramref name="tableView"/>.</summary>
  8. public TableCollectionNavigator (TableView tableView) { this._tableView = tableView; }
  9. /// <inheritdoc/>
  10. protected override object ElementAt (int idx)
  11. {
  12. int col = _tableView.FullRowSelect ? 0 : _tableView.SelectedColumn;
  13. object rawValue = _tableView.Table [idx, col];
  14. ColumnStyle style = _tableView.Style.GetColumnStyleIfAny (col);
  15. return style?.RepresentationGetter?.Invoke (rawValue) ?? rawValue;
  16. }
  17. /// <inheritdoc/>
  18. protected override int GetCollectionLength () { return _tableView.Table.Rows; }
  19. }