public virtual void Draw(Surfaces.SurfaceBase surface, Rectangle area, object item, ControlStates itemState) { if (item is Color || item is Tuple <Color, Color, string> ) { string value = new string(' ', area.Width - 2); Cell cellLook = GetStateAppearance(itemState).Clone(); if (item is Color color) { cellLook.Background = color; surface.Print(area.Left + 1, area.Top, value, cellLook); } else { cellLook.Foreground = ((Tuple <Color, Color, string>)item).Item2; cellLook.Background = ((Tuple <Color, Color, string>)item).Item1; value = ((Tuple <Color, Color, string>)item).Item3.Align(HorizontalAlignment.Left, area.Width - 2); surface.Print(area.Left + 1, area.Top, value, cellLook); } surface.Print(area.Left, area.Top, " ", cellLook); surface.Print(area.Left + area.Width - 1, area.Top, " ", cellLook); if (itemState.HasFlag(ControlStates.Clicked)) { surface.SetGlyph(area.Left, area.Top, 16); surface.SetGlyph(area.Left + area.Width - 1, area.Top, 17); } } else { base.Draw(surface, area, item, itemState); } }
public virtual void Draw(Surfaces.SurfaceBase surface, Rectangle area, object item, ControlStates itemState) { string value = item.ToString(); if (value.Length < area.Width) { value += new string(' ', area.Width - value.Length); } else if (value.Length > area.Width) { value = value.Substring(0, area.Width); } if (Helpers.HasFlag(itemState, ControlStates.Selected) && !Helpers.HasFlag(itemState, ControlStates.MouseOver)) { surface.Print(area.Left, area.Top, value, Selected); } else { surface.Print(area.Left, area.Top, value, GetStateAppearance(itemState)); } }