TableCollectionNavigator.cs 918 B

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