public void Render(double dTime)
        {
            int lTime = (int)(1000.0d * dTime);

            foreach (Line line in m_subs)
            {
                if (lTime >= line.StartTime && lTime <= line.EndTime)
                {
                    if (m_font != null)
                    {
                        try
                        {
                            float fw = 0, fh = 0;
                            m_font.GetTextExtent(line.Text, ref fw, ref fh);
                            int iposx = (GUIGraphicsContext.OverScanWidth - (int)fw) / 2;
                            int iposy = (GUIGraphicsContext.Subtitles - (int)fh);
                            m_font.DrawShadowText((float)iposx, (float)iposy, m_iColor, line.Text, GUIControl.Alignment.ALIGN_LEFT,
                                                  (int)fw, m_iShadow, m_iShadow, 0xff000000);
                        }
                        catch (Exception) {}
                    }
                }
                if (line.StartTime > lTime)
                {
                    return;
                }
            }
        }
예제 #2
0
        public override void PreAllocResources()
        {
            base.PreAllocResources();
            float fWidth = 0, fHeight = 0;

            _font = GUIFontManager.GetFont(_fontName);
            if (null == _font)
            {
                return;
            }
            _font.GetTextExtent("afy", ref fWidth, ref fHeight);
            try
            {
                _itemHeight = (int)(fHeight);
                float fTotalHeight = (float)_height;
                _itemsPerPage = (int)Math.Floor(fTotalHeight / (fHeight * _lineSpacing));
                if (_itemsPerPage == 0)
                {
                    _itemsPerPage = 1;
                }
            }
            catch (Exception)
            {
                _itemHeight   = 1;
                _itemsPerPage = 1;
            }
        }
예제 #3
0
        /// <summary>
        /// Renders the GUICheckMarkControl.
        /// </summary>
        public override void Render(float timePassed)
        {
            // Do not render if not visible.
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

            // Set the selection based on the user specified condition.
            if (_selected.Length != 0)
            {
                try
                {
                    Selected = bool.Parse(GUIPropertyManager.Parse(_selected, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS));
                }
                catch (System.Exception ex)
                {
                    Log.Debug("GUICheckMarkControl: id={0} <selected> expression does not return a boolean value {1}", GetID, ex.Message);
                }
            }

            if (Focus)
            {
                GUIPropertyManager.SetProperty("#highlightedbutton", _label);
            }
            int dwTextPosX      = _positionX;
            int dwCheckMarkPosX = _positionX;

            _rectangle.X      = _positionY;
            _rectangle.Y      = _positionY;
            _rectangle.Height = _imageCheckMarkFocused.Height;
            if (null != _font)
            {
                if (_alignment == Alignment.ALIGN_LEFT)
                {
                    // calculate the position of the checkmark if the text appears at the left side of the checkmark
                    float fTextHeight = 0, fTextWidth = 0;
                    _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight);
                    dwCheckMarkPosX += ((int)(fTextWidth) + 5);
                    _rectangle.X     = _positionX;
                    _rectangle.Width = 5 + (int)fTextWidth + _imageCheckMarkFocused.Width;
                }
                else
                {
                    // put text at the right side of the checkmark
                    dwTextPosX = (dwCheckMarkPosX + _imageCheckMarkFocused.Width + 5);

                    float fTextHeight = 0, fTextWidth = 0;
                    _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight);
                    _rectangle.X     = dwTextPosX;
                    _rectangle.Width = (dwTextPosX + (int)fTextWidth + 5) - dwTextPosX;
                }
                if (Disabled)
                {
                    // If disabled, draw the text in the disabled color.
                    _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1);
                }
                else
                {
                    // Draw focused text and shadow
                    if (Focus)
                    {
                        if (_shadow)
                        {
                            _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1, 5,
                                                 5, GUIGraphicsContext.MergeAlpha(0xff000000));
                        }
                        else
                        {
                            _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1);
                        }
                    }
                    // Draw non-focused text and shadow
                    else
                    {
                        if (_shadow)
                        {
                            _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT,
                                                 -1,
                                                 5, 5, GUIGraphicsContext.MergeAlpha(0xff000000));
                        }
                        else
                        {
                            _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1);
                        }
                    }
                }
            }

            // Render the selected checkmark image
            if (_isSelected)
            {
                _imageCheckMarkFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkFocused.Render(timePassed);
            }
            else
            {
                // Render the non-selected checkmark image
                _imageCheckMarkNonFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkNonFocused.Render(timePassed);
            }
            base.Render(timePassed);
        }
예제 #4
0
        /// <summary>
        /// Renders the control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            string  strValue = "";
            float   fRange = 0.0f;
            float   fPos = 0.0f;
            float   fPercent = 0.0f;
            float   fTextWidth = 0, fTextHeight = 0;
            GUIFont _font = GUIFontManager.GetFont(_valueFont);

            switch (_spinType)
            {
            // Float based slider
            case GUISpinControl.SpinType.SPIN_CONTROL_TYPE_FLOAT:
                if (null != _font && _showValue)
                {
                    strValue = String.Format("{0}", _floatValue);
                    _font.DrawText((float)_positionX, (float)_positionY,
                                   _textColor, strValue, Alignment.ALIGN_LEFT, -1);
                    _font.GetTextExtent(strValue, ref fTextWidth, ref fTextHeight);
                    _imageBackGround.SetPosition(_positionX + (int)fTextWidth + 10, _positionY);
                }

                fRange      = (float)(_floatEndValue - _floatStartValue);
                fPos        = (float)(_floatValue - _floatStartValue);
                fPercent    = (fPos / fRange) * 100.0f;
                _percentage = (int)fPercent;
                break;

            // Integer based slider
            case GUISpinControl.SpinType.SPIN_CONTROL_TYPE_INT:
                if (null != _font && _showValue)
                {
                    strValue = String.Format("{0}/{1}", _intValue, _intEndValue);
                    _font.DrawText((float)_positionX, (float)_positionY,
                                   _textColor, strValue, Alignment.ALIGN_LEFT, -1);
                    _font.GetTextExtent(strValue, ref fTextWidth, ref fTextHeight);
                    _imageBackGround.SetPosition(_positionX + (int)fTextWidth + 10, _positionY);
                }

                fRange      = (float)(_intEndValue - _intStartValue);
                fPos        = (float)(_intValue - _intStartValue);
                _percentage = (int)((fPos / fRange) * 100.0f);
                break;
            }

            //int iHeight=25;
            _imageBackGround.Render(timePassed);
            //_imageBackGround.SetHeight(iHeight);
            //_height = _imageBackGround.Height;
            //_width = _imageBackGround.Width + (int)fTextWidth + 10;

            float fWidth = (float)(_imageBackGround.TextureWidth - _imageMid.TextureWidth); //-20.0f;

            fPos  = (float)_percentage;
            fPos /= 100.0f;
            fPos *= fWidth;
            fPos += (float)_imageBackGround.XPosition;
            //fPos += 10.0f;
            if ((int)fWidth > 1)
            {
                if (Focus)
                {
                    _imageMidFocus.SetPosition((int)fPos, _imageBackGround.YPosition);
                    _imageMidFocus.Render(timePassed);
                }
                else
                {
                    _imageMid.SetPosition((int)fPos, _imageBackGround.YPosition);
                    _imageMid.Render(timePassed);
                }
            }
            base.Render(timePassed);
        }
예제 #5
0
        /// <summary>
        /// Renders the text onscreen.
        /// </summary>
        public override void Render(float timePassed)
        {
            // Do not render if not visible
            if (!IsVisible)
            {
                base.Render(timePassed);
                return;
            }
            if (_containsProperty && _propertyHasChanged)
            {
                _propertyHasChanged = false;
                CachedLabel();
            }

            if (string.IsNullOrEmpty(_cachedTextLabel))
            {
                base.Render(timePassed);
                return;
            }

            if (_reCalculate)
            {
                _reCalculate = false;
                ClearFontCache();
            }

            if (null != _font)
            {
                if (_textwidth == 0 || _textheight == 0)
                {
                    float width  = _textwidth;
                    float height = _textheight;
                    _font.GetTextExtent(_cachedTextLabel, ref width, ref height);
                    _textwidth  = (int)width;
                    _textheight = (int)height;
                }

                // Compute the vertical position of text in the controls height extent.
                // Default is align to top.
                float vpos = _positionY;
                if (_textVAlignment == VAlignment.ALIGN_MIDDLE)
                {
                    vpos += (float)Math.Ceiling((Height - _textheight) / 2.0f);
                }
                else if (_textVAlignment == VAlignment.ALIGN_BOTTOM)
                {
                    vpos += Height - _textheight;
                }

                if (_textAlignment == Alignment.ALIGN_CENTER)
                {
                    int xoff = (_width - _textwidth) / 2;
                    if (xoff < 0 && _width > 0)
                    {
                        xoff = 0;
                    }
                    int yoff = (_height - _textheight) / 2;

                    DrawText((float)_positionX + xoff, (float)_positionY + yoff, _cachedTextLabel, _width);
                }
                else
                {
                    if (_textAlignment == Alignment.ALIGN_RIGHT)
                    {
                        if (_width == 0 || _textwidth < _width)
                        {
                            DrawText((float)_positionX - _textwidth, vpos, _cachedTextLabel, -1);
                        }
                        else
                        {
                            if (_width < 6)
                            {
                                base.Render(timePassed);
                                return;
                            }

                            DrawText((float)_positionX - _textwidth, vpos, _cachedTextLabel, _width - 5);
                        }
                        base.Render(timePassed);
                        return;
                    }

                    if (_width == 0 || _textwidth < _width)
                    {
                        DrawText(_positionX, vpos, _cachedTextLabel, _width);
                    }
                    else
                    {
                        if (_width < 6)
                        {
                            return;
                        }
                        DrawText(_positionX, vpos, _cachedTextLabel, _width - 5);
                    }
                }
            }
            base.Render(timePassed);
        }
