public override void ScaleToScreenResolution()
 {
     base.ScaleToScreenResolution();
     GUIGraphicsContext.ScalePosToScreenResolution(ref _fillBackgroundOffsetX, ref _fillBackgroundOffsetY);
     GUIGraphicsContext.ScaleVertical(ref _fillBackgroundHeight);
     GUIGraphicsContext.ScaleVertical(ref _topTextureOffsetY);
 }
        /// Renders the control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (!IsVisible)
            {
                base.Render(timePassed);
                return;
            }
            if (Disabled)
            {
                base.Render(timePassed);
                return;
            }
            if (!GUIGraphicsContext.MouseSupport)
            {
                IsVisible = false;
                base.Render(timePassed);
                return;
            }

            int iHeight = _imageBackGround.Height;

            _imageBackGround.Height = iHeight;

            float fPercent = (float)_percentage;
            float fPosXOff = (fPercent / 100.0f);

            // Scale handle-parts for resolution. Background is already scaled in parent control
            int handleHeight = _imageLeft.TextureHeight;

            GUIGraphicsContext.ScaleVertical(ref handleHeight);
            _imageLeft.Height  = handleHeight;
            _imageRight.Height = handleHeight;

            int handleWidth = _imageLeft.TextureWidth;

            GUIGraphicsContext.ScaleVertical(ref handleWidth);
            _imageLeft.Width  = handleWidth;
            _imageRight.Width = handleWidth;

            _widthKnob          = (int)(2 * _imageLeft.Width);
            _startX             = _imageBackGround.XPosition;
            _endX               = _startX + _imageBackGround.Width - _widthKnob;
            fPosXOff           *= (float)(_endX - _startX);
            _startPositionXKnob = _startX + (int)fPosXOff;

            _imageBackGround.Render(timePassed);

            int iXPos = _startPositionXKnob;
            int iYPos = _imageBackGround.YPosition + ((_imageBackGround.Height / 2) - (_imageLeft.Height / 2));

            _imageLeft.SetPosition(iXPos, iYPos);
            _imageLeft.Render(timePassed);

            iXPos += _imageLeft.Width;

            _imageRight.SetPosition(iXPos, iYPos);
            _imageRight.Render(timePassed);

            base.Render(timePassed);
        }
        public override void ScaleToScreenResolution()
        {
            base.ScaleToScreenResolution();

            GUIGraphicsContext.ScalePosToScreenResolution(ref _upBtnWidth, ref _upBtnHeight);
            GUIGraphicsContext.ScalePosToScreenResolution(ref _downBtnWidth, ref _downBtnHeight);
            GUIGraphicsContext.ScalePosToScreenResolution(ref _deleteBtnWidth, ref _deleteBtnHeight);

            GUIGraphicsContext.ScaleHorizontal(ref _upBtnXOffset);
            GUIGraphicsContext.ScaleHorizontal(ref _downBtnXOffset);
            GUIGraphicsContext.ScaleHorizontal(ref _deleteBtnXOffset);

            GUIGraphicsContext.ScaleVertical(ref _upBtnYOffset);
            GUIGraphicsContext.ScaleVertical(ref _downBtnYOffset);
            GUIGraphicsContext.ScaleVertical(ref _deleteBtnYOffset);
        }
