From 0f0d8df5724032d4c8d422cf4587de1c2eb5887d Mon Sep 17 00:00:00 2001 From: John Colvin Date: Sun, 17 Apr 2022 14:10:51 -0400 Subject: [PATCH] fix: Set init val through display-translator in SizeCalculator The init val was being passed to the erroneous `UserProperty _value` field, which should have been deleted when the _display_translator was introduced. Bugs (fixed): * the ladder-view's initial size field is null when --- .../spark/view/Spark/Shell/CalculatorLogic.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/client/spark/view/Spark/Shell/CalculatorLogic.cs b/src/client/spark/view/Spark/Shell/CalculatorLogic.cs index 3db4eebbe..9b399d127 100644 --- a/src/client/spark/view/Spark/Shell/CalculatorLogic.cs +++ b/src/client/spark/view/Spark/Shell/CalculatorLogic.cs @@ -1,6 +1,5 @@ namespace mbts.spark { using bts.api.domain; - using bts.utils; using mbts.ui; using mbts.ui.shell; @@ -10,16 +9,18 @@ using System.Windows.Input; public class CalculatorLogic : DisposableViewModelBase where T : struct, IFloatingPoint { - readonly UserProperty _value; readonly OptionalDisplayQuantityMultiplier _display_translator = new(); TickDisplaySettingsImmutable _display_settings = SecurityDataHelper.Defaults.quantity_display_settingsi; + bool _value_setter_called; IDisposable _prop_changes_echo; T[] _buttons; public CalculatorLogic(T? initial_size) { - _value = new UserProperty(backing(nameof(value), initial_size)); + if (initial_size.HasValue) { + bypass_value_setter(initial_size.Value, true); + } _echo_props_changed(); } @@ -37,7 +38,10 @@ } public T? display_value { get => _display_translator.display_value; - set => _display_translator.display_value = value; + set { + _display_translator.display_value = value; + value_setter_called = true; + } } public TickDisplaySettingsImmutable display_settings { get => _display_settings; @@ -50,7 +54,11 @@ public double unit_quantity => display_settings.TickFactors.to_tick_factors().tick_unit_frac(); - public bool value_setter_called => _value.setter_called; + public bool value_setter_called { + get => _value_setter_called; + set => Set(ref _value_setter_called, value); + } + public T[] buttons { get => _buttons; set => Set(ref _buttons, value); } public ICommand click => new DelegateCommand(handle_calculator_click); public ICommand set_display_value_command => new DelegateCommand(v => _display_translator.display_value = v);