Ejemplo n.º 1
0
 public virtual void GetFontParameters(StreamDeckTools.StreamDeckTitleParameters titleParameters, out Font drawFont, out Color drawColor)
 {
     if (FontInherit && titleParameters != null)
     {
         drawFont  = StreamDeckTools.ConvertFontParameter(titleParameters);
         drawColor = StreamDeckTools.ConvertColorParameter(titleParameters);
     }
     else
     {
         drawFont  = new Font(FontName, GetNumValue(FontSize, 10), (FontStyle)FontStyle);
         drawColor = ColorTranslator.FromHtml(FontColor);
     }
 }
Ejemplo n.º 2
0
        public virtual void GetFontParameters(StreamDeckTools.StreamDeckTitleParameters titleParameters, string value, out Font drawFont, out Color drawColor)
        {
            if (FontInherit && titleParameters != null)
            {
                drawFont  = StreamDeckTools.ConvertFontParameter(titleParameters);
                drawColor = StreamDeckTools.ConvertColorParameter(titleParameters);
            }
            else
            {
                drawFont  = new Font(FontName, ModelDisplayText.GetNumValue(FontSize, 10), (FontStyle)FontStyle);
                drawColor = ColorTranslator.FromHtml(FontColor);
            }

            if (UseWarnColors && DrawWarnRange)
            {
                if (ValueWithinRange(value, WarnRange))
                {
                    drawColor = ColorTranslator.FromHtml(WarnColor);
                }
                else if (ValueWithinRange(value, CriticalRange))
                {
                    drawColor = ColorTranslator.FromHtml(CriticalColor);
                }

                if (SymmRange && float.TryParse(MinimumValue, NumberStyles.Number, new RealInvariantFormat(MinimumValue), out float minimumTotal) && float.TryParse(MaximumValue, NumberStyles.Number, new RealInvariantFormat(MinimumValue), out float maximumTotal))
                {
                    float[][] ranges = GetWarnRange();

                    string rangeStr = Convert.ToString(ImageRenderer.NormalizedValue(maximumTotal, minimumTotal) - ImageRenderer.NormalizedValue(ranges[1][1], minimumTotal), CultureInfo.InvariantCulture.NumberFormat);
                    rangeStr += ";" + Convert.ToString(ImageRenderer.NormalizedValue(maximumTotal, minimumTotal) - ImageRenderer.NormalizedValue(ranges[1][0], minimumTotal), CultureInfo.InvariantCulture.NumberFormat);
                    if (ValueWithinRange(value, rangeStr))
                    {
                        drawColor = ColorTranslator.FromHtml(WarnColor);
                    }
                    else
                    {
                        rangeStr  = Convert.ToString(ImageRenderer.NormalizedValue(maximumTotal, minimumTotal) - ImageRenderer.NormalizedValue(ranges[0][1], minimumTotal), CultureInfo.InvariantCulture.NumberFormat);
                        rangeStr += ";" + Convert.ToString(ImageRenderer.NormalizedValue(maximumTotal, minimumTotal) - ImageRenderer.NormalizedValue(ranges[0][0], minimumTotal), CultureInfo.InvariantCulture.NumberFormat);
                        if (ValueWithinRange(value, rangeStr))
                        {
                            drawColor = ColorTranslator.FromHtml(CriticalColor);
                        }
                    }
                }
            }
        }