Esempio n. 4
0
        public override void FinalizeConstruction()
        {
            base.FinalizeConstruction();

            GUIGraphicsContext.ScaleHorizontal(ref _textureWidth);
            GUIGraphicsContext.ScaleVertical(ref _textureHeight);

            for (int i = 0; i < SubItemCount; ++i)
            {
                string   strTexture = (string)GetSubItem(i);
                GUIImage img        = new GUIImage(_parentControlId, _controlId, _positionX, _positionY, _textureWidth, _textureHeight,
                                                   strTexture, 0);
                img.ParentControl = this;
                img.DimColor      = DimColor;
                _itemList.Add(img);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Does any scaling on the inital size\position values to fit them to screen
        /// resolution.
        /// </summary>
        public override void ScaleToScreenResolution()
        {
            base.ScaleToScreenResolution();

            if (_layout == null)
            {
                return;
            }

            int width  = (int)System.Math.Round(_layout.Spacing.Width);
            int height = (int)System.Math.Round(_layout.Spacing.Height);

            GUIGraphicsContext.ScaleHorizontal(ref width);
            GUIGraphicsContext.ScaleVertical(ref height);

            _layout.Spacing = new Size(width, height);
        }
Esempio n. 6
0
        /// <summary>
        /// Draws the progress bar with the given width and percentage
        /// </summary>
        /// <param name="graph">Graphics</param>
        /// <param name="fWidth">Width, depending on the percentage</param>
        /// <param name="percent">Percentage</param>
        private void DrawProgressBar(Graphics graph, float fWidth, int percent)
        {
            fWidth /= 100.0f;
            if (_backgroundBitmap != null)
            {
                graph.DrawImage(_backgroundBitmap, _progressControl.XPosition, _progressControl.YPosition, _progressControl.Width, _progressControl.Height);
            }
            int iWidthLeft   = _leftBitmap != null ? _leftBitmap.Width:0;
            int iHeightLeft  = _leftBitmap != null ? _leftBitmap.Height:0;
            int iHeightMid   = _midBitmap != null ? _midBitmap.Height : 0;
            int iWidthRight  = _rightBitmap != null ? _rightBitmap.Width:0;
            int iHeightRight = _rightBitmap != null ? _rightBitmap.Height : 0;

            GUIGraphicsContext.ScaleHorizontal(ref iWidthLeft);
            GUIGraphicsContext.ScaleHorizontal(ref iWidthRight);
            GUIGraphicsContext.ScaleVertical(ref iHeightLeft);
            GUIGraphicsContext.ScaleVertical(ref iHeightRight);
            //iHeight=20;
            int off = 12;

            GUIGraphicsContext.ScaleHorizontal(ref off);
            fWidth *= _progressControl.Width - 2 * off - iWidthLeft - iWidthRight;
            int iXPos = off + _progressControl.XPosition;

            int iYPos = _progressControl.YPosition + (_progressControl.Height - iHeightLeft) / 2;

            if (_leftBitmap != null)
            {
                graph.DrawImage(_leftBitmap, iXPos, iYPos, iWidthLeft, iHeightLeft);
            }
            iXPos += iWidthLeft;
            if (percent > 0 && (int)fWidth > 1)
            {
                if (_midBitmap != null)
                {
                    iYPos = _progressControl.YPosition + (_progressControl.Height - iHeightMid) / 2;
                    graph.DrawImage(_midBitmap, iXPos, iYPos, (int)Math.Abs(fWidth), iHeightMid);
                }
                iXPos += (int)fWidth;
            }
            if (_rightBitmap != null)
            {
                iYPos = _progressControl.YPosition + (_progressControl.Height - iHeightRight) / 2;
                graph.DrawImage(_rightBitmap, iXPos, iYPos, iWidthRight, iHeightRight);
            }
        }
Esempio n. 7
0
        private void PositionLeftAndRightImages()
        {
            //	Position right arrow
            int x1 = 8;
            int x2 = 16;

            GUIGraphicsContext.ScaleHorizontal(ref x1);
            GUIGraphicsContext.ScaleHorizontal(ref x2);
            int dwPosX = (_positionX + _width - x1) - x2;

            int y1 = 16;

            GUIGraphicsContext.ScaleVertical(ref y1);
            int dwPosY = _positionY + (_height - y1) / 2;

            _imageRight.SetPosition(dwPosX, dwPosY);
            _imageRightFocus.SetPosition(dwPosX, dwPosY);

            //	Position left arrow
            dwPosX = _positionX + x1;
            _imageLeft.SetPosition(dwPosX, dwPosY);
            _imageLeftFocus.SetPosition(dwPosX, dwPosY);
        }
Esempio n. 8
0
        public bool Create(XmlNode node)
        {
            string animType = node.InnerText.ToLowerInvariant();

            if (String.Compare(animType, "visible", true) == 0)
            {
                _type = AnimationType.Visible;
            }

            else if (String.Compare(animType, "visiblechange", true) == 0)
            {
                _type = AnimationType.VisibleChange;
            }
            else if (String.Compare(animType, "hidden", true) == 0)
            {
                _type = AnimationType.Hidden;
            }
            else if (String.Compare(animType, "focus", true) == 0)
            {
                _type = AnimationType.Focus;
            }
            else if (String.Compare(animType, "unfocus", true) == 0)
            {
                _type = AnimationType.Unfocus;
            }
            else if (String.Compare(animType, "windowopen", true) == 0)
            {
                _type = AnimationType.WindowOpen;
            }
            else if (String.Compare(animType, "windowclose", true) == 0)
            {
                _type = AnimationType.WindowClose;
            }
            else if (String.Compare(animType, "conditional", true) == 0)
            {
                _type = AnimationType.Conditional;
                SetInitialCondition();
            }
            if (_type == AnimationType.None)
            {
                Log.Error(String.Format("Control has invalid animation type [{0} on {1}]", animType, node.Name));
                return(false);
            }
            XmlNode nodeAttribute = node.Attributes.GetNamedItem("condition");

            if (nodeAttribute != null)
            {
                string conditionString = nodeAttribute.Value;
                _condition = GUIInfoManager.TranslateString(conditionString);
            }
            nodeAttribute = node.Attributes.GetNamedItem("effect");
            if (nodeAttribute == null)
            {
                return(false);
            }
            string effectType = nodeAttribute.Value;

            // effect type
            if (String.Compare(effectType, "fade", true) == 0)
            {
                _effect = EffectType.Fade;
            }
            else if (String.Compare(effectType, "slide", true) == 0)
            {
                _effect = EffectType.Slide;
            }
            else if (String.Compare(effectType, "rotate", true) == 0)
            {
                _effect = EffectType.RotateZ;
            }
            else if (String.Compare(effectType, "rotatey", true) == 0)
            {
                _effect = EffectType.RotateY;
            }
            else if (String.Compare(effectType, "rotatex", true) == 0)
            {
                _effect = EffectType.RotateX;
            }
            else if (String.Compare(effectType, "zoom", true) == 0)
            {
                _effect = EffectType.Zoom;
            }
            if (_effect == EffectType.None)
            {
                Log.Error(String.Format("Control has invalid effect type [{0} on {1}]", effectType, node.Name));
                return(false);
            }
            // time and delay
            nodeAttribute = node.Attributes.GetNamedItem("time");
            UInt32.TryParse(nodeAttribute.Value.ToString(), out _length);

            nodeAttribute = node.Attributes.GetNamedItem("delay");
            if (nodeAttribute != null)
            {
                UInt32.TryParse(nodeAttribute.Value.ToString(), out _delay);
            }

            //_length = (uint)(_length * g_SkinInfo.GetEffectsSlowdown());
            //_delay = (uint)(_delay * g_SkinInfo.GetEffectsSlowdown());

            _tweener      = null;
            nodeAttribute = node.Attributes.GetNamedItem("tween");
            if (nodeAttribute != null)
            {
                string tweenMode = nodeAttribute.Value;
                if (tweenMode == "linear")
                {
                    _tweener = new LinearTweener();
                }
                else if (tweenMode == "quadratic")
                {
                    _tweener = new QuadTweener();
                }
                else if (tweenMode == "cubic")
                {
                    _tweener = new CubicTweener();
                }
                else if (tweenMode == "sine")
                {
                    _tweener = new SineTweener();
                }
                else if (tweenMode == "back")
                {
                    _tweener = new BackTweener();
                }
                else if (tweenMode == "circle")
                {
                    _tweener = new CircleTweener();
                }
                else if (tweenMode == "bounce")
                {
                    _tweener = new BounceTweener();
                }
                else if (tweenMode == "elastic")
                {
                    _tweener = new ElasticTweener();
                }
                nodeAttribute = node.Attributes.GetNamedItem("easing");
                if (nodeAttribute != null && _tweener != null)
                {
                    string easing = nodeAttribute.Value;
                    if (easing == "in")
                    {
                        _tweener.Easing = TweenerType.EASE_IN;
                    }
                    else if (easing == "out")
                    {
                        _tweener.Easing = TweenerType.EASE_OUT;
                    }
                    else if (easing == "inout")
                    {
                        _tweener.Easing = TweenerType.EASE_INOUT;
                    }
                }
            }

            // acceleration of effect
            //float accel;
            nodeAttribute = node.Attributes.GetNamedItem("acceleration");
            if (nodeAttribute != null)
            {
                float acceleration = GetFloat(nodeAttribute.Value.ToString());
                if (_tweener == null)
                {
                    if (acceleration != 0.0f)
                    {
                        _tweener        = new QuadTweener(acceleration);
                        _tweener.Easing = TweenerType.EASE_IN;
                    }
                    else
                    {
                        _tweener = new LinearTweener();
                    }
                }
            }


            // reversible (defaults to true)
            nodeAttribute = node.Attributes.GetNamedItem("reversible");
            if (nodeAttribute != null)
            {
                string reverse = nodeAttribute.Value;
                if (String.Compare(reverse, "false") == 0)
                {
                    _isReversible = false;
                }
            }

            // conditional parameters
            if (_type == AnimationType.Conditional)
            {
                nodeAttribute = node.Attributes.GetNamedItem("pulse");
                if (nodeAttribute != null)
                {
                    string reverse = nodeAttribute.Value;
                    if (String.Compare(reverse, "true") == 0)
                    {
                        _repeatAnim = AnimationRepeat.Pulse;
                    }
                }
                nodeAttribute = node.Attributes.GetNamedItem("loop");
                if (nodeAttribute != null)
                {
                    string reverse = nodeAttribute.Value;
                    if (String.Compare(reverse, "true") == 0)
                    {
                        _repeatAnim = AnimationRepeat.Loop;
                    }
                }

                // Analog Clock animation
                nodeAttribute = node.Attributes.GetNamedItem("clockhandle");
                if (nodeAttribute != null)
                {
                    string clockType = nodeAttribute.Value;
                    if (String.Compare(clockType, "second") == 0)
                    {
                        _clockHandle = ClockHandleType.Second;
                    }
                    else if (String.Compare(clockType, "minute") == 0)
                    {
                        _clockHandle = ClockHandleType.Minute;
                    }
                    else if (String.Compare(clockType, "hour") == 0)
                    {
                        _clockHandle = ClockHandleType.Hour;
                    }
                    else
                    {
                        _clockHandle = ClockHandleType.None;
                    }
                }
            }

            // slide parameters
            if (_effect == EffectType.Slide)
            {
                nodeAttribute = node.Attributes.GetNamedItem("start");
                if (nodeAttribute != null)
                {
                    string startPos = nodeAttribute.Value;
                    GetPosition(startPos, ref _startX, ref _startY);
                }
                nodeAttribute = node.Attributes.GetNamedItem("end");
                if (nodeAttribute != null)
                {
                    string endPos = nodeAttribute.Value;
                    GetPosition(endPos, ref _endX, ref _endY);
                }
                // scale our parameters
                GUIGraphicsContext.ScaleHorizontal(ref _startX);
                GUIGraphicsContext.ScaleVertical(ref _startY);
                GUIGraphicsContext.ScaleHorizontal(ref _endX);
                GUIGraphicsContext.ScaleVertical(ref _endY);
            }
            else if (_effect == EffectType.Fade)
            {
                // alpha parameters
                if (_type < 0)
                {
                    // out effect defaults
                    _startAlpha = 100;
                    _endAlpha   = 0;
                }
                else
                {
                    // in effect defaults
                    _startAlpha = 0;
                    _endAlpha   = 100;
                }
                nodeAttribute = node.Attributes.GetNamedItem("start");
                if (nodeAttribute != null)
                {
                    _startAlpha = Int32.Parse(nodeAttribute.Value.ToString());
                }
                nodeAttribute = node.Attributes.GetNamedItem("end");
                if (nodeAttribute != null)
                {
                    _endAlpha = Int32.Parse(nodeAttribute.Value.ToString());
                }

                if (_startAlpha > 100)
                {
                    _startAlpha = 100;
                }
                if (_endAlpha > 100)
                {
                    _endAlpha = 100;
                }
                if (_startAlpha < 0)
                {
                    _startAlpha = 0;
                }
                if (_endAlpha < 0)
                {
                    _endAlpha = 0;
                }
            }
            else if (_effect == EffectType.RotateZ || _effect == EffectType.RotateX || _effect == EffectType.RotateY)
            {
                nodeAttribute = node.Attributes.GetNamedItem("start");
                if (nodeAttribute != null)
                {
                    _startX = float.Parse(nodeAttribute.Value);
                }
                nodeAttribute = node.Attributes.GetNamedItem("end");
                if (nodeAttribute != null)
                {
                    _endX = float.Parse(nodeAttribute.Value);
                }

                // convert to a negative to account for our reversed vertical axis
                _startX *= -1;
                _endX   *= -1;


                nodeAttribute = node.Attributes.GetNamedItem("center");
                if (nodeAttribute != null)
                {
                    string centerPos = nodeAttribute.Value;
                    GetPosition(centerPos, ref _centerX, ref _centerY);
                    GUIGraphicsContext.ScaleHorizontal(ref _centerX);
                    GUIGraphicsContext.ScaleVertical(ref _centerY);
                }
            }
            else // if (effect == EffectType.Zoom)
            {
                // effect defaults
                _startX = _startY = 100;
                _endX   = _endY = 100;

                nodeAttribute = node.Attributes.GetNamedItem("start");
                if (nodeAttribute != null)
                {
                    string start = nodeAttribute.Value;
                    GetPosition(start, ref _startX, ref _startY);
                    if (_startX == 0)
                    {
                        _startX = 100;
                    }
                    if (_startY == 0)
                    {
                        _startY = 100;
                    }
                }
                nodeAttribute = node.Attributes.GetNamedItem("end");
                if (nodeAttribute != null)
                {
                    string endLine = nodeAttribute.Value;
                    GetPosition(endLine, ref _endX, ref _endY);
                    if (_endX == 0)
                    {
                        _endX = 100;
                    }
                    if (_endY == 0)
                    {
                        _endY = 100;
                    }
                }
                nodeAttribute = node.Attributes.GetNamedItem("center");
                if (nodeAttribute != null)
                {
                    string center = nodeAttribute.Value;
                    GetPosition(center, ref _centerX, ref _centerY);
                    GUIGraphicsContext.ScaleHorizontal(ref _centerX);
                    GUIGraphicsContext.ScaleVertical(ref _centerY);
                }
                else
                {
                    /*
                     * // no center specified
                     * // calculate the center position...
                     * if (_startX != 0)
                     * {
                     * float scale = _endX / _startX;
                     * if (scale != 1)
                     *  _centerX = (_endPosX - scale * _startPosX) / (1 - scale);
                     * }
                     * if (_startY != 0)
                     * {
                     * float scale = _endY / _startY;
                     * if (scale != 1)
                     *  _centerY = (_endPosY - scale * _startPosY) / (1 - scale);
                     * }*/
                }
            }
            return(true);
        }
        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 progress control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
                if (Disabled)
                {
                    base.Render(timePassed);
                    return;
                }
            }

            if (_containsProperty)
            {
                string m_strText = GUIPropertyManager.Parse(_property);
                if (m_strText != string.Empty)
                {
                    float p;
                    Single.TryParse(m_strText, out p);
                    Percentage = p;
                }
            }

            // Render the background
            int iBkgHeight = _height;

            //GUIGraphicsContext.ScaleVertical(ref iBkgHeight); // fixing scaling bug
            _imageBackGround.Height = iBkgHeight;
            _imageBackGround.SetPosition(_imageBackGround.XPosition, _imageBackGround.YPosition);
            _imageBackGround.Render(timePassed);

            int iWidthLeft  = _imageLeft.TextureWidth;
            int iHeightLeft = (_innerheight != -1) ? _innerheight : _imageLeft.TextureHeight;
            // Legacy skin don't use innerheight
            int iWidthRight  = _imageRight.TextureWidth;
            int iHeightRight = (_innerheight != -1) ? _innerheight : _imageRight.TextureHeight;

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

            int offset = (_offset != -1) ? _offset : 12; // Legacy offset

            GUIGraphicsContext.ScaleHorizontal(ref offset);

            int iWidthMid  = (_midWidth != 0) ? _midWidth : _imageMid.TextureWidth;
            int iHeightMid = (_midHeight != 0) ? _midHeight : _imageMid.TextureHeight;

            GUIGraphicsContext.ScaleHorizontal(ref iWidthMid);
            GUIGraphicsContext.ScaleVertical(ref iHeightMid);

            int midOffsetX = (_midOffsetX != -1) ? _midOffsetX : 0;
            int midOffsetY = (_midOffsetY != -1) ? _midOffsetY : 0;

            GUIGraphicsContext.ScaleHorizontal(ref midOffsetX);
            GUIGraphicsContext.ScaleVertical(ref midOffsetY);

            float fWidth = _percentage;

            if (fWidth > 100.0f)
            {
                fWidth = 100.0f;
            }

            if (_onlyMidTexture)
            {
                fWidth *= (float)(iWidthMid);
                fWidth /= 100.0f;

                int iXPos = _imageBackGround.XPosition + midOffsetX;
                int iYPos = _imageBackGround.YPosition + midOffsetY;

                if (_percentage > 0 && fWidth > 1)
                {
                    _imageMid.SetPosition(iXPos, iYPos);
                    _imageMid.Height = iHeightMid;
                    _imageMid.Width  = (int)Math.Abs(fWidth);
                    _imageMid.SetPosition(iXPos, iYPos);
                    _imageMid.Render(timePassed);
                }
            }
            else
            {
                fWidth *= (float)(_imageBackGround.Width - 2 * offset - iWidthLeft - iWidthRight);
                fWidth /= 100.0f;

                int iXPos = offset + _imageBackGround.XPosition;

                int iYPos = _imageBackGround.YPosition + (iBkgHeight - iHeightLeft) / 2;

                _imageLeft.SetPosition(iXPos, iYPos);
                _imageLeft.Height = iHeightLeft;
                _imageLeft.Width  = iWidthLeft;
                _imageLeft.SetPosition(iXPos, iYPos);
                _imageLeft.Render(timePassed);

                iXPos += iWidthLeft;
                if (_percentage > 0 && fWidth > 1)
                {
                    _imageMid.SetPosition(iXPos, iYPos);
                    _imageMid.Height = iHeightLeft;
                    _imageMid.Width  = (int)Math.Abs(fWidth);
                    _imageMid.SetPosition(iXPos, iYPos);
                    _imageMid.Render(timePassed);
                    iXPos += (int)fWidth;
                }

                _imageRight.SetPosition(iXPos, iYPos);
                _imageRight.Height = iHeightRight;
                _imageRight.Width  = iWidthRight;
                _imageRight.SetPosition(iXPos, iYPos);
                _imageRight.Render(timePassed);
            }

            base.Render(timePassed);
        }
