private void SetForegroundColor(DataHighlightColor color) { var selectedColumns = _table.GetSelectedDataColumnIndexes(_clickedColumnIndex); _stylingOptions.ForegroundColors = DataHighlightColors.UpdateColorStringRange(_stylingOptions.ForegroundColors, selectedColumns, color, _table.DataColumnCount); _table.ClearSelection(); }
private static char GetCharRepresentation(this DataHighlightColor color) { switch (color) { case DataHighlightColor.Red: return('r'); case DataHighlightColor.Green: return('g'); case DataHighlightColor.Blue: return('b'); default: return(' '); } }
public static string GetDisplayName(this DataHighlightColor item) { switch (item) { case DataHighlightColor.None: return("Data"); case DataHighlightColor.Inactive: return("Data - Inactive"); case DataHighlightColor.Red: return("Data - Red Highlight"); case DataHighlightColor.Green: return("Data - Green Highlight"); case DataHighlightColor.Blue: return("Data - Blue Highlight"); } throw new NotImplementedException(); }
public (Color fg, Color bg, bool bold) GetHighlightInfo(DataHighlightColor highlight) { ThreadHelper.ThrowIfNotOnUIThread(); return(GetInfo(highlight.GetDisplayName())); }
public static string UpdateColorStringRange(string colorString, IEnumerable <int> indexes, DataHighlightColor newColor, int columnCount) { StringBuilder colors = new StringBuilder(columnCount); if (colorString?.Length == columnCount) { colors.Append(colorString); } else { colors.Append(' ', columnCount); } foreach (var i in indexes) { if (i >= 0 && i < columnCount) { colors[i] = newColor.GetCharRepresentation(); } } colorString = colors.ToString(); if (string.IsNullOrWhiteSpace(colorString)) { return(""); } return(colorString); }