Ladder - restoring badge context menu and hooking up crack
This commit is contained in:
1 parent
dd4ef2429e
commit
792801f936
3 files changed
+37
-3
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -433,6 +433,27 @@
|
||||
<Setter Property="CornerRadius" Value="1" />
|
||||
<Setter Property="Opacity" Value="{Binding opacity}" />
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="ContextMenu">
|
||||
<Setter.Value>
|
||||
<ContextMenu>
|
||||
<MenuItem Command="{Binding cancel_command}" Header="Cancel">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{StaticResource CancelSelected}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Command="{Binding modify_command}" Header="Modify">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{StaticResource ModifyOrder}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Command="{Binding detach_command}" Header="Detach">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{StaticResource ModifyOrder}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{Binding hoverbackground}" />
|
||||
|
||||
Reference in new issue
Block a user