diff --git a/src/client/spark/Modules/Trading/LadderWindowFactory.cs b/src/client/spark/Modules/Trading/LadderWindowFactory.cs index 5036c088e..c1d1234e8 100644 --- a/src/client/spark/Modules/Trading/LadderWindowFactory.cs +++ b/src/client/spark/Modules/Trading/LadderWindowFactory.cs @@ -31,7 +31,7 @@ namespace bts.shell { _settings_hub = settings_hub; _orders_model = orders_model; var window_props = Configuration.get(); - _max_ladders_open = (int)(window_props?.ladder?.max_total_open ?? 50); + _max_ladders_open = (int)(window_props?.ladder?.max_total_open ?? 75); _dispose = Disposable.Create( bus.subscribe(SparkTags.SecuritiesTag).Subscribe(s => _securities = s), bus.subscribe(SparkTags.ShowLadderTag).ObserveOnDispatcher().Subscribe(s => show_windows(new[] { s })), diff --git a/src/client/spark/view/Spark/Ladder/LadderGridHost.cs b/src/client/spark/view/Spark/Ladder/LadderGridHost.cs index 287a611bc..c6fcbea89 100644 --- a/src/client/spark/view/Spark/Ladder/LadderGridHost.cs +++ b/src/client/spark/view/Spark/Ladder/LadderGridHost.cs @@ -19,7 +19,7 @@ using System.Windows.Media.Animation; namespace mbts.spark { partial class LadderGridHost : Control { - const int _min_row_count = 1001, _max_row_count = 2001, _column_min_width = 8; + const int _min_row_count = 501, _max_row_count = 2001, _column_min_width = 8; int _row_count = _min_row_count; readonly VisualHost _visualHost = new VisualHost(); @@ -61,7 +61,7 @@ namespace mbts.spark { }; Loaded += (_, __) => { if (_settings != null) { - _render_grid_lines(); + _render_grid_background(); _init_tactile_adorner(); } _scroll_to_center(); @@ -102,9 +102,9 @@ namespace mbts.spark { private static void bid_column_width_callback(DependencyObject source, DependencyPropertyChangedEventArgs e) { - var lgh = source as LadderGridHost; - double width_adjustment = (double)(uint) e.NewValue - (double)(uint) e.OldValue; - lgh._adjust_column_width(lgh.columns.First(c => c.column_type == ColumnType.Bid), width_adjustment); + var lgh = source as LadderGridHost; + double width_adjustment = (double)(uint) e.NewValue - (double)(uint) e.OldValue; + lgh._adjust_column_width(lgh.columns.First(c => c.column_type == ColumnType.Bid), width_adjustment); } public uint price_column_width @@ -196,8 +196,7 @@ namespace mbts.spark { public override void OnApplyTemplate() { base.OnApplyTemplate(); _scrollViewer = this.descendants_of_type().First(); - // _visualHost draws grid lines on top of _ordershost - var grid = new Grid() { Children = { _ordershost, _visualHost, } }; + var grid = new Grid() { Children = { _visualHost, _ordershost, } }; _scrollViewer.Content = grid; _connect_vm(); } @@ -317,6 +316,7 @@ namespace mbts.spark { } } _apply_column_visual_offset(); + _render_grid_background(); } void _set_columns() { @@ -464,7 +464,7 @@ namespace mbts.spark { double height = _row_count * _settings.row_height; _visualHost.Height = height; _ordershost.Height = height; - _render_grid_lines(); + _render_grid_background(); } #region Market Break Utils @@ -516,6 +516,8 @@ namespace mbts.spark { _price_dirty = _settings.price_column.show; // Clear and re-add the columns to the viewer to ensure offset/visibility is correct _visualHost.Clear(); + // Renders the grid lines and column backgrounds + _visualHost.AddVisualChild(_gridvis); // Orders column orders_column_width = s.orders_column.width; _ordershost.update_settings(_price_list, _price_comparer, s.row_height, s.orders_column); @@ -528,17 +530,17 @@ namespace mbts.spark { case ColumnType.Ask: ask_column_width = col.settings.width; break; } } - // Renders the grid lines - _visualHost.AddVisualChild(_gridvis); _visualHost.AddVisualChild(_mid_mkt_break_vis); _visualHost.AddVisualChild(_ask_mkt_break_vis); _visualHost.AddVisualChild(_bid_mkt_break_vis); _init_tactile_adorner(); // this effectively sets the background of the "Last" column - if (_scrollViewer != null) + if (_scrollViewer != null) { _scrollViewer.Background = s.last_column.background.rgb_brush(); - if (init) + } + if (init) { _scroll_to_center(); + } } void _init_tactile_adorner() { @@ -555,18 +557,24 @@ namespace mbts.spark { (!double.IsNaN(high) && _price_list[0] < high); } - void _render_grid_lines() => - LadderRender.render_grid(_gridvis, _row_count, _settings.row_height, _settings.grid_line_color); + void _render_grid_background() { + LadderRender.render_grid(_gridvis, columns, _row_count, _settings.row_height, _settings.grid_line_color); + } class VisualGlyphTuple { public readonly DrawingVisual visual = new DrawingVisual(); public GlyphContext glyph_context { get; set; } } - - class Column : IEquatable { + + internal interface IColumn { + double x_left { get; } + double x_right { get; } + LadderColumnSettings settings { get; } + } + class Column : IEquatable, IColumn { public static readonly Column Empty = new Column(new LadderColumnSettings { width = 0 }, ColumnType.None, null, 0); - public readonly LadderColumnSettings settings; + public LadderColumnSettings settings { get; } public readonly ColumnType column_type; public readonly VisualGlyphTuple visual_tup; diff --git a/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs b/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs index 602878333..ad96e200b 100644 --- a/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs +++ b/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs @@ -36,7 +36,7 @@ namespace mbts.spark { _price_list = prices; _price_comparer = price_comparer; _row_height = row_height; - Background = new SolidColorBrush(settings.background.rgb_color()); + Background = Brushes.Transparent; set_col_width(settings.width); foreach (var kv in _stacks) _position_panel(kv.Value.panel, kv.Key); diff --git a/src/client/spark/view/Spark/Ladder/LaderRender.cs b/src/client/spark/view/Spark/Ladder/LaderRender.cs index 60660fb25..a3009d305 100644 --- a/src/client/spark/view/Spark/Ladder/LaderRender.cs +++ b/src/client/spark/view/Spark/Ladder/LaderRender.cs @@ -50,23 +50,31 @@ namespace mbts.spark { public static void render_prices(DrawingVisual price, GlyphContext glyph_context, int row_count, double row_height, double[] dprices, LadderColumnSettings settings, ContractSpecificationImmutable spec) { var foreground = new SolidColorBrush(settings.foreground.rgb_color()); - var background = new SolidColorBrush(settings.background.rgb_color()); + //var background = new SolidColorBrush(settings.background.rgb_color()); var fprices = format_prices(dprices, row_height, settings, glyph_context, spec); using (var dc = price.RenderOpen()) using (_draw_with_clip(dc, settings, row_height, row_count)) { - dc.DrawRectangle(background, null, new Rect(0, 0, settings.width, row_count * row_height)); + //dc.DrawRectangle(background, null, new Rect(0, 0, settings.width, row_count * row_height)); for (int x = 0; x < row_count; ++x) dc.DrawGlyphRun(foreground, fprices[x]); } } - public static void render_grid(DrawingVisual dv, int rowcount, double row_height, UInt32 line_color) { + public static void render_grid(DrawingVisual dv, IEnumerable columns, int rowcount, double row_height, UInt32 line_color) { var height = rowcount * row_height; - var pen = new Pen(new SolidColorBrush(line_color.rgb_color()), 1.0); + var brush = new SolidColorBrush(line_color.rgb_color()); + brush.Freeze(); using (var dc = dv.RenderOpen()) { + // draw column backgrounds + foreach (var col in columns) { + var background = new SolidColorBrush(col.settings.background.rgb_color()); + background.Freeze(); + dc.DrawRectangle(background, null, new Rect(col.x_left, 0, col.settings.width, rowcount * row_height)); + } + // draw grid lines for (int row = 1; row < rowcount; ++row) { double y = row * row_height; - dc.DrawLine(pen, new Point(0, y), new Point(SystemParameters.FullPrimaryScreenWidth, y)); + dc.DrawRectangle(brush, null, new Rect(0, y, 500, 1)); } } } @@ -81,10 +89,10 @@ namespace mbts.spark { ContractSpecificationImmutable spec, LadderColumnSettings settings ) { - var background = new SolidColorBrush(settings.background.rgb_color()); + //var background = new SolidColorBrush(settings.background.rgb_color()); using (var dc = dv.RenderOpen()) using (_draw_with_clip(dc, settings, row_height, prices.Length)) { - dc.DrawRectangle(background, null, new Rect(0, 0, settings.width, prices.Length * row_height)); + //dc.DrawRectangle(background, null, new Rect(0, 0, settings.width, prices.Length * row_height)); if (!prices.within_range(origin_index) || rungs.is_null_or_empty()) return; var foreground = new SolidColorBrush(settings.foreground.rgb_color());