예제 #1
0
        private async Task InitializeSettings(GenericGaugeSettings settings)
        {
            //keep constructor'd settings if the gauge is newly added.
            bool emptyPayload = settings?.EmptyPayload ?? true;

            if (emptyPayload)
            {
                await this.UpdatePropertyInspector();
            }
            else
            {
                this.settings = settings;
            }

            TOGGLE_EVENT?newToggleEvent        = enumConverter.GetEventEnum(this.settings.ToggleValue);
            TOGGLE_VALUE?newDisplayValue       = enumConverter.GetVariableEnum(this.settings.DisplayValue);
            TOGGLE_VALUE?newSubDisplayValue    = enumConverter.GetVariableEnum(this.settings.SubDisplayValue);
            TOGGLE_VALUE?newDisplayValueBottom = enumConverter.GetVariableEnum(this.settings.DisplayValueBottom);
            TOGGLE_VALUE?newMinValue           = enumConverter.GetVariableEnum(this.settings.MinValue);
            TOGGLE_VALUE?newMaxValue           = enumConverter.GetVariableEnum(this.settings.MaxValue);

            if (newDisplayValue != displayValue || newDisplayValueBottom != displayValueBottom || newSubDisplayValue != subDisplayValue || newMinValue != minValue || newMaxValue != maxValue)
            {
                DeRegisterValues();
            }

            toggleEvent        = newToggleEvent;
            displayValue       = newDisplayValue;
            subDisplayValue    = newSubDisplayValue;
            displayValueBottom = newDisplayValueBottom;
            minValue           = newMinValue;
            maxValue           = newMaxValue;

            RegisterValues();
        }
예제 #2
0
        private async Task InitializeSettings(GenericGaugeSettings settings)
        {
            //keep constructor'd settings if the gauge is newly added.
            bool emptyPayload = settings?.EmptyPayload ?? true;

            if (emptyPayload)
            {
                await this.UpdatePropertyInspector();
            }
            else
            {
                this.settings = settings;
            }

            TOGGLE_EVENT?newToggleEvent        = enumConverter.GetEventEnum(this.settings.ToggleValue);
            TOGGLE_VALUE?newDisplayValue       = enumConverter.GetVariableEnum(this.settings.DisplayValue);
            TOGGLE_VALUE?newSubDisplayValue    = enumConverter.GetVariableEnum(this.settings.SubDisplayValue);
            TOGGLE_VALUE?newDisplayValueBottom = enumConverter.GetVariableEnum(this.settings.DisplayValueBottom);

            TOGGLE_VALUE?newMinValue = enumConverter.GetVariableEnum(this.settings.MinValue);
            TOGGLE_VALUE?newMaxValue = enumConverter.GetVariableEnum(this.settings.MaxValue);

            if (double.TryParse(string.IsNullOrWhiteSpace(settings.MinValue) ? DefaultSettings.MinValue : settings.MinValue, out var min))
            {
                currentMinValue = min;
            }
            if (double.TryParse(string.IsNullOrWhiteSpace(settings.MaxValue) ? DefaultSettings.MaxValue : settings.MaxValue, out var max))
            {
                currentMaxValue = max;
            }

            if (int.TryParse(settings.ValuePrecision, out int decimals))
            {
                customDecimals = decimals;
            }
            else
            {
                customDecimals = null;
            }

            var newUnit = settings.ValueUnit?.Trim();

            if (string.IsNullOrWhiteSpace(newUnit))
            {
                newUnit = null;
            }

            if (newDisplayValue != displayValue || newDisplayValueBottom != displayValueBottom || newSubDisplayValue != subDisplayValue ||
                newMinValue != minValue || newMaxValue != maxValue || newUnit != customUnit)
            {
                DeRegisterValues();
            }

            toggleEvent        = newToggleEvent;
            displayValue       = newDisplayValue;
            customUnit         = newUnit;
            subDisplayValue    = newSubDisplayValue;
            displayValueBottom = newDisplayValueBottom;
            minValue           = newMinValue;
            maxValue           = newMaxValue;

            RegisterValues();
        }