PR edits - devolving qty/dirty and price/dirty

This commit is contained in:
Jake Norbut committed 2019-02-04 12:29:34 -06:00
1 parent b8c3b36a98
commit dcf509d21b
2 files changed
+29 -18

No files matched your search

@@ -197,7 +197,7 @@ namespace mbts.spark {
// edit quantity column
// not usually part of the main order book, but it's useful to add it
// rather than debugging the popup window
//Add(edit_qty_column = new EditableQtyColumn(Columns.EditableQty));
//Add(edit_qty_column = new EditableQtyColumn());
// filled quantity
Add(filled_qty_column = new FilledColumn(
new UIntMinMax<OrderRecordTuple>(ort => ort.order.filled(), nameof(OrderBookRowVM.filled_quantity))));
@@ -20,9 +20,10 @@ namespace mbts.spark {
bool _is_parent, _is_expanded, _is_selected;
int _depth_level;
SecurityMD? _security_md => order_tuple.security_md;
Property<uint> _prospective_quantity;
Property<double> _prospective_price;
Property<bool> _is_qty_dirty, _is_price_dirty;
// for mini-ob
uint _prospective_quantity;
double _prospective_price;
public OrderBookRowVM(OrderBookVM owner, OrderRecordTuple order_tuple, bool is_expanded) {
@@ -30,10 +31,8 @@ namespace mbts.spark {
this.order_tuple = order_tuple;
is_visible = !is_child;
_is_expanded = is_expanded;
_prospective_quantity = backing(nameof(prospective_quantity), this.quantity);
_prospective_price = backing(nameof(prospective_price), this.price);
_is_qty_dirty = backing(nameof(is_qty_dirty), () => this.prospective_quantity != this.quantity, nameof(prospective_quantity), nameof(quantity));
_is_price_dirty = backing(nameof(is_price_dirty), () => this.prospective_price != this.price, nameof(prospective_price), nameof(price));
prospective_quantity = this.quantity;
prospective_price = this.price;
this.invalidated += OrderBookRowVM_invalidated;
}
@@ -101,20 +100,28 @@ namespace mbts.spark {
set => Set(ref _is_selected, value);
}
public uint prospective_quantity {
get => _prospective_quantity.Value;
set => _prospective_quantity.set(value);
get => _prospective_quantity;
set {
var property_was_changed = Set(ref _prospective_quantity, value);
if (property_was_changed) {
RaisePropertyChanged(nameof(is_qty_dirty));
}
}
}
public double prospective_price {
get => _prospective_price.Value;
set => _prospective_price.set(value);
get => _prospective_price;
set {
var property_was_changed = Set(ref _prospective_price, value);
if (property_was_changed) {
RaisePropertyChanged(nameof(is_price_dirty));
}
}
}
public bool is_qty_dirty {
get => _is_qty_dirty.Value;
set => _is_qty_dirty.set(value);
get => this.prospective_quantity != this.quantity;
}
public bool is_price_dirty {
get => _is_price_dirty.Value;
set => _is_price_dirty.set(value);
get => this.prospective_price != this.price;
}
// Commands
@@ -169,10 +176,14 @@ namespace mbts.spark {
// however, the order-type and security cells DO use databindings - if these cells have changed, the PropertyChanged event must be raised regardless of whether or not invalidated is raised
if (old_order.order_type() != order.order_type())
RaisePropertyChanged(nameof(order_type), nameof(order_metadata));
if (old_order.quantity() != order.quantity())
if (old_order.quantity() != order.quantity()) {
RaisePropertyChanged(nameof(quantity));
if (old_order.price() != order.price())
RaisePropertyChanged(nameof(is_qty_dirty));
}
if (old_order.price() != order.price()) {
RaisePropertyChanged(nameof(price));
RaisePropertyChanged(nameof(is_price_dirty));
}
if (!had_security && _security_md.HasValue) {
RaisePropertyChanged(nameof(security), nameof(security_text));
// need to raise invalidated to refresh the price cells (the security.ContractSpec determines how they are formatted - Ticks!)