예제 #6
0
        public override void Render(float timePassed)
        {
            if (null == _font)
            {
                return;
            }
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

            if (_containsProperty)
            {
                string strText = GUIPropertyManager.Parse(_property);

                strText = strText.Replace("\\r", "\r");
                if (strText != _previousProperty)
                {
                    _offset = 0;
                    _itemList.DisposeAndClearList();

                    _previousProperty = strText;
                    SetText(strText);
                }
            }

            int dwPosY = _positionY;

            for (int i = 0; i < _itemsPerPage; i++)
            {
                int dwPosX = _positionX;
                if (i + _offset < _itemList.Count)
                {
                    // render item
                    GUIListItem item      = (GUIListItem)_itemList[i + _offset];
                    string      strLabel1 = item.Label;
                    string      strLabel2 = item.Label2;

                    string wszText1  = String.Format("{0}", strLabel1);
                    int    dMaxWidth = _width + 16;
                    float  x         = 0;
                    if (strLabel2.Length > 0)
                    {
                        string wszText2;
                        float  fTextWidth = 0, fTextHeight = 0;
                        wszText2 = String.Format("{0}", strLabel2);
                        _font.GetTextExtent(wszText2, ref fTextWidth, ref fTextHeight);
                        dMaxWidth -= (int)(fTextWidth);
                        uint color = (uint)_textColor;
                        color = GUIGraphicsContext.MergeAlpha(color);
                        if (Shadow)
                        {
                            uint sc = (uint)_shadowColor;
                            sc = GUIGraphicsContext.MergeAlpha(sc);
                            _font.DrawShadowTextWidth((float)dwPosX + dMaxWidth, (float)dwPosY + 2, color, wszText2, _textAlignment,
                                                      _shadowAngle, _shadowDistance, sc, (float)fTextWidth);
                        }
                        else
                        {
                            _font.DrawTextWidth((float)dwPosX + dMaxWidth, (float)dwPosY + 2, color, wszText2, (float)fTextWidth,
                                                _textAlignment);
                        }
                    }
                    switch (_textAlignment)
                    {
                    case Alignment.ALIGN_RIGHT:
                        x = (float)dwPosX + _width;
                        break;

                    default:
                        x = (float)dwPosX;
                        break;
                    }
                    {
                        uint color = (uint)_textColor;
                        color = GUIGraphicsContext.MergeAlpha(color);
                        if (Shadow)
                        {
                            uint sc = (uint)_shadowColor;
                            sc = GUIGraphicsContext.MergeAlpha(sc);
                            _font.DrawShadowTextWidth(x, (float)dwPosY + 2, color, wszText1, _textAlignment,
                                                      _shadowAngle, _shadowDistance, sc, (float)dMaxWidth);
                        }
                        else
                        {
                            _font.DrawTextWidth(x, (float)dwPosY + 2, color, wszText1, (float)dMaxWidth, _textAlignment);
                        }
                        dwPosY += (int)(_itemHeight * _lineSpacing);
                    }
                }
            }
            if (_upDownEnabled)
            {
                int iPages = _itemList.Count / _itemsPerPage;
                if ((_itemList.Count % _itemsPerPage) != 0)
                {
                    iPages++;
                }

                if (iPages > 1)
                {
                    _upDownControl.Render(timePassed);
                }
            }
            base.Render(timePassed);
        }
예제 #7
0
        /// <summary>
        /// Renders the text.
        /// </summary>
        /// <param name="timePassed"></param>
        /// <param name="positionX">The X position of the text.</param>
        /// <param name="positionY">The Y position of the text.</param>
        /// <param name="maxWidth">The maximum render width.</param>
        /// <param name="text">The actual text.</param>
        /// <returns>true if the render was successful</returns>
        private bool RenderText(float timePassed, float positionX, float positionY, float maxWidth, string text)
        {
            bool result = false;

            // do not render if we don't have a font
            if (_font == null)
            {
                return(true);
            }

            // get the text dimensions.
            float textHeight = 0;
            float textWidth  = 0;

            _font.GetTextExtent(text, ref textWidth, ref textHeight);
            float fWidth  = textWidth;
            float fHeight = textHeight;

            // set text color and apply dimming if requested
            long color = _textColor;

            if (Dimmed)
            {
                color &= DimColor;
            }

            // scroll
            string originalText = text;

            if (_textAlignment != Alignment.ALIGN_RIGHT)
            {
                do
                {
                    _font.GetTextExtent(originalText, ref textWidth, ref textHeight);
                    originalText += _labelTail;
                } while (textWidth > 0 && textWidth < maxWidth);
            }

            string scrollText = "";

            if (_timeElapsed > _scrollStartDelay)
            {
                if (_allowScrolling)
                {
                    if (GUIGraphicsContext.ScrollSpeedHorizontal < 3)
                    {
                        if (_frameLimiter % (4 - GUIGraphicsContext.ScrollSpeedHorizontal) == 0)
                        {
                            _scrollPosititionX++;
                        }
                    }
                    else
                    {
                        _scrollPosititionX = _scrollPosititionX + GUIGraphicsContext.ScrollSpeedHorizontal - 2;
                    }
                }

                string tempText = _scrollPosition >= originalText.Length ? " " : originalText.Substring(_scrollPosition, 1);
                _font.GetTextExtent(tempText, ref fWidth, ref fHeight);

                if (_scrollPosititionX - _scrollOffset >= fWidth)
                {
                    _scrollPosition++;
                    if (_scrollPosition > text.Length)
                    {
                        _scrollPosition = 0;
                        result          = true;
                        if (!WrapAround())
                        {
                            return(true);
                        }
                    }
                    _scrollOffset += fWidth;
                }

                int wrapPosition = 0;
                for (int i = 0; i < originalText.Length; i++)
                {
                    if (_scrollPosition + i < originalText.Length)
                    {
                        scrollText += originalText[i + _scrollPosition];
                    }
                    else
                    {
                        scrollText += WrapAround() ? originalText[wrapPosition++] : ' ';
                    }
                }

                _labelControl.TextAlignment  = Alignment.ALIGN_LEFT;
                _labelControl.TextVAlignment = _textVAlignment;
                _labelControl.Label          = scrollText;
                _labelControl.Width          = (int)(maxWidth + _scrollPosititionX - _scrollOffset);
                _labelControl.TextColor      = color;

                double xpos;
                double xoff;
                double xclipoff = 0;
                switch (_textAlignment)
                {
                case Alignment.ALIGN_RIGHT:
                    float fwt = 0;
                    GetShortenedText(originalText, _width, ref fwt);
                    //xoff = textWidth >= _width ? 0 : _width - fwt;
                    xoff     = textWidth >= _width ? -fwt : _width - fwt;
                    xclipoff = xoff;
                    xpos     = positionX + xoff - _scrollPosititionX + _scrollOffset;
                    _labelControl.SetPosition((int)xpos, (int)positionY);
                    break;

                case Alignment.ALIGN_CENTER:
                    _labelControl.TextColor      = color;
                    _labelControl.TextVAlignment = VAlignment.ALIGN_TOP;
                    xpos = positionX - _scrollPosititionX + _scrollOffset;
                    xoff = (_width - textWidth) / 2;
                    if (xoff < 0)
                    {
                        xoff = 0;
                    }
                    double yoff = (_height - textHeight) / 2;
                    _labelControl.SetPosition((int)(xpos + xoff), (int)(positionY + yoff));
                    break;

                default:
                    xpos = positionX - _scrollPosititionX + _scrollOffset;
                    _labelControl.SetPosition((int)xpos, (int)positionY);
                    break;
                }

                var clipRect = new Rectangle();
                clipRect.X      = (int)(positionX + xclipoff);
                clipRect.Y      = _labelControl.YPosition;
                clipRect.Width  = maxWidth > 0 ? (int)(maxWidth - xclipoff) : GUIGraphicsContext.Width - clipRect.X;
                clipRect.Height = GUIGraphicsContext.Height - clipRect.Y;

                GUIGraphicsContext.BeginClip(clipRect);
                _labelControl.Render(timePassed);
                GUIGraphicsContext.EndClip();
            }
            else
            {
                float fwt = 0;
                float fht = 0;
                _labelControl.Label = GetShortenedText(text, (int)maxWidth, ref fwt);
                _font.GetTextExtent(_labelControl.Label, ref fwt, ref fht);
                _labelControl.Width          = _textAlignment == Alignment.ALIGN_RIGHT ? (int)fwt : (int)maxWidth;
                _labelControl.TextColor      = color;
                _labelControl.TextVAlignment = _textVAlignment;

                double xoff = 0;
                if (_textAlignment == Alignment.ALIGN_RIGHT)
                {
                    //xoff = textWidth >= maxWidth ? fwt : maxWidth;
                    xoff = textWidth >= maxWidth ? 0 : maxWidth;
                }
                _labelControl.SetPosition((int)positionX + (int)xoff, (int)positionY);
                _labelControl.Render(timePassed);
            }

            return(result);
        }
