From 792801f9365c2508ace28ecfcaa42dfe3330899e Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 25 May 2018 15:20:25 -0500 Subject: [PATCH] Ladder - restoring badge context menu and hooking up crack --- .../spark/view/Spark/Ladder/LadderOrderVM.cs | 2 +- .../view/Spark/Ladder/LadderOrdersHost.cs | 17 +++++++++++++-- .../spark/view/Spark/Ladder/LadderView.xaml | 21 +++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/client/spark/view/Spark/Ladder/LadderOrderVM.cs b/src/client/spark/view/Spark/Ladder/LadderOrderVM.cs index 3b4829c4a..6eee39c83 100644 --- a/src/client/spark/view/Spark/Ladder/LadderOrderVM.cs +++ b/src/client/spark/view/Spark/Ladder/LadderOrderVM.cs @@ -159,7 +159,7 @@ namespace mbts.spark { public bool has_parent => _order.has_parent(); public bool has_phantom_price => !double.IsNaN(_phantom_price); - public ICommand shatter_command => new DelegateCommand(() => _execute_command(model.order_gateway.crack_order(_order.Key).ignore) , () => !has_parent); + public ICommand detach_command => new DelegateCommand(() => _execute_command(model.order_gateway.crack_order(_order.Key).ignore), () => !has_parent); public ICommand cancel_command => new DelegateCommand(() => _execute_command(_cancel_order)); public ICommand modify_command => new DelegateCommand(() => _execute_command(() => _bus.post(SparkTags.ShowModifyOrderTag, _order.Key)), () => !has_parent); public event Action command_executed; diff --git a/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs b/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs index 602878333..e7cdbb2db 100644 --- a/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs +++ b/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs @@ -114,14 +114,27 @@ namespace mbts.spark { b.MouseUp += (s, e) => { var curr_order = b.DataContext as LadderOrderVM; if (e.ChangedButton == MouseButton.Middle) { - if (curr_order?.modify_command?.CanExecute(null) == true) { - curr_order.modify_command.Execute(null); + b.ContextMenu.DataContext = b.DataContext; + b.ContextMenu.IsOpen = true; + // close context menu after command executed + if (curr_order != null) { + Action command_executed = null; + command_executed = () => { + try { + b.ContextMenu.IsOpen = false; + curr_order.command_executed -= command_executed; + } catch (Exception ex) { + Logger.warn(bts.log.Subsystem.Ui, $"Error in {typeof(LadderGridHost)}'s {typeof(Badge)} {nameof(LadderOrderVM.command_executed)} local handler: {ex}"); + } + }; + curr_order.command_executed += command_executed; } } else if (e.ChangedButton == MouseButton.Left) { if (curr_order?.cancel_command?.CanExecute(null) == true) curr_order.cancel_command.Execute(null); } }; + b.ContextMenuOpening += (s, e) => e.Handled = true; return b; } diff --git a/src/client/spark/view/Spark/Ladder/LadderView.xaml b/src/client/spark/view/Spark/Ladder/LadderView.xaml index f34b99d70..fcfc93a8f 100644 --- a/src/client/spark/view/Spark/Ladder/LadderView.xaml +++ b/src/client/spark/view/Spark/Ladder/LadderView.xaml @@ -433,6 +433,27 @@ + + + + + + + + + + + + + + + + + + + + +