Exemplo n.º 1
0
        //public override void RegisterAddress(IPCManager ipcManager)
        //{
        //    base.RegisterAddress(ipcManager);

        //    ipcManager.RegisterAddress(Settings.Address2, AppSettings.groupStringRead);
        //    LastAddress2 = Settings.Address2;
        //}

        //public override void UpdateAddress(IPCManager ipcManager)
        //{
        //    base.UpdateAddress(ipcManager);

        //    LastAddress2 = UpdateAddress(ipcManager, LastAddress2, Settings.Address2);
        //}

        //public override void DeregisterAddress(IPCManager ipcManager)
        //{
        //    base.DeregisterAddress(ipcManager);

        //    ipcManager.DeregisterValue(Settings.Address2);
        //    if (Settings.Address2 != LastAddress2)
        //        Log.Logger.Error($"DeregisterValue: LastAddress and Address different for {ActionID} [ {Settings.Address2} != {LastAddress2} ] ");
        //}

        //public override void RefreshValue(IPCManager ipcManager)
        //{
        //    int results = 0;

        //    if (RefreshValue(ipcManager, Address, out string currentValue))
        //        results++;
        //    CurrentValue = currentValue;

        //    if (RefreshValue(ipcManager, Settings.Address2, out currentValue))
        //        results++;
        //    CurrentValue2 = currentValue;

        //    if (results > 0)
        //        IsChanged = true;
        //}

        protected override void DrawBar(string value, ImageRenderer render)
        {
            if (GaugeSettings.BarOrientation == (int)GaugeOrientation.LEFT)
            {
                GaugeSettings.IndicatorFlip = false;
            }
            else
            {
                GaugeSettings.IndicatorFlip = true;
            }

            base.DrawBar(value, render);

            value = ValueManager[ID.Second];
            if (GaugeSettings.DecodeBCD)
            {
                value = ModelDisplay.ConvertFromBCD(value);
            }
            value = GaugeSettings.ScaleValue(value);

            float min = ModelDisplayText.GetNumValue(GaugeSettings.MinimumValue, 0);
            float max = ModelDisplayText.GetNumValue(GaugeSettings.MaximumValue, 100);

            render.DrawBarIndicator(GaugeSettings.GetBar(), ColorTranslator.FromHtml(GaugeSettings.IndicatorColor), ModelDisplayText.GetNumValue(GaugeSettings.IndicatorSize, 10), ModelDisplayText.GetNumValue(value, 0), min, max, !GaugeSettings.IndicatorFlip);
        }
Exemplo n.º 2
0
 private Font GetFont(FontStyle style)
 {
     if (Settings.FontInherit && TitleParameters != null)
     {
         return(new Font(TitleParameters.FontName, TitleParameters.FontSize, style));
     }
     else
     {
         return(new Font(Settings.FontName, ModelDisplayText.GetNumValue(Settings.FontSize, 10), style));
     }
 }
Exemplo n.º 3
0
        protected virtual void RenderImages(ImageManager imgManager)
        {
            if (TextSettings.DrawBox)
            {
                ImageRenderer render = new ImageRenderer(imgManager.GetImageObject(TextSettings.DefaultImage, DeckType));
                render.DrawBox(ColorTranslator.FromHtml(TextSettings.BoxColor), ModelDisplayText.GetNumValue(TextSettings.BoxSize, 2), TextSettings.GetRectangleBox());
                DefaultImageRender = render.RenderImage64();
                render.Dispose();

                render = new ImageRenderer(imgManager.GetImageObject(TextSettings.ErrorImage, DeckType));
                render.DrawBox(ColorTranslator.FromHtml("#d70000"), ModelDisplayText.GetNumValue(TextSettings.BoxSize, 2), TextSettings.GetRectangleBox());
                ErrorImageRender = render.RenderImage64();
                render.Dispose();
            }
        }
Exemplo n.º 4
0
        public Arc GetArc()
        {
            float[] arcsize = GetNumValues(GaugeSize, 48, 6);
            float[] offset  = GetNumValues(Offset, 0, 0);
            Arc     arc     = new Arc
            {
                Radius     = arcsize[0],
                Width      = arcsize[1],
                Offset     = new PointF(offset[0], offset[1]),
                StartAngle = ModelDisplayText.GetNumValue(StartAngle, 135),
                SweepAngle = ModelDisplayText.GetNumValue(SweepAngle, 180)
            };

            return(arc);
        }
Exemplo n.º 5
0
        protected override void DrawArc(string value, ImageRenderer render)
        {
            base.DrawArc(value, render);

            value = ValueManager[ID.Second];
            if (GaugeSettings.DecodeBCD)
            {
                value = ModelDisplay.ConvertFromBCD(value);
            }
            value = GaugeSettings.ScaleValue(value);

            float min = ModelDisplayText.GetNumValue(GaugeSettings.MinimumValue, 0);
            float max = ModelDisplayText.GetNumValue(GaugeSettings.MaximumValue, 100);

            render.DrawArcIndicator(GaugeSettings.GetArc(), ColorTranslator.FromHtml(GaugeSettings.IndicatorColor), ModelDisplayText.GetNumValue(GaugeSettings.IndicatorSize, 10), ModelDisplayText.GetNumValue(value, 0), min, max, !GaugeSettings.IndicatorFlip);
        }
