From ffd2dd22c27a3636b10cd008c91c22ab5d66dc43 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 5 Sep 2019 16:58:34 -0500 Subject: [PATCH] SP-220 fix raw day pos tooltip in ladder --- .../Modules/Trading/Ladder/VM/LadderVM.cs | 2 +- .../Trading/Ladder/View/LadderView.xaml | 1 + .../Trading/Ladder/View/LadderView.xaml.cs | 56 ++++++++++++------- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs index 2bd48534a..f72d2cc1c 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs @@ -138,7 +138,7 @@ namespace mbts.spark { // //_window_height = backing(nameof(window_height), settings_manager.subscribe_current().OnDispatcher().Select(s => s.zoom_factor), (scale) => scale * 600); //_window_width = backing(nameof(window_width), settings_manager.subscribe_current().OnDispatcher().Select(s => s.zoom_factor), (scale) => scale * 420); - position_click_command = new DelegateCommand(() => size_calculator.value = DoubleHelper.safe_convert_to_uint(Math.Abs(_show_day_position ? day_position : position))); + position_click_command = new DelegateCommand(() => size_calculator.value = DoubleHelper.safe_convert_to_uint(Math.Abs(_show_day_position ? day_position : (_show_raw_day_position ? _raw_day_position : position)))); send_order_command = new AsyncCommand<(double price, Side? side, MouseButton button)>(send_order_async); cancel_command = new AsyncCommand(_model.cancel_orders, true); show_book_command = new DelegateCommand(_show_book); diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml index 5e041034f..b761e9b75 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml @@ -487,6 +487,7 @@ + diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml.cs index efaf28cda..c3b368a1f 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml.cs @@ -18,31 +18,47 @@ namespace mbts.spark { MaxZoomFactor = 1.5; public static IMultiValueConverter PositionToolTipConverter = - ValueConverter.create((account, show_day_pos, show_total_pos) => { - const string day_pos_text = "day", total_pos_text = "total"; + ValueConverter.create((account, show_day_pos, show_raw_day_pos, show_total_pos) => { + const string day_pos_text = "day", raw_day_pos_text = "raw day", total_pos_text = "total"; if (!account.HasValue) return string.Empty; - var sb = new StringBuilderEx(account.Value.name); - string primary_pos; + // + string primary_pos = null; + int part_count = 0; + var sb = new StringBuilderEx(); if (show_day_pos) { primary_pos = day_pos_text; - if (show_total_pos) { - sb.Add(" '", primary_pos, " "); - sb.Add("(", total_pos_text, ")' "); - } else { - sb.Add(" ", primary_pos, " "); - } - } else if (show_total_pos) { - primary_pos = total_pos_text; - sb.Add(" ", primary_pos, " "); - } else { - // unexpected code path (the button for which this tooltip is destined should be invisible in this case), but no need to throw an exception. - return string.Empty; + part_count++; } - sb.Add("position\n(click to copy "); - if (show_day_pos && show_total_pos) - sb.Add(primary_pos, " position "); - sb.Add("to size)"); + if (show_raw_day_pos) { + if (primary_pos == null) { + primary_pos = raw_day_pos_text; + } else { + sb.Add(" / ", raw_day_pos_text); + } + part_count++; + } + if (show_total_pos) { + if (primary_pos == null) { + primary_pos = total_pos_text; + } else { + sb.Add(" (", total_pos_text, ")"); + } + part_count++; + } + if (part_count == 0) { + return null; + } + // + sb.Insert(0, primary_pos); + if (part_count > 1) { + sb.Insert(0, "'"); + sb.Add("'"); + sb.Add(" position\n(click to copy ", primary_pos, " to size)"); + } else { + sb.Add(" position\n(click to copy to size)"); + } + sb.Insert(0, account.Value.name + " "); return sb.ToString(); });