Esempio n. 11
0
        /// <summary>
        /// Renders the label
        /// </summary>
        /// <param name="graph">Graphics</param>
        /// <param name="buttonNr">Number of the button</param>
        /// <param name="dwPosX">X Position</param>
        /// <param name="dwPosY">Y Position</param>
        private void RenderLabel(Graphics graph, int buttonNr, int dwPosX, int dwPosY)
        {
            GUIListItem pItem = _listItems[buttonNr + _offset];
            long        dwColor;

            if (pItem.Shaded)
            {
                dwColor = _list.ShadedColor;
            }

            if (pItem.Selected)
            {
                dwColor = _list.SelectedColor;
            }

            dwPosX += _list.TextOffsetX;
            int dMaxWidth = (_list.Width - _list.TextOffsetX - _list.ImageWidth - GUIGraphicsContext.ScaleHorizontal(20));

            if ((_list.TextVisible2 && pItem.Label2.Length > 0) &&
                (_list.TextOffsetY == _list.TextOffsetY2))
            {
                dwColor = _list.TextColor2;

                if (pItem.Selected)
                {
                    dwColor = _list.SelectedColor2;
                }

                if (pItem.IsPlayed)
                {
                    dwColor = _list.PlayedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _list.RemoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _list.DownloadColor;
                    }
                }

                int xpos = dwPosX;
                int ypos = dwPosY;

                if (0 == _list.TextOffsetX2)
                {
                    xpos = _list.XPosition + _list.Width - GUIGraphicsContext.ScaleHorizontal(16);
                }
                else
                {
                    xpos = _list.XPosition + _list.TextOffsetX2;
                }

                if ((_labelControls2 != null) &&
                    (buttonNr >= 0) && (buttonNr < _labelControls2.Count))
                {
                    ListLabelElement label2 = _labelControls2[buttonNr];
                    if (label2 != null)
                    {
                        label2.XPosition = xpos;
                        label2.YPosition = ypos + GUIGraphicsContext.ScaleVertical(2) + _list.TextOffsetY2;

                        label2.Label     = pItem.Label2;
                        label2.Alignment = GUIControl.Alignment.ALIGN_RIGHT;
                        label2.Font      = getFont(_list.FontName2);
                        SizeF stringSize = label2.GetStringSize(graph);
                        dMaxWidth = (int)label2.XPosition - dwPosX - (int)stringSize.Width - GUIGraphicsContext.ScaleHorizontal(20);
                    }
                }
            }

            _textLine = pItem.Label;
            if (_list.TextVisible1)
            {
                dwColor = _list.TextColor;

                if (pItem.Selected)
                {
                    dwColor = _list.SelectedColor;
                }

                if (pItem.IsPlayed)
                {
                    dwColor = _list.PlayedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _list.RemoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _list.DownloadColor;
                    }
                }

                RenderText(graph, buttonNr, (float)dwPosX, (float)dwPosY + GUIGraphicsContext.ScaleVertical(2) + _list.TextOffsetY, (float)dMaxWidth, dwColor, _textLine);
            }

            if (pItem.Label2.Length > 0)
            {
                dwColor = _list.TextColor2;

                if (pItem.Selected)
                {
                    dwColor = _list.SelectedColor2;
                }

                if (pItem.IsPlayed)
                {
                    dwColor = _list.PlayedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _list.RemoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _list.DownloadColor;
                    }
                }
                if (0 == _list.TextOffsetX2)
                {
                    dwPosX = _list.XPosition + _list.Width - GUIGraphicsContext.ScaleHorizontal(16);
                }
                else
                {
                    dwPosX = _list.XPosition + _list.TextOffsetX2;
                }

                _textLine = pItem.Label2;

                if (_list.TextVisible2 &&
                    (_labelControls2 != null) &&
                    (buttonNr >= 0) && (buttonNr < _labelControls2.Count))
                {
                    ListLabelElement label2 = _labelControls2[buttonNr];
                    if (label2 != null)
                    {
                        label2.XPosition = dwPosX - GUIGraphicsContext.ScaleHorizontal(6);
                        label2.YPosition = dwPosY + GUIGraphicsContext.ScaleVertical(2) + _list.TextOffsetY2;
                        label2.Label     = _textLine;
                        label2.Alignment = GUIControl.Alignment.ALIGN_RIGHT;
                        label2.Font      = getFont(_list.FontName2);
                        label2.DrawElement(graph);
                        label2 = null;
                    }
                }
            }

            if (pItem.Label3.Length > 0)
            {
                dwColor = _list.TextColor3;

                if (pItem.Selected)
                {
                    dwColor = _list.SelectedColor3;
                }

                if (pItem.IsPlayed)
                {
                    dwColor = _list.PlayedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _list.RemoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _list.DownloadColor;
                    }
                }

                if (0 == _list.TextColor3)
                {
                    dwPosX = _list.XPosition + _list.TextOffsetX;
                }
                else
                {
                    dwPosX = _list.XPosition + _list.TextOffsetX3;
                }

                int ypos = dwPosY;

                if (0 == _list.TextOffsetY3)
                {
                    ypos += _list.TextOffsetY2;
                }
                else
                {
                    ypos += _list.TextOffsetY3;
                }

                if (_list.TextVisible3 &&
                    (_labelControls3 != null) &&
                    (buttonNr >= 0) && (buttonNr < _labelControls3.Count))
                {
                    ListLabelElement label3 = _labelControls3[buttonNr];

                    if (label3 != null)
                    {
                        label3.XPosition = dwPosX;
                        label3.YPosition = ypos;
                        label3.Label     = pItem.Label3;
                        label3.Alignment = GUIControl.Alignment.ALIGN_LEFT;
                        label3.Font      = getFont(_list.Font3);
                        label3.Width     = (_list.Width - _list.TextOffsetX - _list.ImageWidth - GUIGraphicsContext.ScaleHorizontal(34));
                        label3.DrawElement(graph);
                    }
                }
            }
        }
        /// <summary>
        /// Renders the control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
                if (Disabled)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            if (!GUIGraphicsContext.MouseSupport)
            {
                IsVisible = false;
                base.Render(timePassed);
                return;
            }

            int iHeight = _height;

            _imageBackground.Height = iHeight;

            float fPercent = (float)_percentage;
            float fPosYOff = (fPercent / 100.0f);

            // Scale handle-parts for resolution.

            //int backgroundWidth = _imageBackground.TextureWidth;
            //int backgroundWidth = _imageBackground.Width;
            int backgroundWidth = Width;

            GUIGraphicsContext.ScaleHorizontal(ref backgroundWidth);
            _imageBackground.Width = backgroundWidth;

            int handleHeight = _imageTop.TextureHeight;

            GUIGraphicsContext.ScaleVertical(ref handleHeight);
            _imageTop.Height    = handleHeight;
            _imageBottom.Height = handleHeight;

            double ratio = (double)_imageTop.TextureWidth / (double)_imageBackground.TextureWidth;

            //int handleWidth = _imageTop.TextureWidth;
            int handleWidth = (int)(Width * ratio);

            GUIGraphicsContext.ScaleHorizontal(ref handleWidth);
            _imageTop.Width    = handleWidth;
            _imageBottom.Width = handleWidth;

            _heightKnob     = (int)(2 * _imageTop.Height);
            _startPositionY = _imageBackground.YPosition;
            _endPositionY   = _startPositionY + _imageBackground.Height;
            fPosYOff       *= (float)(_endPositionY - _imageTop.Height - _startPositionY);
            _knobPositionY  = _startPositionY + (int)fPosYOff;

            _imageBackground.Render(timePassed);

            int iXPos = _imageBackground.XPosition + ((_imageBackground.Width / 2) - (_imageTop.Width));
            int iYPos = _knobPositionY;

            _imageTop.SetPosition(iXPos, iYPos);
            _imageTop.Render(timePassed);

            iXPos += _imageTop.Width;

            _imageBottom.SetPosition(iXPos, iYPos);
            _imageBottom.Render(timePassed);

            base.Render(timePassed);
        }