예제 #8
0
        /// <summary>
        /// Renders the GUICheckMarkControl.
        /// </summary>
        public override void Render(float timePassed)
        {
            // Do not render if not visible.
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            if (Focus)
            {
                GUIPropertyManager.SetProperty("#highlightedbutton", _label);
            }
            int dwTextPosX      = _positionX;
            int dwCheckMarkPosX = _positionX;

            _rectangle.X      = _positionY;
            _rectangle.Y      = _positionY;
            _rectangle.Height = _imageCheckMarkFocused.Height;
            if (null != _font)
            {
                if (_alignment == Alignment.ALIGN_LEFT)
                {
                    // calculate the position of the checkmark if the text appears at the left side of the checkmark
                    float fTextHeight = 0, fTextWidth = 0;
                    _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight);
                    dwCheckMarkPosX += ((int)(fTextWidth) + 5);
                    _rectangle.X     = _positionX;
                    _rectangle.Width = 5 + (int)fTextWidth + _imageCheckMarkFocused.Width;
                }
                else
                {
                    // put text at the right side of the checkmark
                    dwTextPosX = (dwCheckMarkPosX + _imageCheckMarkFocused.Width + 5);

                    float fTextHeight = 0, fTextWidth = 0;
                    _font.GetTextExtent(_label, ref fTextWidth, ref fTextHeight);
                    _rectangle.X     = dwTextPosX;
                    _rectangle.Width = (dwTextPosX + (int)fTextWidth + 5) - dwTextPosX;
                }
                if (Disabled)
                {
                    // If disabled, draw the text in the disabled color.
                    _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1);
                }
                else
                {
                    // Draw focused text and shadow
                    if (Focus)
                    {
                        if (_shadow)
                        {
                            _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1, 5,
                                                 5, GUIGraphicsContext.MergeAlpha(0xff000000));
                        }
                        else
                        {
                            _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_textColor), _label, Alignment.ALIGN_LEFT, -1);
                        }
                    }
                    // Draw non-focused text and shadow
                    else
                    {
                        if (_shadow)
                        {
                            _font.DrawShadowText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT,
                                                 -1,
                                                 5, 5, GUIGraphicsContext.MergeAlpha(0xff000000));
                        }
                        else
                        {
                            _font.DrawText((float)dwTextPosX, (float)_positionY, GUIGraphicsContext.MergeAlpha((uint)_disabledColor), _label, Alignment.ALIGN_LEFT, -1);
                        }
                    }
                }
            }

            // Render the selected checkmark image
            if (_isSelected)
            {
                _imageCheckMarkFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkFocused.Render(timePassed);
            }
            else
            {
                // Render the non-selected checkmark image
                _imageCheckMarkNonFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkNonFocused.Render(timePassed);
            }
            base.Render(timePassed);
        }
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
                if (Disabled)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            if (_propertyLabel.Length > 0)
            {
                string m_strText = GUIPropertyManager.Parse(_propertyLabel);
                if (m_strText.Length > 0)
                {
                    try
                    {
                        Percentage1 = float.Parse(m_strText);
                    }
                    catch (Exception) {}
                    if (Percentage1 < 0 || Percentage1 > 100)
                    {
                        Percentage1 = 0;
                    }
                }
            }
            if (Label1.Length > 0)
            {
                string strText = GUIPropertyManager.Parse(Label1);
                if (strText.Length > 0)
                {
                    try
                    {
                        Percentage1 = float.Parse(strText);
                    }
                    catch (Exception) {}
                    if (Percentage1 < 0 || Percentage1 > 100)
                    {
                        Percentage1 = 0;
                    }
                }
            }

            if (Label2.Length > 0)
            {
                string strText = GUIPropertyManager.Parse(Label2);
                if (strText.Length > 0)
                {
                    try
                    {
                        Percentage2 = float.Parse(strText);
                    }
                    catch (Exception) {}
                    if (Percentage2 < 0 || Percentage2 > 100)
                    {
                        Percentage2 = 0;
                    }
                }
            }
            if (Label3.Length > 0)
            {
                string strText = GUIPropertyManager.Parse(Label3);
                if (strText.Length > 0)
                {
                    try
                    {
                        Percentage3 = float.Parse(strText);
                    }
                    catch (Exception) {}
                    if (Percentage3 < 0 || Percentage3 > 100)
                    {
                        Percentage3 = 0;
                    }
                }
            }

            int xPos = _positionX;

            _imageLeft.SetPosition(xPos, _positionY);

            xPos = _positionX + _imageLeft.TextureWidth;
            _imageMid.SetPosition(xPos, _positionY);

            int iWidth = _width - (_imageLeft.TextureWidth + _imageRight.TextureWidth);

            _imageMid.Width = iWidth;

            xPos = iWidth + _positionX + _imageLeft.TextureWidth;
            _imageRight.SetPosition(xPos, _positionY);

            _imageLeft.Render(timePassed);
            _imageRight.Render(timePassed);
            _imageMid.Render(timePassed);

            int iWidth1 = 0, iWidth2 = 0, iWidth3 = 0;

            iWidth -= 2 * _fillBackgroundOffsetX;
            float fWidth  = iWidth;
            int   iCurPos = 0;

            // render fillbkg

            xPos = _positionX + _imageLeft.TextureWidth + _fillBackgroundOffsetX;
            _imageFillBackground.Width  = iWidth;
            _imageFillBackground.Height = _imageMid.TextureHeight - _fillBackgroundOffsetY * 2;
            _imageFillBackground.SetPosition(xPos, _positionY + _fillBackgroundOffsetY);
            _imageFillBackground.Render(timePassed);

            // render first color
            int xoff = GUIGraphicsContext.ScaleHorizontal(3);

            xPos = _positionX + _imageLeft.TextureWidth + _fillBackgroundOffsetX + xoff;
            int yPos = _imageFillBackground.YPosition + (_imageFillBackground.Height / 2) - (_fillBackgroundHeight / 2);

            if (yPos < _positionY)
            {
                yPos = _positionY;
            }
            fWidth  = (float)iWidth;
            fWidth /= 100.0f;
            fWidth *= (float)Percentage1;
            iWidth1 = (int)Math.Floor(fWidth);
            if (iWidth1 > 0)
            {
                _imageFill1.Height = _fillBackgroundHeight;
                _imageFill1.Width  = iWidth1;
                _imageFill1.SetPosition(xPos, yPos);
                _imageFill1.Render(timePassed); // red
            }
            iCurPos = iWidth1 + xPos;

            //render 2nd color
            float fPercent;

            if (Percentage2 >= Percentage1)
            {
                fPercent = Percentage2 - Percentage1;
            }
            else
            {
                fPercent = 0;
            }
            fWidth  = (float)iWidth;
            fWidth /= 100.0f;
            fWidth *= (float)fPercent;
            iWidth2 = (int)Math.Floor(fWidth);
            if (iWidth2 > 0)
            {
                _imageFill2.Width  = iWidth2;
                _imageFill2.Height = _fillBackgroundHeight;
                _imageFill2.SetPosition(iCurPos, yPos);
                _imageFill2.Render(timePassed);
            }
            iCurPos = iWidth1 + iWidth2 + xPos;

            if (Percentage3 >= Percentage2)
            {
                //render 3th color
                fPercent = Percentage3 - Percentage2;
            }
            else
            {
                fPercent = 0;
            }
            fWidth  = (float)iWidth;
            fWidth /= 100.0f;
            fWidth *= (float)fPercent;
            iWidth3 = (int)Math.Floor(fWidth);
            if (iWidth3 > 0)
            {
                _imageFill3.Width  = iWidth3;
                _imageFill3.Height = _fillBackgroundHeight;
                _imageFill3.SetPosition(iCurPos, yPos);
                _imageFill3.Render(timePassed);
            }

            // render ticks
            _imageTick.Height = _imageTick.TextureHeight;
            _imageTick.Width  = _imageTick.TextureWidth;
            int posx1 = 10;
            int posx2 = 20;
            int posy1 = 3;

            GUIGraphicsContext.ScaleHorizontal(ref posx1);
            GUIGraphicsContext.ScaleHorizontal(ref posx2);
            GUIGraphicsContext.ScaleVertical(ref posy1);
            for (int i = 0; i <= 100; i += 10)
            {
                float fpos = (float)_positionX + _imageLeft.TextureWidth + posx1;
                fWidth  = (float)(iWidth - posx2);
                fWidth /= 100.0f;
                fWidth *= (float)i;
                _imageTick.SetPosition((int)(fpos + fWidth), (int)_positionY + posy1);
                _imageTick.Render(timePassed);
            }

            // render top
            _imageTop.Height = GUIGraphicsContext.ScaleVertical(_imageTop.TextureHeight);
            _imageTop.Width  = GUIGraphicsContext.ScaleHorizontal(_imageTop.TextureWidth);

            xPos = iCurPos - (_imageTop.Width / 2);
            _imageTop.SetPosition(xPos,
                                  _positionY - _imageTop.Height + _topTextureOffsetY - GUIGraphicsContext.ScaleVertical(1));
            _imageTop.Render(timePassed);

            //render tick @ current position
            _imageTick.Height = _imageFillBackground.TextureHeight;
            _imageTick.Width  = _imageTick.TextureWidth * 2;
            _imageTick.SetPosition((int)(_imageTop.XPosition + (_imageTop.TextureWidth / 2) - (_imageTick.Width / 2)),
                                   (int)_imageFillBackground.YPosition);
            _imageTick.Render(timePassed);

            // render bottom
            xPos = _imageTop.XPosition + (_imageTop.TextureWidth / 2) - (_imageBottom.TextureWidth / 2);
            _imageBottom.SetPosition(xPos, _positionY + _imageMid.TextureHeight);
            _imageBottom.Render(timePassed);


            //render logo
            float fx = (float)_imageBottom.XPosition;

            fx += (((float)_imageBottom.TextureWidth) / 2f);
            fx -= (((float)_imageLogo.TextureWidth) / 2f);

            float fy = (float)_imageBottom.YPosition;

            fy += (((float)_imageBottom.TextureHeight) / 2f);
            fy -= (((float)_imageLogo.TextureHeight) / 2f);
            _imageLogo.SetPosition((int)fx, (int)fy);
            _imageLogo.Render(timePassed);

            if (_font != null)
            {
                float  fW = 0, fH = 0;
                float  fHeight = 0;
                string strText = "";

                // render top text
                if (_labelTop.Length > 0)
                {
                    strText = GUIPropertyManager.Parse(_labelTop);
                    _font.GetTextExtent(strText, ref fW, ref fH);
                    fW      /= 2.0f;
                    fH      /= 2.0f;
                    fWidth   = ((float)_imageTop.TextureWidth) / 2.0f;
                    fHeight  = ((float)_imageTop.TextureHeight) / 2.0f;
                    fWidth  -= fW;
                    fHeight -= fH;
                    _font.DrawText((float)_imageTop.XPosition + fWidth, (float)2 + _imageTop.YPosition + fHeight, _textColor,
                                   strText, Alignment.ALIGN_LEFT, -1);
                }


                // render left text
                if (_labelLeft.Length > 0)
                {
                    strText = GUIPropertyManager.Parse(_labelLeft);
                    _font.GetTextExtent(strText, ref fW, ref fH);
                    fW      /= 2.0f;
                    fH      /= 2.0f;
                    fWidth   = ((float)_imageLeft.TextureWidth) / 2.0f;
                    fHeight  = ((float)_imageLeft.TextureHeight) / 2.0f;
                    fWidth  -= fW;
                    fHeight -= fH;
                    _font.DrawText((float)_positionX + fWidth, (float)_positionY + fHeight, _textColor, strText,
                                   Alignment.ALIGN_LEFT, -1);
                }

                // render right text
                if (_labelRight.Length > 0)
                {
                    strText = GUIPropertyManager.Parse(_labelRight);
                    _font.GetTextExtent(strText, ref fW, ref fH);
                    fW      /= 2.0f;
                    fH      /= 2.0f;
                    fWidth   = ((float)_imageRight.TextureWidth) / 2.0f;
                    fHeight  = ((float)_imageRight.TextureHeight) / 2.0f;
                    fWidth  -= fW;
                    fHeight -= fH;
                    _font.DrawText((float)_imageRight.XPosition + fWidth, (float)_imageRight.YPosition + fHeight, _textColor,
                                   strText, Alignment.ALIGN_LEFT, -1);
                }
            }
            base.Render(timePassed);
        }
        /// <summary>
        /// Renders the text.
        /// </summary>
        /// <param name="timePassed"></param>
        /// <param name="positionX">The X position of the text.</param>
        /// <param name="positionY">The Y position of the text.</param>
        /// <param name="maxRenderWidth">The maximum render width.</param>
        /// <param name="text">The actual text.</param>
        /// <returns>true if the render was successful</returns>
        private bool RenderText(float timePassed, float positionX, float positionY, float maxRenderWidth, string text)
        {
            bool result = false;

            // do not render if we don't have a font
            if (_font == null)
            {
                return(true);
            }

            // set text color and apply dimming if requested
            long color = _textColor;

            if (Dimmed)
            {
                color &= DimColor;
            }

            if (WrapAround())
            {
                text += _wrapString;
            }

            // get the text dimensions.
            float textWidth  = 0;
            float textHeight = 0;

            _font.GetTextExtent(text, ref textWidth, ref textHeight);

            // scroll
            string originalText = text;

            do
            {
                _font.GetTextExtent(originalText, ref textWidth, ref textHeight);
                originalText += (!string.IsNullOrEmpty(_labelTail) ? _labelTail : " ");
            } while (textWidth > 0 && textWidth < maxRenderWidth);

            if (_timeElapsed > _scrollStartDelay)
            {
                string scrollText = string.Empty;

                if (_allowScrolling)
                {
                    if (GUIGraphicsContext.ScrollSpeedHorizontal < 3)
                    {
                        if (_frameLimiter % (4 - GUIGraphicsContext.ScrollSpeedHorizontal) == 0)
                        {
                            _scrollPosititionX++;
                        }
                    }
                    else
                    {
                        _scrollPosititionX = _scrollPosititionX + GUIGraphicsContext.ScrollSpeedHorizontal - 2;
                    }
                }

                float  fWidth   = 0;
                float  fHeight  = 0;
                string tempText = _scrollPosition >= originalText.Length ? (!string.IsNullOrEmpty(_labelTail) ? _labelTail : " ") : originalText.Substring(_scrollPosition, 1);
                _font.GetTextExtent(tempText, ref fWidth, ref fHeight);

                if (_scrollPosititionX - _scrollOffset >= fWidth)
                {
                    _scrollPosition++;
                    if (_scrollPosition > text.Length)
                    {
                        _scrollPosition = 0;
                        result          = true;
                        if (!WrapAround())
                        {
                            return(result);
                        }
                    }
                    _scrollOffset += fWidth;
                }

                int wrapPosition = 0;
                for (int i = 0; i < originalText.Length; i++)
                {
                    if (_scrollPosition + i < originalText.Length)
                    {
                        scrollText += originalText[i + _scrollPosition];
                    }
                    else
                    {
                        scrollText += WrapAround() ? originalText[wrapPosition++] : (!string.IsNullOrEmpty(_labelTail) && _labelTail.Length == 1 ? _labelTail[0] : ' ');
                    }
                }

                _labelControl.TextAlignment  = Alignment.ALIGN_LEFT;
                _labelControl.TextVAlignment = _textVAlignment;
                _labelControl.TrimText       = false;
                _labelControl.Label          = scrollText + " "; // Fade end of text in GUILabel...
                if (_maxWidth > 0)
                {
                    _labelControl.MinWidth = MinWidth;
                    _labelControl.MaxWidth = (int)(maxRenderWidth + _scrollPosititionX - _scrollOffset);
                }
                else
                {
                    _labelControl.Width = (int)(maxRenderWidth + _scrollPosititionX - _scrollOffset);
                }
                _labelControl.TextColor = color;

                double xpos;
                double xoff;
                double xclipoff = 0;
                switch (_textAlignment)
                {
                case Alignment.ALIGN_RIGHT:
                    xoff     = textWidth >= maxRenderWidth ? -1 * maxRenderWidth : 0;
                    xclipoff = xoff;
                    xpos     = positionX + xoff - _scrollPosititionX + _scrollOffset;
                    _labelControl.SetPosition((int)xpos, (int)positionY);
                    break;

                case Alignment.ALIGN_CENTER:
                    _labelControl.TextVAlignment = VAlignment.ALIGN_TOP;
                    xpos = positionX - _scrollPosititionX + _scrollOffset;
                    xoff = System.Math.Max(0, (maxRenderWidth - textWidth) / 2);
                    double yoff = (Height - textHeight) / 2;
                    _labelControl.SetPosition((int)(xpos + xoff), (int)(positionY + yoff));
                    break;

                default:
                    xpos = positionX - _scrollPosititionX + _scrollOffset;
                    _labelControl.SetPosition((int)xpos, (int)positionY);
                    break;
                }

                var clipRect = new Rectangle();
                clipRect.X      = (int)(positionX + xclipoff);
                clipRect.Y      = _labelControl.YPosition;
                clipRect.Width  = maxRenderWidth > 0 ? (int)(maxRenderWidth - xclipoff) : GUIGraphicsContext.Width - clipRect.X;
                clipRect.Height = GUIGraphicsContext.Height - clipRect.Y;

                GUIGraphicsContext.BeginClip(clipRect);
                _labelControl.Render(timePassed);
                GUIGraphicsContext.EndClip();
            }
            else
            {
                _labelControl.TextAlignment  = _textAlignment;
                _labelControl.TextVAlignment = _textVAlignment;
                _labelControl.TrimText       = true;
                _labelControl.Label          = originalText;

                if (_maxWidth > 0)
                {
                    _labelControl.MinWidth = MinWidth;
                    _labelControl.MaxWidth = (int)maxRenderWidth;
                }
                else
                {
                    _labelControl.Width = (int)maxRenderWidth;
                }
                _labelControl.Render(timePassed);
            }

            return(result);
        }
