Beispiel #1
0
 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(" "));
 }
Beispiel #3
0
        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)
            });
        }
Beispiel #4
0
 public abstract string GetTitle(TableComponent <T> parent, int width);
Beispiel #5
0
 public abstract Component GetRowInformation(T data, int index, int width, bool isFocused, bool isSelected,
                                             TableComponent <T> parent);
Beispiel #6
0
 public override string GetTitle(TableComponent <T> parent, int width)
 {
     return(ColumnTitle);
 }
Beispiel #7
0
 public override string GetTitle(TableComponent <T> parent, int width)
 {
     return(_titles.Last(s => s.Length <= width));
 }