Esempio n. 1
0
        private async Task UpdateImage()
        {
            if (settings != null)
            {
                float  MinValue   = settings.MinValue.ConvertTo <float>(this.defaultSettings.MinValue);
                float  MaxValue   = settings.MaxValue.ConvertTo <float>(this.defaultSettings.MaxValue);
                string chartSplit = string.IsNullOrEmpty(settings.ChartSplitValue) ? defaultSettings.ChartSplitValue : settings.ChartSplitValue;
                if (settings.Type?.Equals("Custom", StringComparison.OrdinalIgnoreCase) ?? false)
                {
                    bool.TryParse(settings.AbsValText, out bool absValueText);

                    int   chartThickness   = settings.ChartThicknessValue.ConvertTo <int>(this.defaultSettings.ChartThicknessValue);
                    float chartChevronSize = settings.ChartChevronSizeValue.ConvertTo <int>(this.defaultSettings.ChartChevronSizeValue);
                    int   modifier         = MinValue > MaxValue ? -1 : 1;
                    await SetImageAsync(
                        imageLogic.GetCustomGaugeImage(
                            settings.Header,
                            settings.HeaderBottom,
                            (currentValue * modifier).ToString(this.precision),
                            (currentValueBottom *modifier).ToString(this.precision),
                            MinValue,
                            MaxValue,
                            settings.DisplayHorizontalValue,
                            chartSplit?.Split(','),
                            chartThickness,
                            chartChevronSize,
                            absValueText,
                            precision,
                            settings.HideLabelOutsideMinMaxTop,
                            settings.HideLabelOutsideMinMaxBottom
                            )
                        );
                }
                else
                {
                    await SetImageAsync(
                        imageLogic.GetGenericGaugeImage(
                            settings.Header,
                            currentValue,
                            MinValue,
                            MaxValue,
                            precision,
                            currentSubValue
                            )
                        );
                }
            }
        }
Esempio n. 2
0
 private async Task UpdateImage()
 {
     if (settings != null)
     {
         string precision = $"F{((settings.ValuePrecision?.Length ?? 0) > 0 ? settings.ValuePrecision : "2")}";
         if (settings.Type?.Equals("Custom", StringComparison.OrdinalIgnoreCase) ?? false)
         {
             int modifier = settings.MinValue > settings.MaxValue ? -1 : 1;
             bool.TryParse(settings.AbsValText, out bool absValueText);
             await SetImageAsync(
                 imageLogic.GetCustomGaugeImage(
                     settings.Header,
                     settings.HeaderBottom,
                     (currentValue * modifier).ToString(precision),
                     (currentValueBottom *modifier).ToString(precision),
                     settings.MinValue,
                     settings.MaxValue,
                     settings.DisplayHorizontalValue,
                     settings.ChartSplitValue?.Split(','),
                     settings.ChartThicknessValue,
                     settings.ChartChevronSizeValue,
                     absValueText,
                     precision
                     )
                 );
         }
         else
         {
             await SetImageAsync(
                 imageLogic.GetGenericGaugeImage(
                     settings.Header,
                     currentValue,
                     settings.MinValue,
                     settings.MaxValue,
                     precision,
                     currentSubValue
                     )
                 );
         }
     }
 }