예제 #11
0
        /// <summary>
        /// Renders the text.
        /// </summary>
        /// <param name="fPosX">The X position of the text.</param>
        /// <param name="fPosY">The Y position of the text.</param>
        /// <param name="fMaxWidth">The maximum render width.</param>
        /// <param name="dwTextColor">The color of the text.</param>
        /// <param name="wszText">The actual text.</param>
        /// <returns>true if the render was successful</returns>
        private bool RenderText(float timePassed, float fPosX, float fPosY, float fMaxWidth, long dwTextColor,
                                string wszText)
        {
            bool  bResult = false;
            float fTextHeight = 0, fTextWidth = 0;

            if (_font == null)
            {
                return(true);
            }
            //Get the text width.
            _font.GetTextExtent(wszText, ref fTextWidth, ref fTextHeight);

            long color = _textColor;

            if (Dimmed)
            {
                color &= DimColor;
            }

            float fPosCX = fPosX;
            float fPosCY = fPosY;

            if (fPosCX < 0)
            {
                fPosCX = 0.0f;
            }
            if (fPosCY < 0)
            {
                fPosCY = 0.0f;
            }
            if (fPosCY > GUIGraphicsContext.Height)
            {
                fPosCY = (float)GUIGraphicsContext.Height;
            }

            if (_textAlignment == Alignment.ALIGN_RIGHT)
            {
                fPosCX -= fMaxWidth;
            }
            if (_textAlignment == Alignment.ALIGN_CENTER)
            {
                fPosCX += ((_width - fTextWidth) / 2);
            }

            if (_textAlignment == Alignment.ALIGN_CENTER ||
                _textVAlignment == VAlignment.ALIGN_MIDDLE)
            {
                fPosCY += ((_height - fTextHeight) / 2);
            }
            else if (_textVAlignment == VAlignment.ALIGN_BOTTOM)
            {
                fPosCY += (_height - fTextHeight);
            }

            float fWidth  = 0;
            float fHeight = fTextHeight;

            if (fHeight + fPosCY >= GUIGraphicsContext.Height)
            {
                fHeight = GUIGraphicsContext.Height - fPosCY - 1;
            }
            if (fHeight <= 0)
            {
                return(true);
            }
            if (GUIGraphicsContext.graphics != null)
            {
                GUIGraphicsContext.graphics.SetClip(new Rectangle((int)fPosCX, (int)fPosCY, (int)(fMaxWidth), (int)(fHeight)));
            }
            else
            {
                if (fMaxWidth < 1)
                {
                    return(true);
                }
                if (fHeight < 1)
                {
                    return(true);
                }
                Rectangle clipRect = new Rectangle();
                clipRect.X      = (int)fPosCX;
                clipRect.Y      = (int)fPosCY;
                clipRect.Width  = (int)(fMaxWidth);
                clipRect.Height = (int)(fHeight);
                GUIGraphicsContext.BeginClip(clipRect);
            }
            // scroll
            string wszOrgText = wszText;

            if (_textAlignment != Alignment.ALIGN_RIGHT)
            {
                do
                {
                    _font.GetTextExtent(wszOrgText, ref fTextWidth, ref fTextHeight);
                    wszOrgText += _labelTail;
                } while (fTextWidth >= 0 && fTextWidth < fMaxWidth);
            }
            fMaxWidth += 50.0f;
            string szText = "";

            if (timeElapsed > _scrollStartDelay)
            {
                // doscroll (after having waited some frames)
                string wTmp = "";

                // When scrolling is not allowed (as specified by user) avoid advancing the scroll position.
                if (_allowScrolling)
                {
                    // Add an especially slow setting for far distance + small display + bad eyes + foreign language combination
                    if (GUIGraphicsContext.ScrollSpeedHorizontal < 3)
                    {
                        // Advance one pixel every 3 or 2 frames
                        if (_frameLimiter % (4 - GUIGraphicsContext.ScrollSpeedHorizontal) == 0)
                        {
                            _scrollPosititionX++;
                        }
                    }
                    else
                    {
                        // advance 1 - 3 pixels every frame
                        _scrollPosititionX = _scrollPosititionX + (GUIGraphicsContext.ScrollSpeedHorizontal - 2);
                    }
                }

                if (_scrollPosition >= wszOrgText.Length)
                {
                    wTmp = " ";
                }
                else
                {
                    wTmp = wszOrgText.Substring(_scrollPosition, 1);
                }
                _font.GetTextExtent(wTmp, ref fWidth, ref fHeight);

                if (_scrollPosititionX - _scrollOffset >= fWidth)
                {
                    ++_scrollPosition;
                    if (_scrollPosition > wszText.Length)
                    {
                        _scrollPosition = 0;
                        bResult         = true;
                        // If the label is wrapping around the text then avoid resetting the clip rectangle.  Allowing this clip causes
                        // the label to flash off/on for the one frame when this occurs.  This reset occurs when the label has completed
                        // one scroll cycle.
                        if (!WrapAround())
                        {
                            if (GUIGraphicsContext.graphics != null)
                            {
                                GUIGraphicsContext.graphics.SetClip(new Rectangle(0, 0, GUIGraphicsContext.Width,
                                                                                  GUIGraphicsContext.Height));
                            }
                            else
                            {
                                GUIGraphicsContext.EndClip();
                            }

                            return(true);
                        }
                    }
                    // now we need to correct _scrollPosititionX
                    // with the sum-length of all cut-off characters
                    _scrollOffset += fWidth;
                }

                int ipos     = 0;
                int iposWrap = 0;
                for (int i = 0; i < wszOrgText.Length; i++)
                {
                    if (i + _scrollPosition < wszOrgText.Length)
                    {
                        szText += wszOrgText[i + _scrollPosition];
                    }
                    else
                    {
                        // If a wrap string is specified then fill the end of the scrolling text with the beginning of the original text,
                        // else just fill with blanks (default).
                        if (WrapAround())
                        {
                            szText += wszOrgText[iposWrap++];
                        }
                        else
                        {
                            szText += ' ';
                        }
                        ipos++;
                    }
                }
                if (fPosY >= 0.0)
                {
                    _labelControl.TextAlignment  = Alignment.ALIGN_LEFT;
                    _labelControl.TextVAlignment = _textVAlignment;
                    _labelControl.Label          = szText;
                    _labelControl.Width          = (int)(fMaxWidth - 50 + _scrollPosititionX - _scrollOffset);
                    _labelControl.TextColor      = color;
                    if (Alignment.ALIGN_RIGHT == _textAlignment)
                    {
                        // right alignment => calculate xpos differently
                        float fwt = 0;
                        //            string strLabel = GetShortenedText(wszOrgText, _width, ref fwt);
                        GetShortenedText(wszOrgText, _width, ref fwt);
                        int xpos = (int)(fPosX - fwt - _scrollPosititionX + _scrollOffset);
                        _labelControl.SetPosition(xpos, (int)fPosY);
                    }
                    else if (Alignment.ALIGN_CENTER == _textAlignment)
                    {
                        // 1) reduce maxwidth to ensure faded right edge is drawn
                        // 2) compensate the Width to ensure the faded right edge does not move
                        _labelControl.TextColor      = color;
                        _labelControl.TextVAlignment = VAlignment.ALIGN_TOP; // Computing ypos here (below).
                        int xpos = (int)(fPosX - _scrollPosititionX + _scrollOffset);
                        //            _log.Info("fPosX, _scrollPosititionX, _scrollOffset, xpos: {0} {1} {2} {3}", fPosX, _scrollPosititionX, _scrollOffset, xpos);
                        //            _log.Info("szText {0}", szText);
                        _labelControl.SetPosition(xpos + ((int)((_width - fTextWidth) / 2)),
                                                  (int)(fPosY + ((_height - fTextHeight) / 2)));
                    }
                    else
                    {
                        // 1) reduce maxwidth to ensure faded right edge is drawn
                        // 2) compensate the Width to ensure the faded right edge does not move
                        int xpos = (int)(fPosX - _scrollPosititionX + _scrollOffset);
                        //            _log.Info("fPosX, _scrollPosititionX, _scrollOffset, xpos: {0} {1} {2} {3}", fPosX, _scrollPosititionX, _scrollOffset, xpos);
                        //            _log.Info("szText {0}", szText);
                        _labelControl.SetPosition(xpos, (int)fPosY);
                    }
                    _labelControl.Render(timePassed);
                }
            }
            else
            {
                if (fPosY >= 0.0)
                {
                    float fwt = 0, fht = 0;
                    _labelControl.Label = GetShortenedText(wszText, (int)fMaxWidth - 50, ref fwt);
                    _font.GetTextExtent(_labelControl.Label, ref fwt, ref fht);
                    if (_textAlignment == Alignment.ALIGN_RIGHT)
                    {
                        _labelControl.Width = (int)(fwt);
                    }
                    else
                    {
                        _labelControl.Width = (int)fMaxWidth - 50;
                    }

                    _labelControl.TextColor      = color;
                    _labelControl.TextVAlignment = _textVAlignment;
                    _labelControl.SetPosition((int)fPosX, (int)fPosY);
                    _labelControl.Render(timePassed);
                }
            }

            if (GUIGraphicsContext.graphics != null)
            {
                GUIGraphicsContext.graphics.SetClip(new Rectangle(0, 0, GUIGraphicsContext.Width, GUIGraphicsContext.Height));
            }
            else
            {
                GUIGraphicsContext.EndClip();
            }
            return(bResult);
        }
