Cleanup related to new RenderTextColumn func; deleting classes, etc

This commit is contained in:
Jake Norbut committed 2019-06-13 14:14:45 -05:00
1 parent 64f78e6077
commit 7aae61decd
3 files changed
+3 -59

No files matched your search

@@ -49,13 +49,8 @@ namespace mbts.spark {
add_column(TimeAndSalesView.Columns.Aggressor, DefaultColumnHeaders.Aggressor, DefaultColumnWidths.Aggressor, nameof(Row.aggressor_side), aggressor_filter, DataGridFilterKnownTemplates.EnumValues);
add_column(TimeAndSalesView.Columns.SecurityKey, DefaultColumnHeaders.SecurityKey, DefaultColumnWidths.SecurityKey, nameof(Row.security_key), security_key_filter, DataGridFilterKnownTemplates.Regex);
void add_column(TimeAndSalesView.Columns col_key, string header, double width, string sort_member_path, IDataGridColumnFilter filter, string filter_template, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) =>
columns.Add(new TimeAndSalesColumn(
col_key
, (r) => _get_aggressor_brush(r)
, filter
, filter_template
)
{ Header = header, Width = width, sort_member_path = sort_member_path, horizontal_alignment = h_alignment }
columns.Add(new RenderTextColumn<Row, TimeAndSalesView.Columns>(col_key, r => r[col_key], filter, filter_template, r => _get_aggressor_brush(r))
{ id = col_id(col_key), Header = header, Width = width, sort_member_path = sort_member_path, horizontal_alignment = h_alignment }
);
// be sure to load GridSettings AFTER the columns collection has been populated, the grid settings manager looks columns by id to apply the appropriate settings,
@@ -1,40 +0,0 @@
using bts.shell;
using mbts.spark;
using mbts.spark.filters;
using mbts.ui.spark;
using mbts.ui.utility.text;
using System;
using System.Windows.Media;
namespace mbts.ui.controls {
partial class DIYGrid {
internal class TimeAndSalesColumn : RenderTextColumn<TimeAndSalesVM.Row>, IKeyedColumn<TimeAndSalesView.Columns> {
readonly Func<TimeAndSalesVM.Row, Brush> _get_brush;
public TimeAndSalesColumn(TimeAndSalesView.Columns key, Func<TimeAndSalesVM.Row, Brush> get_brush, IDataGridColumnFilter filter = null, string filter_template = null)
: base(r => r[key], filter, filter_template) {
this.key = key;
// id is used for settings (another case of ProtoBufs vs Generics - strings seemed like the easiest way to provide an identifier for the common GridColumnSettings proto)
id = TimeAndSalesWindowFactory.col_id(key);
_get_brush = get_brush;
}
public TimeAndSalesView.Columns key { get; }
public override void draw(TimeAndSalesVM.Row 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_brush(row)
, horizontal_alignment
, vertical_alignment
, padding);
}
}
}
}
+1 -12
View File
@@ -152,9 +152,7 @@ namespace mbts.spark {
add_col(Columns.TotalPNL, DefaultColumnHeaders.TotalPnL, r => r.total_pnl_text, nameof(PnLSummaryRow.total_pnl), DefaultColumnWidths.PnL_Generic, total_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.total_pnl_background);
add_col(Columns.PNLPrice, DefaultColumnHeaders.PnLPrice, r => r.pnl_price_text, nameof(PnLSummaryRow.pnl_price), DefaultColumnWidths.PnL_Generic, pnl_price_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right);
void add_col(Columns key, string header, Func<PnLSummaryRow, string> get_text, string sort_prop, double width, IDataGridColumnFilter filter, string filter_template, HorizontalAlignment h_align = HorizontalAlignment.Left, Func<PnLSummaryRow, Brush> get_background = null) {
var col = get_background == null ?
new RenderTextColumn<PnLSummaryRow, Columns>(key, get_text, filter, filter_template) :
new PnLDelegateBackgroundColumn(key, get_text, get_background, filter, filter_template);
var col = new RenderTextColumn<PnLSummaryRow, Columns>(key, get_text, filter, filter_template, get_background);
col.Header = header;
col.Width = width;
col.sort_member_path = sort_prop;
@@ -357,14 +355,5 @@ namespace mbts.spark {
DateTime _last_pnl_update_time = DateTime.MinValue;
ObservableCollection<PnLSummaryRow> _pnl_data = new ObservableCollection<PnLSummaryRow>();
class PnLDelegateBackgroundColumn : RenderTextColumn<PnLSummaryRow, Columns> {
readonly Func<PnLSummaryRow, Brush> _get_brush;
public PnLDelegateBackgroundColumn(Columns key, Func<PnLSummaryRow, string> get_text, Func<PnLSummaryRow, Brush> get_brush, IDataGridColumnFilter filter, string filter_template)
: base(key, get_text, filter, filter_template) => _get_brush = get_brush;
public override void draw(PnLSummaryRow 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_brush.Invoke(row), horizontal_alignment, VerticalAlignment.Center, DefaultCellPadding);
}
}
}