Exemplo n.º 6
0
        protected virtual void DrawText(string value, ImageRenderer render)
        {
            if (GaugeSettings.ShowText)
            {
                value = GaugeSettings.RoundValue(value);

                if (GaugeSettings.BarOrientation == (int)GaugeOrientation.LEFT && !GaugeSettings.DrawArc)
                {
                    render.Rotate(180, new PointF(0, 0));
                }

                GaugeSettings.GetFontParameters(TitleParameters, value, out Font drawFont, out Color drawColor);
                string text = ModelDisplay.FormatValue(value, GaugeSettings.Format);
                text = GaugeSettings.GetValueMapped(text);
                render.DrawText(text, drawFont, drawColor, ModelDisplayText.GetRectangleF(GaugeSettings.RectCoord));
            }
        }
Exemplo n.º 7
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);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        protected virtual void DrawArc(string value, ImageRenderer render)
        {
            Arc   drawArc = GaugeSettings.GetArc();
            float min     = ModelDisplayText.GetNumValue(GaugeSettings.MinimumValue, 0);
            float max     = ModelDisplayText.GetNumValue(GaugeSettings.MaximumValue, 100);

            render.DrawArc(drawArc, ColorTranslator.FromHtml(GaugeSettings.GaugeColor));

            if (GaugeSettings.DrawWarnRange)
            {
                render.DrawArcRanges(drawArc, GaugeSettings.GetColorRange(), GaugeSettings.GetWarnRange(), min, max, GaugeSettings.SymmRange);
            }

            if (GaugeSettings.CenterLine)
            {
                render.DrawArcCenterLine(drawArc, ColorTranslator.FromHtml(GaugeSettings.CenterLineColor), ModelDisplayText.GetNumValue(GaugeSettings.CenterLineThickness, 2));
            }

            render.DrawArcIndicator(drawArc, ColorTranslator.FromHtml(GaugeSettings.IndicatorColor), ModelDisplayText.GetNumValue(GaugeSettings.IndicatorSize, 10), ModelDisplayText.GetNumValue(value, 0), min, max, GaugeSettings.IndicatorFlip);
        }
Exemplo n.º 9
0
        protected virtual void DrawBar(string value, ImageRenderer render)
        {
            Bar   drawBar = GaugeSettings.GetBar();
            float min     = ModelDisplayText.GetNumValue(GaugeSettings.MinimumValue, 0);
            float max     = ModelDisplayText.GetNumValue(GaugeSettings.MaximumValue, 100);

            render.Rotate(GaugeSettings.BarOrientation, new PointF(0, 0));
            render.DrawBar(ColorTranslator.FromHtml(GaugeSettings.GaugeColor), drawBar);

            if (GaugeSettings.DrawWarnRange)
            {
                render.DrawBarRanges(drawBar, GaugeSettings.GetColorRange(), GaugeSettings.GetWarnRange(), min, max, GaugeSettings.SymmRange);
            }

            if (GaugeSettings.CenterLine)
            {
                render.DrawBarCenterLine(drawBar, ColorTranslator.FromHtml(GaugeSettings.CenterLineColor), ModelDisplayText.GetNumValue(GaugeSettings.CenterLineThickness, 2));
            }

            render.DrawBarIndicator(drawBar, ColorTranslator.FromHtml(GaugeSettings.IndicatorColor), ModelDisplayText.GetNumValue(GaugeSettings.IndicatorSize, 10), ModelDisplayText.GetNumValue(value, 0), min, max, GaugeSettings.IndicatorFlip);
        }
Exemplo n.º 10
0
 public Rectangle GetRectangleBot()
 {
     return(ModelDisplayText.GetRectangle(BotRect));
 }
Exemplo n.º 11
0
 public Rectangle GetRectangleTop()
 {
     return(ModelDisplayText.GetRectangle(TopRect));
 }