예제 #12
0
        public override void Render(float timePassed)
        {
            try
            {
                _invalidate = false;
                // Nothing visibile - save CPU cycles
                if (null == _font)
                {
                    base.Render(timePassed);
                    return;
                }
                if (GUIGraphicsContext.EditMode == false)
                {
                    if (!IsVisible)
                    {
                        base.Render(timePassed);
                        return;
                    }
                }

                int dwPosY = _positionY;

                _timeElapsed += timePassed;
                if (_frameLimiter < GUIGraphicsContext.MaxFPS)
                {
                    _frameLimiter++;
                }
                else
                {
                    _frameLimiter = 1;
                }

                var strText = _containsProperty ? GUIPropertyManager.Parse(_property) : _property;

                strText = strText.Replace("\\r", "\r");
                if (strText != _previousProperty)
                {
                    // Reset the scrolling position - e.g. if we switch in TV Guide between various items
                    ClearOffsets();

                    _previousProperty = strText;
                    SetText(strText);
                }

                if (GUIGraphicsContext.graphics != null)
                {
                    _offset = 0;
                }
                if (_listItems.Count > _itemsPerPage)
                {
                    // rest before we start scrolling
                    if ((int)_timeElapsed > _scrollStartDelay)
                    {
                        _invalidate = true;
                        // apply user scroll speed setting. 1 = slowest / 10 = fastest
                        //int userSpeed = 11 - GUIGraphicsContext.ScrollSpeedVertical;           //  10 - 1

                        //if (_frameLimiter % (6 - GUIGraphicsContext.ScrollSpeedVertical) == 0)
                        //  _yPositionScroll++;
                        //_yPositionScroll = _yPositionScroll + GUIGraphicsContext.ScrollSpeedVertical;

                        int vScrollSpeed = (6 - GUIGraphicsContext.ScrollSpeedVertical);
                        if (vScrollSpeed == 0)
                        {
                            vScrollSpeed = 1;
                        }

                        _yPositionScroll += (1.0 / vScrollSpeed) * _lineSpacing; // faster scrolling, if there is bigger linespacing

                        dwPosY -= (int)((_yPositionScroll - _scrollOffset));
                        // Log.Debug("*** _frameLimiter: {0}, dwPosY: {1}, _scrollOffset: {2}, _yPositionScroll: {3}", _frameLimiter, dwPosY, _scrollOffset, _yPositionScroll);

                        if (_positionY - dwPosY >= _itemHeight * _lineSpacing)
                        {
                            // one line has been scrolled away entirely
                            dwPosY        += (int)(_itemHeight * _lineSpacing);
                            _scrollOffset += (_itemHeight * _lineSpacing);
                            _offset++;
                            if (_offset >= _listItems.Count)
                            {
                                // restart with the first line
                                if (Seperator.Length > 0)
                                {
                                    if (_offset >= _listItems.Count + 1)
                                    {
                                        _offset = 0;
                                    }
                                }
                                else
                                {
                                    _offset = 0;
                                }
                            }
                        }
                    }
                    else
                    {
                        _scrollOffset = 0.0f;
                        _frameLimiter = 1;
                        _offset       = 0;
                    }
                }
                else
                {
                    _scrollOffset = 0.0f;
                    _frameLimiter = 1;
                    _offset       = 0;
                }

                if (GUIGraphicsContext.graphics != null)
                {
                    GUIGraphicsContext.graphics.SetClip(new Rectangle(_positionX, _positionY, _width, _height));
                }
                else
                {
                    if (_width < 1 || _height < 1)
                    {
                        base.Render(timePassed);
                        return;
                    }

                    Rectangle clipRect = new Rectangle(_positionX, _positionY, _width, _height);
                    GUIGraphicsContext.BeginClip(clipRect);
                }
                long color = _textColor;
                if (Dimmed)
                {
                    color &= DimColor;
                }
                for (int i = 0; i < 2 + _itemsPerPage; i++) // add one as the itemsPerPage might be almost one less than actual height plus one for the "incoming" item
                {
                    // skip half lines - enable, if only full lines should be visible on initial view (before scrolling starts)
                    // if (!_invalidate && i >= _itemsPerPage) continue;

                    // render each line
                    int dwPosX    = _positionX;
                    int iItem     = i + _offset;
                    int iMaxItems = _listItems.Count;
                    if (_listItems.Count > _itemsPerPage && Seperator.Length > 0)
                    {
                        iMaxItems++;
                    }

                    if (iItem >= iMaxItems)
                    {
                        if (iMaxItems > _itemsPerPage)
                        {
                            iItem -= iMaxItems;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (iItem >= 0 && iItem < iMaxItems)
                    {
                        // render item
                        string strLabel1 = "", strLabel2 = "";
                        if (iItem < _listItems.Count)
                        {
                            GUIListItem item = (GUIListItem)_listItems[iItem];
                            if (_font.containsOutOfBoundsChar(item.Label))
                            {
                                // Will hold clipped coordinates
                                float xpos = (float)dwPosX;
                                float ypos = (float)dwPosY;

                                // Get the clip rectangle.
                                Rectangle clipRect = new Rectangle(_positionX, _positionY, _width, _height);
                                float     minX     = clipRect.Left;
                                float     minY     = clipRect.Top;
                                float     maxX     = clipRect.Right;
                                float     maxY     = clipRect.Bottom;

                                // A clip rectangle is defined.  Determine if the character is inside the clip rectangle.
                                // If the character is inside the clip rectangle then clip it as necessary at the clip rectangle boundary.
                                // If the character is not inside the clip rectangle then move on to the next character (continue).
                                if (xpos < maxX && xpos >= minX && ypos < maxY && ypos >= minY)
                                {
                                }
                                else
                                {
                                    dwPosY += (int)(_itemHeight * _lineSpacing);
                                    continue;
                                }
                            }
                            strLabel1 = item.Label;
                            strLabel2 = item.Label2;
                        }
                        else
                        {
                            strLabel1 = Seperator;
                        }

                        int ixoff = _xOffset;
                        int ioffy = _yOffset;
                        GUIGraphicsContext.ScaleVertical(ref ioffy);
                        GUIGraphicsContext.ScaleHorizontal(ref ixoff);
                        string wszText1  = String.Format("{0}", strLabel1);
                        int    dMaxWidth = _width + ixoff;
                        float  x         = dwPosX;
                        if (strLabel2.Length > 0)
                        {
                            string wszText2;
                            float  fTextWidth = 0, fTextHeight = 0;
                            wszText2 = String.Format("{0}", strLabel2);
                            _font.GetTextExtent(wszText2.Trim(), ref fTextWidth, ref fTextHeight);
                            dMaxWidth -= (int)(fTextWidth);

                            switch (_textAlignment)
                            {
                            case Alignment.ALIGN_LEFT:
                            case Alignment.ALIGN_CENTER:
                                x = dwPosX + dMaxWidth;
                                break;

                            case Alignment.ALIGN_RIGHT:
                                x = dwPosX + dMaxWidth + _width;
                                break;
                            }

                            uint aColor = GUIGraphicsContext.MergeAlpha((uint)color);
                            if (Shadow)
                            {
                                uint sColor = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
                                _font.DrawShadowTextWidth(x, (float)dwPosY + ioffy,
                                                          (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor), wszText2.Trim(),
                                                          _textAlignment,
                                                          _shadowAngle, _shadowDistance, sColor, (float)dMaxWidth);
                            }
                            else
                            {
                                _font.DrawTextWidth(x, (float)dwPosY + ioffy, (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor),
                                                    wszText2.Trim(), fTextWidth, _textAlignment);
                            }
                        }

                        switch (_textAlignment)
                        {
                        case Alignment.ALIGN_CENTER:
                        case Alignment.ALIGN_LEFT:
                            x = dwPosX;
                            break;

                        case Alignment.ALIGN_RIGHT:
                            x = dwPosX + _width;
                            break;
                        }
                        {
                            uint aColor = GUIGraphicsContext.MergeAlpha((uint)color);
                            if (Shadow)
                            {
                                uint sColor = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
                                _font.DrawShadowTextWidth(x, (float)dwPosY + ioffy, (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor),
                                                          wszText1.Trim(), _textAlignment,
                                                          _shadowAngle, _shadowDistance, sColor, (float)dMaxWidth);
                            }
                            else
                            {
                                _font.DrawTextWidth(x, (float)dwPosY + ioffy, (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor),
                                                    wszText1.Trim(), (float)dMaxWidth, _textAlignment);
                            }

                            // Log.Info("dw _positionY, dwPosY, _yPositionScroll, _scrollOffset: {0} {1} {2} {3} - wszText1.Trim() {4}", _positionY, dwPosY, _yPositionScroll, _scrollOffset, wszText1.Trim());

                            dwPosY += (int)(_itemHeight * _lineSpacing);
                        }
                    }
                }

                if (GUIGraphicsContext.graphics != null)
                {
                    GUIGraphicsContext.graphics.SetClip(new Rectangle(0, 0, GUIGraphicsContext.Width, GUIGraphicsContext.Height));
                }
                else
                {
                    GUIGraphicsContext.EndClip();
                }
                base.Render(timePassed);
            }
            catch (Exception ex)
            {
                Log.Error("GUITextScrollUpControl: Error during the render process - maybe a threading issue. {0}",
                          ex.ToString());
                GUIGraphicsContext.EndClip();
            }
        }
        public override void Render(float timePassed)
        {
            try
            {
                _invalidate = false;
                // Nothing visibile - save CPU cycles
                if (null == _font)
                {
                    base.Render(timePassed);
                    return;
                }
                if (GUIGraphicsContext.EditMode == false)
                {
                    if (!IsVisible)
                    {
                        base.Render(timePassed);
                        return;
                    }
                }

                int dwPosY = _positionY;

                _timeElapsed += timePassed;
                if (_frameLimiter < GUIGraphicsContext.MaxFPS)
                {
                    _frameLimiter++;
                }
                else
                {
                    _frameLimiter = 1;
                }

                if (_containsProperty)
                {
                    string strText = GUIPropertyManager.Parse(_property);

                    strText = strText.Replace("\\r", "\r");
                    if (strText != _previousProperty)
                    {
                        // Reset the scrolling position - e.g. if we switch in TV Guide between various items
                        ClearOffsets();

                        _previousProperty = strText;
                        SetText(strText);
                    }
                }

                if (GUIGraphicsContext.graphics != null)
                {
                    _offset = 0;
                }
                if (_listItems.Count > _itemsPerPage)
                {
                    // rest before we start scrolling
                    if ((int)_timeElapsed > _scrollStartDelay)
                    {
                        _invalidate = true;
                        // apply user scroll speed setting. 1 = slowest / 10 = fastest
                        //int userSpeed = 11 - GUIGraphicsContext.ScrollSpeedVertical;           //  10 - 1

                        if (_frameLimiter % (6 - GUIGraphicsContext.ScrollSpeedVertical) == 0)
                        {
                            _yPositionScroll++;
                        }
                        //_yPositionScroll = _yPositionScroll + GUIGraphicsContext.ScrollSpeedVertical;

                        dwPosY -= (int)((_yPositionScroll - _scrollOffset) * _lineSpacing);
                        // Log.Debug("*** _frameLimiter: {0}, dwPosY: {1}, _scrollOffset: {2}", _frameLimiter, dwPosY, _scrollOffset);

                        if (_positionY - dwPosY >= _itemHeight)
                        {
                            // one line has been scrolled away entirely
                            dwPosY        += (int)(_itemHeight * _lineSpacing);
                            _scrollOffset += _itemHeight;
                            _offset++;
                            if (_offset >= _listItems.Count)
                            {
                                // restart with the first line
                                if (Seperator.Length > 0)
                                {
                                    if (_offset >= _listItems.Count + 1)
                                    {
                                        _offset = 0;
                                    }
                                }
                                else
                                {
                                    _offset = 0;
                                }
                            }
                        }
                    }
                    else
                    {
                        _scrollOffset = 0.0f;
                        _frameLimiter = 1;
                        _offset       = 0;
                    }
                }
                else
                {
                    _scrollOffset = 0.0f;
                    _frameLimiter = 1;
                    _offset       = 0;
                }

                if (GUIGraphicsContext.graphics != null)
                {
                    GUIGraphicsContext.graphics.SetClip(new Rectangle(_positionX, _positionY,
                                                                      _width, (int)(_itemsPerPage * _itemHeight * _lineSpacing)));
                }
                else
                {
                    if (_width < 1)
                    {
                        base.Render(timePassed);
                        return;
                    }
                    if (_height < 1)
                    {
                        base.Render(timePassed);
                        return;
                    }

                    Rectangle clipRect = new Rectangle();
                    clipRect.X      = _positionX;
                    clipRect.Y      = _positionY;
                    clipRect.Width  = _width;
                    clipRect.Height = (int)(_height * _lineSpacing);
                    GUIGraphicsContext.BeginClip(clipRect);
                }
                long color = _textColor;
                if (Dimmed)
                {
                    color &= DimColor;
                }
                for (int i = 0; i < 1 + _itemsPerPage; i++)
                {
                    // render each line
                    int dwPosX    = _positionX;
                    int iItem     = i + _offset;
                    int iMaxItems = _listItems.Count;
                    if (_listItems.Count > _itemsPerPage && Seperator.Length > 0)
                    {
                        iMaxItems++;
                    }

                    if (iItem >= iMaxItems)
                    {
                        if (iMaxItems > _itemsPerPage)
                        {
                            iItem -= iMaxItems;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (iItem >= 0 && iItem < iMaxItems)
                    {
                        // render item
                        string strLabel1 = "", strLabel2 = "";
                        if (iItem < _listItems.Count)
                        {
                            GUIListItem item = (GUIListItem)_listItems[iItem];
                            strLabel1 = item.Label;
                            strLabel2 = item.Label2;
                        }
                        else
                        {
                            strLabel1 = Seperator;
                        }

                        int ixoff = _xOffset;
                        int ioffy = 2;
                        GUIGraphicsContext.ScaleVertical(ref ioffy);
                        GUIGraphicsContext.ScaleHorizontal(ref ixoff);
                        string wszText1  = String.Format("{0}", strLabel1);
                        int    dMaxWidth = _width + ixoff;
                        float  x         = dwPosX;
                        if (strLabel2.Length > 0)
                        {
                            string wszText2;
                            float  fTextWidth = 0, fTextHeight = 0;
                            wszText2 = String.Format("{0}", strLabel2);
                            _font.GetTextExtent(wszText2.Trim(), ref fTextWidth, ref fTextHeight);
                            dMaxWidth -= (int)(fTextWidth);

                            switch (_textAlignment)
                            {
                            case Alignment.ALIGN_LEFT:
                            case Alignment.ALIGN_CENTER:
                                x = dwPosX + dMaxWidth;
                                break;

                            case Alignment.ALIGN_RIGHT:
                                x = dwPosX + dMaxWidth + _width;
                                break;
                            }

                            uint aColor = GUIGraphicsContext.MergeAlpha((uint)color);
                            if (Shadow)
                            {
                                uint sColor = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
                                _font.DrawShadowTextWidth(x, (float)dwPosY + ioffy,
                                                          (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor), wszText2.Trim(),
                                                          _textAlignment,
                                                          _shadowAngle, _shadowDistance, sColor, (float)dMaxWidth);
                            }
                            else
                            {
                                _font.DrawTextWidth(x, (float)dwPosY + ioffy, (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor),
                                                    wszText2.Trim(), fTextWidth, _textAlignment);
                            }
                        }

                        switch (_textAlignment)
                        {
                        case Alignment.ALIGN_CENTER:
                        case Alignment.ALIGN_LEFT:
                            x = dwPosX;
                            break;

                        case Alignment.ALIGN_RIGHT:
                            x = dwPosX + _width;
                            break;
                        }
                        {
                            uint aColor = GUIGraphicsContext.MergeAlpha((uint)color);
                            if (Shadow)
                            {
                                uint sColor = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
                                _font.DrawShadowTextWidth(x, (float)dwPosY + ioffy, (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor),
                                                          wszText1.Trim(), _textAlignment,
                                                          _shadowAngle, _shadowDistance, sColor, (float)dMaxWidth);
                            }
                            else
                            {
                                _font.DrawTextWidth(x, (float)dwPosY + ioffy, (uint)GUIGraphicsContext.MergeAlpha((uint)_textColor),
                                                    wszText1.Trim(), (float)dMaxWidth, _textAlignment);
                            }

                            //            Log.Info("dw _positionY, dwPosY, _yPositionScroll, _scrollOffset: {0} {1} {2} {3}", _positionY, dwPosY, _yPositionScroll, _scrollOffset);
                            //            Log.Info("dw wszText1.Trim() {0}", wszText1.Trim());

                            dwPosY += (int)(_itemHeight * _lineSpacing);
                        }
                    }
                }

                if (GUIGraphicsContext.graphics != null)
                {
                    GUIGraphicsContext.graphics.SetClip(new Rectangle(0, 0, GUIGraphicsContext.Width, GUIGraphicsContext.Height));
                }
                else
                {
                    GUIGraphicsContext.EndClip();
                }
                base.Render(timePassed);
            }
            catch (Exception ex)
            {
                Log.Error("GUITextScrollUpControl: Error during the render process - maybe a threading issue. {0}",
                          ex.ToString());
            }
        }
예제 #14
0
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
                if (Disabled)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            if (_propertyLabel.Length > 0)
            {
                string m_strText = GUIPropertyManager.Parse(_propertyLabel);
                if (m_strText.Length > 0 && !m_strText.Contains(@"#"))
                {
                    try
                    {
                        Percentage1 = float.Parse(m_strText);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("GUITVProgressControl: Render() {0}", ex.Message);
                    }
                    if (Percentage1 < 0 || Percentage1 > 100)
                    {
                        Percentage1 = 0;
                    }
                }
            }
            if (Label1.Length > 0)
            {
                string strText = GUIPropertyManager.Parse(Label1);
                if (strText.Length > 0 && !strText.Contains(@"#"))
                {
                    try
                    {
                        Percentage1 = float.Parse(strText);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("GUITVProgressControl: Render2() {0}", ex.Message);
                    }

                    if (Percentage1 < 0 || Percentage1 > 100)
                    {
                        Percentage1 = 0;
                    }
                }
            }

            if (Label2.Length > 0)
            {
                string strText = GUIPropertyManager.Parse(Label2);
                if (strText.Length > 0 && !strText.Contains(@"#"))
                {
                    try
                    {
                        Percentage2 = float.Parse(strText);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("GUITVProgressControl: Render3() {0}", ex.Message);
                    }
                    if (Percentage2 < 0 || Percentage2 > 100)
                    {
                        Percentage2 = 0;
                    }
                }
            }
            if (Label3.Length > 0)
            {
                string strText = GUIPropertyManager.Parse(Label3);
                if (strText.Length > 0 && !strText.Contains(@"#"))
                {
                    try
                    {
                        Percentage3 = float.Parse(strText);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("GUITVProgressControl: Render4() {0}", ex.Message);
                    }
                    if (Percentage3 < 0 || Percentage3 > 100)
                    {
                        Percentage3 = 0;
                    }
                }
            }

            //parse labels for markers
            //only going to parse if the values are different than the current value
            string tempStarts = GUIPropertyManager.Parse(LabelMarkerStarts);
            string tempEnds   = GUIPropertyManager.Parse(LabelMarkerEnds);

            if (_markerStarts != tempStarts || _markerEnds != tempEnds)
            {
                parseMarkerValues(tempStarts, tempEnds);
                _markerStarts = tempStarts;
                _markerEnds   = tempEnds;
            }

            int iWidthLeft   = _imageLeft.TextureWidth;
            int iHeightLeft  = _imageLeft.TextureHeight;
            int iWidthRight  = _imageRight.TextureWidth;
            int iHeightRight = _imageRight.TextureHeight;

            GUIGraphicsContext.ScaleHorizontal(ref iWidthLeft);
            GUIGraphicsContext.ScaleHorizontal(ref iWidthRight);
            GUIGraphicsContext.ScaleVertical(ref iHeightLeft);
            GUIGraphicsContext.ScaleVertical(ref iHeightRight);

            int xPos = _positionX;

            _imageLeft.SetPosition(xPos, _positionY);

            _imageLeft.Height = iHeightLeft;
            _imageLeft.Width  = iWidthLeft;

            xPos = _positionX + iWidthLeft;
            _imageMid.SetPosition(xPos, _positionY);

            int iWidth = _width - (iWidthLeft + iWidthRight);

            _imageMid.Width = iWidth;

            xPos = iWidth + _positionX + iWidthLeft;
            _imageRight.SetPosition(xPos, _positionY);

            _imageRight.Height = iHeightRight;
            _imageRight.Width  = iWidthRight;

            _imageLeft.Render(timePassed);
            _imageRight.Render(timePassed);
            _imageMid.Render(timePassed);

            int iWidth1 = 0, iWidth2 = 0, iWidth3 = 0;

            iWidth -= 2 * _fillBackgroundOffsetX;
            float fWidth  = iWidth;
            int   iCurPos = 0;

            // render fillbkg

            xPos = _positionX + iWidthLeft + _fillBackgroundOffsetX;
            _imageFillBackground.Width  = iWidth;
            _imageFillBackground.Height = _imageMid.TextureHeight - _fillBackgroundOffsetY * 2;
            _imageFillBackground.SetPosition(xPos, _positionY + _fillBackgroundOffsetY);
            _imageFillBackground.Render(timePassed);


            int xoff = GUIGraphicsContext.ScaleHorizontal(3);

            xPos = _positionX + iWidthLeft + _fillBackgroundOffsetX + xoff;
            int yPos = _imageFillBackground.YPosition + (_imageFillBackground.Height / 2) - (_fillBackgroundHeight / 2);

            iWidth -= 2 * xoff;
            if (yPos < _positionY)
            {
                yPos = _positionY;
            }
            //render commercial markers
            fWidth  = (float)iWidth;
            fWidth /= 100.0f;
            calculateMarkerSizeAndPosition(xPos, yPos, fWidth);
            for (int i = 0; i < _markerYPositions.Count || i < _markerXPositions.Count || i < _markerWidths.Count; i++)
            {
                _imageFillMarker.Width = _markerWidths[i];
                _imageFillMarker.SetPosition(_markerXPositions[i], _markerYPositions[i]);
                _imageFillMarker.Render(timePassed);
            }

            //render first color
            xPos    = _positionX + _imageLeft.TextureWidth + _fillBackgroundOffsetX + xoff;
            fWidth  = (float)iWidth;
            fWidth /= 100.0f;
            fWidth *= (float)Percentage1;
            iWidth1 = (int)Math.Floor(fWidth);
            if (iWidth1 > 0)
            {
                _imageFill1.Height = _fillBackgroundHeight;
                _imageFill1.Width  = iWidth1;
                _imageFill1.SetPosition(xPos, yPos);
                _imageFill1.Render(timePassed); // red
            }
            iCurPos = iWidth1 + xPos;

            //render 2nd color
            float fPercent;

            if (Percentage2 >= Percentage1)
            {
                fPercent = Percentage2 - Percentage1;
            }
            else
            {
                fPercent = 0;
            }
            fWidth  = (float)iWidth;
            fWidth /= 100.0f;
            fWidth *= (float)fPercent;
            iWidth2 = (int)Math.Floor(fWidth);
            if (iWidth2 > 0)
            {
                _imageFill2.Width  = iWidth2;
                _imageFill2.Height = _fillBackgroundHeight;
                _imageFill2.SetPosition(iCurPos, yPos);
                _imageFill2.Render(timePassed);
            }
            iCurPos = iWidth1 + iWidth2 + xPos;

            if (Percentage3 >= Percentage2)
            {
                //render 3th color
                fPercent = Percentage3 - Percentage2;
            }
            else
            {
                fPercent = 0;
            }
            fWidth  = (float)iWidth;
            fWidth /= 100.0f;
            fWidth *= (float)fPercent;
            iWidth3 = (int)Math.Floor(fWidth);
            if (iWidth3 > 0)
            {
                _imageFill3.Width  = iWidth3;
                _imageFill3.Height = _fillBackgroundHeight;
                _imageFill3.SetPosition(iCurPos, yPos);
                _imageFill3.Render(timePassed);
            }

            // render ticks
            _imageTick.Height = _imageTick.TextureHeight;
            _imageTick.Width  = _imageTick.TextureWidth;
            int posx1 = 10;
            int posx2 = 20;
            int posy1 = 3;

            GUIGraphicsContext.ScaleHorizontal(ref posx1);
            GUIGraphicsContext.ScaleHorizontal(ref posx2);
            GUIGraphicsContext.ScaleVertical(ref posy1);
            for (int i = 0; i <= 100; i += 10)
            {
                float fpos = (float)_positionX + iWidthLeft + posx1;
                fWidth  = (float)(iWidth - posx2);
                fWidth /= 100.0f;
                fWidth *= (float)i;
                _imageTick.SetPosition((int)(fpos + fWidth), (int)_positionY + posy1);
                _imageTick.Render(timePassed);
            }

            // render top
            _imageTop.Height = GUIGraphicsContext.ScaleVertical(_imageTop.TextureHeight);
            _imageTop.Width  = GUIGraphicsContext.ScaleHorizontal(_imageTop.TextureWidth);

            xPos = iCurPos - (_imageTop.Width / 2);
            _imageTop.SetPosition(xPos,
                                  _positionY - _imageTop.Height + _topTextureOffsetY - GUIGraphicsContext.ScaleVertical(1));
            _imageTop.Render(timePassed);

            //render tick @ current position
            _imageTick.Height = _imageFillBackground.TextureHeight;
            _imageTick.Width  = _imageTick.TextureWidth * 2;
            _imageTick.SetPosition((int)(_imageTop.XPosition + (_imageTop.TextureWidth / 2) - (_imageTick.Width / 2)),
                                   (int)_imageFillBackground.YPosition);
            _imageTick.Render(timePassed);

            // render bottom
            _imageBottom.Height = GUIGraphicsContext.ScaleVertical(_imageBottom.TextureHeight);
            _imageBottom.Width  = GUIGraphicsContext.ScaleHorizontal(_imageBottom.TextureWidth);

            xPos = _imageTop.XPosition + (_imageTop.Width / 2) - (_imageBottom.Width / 2);
            _imageBottom.SetPosition(xPos, _positionY + _imageMid.Height);
            _imageBottom.Render(timePassed);


            //render logo
            _imageLogo.Height = GUIGraphicsContext.ScaleVertical(_imageLogo.TextureHeight);
            _imageLogo.Width  = GUIGraphicsContext.ScaleHorizontal(_imageLogo.TextureWidth);
            float fx = (float)_imageBottom.XPosition;

            fx += (((float)_imageBottom.Width) / 2f);
            fx -= (((float)_imageLogo.TextureWidth) / 2f);

            float fy = (float)_imageBottom.YPosition;

            fy += (((float)_imageBottom.Height) / 2f);
            fy -= (((float)_imageLogo.Height) / 2f);
            _imageLogo.SetPosition((int)fx, (int)fy);
            _imageLogo.Render(timePassed);

            if (_font != null)
            {
                float  fW = 0, fH = 0;
                float  fHeight = 0;
                string strText = "";

                // render top text
                if (_labelTop.Length > 0)
                {
                    strText = GUIPropertyManager.Parse(_labelTop);
                    _font.GetTextExtent(strText, ref fW, ref fH);
                    fW      /= 2.0f;
                    fH      /= 2.0f;
                    fWidth   = ((float)_imageTop.Width) / 2.0f;
                    fHeight  = ((float)_imageTop.Height) / 2.0f;
                    fWidth  -= fW;
                    fHeight -= fH;
                    _font.DrawText((float)_imageTop.XPosition + fWidth, (float)2 + _imageTop.YPosition + fHeight, _textColor,
                                   strText, Alignment.ALIGN_LEFT, -1);
                }


                // render left text
                if (_labelLeft.Length > 0)
                {
                    strText = GUIPropertyManager.Parse(_labelLeft);
                    _font.GetTextExtent(strText, ref fW, ref fH);
                    fW      /= 2.0f;
                    fH      /= 2.0f;
                    fWidth   = ((float)iWidthLeft) / 2.0f;
                    fHeight  = ((float)iHeightLeft) / 2.0f;
                    fWidth  -= fW;
                    fHeight -= fH;
                    _font.DrawText((float)_positionX + fWidth, (float)_positionY + fHeight, _textColor, strText,
                                   Alignment.ALIGN_LEFT, -1);
                }

                // render right text
                if (_labelRight.Length > 0)
                {
                    strText = GUIPropertyManager.Parse(_labelRight);
                    _font.GetTextExtent(strText, ref fW, ref fH);
                    fW      /= 2.0f;
                    fH      /= 2.0f;
                    fWidth   = ((float)iWidthRight) / 2.0f;
                    fHeight  = ((float)iHeightRight) / 2.0f;
                    fWidth  -= fW;
                    fHeight -= fH;
                    _font.DrawText((float)_imageRight.XPosition + fWidth, (float)_imageRight.YPosition + fHeight, _textColor,
                                   strText, Alignment.ALIGN_LEFT, -1);
                }
            }
            base.Render(timePassed);
        }