From dcf509d21b191f8ca3f7791233909a366eb0046d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 4 Feb 2019 12:29:34 -0600 Subject: [PATCH] PR edits - devolving qty/dirty and price/dirty --- .../Trading/OrderBook/OrderBookColumns.cs | 2 +- .../Trading/OrderBook/OrderBookRowVM.cs | 45 ++++++++++++------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs index dd240cfb7..58a62d2b4 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs @@ -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(ort => ort.order.filled(), nameof(OrderBookRowVM.filled_quantity)))); diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs index ca6bf6be2..d40f36dc3 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs @@ -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 _prospective_quantity; - Property _prospective_price; - Property _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!)