Пример #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);
        }
Пример #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));
     }
 }
Пример #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();
            }
        }
Пример #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);
        }
Пример #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);
        }
Пример #6
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);
                        }
                    }
                }
            }
        }
Пример #7
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);
        }
Пример #8
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);
        }
Пример #9
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();
            }
        }