public override Component GetRowInformation(T data, int index, int width, bool isFocused, bool isSelected, TableComponent <T> parent) { // Cache the same component so as to avoid recreating lots of components. return(new TextComponent { Text = _infoGetter(data), Background = isFocused ? _colorGetter?.Invoke(data) : null, Foreground = isFocused ? null : _colorGetter?.Invoke(data), HAlign = HAlign }); }
public override Component GetRowInformation(T data, int index, int width, bool isFocused, bool isSelected, TableComponent <T> parent) { if (isFocused && isSelected) { return(new TextComponent("=")); } if (isFocused) { return(new TextComponent(">")); } if (isSelected) { return(new TextComponent("*")); } return(new TextComponent(" ")); }
public override Component GetRowInformation(T data, int index, int width, bool isFocused, bool isSelected, TableComponent <T> parent) { if (data == null) { return(new TextComponent()); } var possibilities = new List <string>(_translators(data)); possibilities.Sort((s1, s2) => s1.Length.CompareTo(s2.Length)); return(possibilities.Any(s => s.Length <= width) ? new TextComponent(possibilities.Last(s => s.Length <= width)) { HAlign = HAlign, Background = isFocused ? _colorGetter?.Invoke(data) : null, Foreground = isFocused ? null : _colorGetter?.Invoke(data) } : new TextComponent(possibilities.MinBy(s => s.Length).First()) { Background = isFocused ? _colorGetter?.Invoke(data) : null, Foreground = isFocused ? null : _colorGetter?.Invoke(data) }); }
public abstract string GetTitle(TableComponent <T> parent, int width);
public abstract Component GetRowInformation(T data, int index, int width, bool isFocused, bool isSelected, TableComponent <T> parent);
public override string GetTitle(TableComponent <T> parent, int width) { return(ColumnTitle); }
public override string GetTitle(TableComponent <T> parent, int width) { return(_titles.Last(s => s.Length <= width)); }