Exemplo n.º 12
0
        protected override void Redraw(ImageManager imgManager)
        {
            if (!ValueManager.IsChanged(ID.Active) && !ValueManager.IsChanged(ID.Standby) && !ForceUpdate && !wasPushed)
            {
                return;
            }

            string valueAct = ValueManager[ID.Active];

            if (Settings.DecodeBCD)
            {
                valueAct = ModelDisplay.ConvertFromBCD(valueAct);
            }
            valueAct = Settings.ScaleValue(valueAct);
            valueAct = Settings.RoundValue(valueAct);
            valueAct = Settings.FormatValue(valueAct);

            string valueStb = ValueManager[ID.Standby];

            if (Settings.DecodeBCD && !Settings.StbyHasDiffFormat || Settings.StbyHasDiffFormat && Settings.DecodeBCDStby)
            {
                valueStb = ModelDisplay.ConvertFromBCD(valueStb);
            }
            valueStb = ModelDisplay.ScaleValue(valueStb, Settings.StbyHasDiffFormat ? Settings.ScalarStby : Settings.Scalar);
            valueStb = ModelDisplay.RoundValue(valueStb, Settings.StbyHasDiffFormat ? Settings.FormatStby : Settings.Format);
            valueStb = ModelDisplay.FormatValue(valueStb, Settings.StbyHasDiffFormat ? Settings.FormatStby : Settings.Format);

            string background = Settings.DefaultImage;

            if (wasPushed)
            {
                ticksIndication++;
                if (ticksIndication < ticksActive)
                {
                    background = Settings.IndicationImage;
                }
                else
                {
                    wasPushed       = false;
                    ticksIndication = 0;
                }
            }

            if (lastText != valueAct + valueStb || ForceUpdate || wasPushed && ticksIndication < ticksActive)
            {
                Font fontAct = GetFont(FontStyle.Bold);
                Font fontStb = GetFont(FontStyle.Regular);

                Color colorAct;
                if (Settings.FontInherit && TitleParameters != null)
                {
                    colorAct = ColorTranslator.FromHtml(TitleParameters.FontColor);
                }
                else
                {
                    colorAct = ColorTranslator.FromHtml(Settings.FontColor);
                }

                Color colorStb;
                if (Settings.FontInherit && TitleParameters != null)
                {
                    colorStb = GetDarkenedColor(TitleParameters.FontColor);
                }
                else
                {
                    colorStb = ColorTranslator.FromHtml(Settings.FontColorStby);
                }

                ImageRenderer render = new ImageRenderer(imgManager.GetImageObject(background, DeckType));
                render.DrawText(valueAct, fontAct, colorAct, Settings.GetRectangleText());
                render.DrawText(valueStb, fontStb, colorStb, ModelDisplayText.GetRectangleF(Settings.RectCoordStby));

                DrawImage  = render.RenderImage64();
                IsRawImage = true;
                NeedRedraw = true;
                if (!wasPushed)
                {
                    lastText = valueAct + valueStb;
                }
                else
                {
                    lastText = "";
                }
                render.Dispose();
            }
        }
Exemplo n.º 13
0
        protected override void DrawText(string value, ImageRenderer render)
        {
            base.DrawText(value, render);

            if (!GaugeSettings.DrawArc)
            {
                value = ValueManager[ID.Second];
                if (GaugeSettings.DecodeBCD)
                {
                    value = ModelDisplay.ConvertFromBCD(value);
                }
                value = GaugeSettings.ScaleValue(value);

                if (GaugeSettings.ShowText)
                {
                    value = GaugeSettings.RoundValue(value);

                    GaugeSettings.GetFontParameters(TitleParameters, value, out Font drawFont, out Color drawColor);
                    render.DrawText(ModelDisplay.FormatValue(value, GaugeSettings.Format), drawFont, drawColor, ModelDisplayText.GetRectangleF(Settings.RectCoord2));
                }
            }
        }
Exemplo n.º 14
0
 public HandlerDisplayText(string context, ModelDisplayText settings, StreamDeckType deckType) : base(context, settings, deckType)
 {
     Settings = settings;
     DrawBox  = settings.DrawBox;
 }
Exemplo n.º 15
0
        protected override void Redraw(ImageManager imgManager)
        {
            if (!ValueManager.IsChanged(ID.ControlState) && !ForceUpdate)
            {
                return;
            }

            string value = ValueManager[ID.ControlState];

            if (Settings.DecodeBCD)
            {
                value = ModelDisplay.ConvertFromBCD(value);
            }

            value = TextSettings.ScaleValue(value);
            value = TextSettings.RoundValue(value);

            //evaluate value and set indication
            string background = DefaultImage;

            TextSettings.GetFontParameters(TitleParameters, out Font drawFont, out Color drawColor);
            Color boxColor = ColorTranslator.FromHtml(TextSettings.BoxColor);

            string text = "";

            if (TextSettings.HasIndication && TextSettings.IndicationValue == value)
            {
                background = TextSettings.IndicationImage;
                if (!TextSettings.IndicationHideValue)
                {
                    text = TextSettings.FormatValue(value);
                    if (TextSettings.IndicationUseColor)
                    {
                        drawColor = ColorTranslator.FromHtml(TextSettings.IndicationColor);
                    }
                }

                if (TextSettings.IndicationUseColor)
                {
                    boxColor = ColorTranslator.FromHtml(TextSettings.IndicationColor);
                }
            }
            else
            {
                text = TextSettings.FormatValue(value);
            }

            text = TextSettings.GetValueMapped(text);

            if (text != lastText || ForceUpdate)
            {
                ImageRenderer render = new ImageRenderer(imgManager.GetImageObject(background, DeckType));
                if (TextSettings.DrawBox)
                {
                    render.DrawBox(boxColor, ModelDisplayText.GetNumValue(TextSettings.BoxSize, 2), TextSettings.GetRectangleBox());
                }

                if (text != "")
                {
                    render.DrawText(text, drawFont, drawColor, TextSettings.GetRectangleText());
                }

                DrawImage  = render.RenderImage64();
                IsRawImage = true;
                NeedRedraw = true;
                lastText   = text;
                render.Dispose();
            }
        }