TableCollectionNavigator.cs 879 B

123456789101112131415161718192021222324
  1. namespace Terminal.Gui;
  2. /// <summary>Collection navigator for cycling selections in a <see cref="TableView"/>.</summary>
  3. public 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.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. }