no more context menu, just directly bring up the modify order ticket on mid click

This commit is contained in:
Jake Norbut committed 2018-05-23 10:32:17 -05:00
1 parent 3ab3259f9a
commit 152c02e45e
2 files changed
+2 -33

No files matched your search

@@ -112,23 +112,10 @@ namespace mbts.spark {
// Hook up the style from xaml
b.Style = this.TryFindResource(typeof(Badge)) as Style;
b.MouseUp += (s, e) => {
// open context menu on mid click, cancel order on left click
if (e.ChangedButton == MouseButton.Middle) {
b.ContextMenu.DataContext = b.DataContext;
b.ContextMenu.IsOpen = true;
// close context menu after command executed
var curr_order = b.DataContext as LadderOrderVM;
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;
if (curr_order != null && curr_order.modify_command.CanExecute(null)) {
curr_order.modify_command.Execute(null);
}
} else if (e.ChangedButton == MouseButton.Left) {
var curr_order = b.DataContext as LadderOrderVM;
@@ -136,8 +123,6 @@ namespace mbts.spark {
curr_order.cancel_command.Execute(null);
}
};
// block right click from opening context menu
b.ContextMenuOpening += (s, e) => e.Handled = true;
return b;
}
@@ -433,22 +433,6 @@
<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>
</ContextMenu>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{Binding hoverbackground}" />