mini ob - select/unselect all checkbox in header
This commit is contained in:
1 parent
220af155a9
commit
219da9b22a
3 files changed
+33
-4
No files matched your search
@@ -730,6 +730,11 @@ namespace mbts.spark {
|
||||
id = key.ToString();
|
||||
Width = 30;
|
||||
_checked_binding = new Binding(checked_property);
|
||||
|
||||
var header_cb = new CheckBox();
|
||||
header_cb.ToolTip = "Select / Unselect All";
|
||||
header_cb.SetBinding(CheckBox.IsCheckedProperty, new Binding(nameof(OrderBookVM.all_rows_selected)));
|
||||
this.Header = header_cb;
|
||||
}
|
||||
|
||||
public override FrameworkElement view_factory() {
|
||||
|
||||
@@ -27,14 +27,16 @@ namespace mbts.spark {
|
||||
// for mini-ob
|
||||
uint _prospective_quantity;
|
||||
double _prospective_price;
|
||||
Action<bool> _on_selection_changed;
|
||||
|
||||
public OrderBookRowVM(OrderBookVM owner, OrderSecurity order_tuple, bool is_expanded) {
|
||||
public OrderBookRowVM(OrderBookVM owner, OrderSecurity order_tuple, bool is_expanded, Action<bool> on_selection_changed) {
|
||||
_owner = owner;
|
||||
this.order_tuple = order_tuple;
|
||||
is_visible = !is_child;
|
||||
_is_expanded = is_expanded;
|
||||
prospective_quantity = this.quantity;
|
||||
prospective_price = this.price;
|
||||
_on_selection_changed = on_selection_changed;
|
||||
}
|
||||
|
||||
//// This takes care of the case where the OB has all rows visible
|
||||
@@ -118,7 +120,11 @@ namespace mbts.spark {
|
||||
public int depth_level { get => _depth_level; set => Set(ref _depth_level, value); }
|
||||
public bool is_selected {
|
||||
get => _is_selected;
|
||||
set => Set(ref _is_selected, value);
|
||||
set {
|
||||
if (Set(ref _is_selected, value)) {
|
||||
_on_selection_changed(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
public uint prospective_quantity {
|
||||
get => _prospective_quantity;
|
||||
|
||||
@@ -56,7 +56,8 @@ namespace mbts.spark {
|
||||
bool
|
||||
_show_right_panel = OrderBookStartupData.Default.show_right_panel,
|
||||
_is_attaching_orders,
|
||||
_is_row_collection_populated;
|
||||
_is_row_collection_populated,
|
||||
_all_rows_selected;
|
||||
IReadOnlyDictionary<uint, OrderSecurity> _cached_orders = DictionaryHelper.empty<uint, OrderSecurity>();
|
||||
IReadOnlyDictionary<uint, bool> _cached_attachable = DictionaryHelper.empty<uint, bool>(), _cached_detachable = DictionaryHelper.empty<uint, bool>();
|
||||
HashSet<uint>
|
||||
@@ -99,7 +100,17 @@ namespace mbts.spark {
|
||||
// we use an ObservableAppendCollection b/c the mini-ob needs a cancel column at the front
|
||||
columns = new ObservableAppendCollection<DIYGrid.ColumnBase>(_columns);
|
||||
_row_collection = new OperableHierarchicalCollection<OrderBookRowVM, OrderSecurity, uint>(
|
||||
o => new OrderBookRowVM(this, o, rows_are_initially_expanded) {
|
||||
o => new OrderBookRowVM(this, o, rows_are_initially_expanded, (row_is_selected) => {
|
||||
// all are selected and one is checked off
|
||||
if (all_rows_selected && !row_is_selected) {
|
||||
_all_rows_selected = false;
|
||||
RaisePropertyChanged(nameof(this.all_rows_selected));
|
||||
// not all selected and now the last one gets turned on
|
||||
} else if (!all_rows_selected && _row_collection.All(r => r.is_selected)) {
|
||||
_all_rows_selected = true;
|
||||
RaisePropertyChanged(nameof(this.all_rows_selected));
|
||||
}
|
||||
}) {
|
||||
is_attachable = _cached_attachable.TryGetValue(o.order.Key, out bool ia) && ia,
|
||||
is_detachable = _cached_detachable.TryGetValue(o.order.Key, out bool id)
|
||||
},
|
||||
@@ -420,6 +431,13 @@ namespace mbts.spark {
|
||||
public bool can_attach_selected_orders => _can_attach_selected_orders.Value;
|
||||
public bool can_detach_selected_orders => _can_detach_selected_orders.Value;
|
||||
public Plurality security_plurality { get; private set; }
|
||||
public bool all_rows_selected {
|
||||
get => _all_rows_selected;
|
||||
set {
|
||||
Set(ref _all_rows_selected, value);
|
||||
_row_collection.ForEach(r => r.is_selected = value);
|
||||
}
|
||||
}
|
||||
|
||||
public IObservable<bool> subscribe_show_fills() => _show_fills.observe_current(true);
|
||||
public IObservable<bool> subscribe_show_ladder() => _show_ladder.observe_current(true);
|
||||
|
||||
Reference in new issue
Block a user