public void ApplyStyle(DataGridView gridView, DataGridViewRow row, RowStyling style) { var isBold = false; var isItalic = false; if (style.BackgroundColor.HasValue) { row.DefaultCellStyle.BackColor = style.BackgroundColor.Value; } if (style.Bold.HasValue) { isBold = style.Bold.Value; } if (style.ForegroundColor.HasValue) { row.DefaultCellStyle.ForeColor = style.ForegroundColor.Value; } if (style.Italic.HasValue) { isItalic = style.Italic.Value; } var newFontStyle = (isItalic ? FontStyle.Italic : FontStyle.Regular) | (isBold ? FontStyle.Bold : FontStyle.Regular); var defaultFont = row.DefaultCellStyle.Font ?? gridView.DefaultCellStyle.Font; row.DefaultCellStyle.Font = new Font(defaultFont, newFontStyle); row.Height = 16; }
public RowStyling GetStyle(Row row) { var rowStyle = new RowStyling(); foreach (var styler in _stylers) { rowStyle.Combine(styler.GetStyle(row)); } return(rowStyle); }
public RowStyling GetStyle(Row row) { if (!_knownSources.Contains(row.SourceIdentifier)) { _knownSources.Add(row.SourceIdentifier); } var index = _knownSources.IndexOf(row.SourceIdentifier) % 5; var result = new RowStyling { BackgroundColor = _backgroundColours[index], ForegroundColor = _foregroundColours[index] }; return(result); }
public RowStyling GetStyle(Row row) { var result = new RowStyling(); LoggerLevel level; if (!Enum.TryParse(row.Level, out level)) { return(result); } switch (level) { case LoggerLevel.Critical: result.Bold = true; result.BackgroundColor = Color.Red; result.ForegroundColor = Color.White; break; case LoggerLevel.Error: result.Bold = true; result.BackgroundColor = Color.DarkOrange; result.ForegroundColor = Color.White; break; case LoggerLevel.Warning: result.Italic = true; result.ForegroundColor = Color.Yellow; result.BackgroundColor = Color.Black; break; case LoggerLevel.Trace: result.Italic = true; result.Bold = true; result.DarkenBackground = true; break; } return(result); }