From 3263cc840acdb4e6200bb3735e4314a229800d10 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 24 Jun 2019 14:15:50 -0500 Subject: [PATCH] SP-77 in miniob settings, changing the column order does not seem to have an effect --- .../Trading/Ladder/VM/LadderOrderVM.cs | 32 +++++++------------ .../Modules/Trading/OrderBook/OrderBookVM.cs | 2 +- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs index 4640d8a58..ea503904d 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs @@ -1,6 +1,7 @@ using bts.api; using bts.api.orderman; -using mbts.spark.utilities; +using bts.shell.orderbook; +using mbts.persist; using mbts.ui; using mbts.ui.shell; using System; @@ -293,7 +294,6 @@ namespace mbts.spark { price_filter.minimum.value = real_price; price_filter.maximum.value = real_price; - var obvm = new OrderBookVM(_owner.bus, null, _owner.model.order_gateway, null, true); var state = new bts.shell.orderbook.OrderBookStartupData( new bts.shell.orderbook.FilterStates { security_criteria = new SecurityCriteria(_owner.security), @@ -304,29 +304,19 @@ namespace mbts.spark { bts.shell.orderbook.OrderBookStartupData.default_mini_grid.with(_owner.current_settings.mini_ob.value), use_defaults: false ); - // NOTE: - // we might need the ObservableAppend to InsertAt - // if these EditXXX ever support settings. - - // The end result after this group of lines will be - // ---------------------------------------------- - // | Cancel | Update | Qty | Price | Commit | Attach | Detach | ... - // ---------------------------------------------- - // + var settings_man = new WindowSettingsManager.DisconnectedImpl(state.orderbook_grid); + var obvm = new OrderBookVM(_owner.bus, null, _owner.model.order_gateway, settings_man, true); + _owner.settings.Subscribe(s => settings_man.instance_settings = settings_man.instance_settings.with(s.mini_ob.value)); obvm.columns.Insert(0, new OrderBookVM.AttachDetachColumn(typeof(MiniOrderBookView))); obvm.columns.Insert(0, new OrderBookVM.CommitColumn()); - if (obvm.columns.Any(x => x.id == OrderBookGridView.ColumnKeys.Price.ToString()) && !obvm.columns.Any(x => x.id == OrderBookGridView.ColumnKeys.EditablePrice.ToString())) { - // insert the edit price column at the beginning - obvm.columns.Insert(0, new OrderBookVM.EditablePriceColumn()); - } - if (obvm.columns.Any(x => x.id == OrderBookGridView.ColumnKeys.Size.ToString()) && !obvm.columns.Any(x => x.id == OrderBookGridView.ColumnKeys.EditableQty.ToString())) { - // insert the edit quantity column at the beginning - obvm.columns.Insert(0, new OrderBookVM.EditableQtyColumn()); - } + obvm.columns.Insert(0, new OrderBookVM.EditablePriceColumn()); + obvm.columns.Insert(0, new OrderBookVM.EditableQtyColumn()); obvm.columns.Insert(0, new OrderBookVM.UpdateColumn(typeof(MiniOrderBookView))); obvm.columns.Insert(0, new OrderBookVM.CancelColumn(nameof(OrderBookRowVM.cancel_command))); - obvm.columns.insert_front( new OrderBookVM.CheckColumn(nameof(OrderBookRowVM.is_selected))); - + // the CheckColumn must be inserted at the front of the ObservableAppendCollection, + // and not mixed with the other columns in said ObservableAppendCollection's underlying ObservableCollection (the settings dialog uses the underlying collection). + // The user cannot adjust this column in the settings dialog, and it should always be the left-most column. + obvm.columns.insert_front(new OrderBookVM.CheckColumn(nameof(OrderBookRowVM.is_selected))); obvm.load_from(state); return obvm; } diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index e26cf5afc..77ecffeb4 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -155,7 +155,7 @@ namespace mbts.spark { vm.RequestClose += (s, e) => WindowUtilities.force_close(dialog); return dialog; })); - grid_settings_manager = new OrderBookGridSettingsManager(bus, notification_service, model, rows, columns); + grid_settings_manager = new OrderBookGridSettingsManager(bus, notification_service, model, rows, core_columns); grid_settings_manager.algo_tree_display_mode_changed += _on_filter_changed; IDisposable attach_vm_hooks = null; begin_attaching += on_begin_attaching;