Esempio n. 13
0
        /// <summary>
        /// Renders the progress control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
                if (Disabled)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            int tb = 0;

            try
            {
                tb = Int32.Parse(GUIPropertyManager.Parse("#statusbarTB"));
            }
            catch (Exception ex)
            {
                Log.Error("GUIStatusbarControl render: " + ex.Message);
            }

            if (_containsProperty)
            {
                string m_strText = GUIPropertyManager.Parse(_property);
                if (m_strText != string.Empty)
                {
                    try
                    {
                        Percentage = Int32.Parse(m_strText);
                        if (Percentage <= -1)
                        {
                            base.Render(timePassed);
                            return;
                        }
                        if (Percentage > 100)
                        {
                            Percentage = 100;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error("GUIStatusbarControl render2: " + ex.Message);
                    }
                }
            }

            int yPosTop = 0;

            try
            {
                yPosTop = Convert.ToInt16(_top);
            }
            catch (Exception ex)
            {
                Log.Error("GUIStatusbarControl render3: " + ex.Message);
            }

            // Render the background
            int iBkgHeight = _height;

            _imageBackground.Height = iBkgHeight;
            if (tb == 1)
            {
                _imageBackground.SetPosition(_imageBackground.XPosition, yPosTop);
            }
            else
            {
                _imageBackground.SetPosition(_imageBackground.XPosition, _imageBackground.YPosition);
            }
            _imageBackground.Render(timePassed);

            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);
            //iHeight=20;
            float fWidth = (float)_percentage;

            fWidth /= 100.0f;
            fWidth *= (float)(_imageBackground.Width - 24 - iWidthLeft - iWidthRight);

            int off = 12;

            GUIGraphicsContext.ScaleHorizontal(ref off);
            int iXPos = off + _imageBackground.XPosition;

            int iYPos = 0;

            if (tb == 1)
            {
                // top
                iYPos = yPosTop + (iBkgHeight - iHeightLeft) / 2;
            }
            else
            {
                // bottom
                iYPos = _imageBackground.YPosition + (iBkgHeight - iHeightLeft) / 2;
            }
            //_imageLeft.SetHeight(iHeight);
            _imageLeft.SetPosition(iXPos, iYPos);
            _imageLeft.Height = iHeightLeft;
            _imageLeft.Width  = iWidthLeft;
            _imageLeft.SetPosition(iXPos, iYPos);
            _imageLeft.Render(timePassed);

            iXPos += iWidthLeft;
            if (_percentage > 0 && (int)fWidth > 1)
            {
                _imageMid.SetPosition(iXPos, iYPos);
                _imageMid.Height = iHeightLeft; //_imageMid.TextureHeight;
                _imageMid.Width  = (int)fWidth;
                _imageMid.SetPosition(iXPos, iYPos);
                _imageMid.Render(timePassed);
                iXPos += (int)fWidth;
            }
            //_imageRight.SetHeight(iHeight);
            _imageRight.SetPosition(iXPos, iYPos);
            _imageRight.Height = iHeightRight;
            _imageRight.Width  = iWidthRight;
            _imageRight.SetPosition(iXPos, iYPos);
            _imageRight.Render(timePassed);
            base.Render(timePassed);
        }
        protected override void RenderLabel(float timePassed, int buttonNr, int dwPosX, int dwPosY, bool gotFocus)
        {
            // if (buttonNr + _offset < 0 || buttonNr + _offset >= _listButtons.Count) return;
            if (buttonNr < 0 || buttonNr >= _listButtons.Count)
            {
                return;
            }
            GUIListItem pItem   = _listItems[buttonNr + _offset];
            long        dwColor = _textColor;

            if (pItem.Shaded)
            {
                dwColor = ShadedColor;
            }
            if (pItem.Selected)
            {
                dwColor = _selectedColor;
            }

            dwPosX += _textOffsetX;
            bool bSelected = false;

            if (buttonNr == _cursorX && IsFocused && _listType == ListType.CONTROL_LIST)
            {
                bSelected = true;
            }

            GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[buttonNr];
            int dMaxWidth = (_width - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8));

            if (btn != null)
            {
                dMaxWidth = (_upBtnXOffset - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8));
            }

            if (_text2Visible && pItem.Label2.Length > 0)
            {
                if (_textOffsetY == _textOffsetY2)
                {
                    dwColor = _textColor2;
                    if (pItem.Selected)
                    {
                        dwColor = _selectedColor2;
                    }
                    if (pItem.IsRemote)
                    {
                        dwColor = _remoteColor;
                        if (pItem.IsDownloading)
                        {
                            dwColor = _downloadColor;
                        }
                    }
                    int xpos = dwPosX;
                    int ypos = dwPosY;

                    if (0 == _textOffsetX2)
                    {
                        xpos = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8);
                    }

                    else
                    {
                        xpos = _positionX + _textOffsetX2;
                    }

                    if (_labelControls2 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls2.Count)
                        {
                            GUILabelControl label2 = _labelControls2[buttonNr];
                            if (label2 != null)
                            {
                                label2.SetPosition(xpos, ypos + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2);
                                if (gotFocus)
                                {
                                    label2.TextColor = dwColor;
                                }
                                else
                                {
                                    label2.TextColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                }
                                label2.Label         = pItem.Label2;
                                label2.TextAlignment = Alignment.ALIGN_RIGHT;
                                label2.FontName      = _fontName2Name;
                                dMaxWidth            = label2._positionX - dwPosX - label2.TextWidth - GUIGraphicsContext.ScaleHorizontal(20);
                            }
                        }
                    }
                }
            }

            _textLine = pItem.Label;

            if (_text1Visible)
            {
                dwColor = _textColor;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (!gotFocus)
                {
                    dwColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                }

                RenderText(timePassed, buttonNr, (float)dwPosX,
                           (float)dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY, (float)dMaxWidth, dwColor,
                           _textLine, bSelected);
            }

            if (pItem.Label2.Length > 0)
            {
                dwColor = _textColor2;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor2;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (0 == _textOffsetX2)
                {
                    dwPosX = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8);
                }

                else
                {
                    dwPosX = _positionX + _textOffsetX2;
                }

                _textLine = pItem.Label2;

                if (_text2Visible)
                {
                    if (_labelControls2 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls2.Count)
                        {
                            GUILabelControl label2 = _labelControls2[buttonNr];
                            if (label2 != null)
                            {
                                label2.SetPosition(dwPosX, dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2);
                                if (gotFocus)
                                {
                                    label2.TextColor = dwColor;
                                }
                                else
                                {
                                    label2.TextColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                }
                                label2.Label         = _textLine;
                                label2.TextAlignment = Alignment.ALIGN_RIGHT;
                                label2.FontName      = _fontName2Name;
                                label2.Render(timePassed);
                                label2 = null;
                            }
                        }
                    }
                }
            }

            if (pItem.Label3.Length > 0)
            {
                dwColor = _textColor3;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor3;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (0 == _textOffsetX3)
                {
                    dwPosX = _positionX + _textOffsetX;
                }

                else
                {
                    dwPosX = _positionX + _textOffsetX3;
                }

                int ypos = dwPosY;

                if (0 == _textOffsetY3)
                {
                    ypos += _textOffsetY2;
                }

                else
                {
                    ypos += _textOffsetY3;
                }

                if (_text3Visible)
                {
                    if (_labelControls3 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls3.Count)
                        {
                            GUILabelControl label3 = _labelControls3[buttonNr];

                            if (label3 != null)
                            {
                                label3.SetPosition(dwPosX, ypos);

                                if (gotFocus)
                                {
                                    label3.TextColor = dwColor;
                                }

                                else
                                {
                                    label3.TextColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                }

                                label3.Label         = pItem.Label3;
                                label3.TextAlignment = Alignment.ALIGN_LEFT;
                                label3.FontName      = _fontName2Name;
                                label3.Render(timePassed);
                                label3 = null;
                            }
                        }
                    }
                }
            }

            pItem = null;
        }
        /// <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 iWidthBackGround = _imageBackGround.TextureWidth;
            int iWidthMidFocus   = _imageMidFocus.TextureWidth;
            int iWidthMid        = _imageMid.TextureWidth;

            int iHeightBackGround = _imageBackGround.TextureHeight;
            int iHeightMidFocus   = _imageMidFocus.TextureHeight;
            int iHeightMid        = _imageMid.TextureHeight;

            GUIGraphicsContext.ScaleHorizontal(ref iWidthBackGround);
            GUIGraphicsContext.ScaleHorizontal(ref iWidthMidFocus);
            GUIGraphicsContext.ScaleHorizontal(ref iWidthMid);

            GUIGraphicsContext.ScaleVertical(ref iHeightBackGround);
            GUIGraphicsContext.ScaleVertical(ref iHeightMidFocus);
            GUIGraphicsContext.ScaleVertical(ref iHeightMid);

            _imageBackGround.Width  = iWidthBackGround;
            _imageBackGround.Height = iHeightBackGround;

            _imageMidFocus.Width  = iWidthMidFocus;
            _imageMidFocus.Height = iHeightMidFocus;

            _imageMid.Width  = iWidthMid;
            _imageMid.Height = iHeightMid;

            _imageBackGround.Render(timePassed);

            float fWidth = (float)(_imageBackGround.Width - _imageMid.Width); //-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);
        }
