combine attach and detach columns into 1 column to rule them all, and in the darkness bind them
This commit is contained in:
1 parent
4436cf9b04
commit
a1b32e3e6e
3 files changed
+45
-66
No files matched your search
@@ -252,8 +252,7 @@ namespace mbts.spark {
|
||||
// | Cancel | Update | Qty | Price | Commit | Attach | Detach | ...
|
||||
// ----------------------------------------------
|
||||
//
|
||||
obvm.columns.Insert(0, new OrderBookVM.DetachColumn(typeof(MiniOrderBookView)));
|
||||
obvm.columns.Insert(0, new OrderBookVM.AttachColumn(typeof(MiniOrderBookView)));
|
||||
obvm.columns.Insert(0, new OrderBookVM.AttachDetachColumn(typeof(MiniOrderBookView)));
|
||||
obvm.columns.Insert(0, new OrderBookVM.CommitColumn());
|
||||
var price_col = obvm.columns.FirstOrDefault(x => x.id == OrderBookGridView.ColumnKeys.Price.ToString());
|
||||
var price_index = obvm.columns.indexOf(price_col);
|
||||
|
||||
@@ -298,7 +298,6 @@ namespace mbts.spark {
|
||||
|
||||
public event Action filter_changed;
|
||||
|
||||
public CancelColumn cancel_column { get; }
|
||||
public SecurityColumn security_column { get; }
|
||||
public SimpleTextColumn<string[]> symbol_column { get; }
|
||||
public SimpleTextColumn<TimeFilterTuple> time_created_column { get; }
|
||||
@@ -313,8 +312,6 @@ namespace mbts.spark {
|
||||
public SizeColumn qty_column { get; }
|
||||
public EditableQtyColumn edit_qty_column { get; }
|
||||
public SimpleTextColumn<DoubleMinMaxState> price_column { get; }
|
||||
public EditablePriceColumn edit_price_column { get; }
|
||||
public AttachColumn attach_column { get; }
|
||||
public FilledColumn filled_qty_column { get; }
|
||||
public SimpleTextColumn<DoubleMinMaxState> last_price_column { get; }
|
||||
public SimpleTextColumn<DoubleMinMaxState> avg_price_column { get; }
|
||||
@@ -721,16 +718,16 @@ namespace mbts.spark {
|
||||
return i;
|
||||
}
|
||||
|
||||
public class AttachColumn : FrameworkElementColumnBase<Columns> {
|
||||
public class AttachDetachColumn : FrameworkElementColumnBase<Columns> {
|
||||
readonly Type _mini_or_full_ob_type;
|
||||
|
||||
public AttachColumn(Type mini_or_full_ob_type) : base(Columns.Attach) {
|
||||
public AttachDetachColumn(Type mini_or_full_ob_type) : base(Columns.Attach) {
|
||||
if (!(mini_or_full_ob_type == typeof(MiniOrderBookView) || mini_or_full_ob_type == typeof(OrderBookView))) {
|
||||
throw new ArgumentException();
|
||||
}
|
||||
id = key.ToString();
|
||||
Header = DefaultColumnHeaders.Attach;
|
||||
Width = 40;
|
||||
Header = DefaultColumnHeaders.AttachDetach;
|
||||
Width = 45;
|
||||
|
||||
_mini_or_full_ob_type = mini_or_full_ob_type;
|
||||
}
|
||||
@@ -747,15 +744,17 @@ namespace mbts.spark {
|
||||
// create the attach button and assign the menu to it
|
||||
var attach_button = new Button() {
|
||||
Name = "attach_button",
|
||||
Content = new Image() { Source = Icons.AttachAlgos }
|
||||
Content = "A",
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
VerticalAlignment = VerticalAlignment.Stretch,
|
||||
};
|
||||
var attach_border = new Border() {
|
||||
Child = attach_button,
|
||||
BorderThickness = new Thickness(1),
|
||||
var attach_grid = new Grid() {
|
||||
Width = 20,
|
||||
Height = 20,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
attach_border.BorderBrush = (new SolidColorBrush(BTSColors.green).frozen());
|
||||
attach_grid.Children.Add(attach_button);
|
||||
attach_button.Click += (s, e) => { popup.IsOpen = !popup.IsOpen; };
|
||||
|
||||
var orderbook_vm_datacontext_binding = new Binding("DataContext");
|
||||
@@ -769,7 +768,7 @@ namespace mbts.spark {
|
||||
|
||||
var row_vm_attach_to_visibility = new Binding(WPFHelper.join_binding_paths("DataContext", nameof(OrderBookRowVM.is_attachable))) { Converter = new mbts.ui.converters.BooleanToVisibilityConverter() };
|
||||
row_vm_attach_to_visibility.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(MiniOrderBookRowView), 1);
|
||||
attach_border.SetBinding(Button.VisibilityProperty, row_vm_attach_to_visibility);
|
||||
attach_button.SetBinding(Button.VisibilityProperty, row_vm_attach_to_visibility);
|
||||
|
||||
var row_vm_attach_command_binding = new Binding(WPFHelper.join_binding_paths("DataContext", nameof(OrderBookRowVM.attach_command)));
|
||||
row_vm_attach_command_binding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(MiniOrderBookRowView), 1);
|
||||
@@ -861,8 +860,32 @@ namespace mbts.spark {
|
||||
RelativeSource = new RelativeSource(RelativeSourceMode.Self)
|
||||
});
|
||||
|
||||
|
||||
var detach_button = new Button() {
|
||||
Name = "detach_button",
|
||||
Content = "D",
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
VerticalAlignment = VerticalAlignment.Stretch,
|
||||
|
||||
};
|
||||
|
||||
//var orderbook_vm_datacontext_binding = new Binding(_detach_command_binding_path);
|
||||
//orderbook_vm_datacontext_binding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, _mini_or_full_ob_type, 1);
|
||||
detach_button.SetBinding(Button.CommandProperty, new Binding(nameof(OrderBookRowVM.detach_command)));
|
||||
detach_button.SetBinding(Button.VisibilityProperty, new Binding(nameof(OrderBookRowVM.is_detachable)) { Converter = new mbts.ui.converters.BooleanToVisibilityConverter() });
|
||||
|
||||
|
||||
var detach_grid = new Grid() {
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
Width = 20,
|
||||
Height = 20,
|
||||
};
|
||||
detach_grid.Children.Add(detach_button);
|
||||
|
||||
var the_whole_thing = new Grid();
|
||||
the_whole_thing.Children.Add(attach_border);
|
||||
the_whole_thing.Children.Add(attach_grid);
|
||||
the_whole_thing.Children.Add(detach_grid);
|
||||
the_whole_thing.Children.Add(popup);
|
||||
|
||||
return the_whole_thing;
|
||||
@@ -1009,52 +1032,6 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
public class DetachColumn : FrameworkElementColumnBase<Columns> {
|
||||
|
||||
public DetachColumn(Type mini_or_full_ob_type) : base(Columns.Detach) {
|
||||
if (!(mini_or_full_ob_type == typeof(MiniOrderBookView) || mini_or_full_ob_type == typeof(OrderBookView))) {
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
id = key.ToString();
|
||||
Header = DefaultColumnHeaders.Detach;
|
||||
Width = 40;
|
||||
}
|
||||
|
||||
public override FrameworkElement view_factory() {
|
||||
var button = new Button() {
|
||||
Name = "detach_button",
|
||||
Content = new Image() { Source = Icons.DetachAlgos }
|
||||
};
|
||||
var detach_border = new Border() {
|
||||
Child = button,
|
||||
BorderThickness = new Thickness(1),
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
detach_border.BorderBrush = (new SolidColorBrush(BTSColors.red).frozen());
|
||||
|
||||
|
||||
|
||||
//var orderbook_vm_datacontext_binding = new Binding(_detach_command_binding_path);
|
||||
//orderbook_vm_datacontext_binding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, _mini_or_full_ob_type, 1);
|
||||
button.SetBinding(Button.CommandProperty, new Binding(nameof(OrderBookRowVM.detach_command)));
|
||||
detach_border.SetBinding(Button.VisibilityProperty, new Binding(nameof(OrderBookRowVM.is_detachable)) { Converter = new mbts.ui.converters.BooleanToVisibilityConverter() });
|
||||
|
||||
// *** Very important
|
||||
// DIYGrid.CellRender.change_position will fool around with your returned
|
||||
// FrameworkElement's VisibilityProperty (perhaps for performance, anyway...)
|
||||
// Since this button's VisibilityProperty has a Binding, it will ultimately be superceded
|
||||
// by set_if_changed's SetValue. Ergo, we must provide the set_if_changed beast with a more
|
||||
// paltable Visibility victim.
|
||||
var visibility_honeypot = new Border() {
|
||||
Child = detach_border
|
||||
};
|
||||
|
||||
return visibility_honeypot;
|
||||
}
|
||||
}
|
||||
|
||||
public class EditableQtyColumn:FrameworkElementColumnBase<Columns> {
|
||||
|
||||
public EditableQtyColumn() : base(Columns.EditableQty) {
|
||||
@@ -1098,7 +1075,9 @@ namespace mbts.spark {
|
||||
public override FrameworkElement view_factory() {
|
||||
var commit_button = new Button() {
|
||||
Name = "commit_button",
|
||||
Content = "✔"
|
||||
Content = "✔",
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
VerticalAlignment = VerticalAlignment.Stretch,
|
||||
};
|
||||
|
||||
var is_enabled_trigger = new Trigger() { Property = Button.IsEnabledProperty, Value = true };
|
||||
@@ -1113,6 +1092,8 @@ namespace mbts.spark {
|
||||
var grid = new Grid() {
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
Width = 20,
|
||||
Height = 20,
|
||||
};
|
||||
grid.Children.Add(commit_button);
|
||||
return grid;
|
||||
|
||||
@@ -108,8 +108,7 @@ namespace mbts.ui.controls {
|
||||
TotalPnL = "Total PnL",
|
||||
PnLPrice = "PnL Price",
|
||||
Cancel = "Cancel",
|
||||
Attach = "Attach",
|
||||
Detach = "Detach",
|
||||
AttachDetach = "A/D",
|
||||
Update = "Update",
|
||||
MarketDescription = "Market Description",
|
||||
ClearedAlias = "Cleared Alias",
|
||||
|
||||
Reference in new issue
Block a user