diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/SideColumn.cs b/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/SideColumn.cs index 26b132066..24a304244 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/SideColumn.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/FrameworkElementColumns/SideColumn.cs @@ -23,7 +23,6 @@ namespace mbts.ui.controls { public TColKey key { get; } public IDataGridColumnFilter filter_model { get; } public string filter_template => DataGridFilterKnownTemplates.DiscreteValues; - public Brush background { get; set; } public VerticalAlignment vertical_alignment { get; set; } = VerticalAlignment.Center; public Thickness padding { get; set; } = DefaultCellPadding; public GlyphContext glyph_context { get; set; } = TextUtils.StandardGlyphContext; @@ -32,7 +31,7 @@ namespace mbts.ui.controls { Side side = _get_side(row); CellRender.draw_text( dc, glyph_context, font_size, side.ToString(), position, row_height, - _get_foreground(side), background, horizontal_alignment, vertical_alignment, padding); + _get_foreground(side), background_brush, horizontal_alignment, vertical_alignment, padding); } static Brush _get_foreground(Side side) => diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/RenderColumn.cs b/src/client/spark/view/Controls/DIYGrid/Columns/RenderColumn.cs index 989bc8d11..f24169f39 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/RenderColumn.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/RenderColumn.cs @@ -23,17 +23,19 @@ namespace mbts.ui.controls { public class RenderTextColumn : RenderColumnBase, IRenderColumn, IFilterableColumn { protected readonly Func _get_text; protected readonly Func _get_background_brush; + protected readonly Func _get_foreground_brush; public RenderTextColumn( Func get_text, IDataGridColumnFilter filter = null, string filter_template = null, - Func get_brush = null) + Func get_background = null, + Func get_foreground = null) : base() { _get_text = get_text; - if (get_brush is not null) { - var get_row_brush = get_brush; - get_brush = r => { + if (get_background is not null) { + var get_row_brush = get_background; + get_background = r => { var row_brush = get_row_brush(r); if (row_brush is null) { return background_brush; @@ -49,9 +51,11 @@ namespace mbts.ui.controls { return row_color.blend(col_color).to_brush(); }; } - _get_background_brush = get_brush ?? new Func(_ => { + _get_background_brush = get_background ?? new Func(_ => { return background_brush; }); + _get_foreground_brush = get_foreground + ?? (_ => font_brush); this.filter_model = filter; this.filter_template = filter_template; font_params_changed += refresh_glyph_context; @@ -68,16 +72,37 @@ namespace mbts.ui.controls { public override void draw(TRowVM row, DrawingContext dc, ColumnGeometry position, double row_height) => CellRender.draw_text( - dc, glyph_context, font_size, _get_text(row), position, row_height, - font_brush, _get_background_brush(row), horizontal_alignment, vertical_alignment, padding); + dc, + glyph_context, + font_size, + _get_text(row), + position, + row_height, + _get_foreground_brush(row), + _get_background_brush(row), + horizontal_alignment, + vertical_alignment, + padding); } public class RenderTextColumn : RenderTextColumn, IKeyedColumn { public RenderTextColumn(TColKey key, Func get_text, IDataGridColumnFilter filter, string filter_template) : base(get_text, filter, filter_template) => this.key = key; - public RenderTextColumn(TColKey key, Func get_text, IDataGridColumnFilter filter, string filter_template, Func get_brush) - : base(get_text, filter, filter_template, get_brush) => this.key = key; + public RenderTextColumn( + TColKey key, + Func get_text, + IDataGridColumnFilter filter, + string filter_template, + Func get_background = null, + Func get_foreground = null) + : base( + get_text, + filter, + filter_template, + get_background: get_background, + get_foreground: get_foreground) => + this.key = key; public TColKey key { get; } }