示例#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
        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);
        }
示例#3
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));
            }
        }
示例#4
0
        protected override void Redraw(ImageManager imgManager)
        {
            if (!ValueManager.IsChanged(ID.ControlState) && !ForceUpdate)
            {
                return;
            }

            //Stopwatch sw = new Stopwatch();
            //sw.Start();

            string value = ValueManager[ID.ControlState];

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

            ImageRenderer render = new ImageRenderer(imgManager.GetImageObject(GaugeSettings.DefaultImage, DeckType));

            if (GaugeSettings.DrawArc)
            {
                DrawText(value, render);
                DrawArc(value, render);
            }
            else
            {
                DrawBar(value, render);
                DrawText(value, render);
            }

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

            //sw.Stop();
            //Log.Logger.Debug($"Time for Gauge-Frame: {sw.Elapsed.TotalMilliseconds}ms [{ActionID}]");
        }
示例#5
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));
                }
            }
        }
        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();
            }
        }
示例#7
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();
            }
        }