Beispiel #1
0
        // Wraps the calls to the GUIFont.  This provides opportunity to shadow the text if requested.
        public void DrawText(float xpos, float ypos, string label, int width)
        {
            long c = _textColor;

            if (Dimmed)
            {
                c &= DimColor;
            }
            c = GUIGraphicsContext.MergeAlpha((uint)c);

            if (Shadow)
            {
                long sc = _shadowColor;
                if (Dimmed)
                {
                    sc &= DimColor;
                }
                sc = GUIGraphicsContext.MergeAlpha((uint)sc);
                _font.DrawShadowText(xpos, ypos, c, label, Alignment.ALIGN_LEFT, width, _shadowAngle, _shadowDistance, sc);
            }
            else
            {
                var clipRect = new Rectangle();
                clipRect.X      = (int)xpos;
                clipRect.Y      = (int)ypos;
                clipRect.Width  = width > 0 ? width : GUIGraphicsContext.Width - clipRect.X;
                clipRect.Height = GUIGraphicsContext.Height - clipRect.Y;

                GUIGraphicsContext.BeginClip(clipRect);
                _font.DrawTextEx(xpos, ypos, c, label, ref _context, width);
                GUIGraphicsContext.EndClip();
            }
        }
Beispiel #2
0
        // Wraps the calls to the GUIFont.  This provides opportunity to shadow the text if requested.
        public void DrawTextWidth(float xpos, float ypos, string label, float fMaxWidth)
        {
            long c = (uint)_textColor;

            if (Dimmed)
            {
                c &= (DimColor);
            }
            c = GUIGraphicsContext.MergeAlpha((uint)c);

            if (Shadow)
            {
                long sc = (uint)_shadowColor;
                if (Dimmed)
                {
                    sc &= DimColor;
                }
                sc = GUIGraphicsContext.MergeAlpha((uint)sc);

                _font.DrawShadowTextWidth(xpos, ypos, c, label, Alignment.ALIGN_LEFT, _shadowAngle, _shadowDistance, sc, fMaxWidth);
            }
            else
            {
                _font.DrawTextWidth(xpos, ypos, c, label, fMaxWidth, Alignment.ALIGN_LEFT);
            }
        }
        /// <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);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
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());
            }
        }