diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs index 1055e3d51..678282a83 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs @@ -110,6 +110,7 @@ namespace mbts.spark { if (Set(ref _show_account_position, s.account_position_visible, nameof(show_account_position)) | Set(ref _show_day_position, s.day_position_visible, nameof(show_day_position))) { RaisePropertyChanged(nameof(position_display_text)); } + size_calculator.buttons = s.calculator_buttons; } }; PropertyAutoWrapper bool_prop(string name, Func get_bool) => @@ -132,7 +133,6 @@ namespace mbts.spark { _dispose = Disposable.Create( settings.OnDispatcher().Subscribe(settings_observer), get_order_properties_editor_hooks(), - size_calculator = new CalculatorLogic(0, settings.Select(s => s.calculator_buttons).OnDispatcher()), bus.subscribe(SparkTags.LogActivity).OnDispatcher().Subscribe(status_update), // we need to hook this up to model.orders which is filtered for just the security model.orders.OnDispatcher().Subscribe(working => { @@ -275,7 +275,7 @@ namespace mbts.spark { public double day_position => _day_position; public ulong volume => _volume.Value; public bool auto_clear { get => _auto_clear.Value; set => _auto_clear.set(value); } - public CalculatorLogic size_calculator { get; } + public CalculatorLogic size_calculator { get; } = new CalculatorLogic(0); /// Important: can be null. public OrderPropertiesEditorVM order_properties_vm { get; } public ObservableCollection orders { get; } diff --git a/src/client/spark/view/Spark/Shell/CalculatorLogic.cs b/src/client/spark/view/Spark/Shell/CalculatorLogic.cs index 56a81f4fb..6433e10e1 100644 --- a/src/client/spark/view/Spark/Shell/CalculatorLogic.cs +++ b/src/client/spark/view/Spark/Shell/CalculatorLogic.cs @@ -7,17 +7,18 @@ using System.Windows.Input; namespace mbts.spark { public class CalculatorLogic : DisposableViewModelBase { readonly UserProperty _value; - readonly Property _buttons; + int[] _buttons; - public CalculatorLogic(uint? initial_size, IObservable buttons_source) { + public CalculatorLogic(uint? initial_size) => _value = new UserProperty(backing(nameof(value), initial_size)); - _buttons = backing(nameof(buttons), buttons_source); - } + + public CalculatorLogic(uint? initial_size, IObservable buttons_source) : this(initial_size) => + _dispose = buttons_source.Subscribe(newval => buttons = newval); public uint? value { get => _value.Value; set => _value.Value = value; } public bool value_setter_called => _value.setter_called; public IObservable value_observable => _value.Select(vals => vals.newval); - public int[] buttons { get => _buttons.Value; set => _buttons.set(value); } + public int[] buttons { get => _buttons; set => Set(ref _buttons, value); } public ICommand click => new DelegateCommand(handle_calculator_click); public ICommand set_value_command => new DelegateCommand(v => _value.Value = v); public ICommand clear => new DelegateCommand(() => _value.Value = null);