Ejemplo n.º 1
0
 public override void prepareRendering(Display display)
 {
     base.prepareRendering(display);
     RenderData.BorderRotation      = rotation_;
     RenderData.BackgroundRotation += rotation_;
 }
Ejemplo n.º 2
0
            public override void prepareRendering(Display display)
            {
                base.prepareRendering(display);
                RenderDataList renderData = RenderData as RenderDataList;
                //Vector2 size = SizeType == ValueType.Relative ? Size * display.RenderArea.Size : Size;
                //Vector2 position = PositionType == ValueType.Relative ? Position * display.RenderArea.Size : Position;
                Vector2 size     = RenderData.InnerSize;
                Vector2 position = RenderData.Position;

                float fontHeight   = textShow_ == true ? Default.CharHeight * Template.FontSize : 0f;
                float barThickness = barThicknessType_ == ValueType.Relative ? barThickness_ * fontHeight : barThickness_;

                renderData.LineHeight = fontHeight + spacing_;
                if (barShow_)
                {
                    renderData.BarSize     = new Vector2(size.X, barThickness);
                    renderData.LineHeight += barEmbedded_ ? 0f : renderData.BarSize.Y;
                }
                else
                {
                    renderData.BarSize = new Vector2();
                }

                if (lines_ > 0)
                {
                    float scale = (size.Y / lines_) / renderData.LineHeight;

                    fontHeight            *= scale;
                    renderData.BarSize.Y  *= scale;
                    renderData.LineHeight *= scale;
                    renderData.Lines       = lines_;
                    renderData.FontSize    = Template.FontSize * scale;
                }
                else
                {
                    renderData.Lines    = (int)(size.Y / renderData.LineHeight);
                    renderData.FontSize = Template.FontSize;
                }

                if (iconShow_ && (!textShow_ || barEmbedded_))
                {
                    renderData.BarSize.X -= renderData.BarSize.Y;
                }

                // calculate bar tiles
                if (barShow_)
                {
                    renderData.BarTiles       = (int)((renderData.BarSize.X / renderData.BarSize.Y) * 2f);
                    renderData.BarTileSpacing = renderData.BarSize.X * 0.01f;
                }

                // calculate Y position
                renderData.TextPositionY = position.Y - (size.Y * 0.5f) + (fontHeight * 0.5f);
                renderData.BarPosition.Y = position.Y - (size.Y * 0.5f) + (renderData.BarSize.Y * 0.5f) + (barEmbedded_ ? 0f : fontHeight);

                // icon
                if (iconShow_)
                {
                    // adjust bar size if no text
                    if (textShow_ == false)
                    {
                        renderData.BarSize.X -= renderData.BarSize.Y;
                        renderData.IconSize   = new Vector2(renderData.BarSize.Y, renderData.BarSize.Y);
                    }
                    else
                    {
                        renderData.IconSize = new Vector2(fontHeight, fontHeight);
                    }

                    renderData.IconPosition.Y = position.Y - (size.Y * 0.5f) + (renderData.IconSize.Y * 0.5f);
                }

                // calculate X position
                renderData.IconPosition.X     = position.X - (size.X * 0.5f) + (renderData.IconSize.X * 0.5f);
                renderData.BarPosition.X      = position.X - (size.X * 0.5f) + (renderData.BarSize.X * 0.5f) + (barEmbedded_ ? renderData.IconSize.X : 0f);
                renderData.TextLeftPositionX  = position.X - (size.X * 0.5f) + renderData.IconSize.X;
                renderData.TextRightPositionX = position.X + (size.X * 0.5f);
                renderData.BarSize            = new Vector2(renderData.BarSize.Y, renderData.BarSize.X);

                // filter list
                DataAccessor.list(out renderData.Container, (item) => isVisible(item.indicator));

                // auto scroll
                if (autoScroll_ == true)
                {
                    if (renderData.Lines >= renderData.Container.Count)
                    {
                        autoScrollLine_ = 0;
                    }
                    else
                    {
                        autoScrollLine_ += autoScrollInc_;

                        if (autoScrollLine_ < 0)
                        {
                            autoScrollLine_ = 0;
                            autoScrollInc_ *= -1;
                        }
                        else if (autoScrollLine_ > (renderData.Container.Count - renderData.Lines))
                        {
                            autoScrollLine_ = renderData.Container.Count - renderData.Lines;
                            autoScrollInc_ *= -1;
                        }
                    }
                }

                if (Gradient.Count == 0)
                {
                    addGradientColor(0.0f, Template.FontColor);
                }
            }