Esempio n. 16
0
 public override void ScaleToScreenResolution()
 {
     base.ScaleToScreenResolution();
     GUIGraphicsContext.ScaleVertical(ref _spaceBetweenItems);
 }
Esempio n. 17
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();
            }
        }
Esempio n. 18
0
        protected override void RenderLabel(float timePassed, int buttonNr, int dwPosX, int dwPosY, bool gotFocus)
        {
            if (buttonNr < 0 || buttonNr >= _listButtons.Count)
            {
                return;
            }

            GUIListItem pItem = _listItems[buttonNr + _offset];
            long        dwColor;

            dwPosX += _textOffsetX;
            bool bSelected = buttonNr == _cursorX && IsFocused && _listType == ListType.CONTROL_LIST;

            GUIPlayListButtonControl btn = (GUIPlayListButtonControl)_listButtons[buttonNr];
            int dMaxWidth = (_width - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8));

            if (btn != null)
            {
                dMaxWidth = (_upBtnXOffset - _imageWidth - PinIconOffsetX - GUIGraphicsContext.ScaleHorizontal(8));
            }

            if (_text2Visible && pItem.Label2.Length > 0)
            {
                if (_textOffsetY == _textOffsetY2)
                {
                    dwColor = _textColor2;
                    if (pItem.Selected)
                    {
                        dwColor = _selectedColor2;
                    }
                    if (pItem.IsRemote)
                    {
                        dwColor = _remoteColor;
                        if (pItem.IsDownloading)
                        {
                            dwColor = _downloadColor;
                        }
                    }

                    if (pItem.IsBdDvdFolder)
                    {
                        dwColor = _bdDvdDirectoryColor;
                    }

                    int xpos;
                    int ypos = dwPosY;

                    if (0 == _textOffsetX2)
                    {
                        xpos = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8);
                    }
                    else
                    {
                        xpos = _positionX + _textOffsetX2;
                    }

                    if (_labelControls2 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls2.Count)
                        {
                            GUILabelControl label2 = _labelControls2[buttonNr];
                            if (label2 != null)
                            {
                                label2.SetPosition(xpos, ypos + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2);
                                label2.TextColor     = gotFocus ? dwColor : Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                label2.Label         = pItem.Label2;
                                label2.TextAlignment = Alignment.ALIGN_RIGHT;
                                label2.FontName      = _fontName2Name;
                                dMaxWidth            = label2._positionX - dwPosX - label2.TextWidth - GUIGraphicsContext.ScaleHorizontal(20);
                            }
                        }
                    }
                }
            }

            if (_text1Visible)
            {
                dwColor = _textColor;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (pItem.IsBdDvdFolder)
                {
                    dwColor = _bdDvdDirectoryColor;
                }

                if (!gotFocus)
                {
                    dwColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                }

                int maxWidth = dMaxWidth;
                if (_textPadding > 0)
                {
                    maxWidth -= GUIGraphicsContext.ScaleHorizontal(_textPadding);
                }

                if (maxWidth <= 0)
                {
                    base.Render(timePassed);
                }
                else
                {
                    RenderText(timePassed, buttonNr, dwPosX, (float)dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY, maxWidth, dwColor, pItem.Label, bSelected);
                }
            }

            if (pItem.Label2.Length > 0)
            {
                dwColor = _textColor2;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor2;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (pItem.IsBdDvdFolder)
                {
                    dwColor = _bdDvdDirectoryColor;
                }

                if (_textOffsetX2 == 0)
                {
                    dwPosX = _positionX + _upBtnXOffset - GUIGraphicsContext.ScaleHorizontal(8);
                }
                else
                {
                    dwPosX = _positionX + _textOffsetX2;
                }

                if (_text2Visible)
                {
                    if (_labelControls2 != null && (buttonNr >= 0 && buttonNr < _labelControls2.Count))
                    {
                        GUILabelControl label2 = _labelControls2[buttonNr];
                        if (label2 != null)
                        {
                            label2.SetPosition(dwPosX, dwPosY + GUIGraphicsContext.ScaleVertical(2) + _textOffsetY2);
                            label2.TextColor = gotFocus
                                   ? dwColor
                                   : Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                            label2.Label         = pItem.Label2;
                            label2.TextAlignment = Alignment.ALIGN_RIGHT;
                            label2.FontName      = _fontName2Name;

                            float width  = label2.Width;
                            float height = label2.Height;
                            _font.GetTextExtent(label2.Label, ref width, ref height);
                            label2.Width  = (int)width + 1;
                            label2.Height = (int)height;

                            if (_textPadding2 > 0)
                            {
                                label2.Width -= GUIGraphicsContext.ScaleHorizontal(_textPadding2);
                            }

                            if (label2.Width > 0)
                            {
                                label2.Render(timePassed);
                            }
                        }
                    }
                }
            }

            if (pItem.Label3.Length > 0)
            {
                dwColor = _textColor3;
                if (pItem.Selected)
                {
                    dwColor = _selectedColor3;
                }

                if (pItem.IsRemote)
                {
                    dwColor = _remoteColor;
                    if (pItem.IsDownloading)
                    {
                        dwColor = _downloadColor;
                    }
                }

                if (pItem.IsBdDvdFolder)
                {
                    dwColor = _bdDvdDirectoryColor;
                }

                if (0 == _textOffsetX3)
                {
                    dwPosX = _positionX + _textOffsetX;
                }
                else
                {
                    dwPosX = _positionX + _textOffsetX3;
                }

                int ypos = dwPosY;

                if (0 == _textOffsetY3)
                {
                    ypos += _textOffsetY2;
                }
                else
                {
                    ypos += _textOffsetY3;
                }

                if (_text3Visible)
                {
                    if (_labelControls3 != null)
                    {
                        if (buttonNr >= 0 && buttonNr < _labelControls3.Count)
                        {
                            GUILabelControl label3 = _labelControls3[buttonNr];

                            if (label3 != null)
                            {
                                label3.SetPosition(dwPosX, ypos);

                                label3.TextColor     = gotFocus ? dwColor : Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
                                label3.Label         = pItem.Label3;
                                label3.TextAlignment = Alignment.ALIGN_LEFT;
                                label3.FontName      = _fontName2Name;

                                float width  = label3.Width;
                                float height = label3.Height;
                                _font.GetTextExtent(label3.Label, ref width, ref height);
                                label3.Width  = (int)width + 1;
                                label3.Height = (int)height;

                                if (_textPadding3 > 0)
                                {
                                    label3.Width -= GUIGraphicsContext.ScaleHorizontal(_textPadding3);
                                }

                                if (label3.Width > 0)
                                {
                                    label3.Render(timePassed);
                                }
                            }
                        }
                    }
                }
            }
        }
        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());
            }
        }
 public override void ScaleToScreenResolution()
 {
     base.ScaleToScreenResolution();
     GUIGraphicsContext.ScaleHorizontal(ref _checkMarkWidth);
     GUIGraphicsContext.ScaleVertical(ref _checkMarkHeight);
 }
        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);
        }