Render() public méthode

Renders the text onscreen.
public Render ( float timePassed ) : void
timePassed float
Résultat void
        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;
        }
Exemple #2
0
        public override void Render(float timePassed)
        {
            // Do not render if not visible.
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

            // The GUIButtonControl has the focus
            if (Focus)
            {
                int dwAlphaCounter = _frameCounter + 2;
                int dwAlphaChannel;
                if ((dwAlphaCounter % 128) >= 64)
                {
                    dwAlphaChannel = dwAlphaCounter % 64;
                }
                else
                {
                    dwAlphaChannel = 63 - (dwAlphaCounter % 64);
                }

                dwAlphaChannel += 192;
                SetAlpha(dwAlphaChannel);
                if (_isSelected)
                {
                    _imageFocused.Render(timePassed);
                }
                else
                {
                    _imageAlternativeFocused.Render(timePassed);
                }
                _frameCounter++;
            }
            else
            {
                SetAlpha(0xff);
                if (_isSelected)
                {
                    _imageNonFocused.Render(timePassed);
                }
                else
                {
                    _imageAlternativeNonFocused.Render(timePassed);
                }
            }

            int labelWidth = _width - 2 * _textOffsetX;

            if (labelWidth <= 0)
            {
                base.Render(timePassed);
                return;
            }
            _labelControl.Width          = labelWidth;
            _labelControl.TextAlignment  = _textAlignment;
            _labelControl.TextVAlignment = _textVAlignment;
            _labelControl.Label          = _label;
            _labelControl.TextColor      = Disabled ? _disabledColor : Focus ? _textColor : _textColorNoFocus;

            // render the text on the button
            int x = 0;
            int y = 0;

            switch (_textAlignment)
            {
            case Alignment.ALIGN_LEFT:
                x = _textOffsetX + _positionX;
                break;

            case Alignment.ALIGN_RIGHT:
                x = _positionX + _width - _textOffsetX;
                break;

            case Alignment.ALIGN_CENTER:
                x = _positionX + ((_width / 2) - (labelWidth / 2));
                break;
            }

            switch (_textVAlignment)
            {
            case VAlignment.ALIGN_TOP:
                y = _textOffsetY + _positionY;
                break;

            case VAlignment.ALIGN_BOTTOM:
                y = _positionY + _height - _textOffsetY;
                break;

            case VAlignment.ALIGN_MIDDLE:
                y = _positionY + ((_height / 2) - (_labelControl.Height / 2));
                break;
            }

            _labelControl.SetPosition(x, y);
            _labelControl.Render(timePassed);
            base.Render(timePassed);
        }
Exemple #3
0
        /// <summary>
        /// Renders the control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (_labelControl == null)
            {
                return;
            }

            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            _isScrolling = false;
            if (!string.IsNullOrEmpty(_label))
            {
                string strText = _label;
                if (_containsProperty)
                {
                    strText = GUIPropertyManager.Parse(strText) ?? string.Empty;
                }

                if (_previousText != strText)
                {
                    _currentLabelIndex = 0;
                    _scrollPosition    = 0;
                    _scrollPosititionX = 0;
                    _scrollOffset      = 0;
                    _currentFrame      = 0;
                    _timeElapsed       = 0;
                    _fadeIn            = _allowFadeIn;
                    _listLabels.DisposeAndClearList();
                    _previousText = strText;
                    strText       = strText.Replace("\\r", "\r");
                    int ipos;
                    do
                    {
                        ipos = strText.IndexOf("\r", System.StringComparison.Ordinal);
                        int ipos2 = strText.IndexOf("\n", System.StringComparison.Ordinal);
                        if (ipos >= 0 && ipos2 >= 0 && ipos2 < ipos)
                        {
                            ipos = ipos2;
                        }
                        if (ipos < 0 && ipos2 >= 0)
                        {
                            ipos = ipos2;
                        }

                        if (ipos >= 0)
                        {
                            string strLine = strText.Substring(0, ipos);
                            if (strLine.Length > 1)
                            {
                                _listLabels.Add(strLine);
                            }
                            if (ipos + 1 >= strText.Length)
                            {
                                break;
                            }
                            strText = strText.Substring(ipos + 1);
                        }
                        else
                        {
                            _listLabels.Add(strText);
                        }
                    } while (ipos >= 0 && strText.Length > 0);
                }
            }
            else
            {
                _listLabels.DisposeAndClearList();
            }

            // if there are no labels do not render
            if (_listLabels.Count == 0)
            {
                base.Render(timePassed);
                return;
            }

            // reset the current label is index is out of bounds
            if (_currentLabelIndex < 0 || _currentLabelIndex >= _listLabels.Count)
            {
                _currentLabelIndex = 0;
            }

            // get the current label
            var strLabel = (string)_listLabels[_currentLabelIndex];

            _labelControl.Width  = _width;
            _labelControl.Height = _height;
            _labelControl.Label  = strLabel;
            _labelControl.SetPosition(_positionX, _positionY);
            _labelControl.TextAlignment  = _textAlignment;
            _labelControl.TextVAlignment = _textVAlignment;
            _labelControl.TextColor      = _textColor;
            _labelControl.CacheFont      = _labelControl.TextWidth < _width;
            if (GUIGraphicsContext.graphics != null)
            {
                _labelControl.Render(timePassed);
                base.Render(timePassed);
                return;
            }

            // if there is only one label just draw the text
            if (_listLabels.Count == 1 && _labelControl.TextWidth < _width)
            {
                _labelControl.Render(timePassed);
                base.Render(timePassed);
                return;
            }

            strLabel += _wrapString;

            _timeElapsed += timePassed;
            _currentFrame = (int)(_timeElapsed / TimeSlice);

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

            // More than one label
            _isScrolling = true;

            // Make the label fade in
            if (_fadeIn && _allowScrolling)
            {
                long dwAlpha = ((((uint)_textColor) >> 24) * _currentFrame) / 12;
                dwAlpha <<= 24;
                dwAlpha  |= (_textColor & 0x00ffffff);
                _labelControl.TextColor = dwAlpha;

                dwAlpha   = ((((uint)_shadowColor) >> 24) * _currentFrame) / 12;
                dwAlpha <<= 24;
                dwAlpha  |= (_shadowColor & 0x00ffffff);
                _labelControl.ShadowColor = dwAlpha;

                float fwt = 0;
                _labelControl.Label = GetShortenedText(strLabel, _width, ref fwt);
                if (_textAlignment == Alignment.ALIGN_RIGHT)
                {
                    _labelControl.Width = (int)(fwt);
                }
                _labelControl.Render(timePassed);
                if (_currentFrame >= 12)
                {
                    _fadeIn = false;
                }
            }
            else if (_fadeIn && !_allowScrolling)
            {
                _fadeIn = false;
            }

            // not fading in
            if (!_fadeIn)
            {
                if (!_allowScrolling)
                {
                    _currentLabelIndex = 0;
                    _scrollPosition    = 0;
                    _scrollPosititionX = 0;
                    _scrollOffset      = 0;
                    _currentFrame      = 0;
                }

                // render the text
                bool bDone = RenderText(timePassed, _positionX, _positionY, _width, strLabel);
                if (bDone)
                {
                    _currentLabelIndex++;
                    _scrollPosition    = 0;
                    _scrollPosititionX = 0;
                    _scrollOffset      = 0;
                    _currentFrame      = 0;
                    if (!WrapAround() || _listLabels.Count > 1)
                    {
                        _timeElapsed = 0f;
                    }
                    _currentFrame = 0;
                }
            }
            base.Render(timePassed);
        }
    /// <summary>
    /// Renders the text.
    /// </summary>
    /// <param name="timePassed"></param>
    /// <param name="item"></param>
    /// <param name="label">The label to render</param>
    /// <param name="bScroll">A bool indication if there is scrolling or not.</param>
    protected void RenderText(float timePassed, int item, GUILabelControl label, bool bScroll)
    {
      float fPosX = label._positionX;
      float fPosY = label._positionY;
      float fMaxWidth = label.Width;
      long dwTextColor = label.TextColor;
      string strTextToRender = label.Label;
      GUIFont font = GUIFontManager.GetFont(label.FontName);

      if (!bScroll || label.TextWidth <= fMaxWidth)
      {
        // don't scroll here => x-position is constant
        label.Render(timePassed);
        return;
      }

      float fTextHeight = 0;
      float fTextWidth = 0;
      font.GetTextExtent(strTextToRender, ref fTextWidth, ref fTextHeight);
      float fWidth = 0;

      float fPosCX = fPosX;
      float fPosCY = fPosY;

      if (fPosCX < 0)
      {
        fPosCX = 0.0f;
      }
      if (fPosCY < 0)
      {
        fPosCY = 0.0f;
      }

      if (fPosCY > GUIGraphicsContext.Height)
      {
        fPosCY = GUIGraphicsContext.Height;
      }

      float fHeight = 60.0f;
      if (fHeight + fPosCY >= GUIGraphicsContext.Height)
      {
        fHeight = GUIGraphicsContext.Height - fPosCY - 1;
      }
      if (fHeight <= 0)
      {
        return;
      }

      //float fwidth = fMaxWidth - 5.0f;
      float fwidth = fMaxWidth + 6f;

      if (fwidth < 1)
      {
        return;
      }
      if (fHeight < 1)
      {
        return;
      }

      if (fPosCX <= 0)
      {
        fPosCX = 0;
      }
      if (fPosCY <= 0)
      {
        fPosCY = 0;
      }

      Rectangle clipRect = new Rectangle
                             {
                               X = (int) fPosCX,
                               Y = (int) fPosCY,
                               Width = (int) (fwidth),
                               Height = (int) (fHeight)
                             };
      GUIGraphicsContext.BeginClip(clipRect);

      // scroll
      int iItem = _cursorX + _offset;
      _brackedText = strTextToRender;
      _brackedText += ("  " + _suffix + " ");
      font.GetTextExtent(_brackedText, ref fTextWidth, ref fTextHeight);

      if (fTextWidth > fMaxWidth)
      {
        // scrolling necessary
        fMaxWidth += 50.0f;
        _textLine2 = "";
        if (_lastItem != iItem)
        {
          _scrollPosition = 0;
          _lastItem = iItem;
          _scrollPosititionX = 0;
          _scrollOffsetX = 0.0f;
          _timeElapsed = 0.0f;
          _scrollContinuously = false;
        }
        if ((int)_timeElapsed > _scrollStartDelay || _scrollContinuously)
        {
          // Add an especially slow setting for far distance + small display + bad eyes + foreign language combination
          if (GUIGraphicsContext.ScrollSpeedHorizontal < 3)
          {
            // Advance one pixel every 3 or 2 frames
            if (_frameLimiter % (4 - GUIGraphicsContext.ScrollSpeedHorizontal) == 0)
            {
              _scrollPosititionX++;
            }
          }
          else
          {
            // advance 1 - 3 pixels every frame
            _scrollPosititionX = _scrollPosititionX + (GUIGraphicsContext.ScrollSpeedHorizontal - 2);
          }

          char wTmp = _scrollPosition >= _brackedText.Length ? ' ' : _brackedText[_scrollPosition];

          font.GetTextExtent(wTmp.ToString(CultureInfo.InvariantCulture), ref fWidth, ref fHeight);
          if (_scrollPosititionX - _scrollOffsetX >= fWidth)
          {
            _scrollPosition++;
            if (_scrollPosition > _brackedText.Length)
            {
              _scrollPosition = 0;
              _scrollPosititionX = 0;
              _scrollOffsetX = 0.0f;
              _timeElapsed = 0.0f;
              _scrollContinuously = true;
            }
            else
            {
              _scrollOffsetX += fWidth;
            }
          }
          int ipos = 0;
          for (int i = 0; i < _brackedText.Length; i++)
          {
            if (i + _scrollPosition < _brackedText.Length)
            {
              _textLine2 += _brackedText[i + _scrollPosition];
            }
            else
            {
              if (ipos == 0)
              {
                _textLine2 += ' ';
              }
              else
              {
                _textLine2 += _brackedText[ipos - 1];
              }
              ipos++;
            }
          }

          if (fPosY >= 0.0)
          {
            long tc = GUIGraphicsContext.MergeAlpha((uint)dwTextColor);
            long sc = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
            if ((_shadowDistance > 0) && ((_shadowColor >> 24) > 0))
            {
              font.DrawShadowTextWidth((int)(fPosX - _scrollPosititionX + _scrollOffsetX),
                            fPosY, tc, _textLine2, Alignment.ALIGN_LEFT,
                            _shadowAngle, _shadowDistance, sc,
                            (int)(fMaxWidth - 50f + _scrollPosititionX - _scrollOffsetX));
            }
            else
            {
              font.DrawText((int)(fPosX - _scrollPosititionX + _scrollOffsetX),
                            fPosY, tc, _textLine2, Alignment.ALIGN_LEFT,
                            (int)(fMaxWidth - 50f + _scrollPosititionX - _scrollOffsetX));
            }
          }
        }
        else if (fPosY >= 0.0)
        {
          long tc = GUIGraphicsContext.MergeAlpha((uint)dwTextColor);
          long sc = GUIGraphicsContext.MergeAlpha((uint)_shadowColor);
          if ((_shadowDistance > 0) && ((_shadowColor >> 24) > 0))
          {
            font.DrawShadowTextWidth(fPosX, fPosY, tc, strTextToRender, Alignment.ALIGN_LEFT, _shadowAngle, _shadowDistance, sc, (int)(fMaxWidth - 50f));
          }
          else
          {
            font.DrawText(fPosX, fPosY, tc, strTextToRender, Alignment.ALIGN_LEFT, (int)(fMaxWidth - 50f));
          }
        }
      }
      GUIGraphicsContext.EndClip();
    }
Exemple #5
0
        /// <summary>
        /// Renders the GUICheckButton.
        /// </summary>
        public override void Render(float timePassed)
        {
            // Do not render if not visible.
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

            // The GUICheckButton has the focus
            if (Focus)
            {
                //render the focused image
                _imageFocused.Render(timePassed);
            }
            else
            {
                //render the non-focused image
                _imageNonFocused.Render(timePassed);
            }

            int labelWidth = _width - 2 * _textOffsetX;

            if (labelWidth <= 0)
            {
                base.Render(timePassed);
                return;
            }
            _labelControl.Width = labelWidth;

            // render the text on the button
            _labelControl.TextAlignment  = _textAlignment;
            _labelControl.TextVAlignment = _textVAlignment;
            _labelControl.Label          = _label;
            _labelControl.TextColor      = Disabled ? _disabledColor : Focus ? _textColor : _textColorNoFocus;

            int x = 0;
            int y = 0;

            switch (_textAlignment)
            {
            case Alignment.ALIGN_LEFT:
                x = _textOffsetX + _positionX;
                break;

            case Alignment.ALIGN_RIGHT:
                x = _positionX + _width - _textOffsetX;
                break;

            case Alignment.ALIGN_CENTER:
                x = _positionX + ((_width / 2) - (labelWidth / 2));
                break;
            }

            switch (_textVAlignment)
            {
            case VAlignment.ALIGN_TOP:
                y = _textOffsetY + _positionY;
                break;

            case VAlignment.ALIGN_BOTTOM:
                y = _positionY + _height - _textOffsetY;
                break;

            case VAlignment.ALIGN_MIDDLE:
                y = _positionY + ((_height / 2) - (_labelControl.Height / 2));
                break;
            }

            _labelControl.SetPosition(x, y);
            _labelControl.Render(timePassed);

            x = 0;
            y = 0;

            switch (_markAlignment)
            {
            case Alignment.ALIGN_LEFT:
                x = _markOffsetX + _positionX;
                break;

            case Alignment.ALIGN_RIGHT:
                x = _positionX + _width - _markOffsetX - checkMark.Width;
                break;

            case Alignment.ALIGN_CENTER:
                x = _positionX + ((_width / 2) - (checkMark.Width / 2));
                break;
            }

            switch (_markVAlignment)
            {
            case VAlignment.ALIGN_TOP:
                y = _markOffsetY + _positionY;
                break;

            case VAlignment.ALIGN_BOTTOM:
                y = _positionY + _height - _markOffsetY - checkMark.Height;
                break;

            case VAlignment.ALIGN_MIDDLE:
                y = _positionY + ((_height / 2) - (checkMark.Height / 2));
                break;
            }

            checkMark.SetPosition(x, y);
            checkMark.Render(timePassed);
            base.Render(timePassed);
        }
Exemple #6
0
        /// <summary>
        /// Renders the control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

            // Are we in selection mode
            _showSelect = Focus;
            if (_showSelect)
            {
                // Yes, render the select control

                // render background, left and right arrow
                _imageBackground.Render(timePassed);

                long dwTextColor = Focus ? _textColor : _textColorNoFocus;

                // User has moved left...
                if (_leftSelected)
                {
                    // ...render focused arrow
                    _startFrame++;
                    if (_autoHide && _startFrame >= 25)
                    {
                        _startFrame   = 0;
                        _leftSelected = false;
                        GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
                        GUIWindowManager.SendThreadMessage(message);
                        _updateNeeded = true;
                    }
                    _imageLeftFocus.Render(timePassed);

                    // If we are moving left	render item text as disabled
                    dwTextColor = _disabledColor;
                }
                else
                {
                    // Render none focused arrow
                    _imageLeft.Render(timePassed);
                }


                // User has moved right...
                if (_rightSelected)
                {
                    // ...render focused arrow
                    _startFrame++;
                    if (_autoHide && _startFrame >= 25)
                    {
                        _startFrame    = 0;
                        _rightSelected = false;
                        GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
                        GUIWindowManager.SendThreadMessage(message);
                        _updateNeeded = true;
                    }
                    _imageRightFocus.Render(timePassed);

                    // If we are moving right render item text as disabled
                    dwTextColor = _disabledColor;
                }
                else
                {
                    // Render none focused arrow
                    _imageRight.Render(timePassed);
                }

                // Render text if a current item is available
                if (SelectedItem >= 0 && null != _font && SelectedItem < _subItemList.Count)
                {
                    _labelControl.FontName = _font.FontName;

                    if (_textPadding > 0)
                    {
                        _width -= GUIGraphicsContext.ScaleHorizontal(_textPadding);
                    }

                    if (_textAlignment == Alignment.ALIGN_RIGHT)
                    {
                        _labelControl.SetPosition(_positionX + _width - _imageLeft.Width - _textOffsetX, _textOffsetY + _positionY);
                    }
                    else
                    {
                        _labelControl.SetPosition(_positionX + _imageLeft.Width + _textOffsetX, _textOffsetY + _positionY);
                    }

                    _labelControl.TextColor     = dwTextColor;
                    _labelControl.TextAlignment = _textAlignment;
                    _labelControl.Label         = (string)_subItemList[SelectedItem];
                    _labelControl.Width         = _width - (_imageRight.Width + _imageLeft.Width + _textOffsetX);

                    if (_labelControl.Width <= 0)
                    {
                        base.Render(timePassed);
                        return;
                    }
                    _labelControl.Render(timePassed);
                }
            }
            // No, render a normal button
            else
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }

                if (Focus)
                {
                    _imageFocused.Render(timePassed);
                }
                else
                {
                    _imageNonFocused.Render(timePassed);
                }

                if (!string.IsNullOrEmpty(_label) && _font != null)
                {
                    _labelControl.FontName = _font.FontName;

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

                    if (_textAlignment == Alignment.ALIGN_RIGHT)
                    {
                        _labelControl.SetPosition(_positionX + _width - _textOffsetX2, _textOffsetY2 + _positionY);
                    }
                    else
                    {
                        _labelControl.SetPosition(_textOffsetX2 + _positionX, _textOffsetY2 + _positionY);
                    }

                    if (Disabled || _subItemList.Count == 0)
                    {
                        _labelControl.TextColor = _disabledColor;
                    }
                    else
                    {
                        _labelControl.TextColor = Focus ? _textColor : _textColorNoFocus;
                    }
                    _labelControl.TextAlignment = _textAlignment;
                    _labelControl.Label         = _label;
                    _labelControl.Width         = _width - (_imageRight.Width + _imageLeft.Width + _textOffsetX);

                    if (_labelControl.Width <= 0)
                    {
                        base.Render(timePassed);
                        return;
                    }
                    _labelControl.Render(timePassed);
                }
            }
            base.Render(timePassed);
        }
Exemple #7
0
        /// <summary>
        /// Renders the control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (_labelControl == null)
            {
                return;
            }

            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            _isScrolling = false;
            if (_label != null && _label.Length > 0)
            {
                string strText = _label;
                if (_containsProperty)
                {
                    strText = GUIPropertyManager.Parse(strText);
                    if (strText == null)
                    {
                        strText = string.Empty;
                    }
                }

                if (_previousText != strText)
                {
                    _currentLabelIndex = 0;
                    _scrollPosition    = 0;
                    _scrollPosititionX = 0;
                    _scrollOffset      = 0.0f;
                    _currentFrame      = 0;
                    timeElapsed        = 0.0f;
                    _fadeIn            = true && _allowFadeIn;
                    _listLabels.DisposeAndClearList();
                    _previousText = strText;
                    strText       = strText.Replace("\\r", "\r");
                    int ipos = 0;
                    do
                    {
                        ipos = strText.IndexOf("\r");
                        int ipos2 = strText.IndexOf("\n");
                        if (ipos >= 0 && ipos2 >= 0 && ipos2 < ipos)
                        {
                            ipos = ipos2;
                        }
                        if (ipos < 0 && ipos2 >= 0)
                        {
                            ipos = ipos2;
                        }

                        if (ipos >= 0)
                        {
                            string strLine = strText.Substring(0, ipos);
                            if (strLine.Length > 1)
                            {
                                _listLabels.Add(strLine);
                            }
                            if (ipos + 1 >= strText.Length)
                            {
                                break;
                            }
                            strText = strText.Substring(ipos + 1);
                        }
                        else
                        {
                            _listLabels.Add(strText);
                        }
                    } while (ipos >= 0 && strText.Length > 0);
                }
            }
            else
            {
                _listLabels.DisposeAndClearList();
            }
            // if there are no labels do not render
            if (_listLabels.Count == 0)
            {
                base.Render(timePassed);
                return;
            }

            // reset the current label is index is out of bounds
            if (_currentLabelIndex < 0 || _currentLabelIndex >= _listLabels.Count)
            {
                _currentLabelIndex = 0;
            }

            // get the current label
            string strLabel = (string)_listLabels[_currentLabelIndex];

            // Add the wrap string (will be stripped later if not needed).
            // SE: why add here? add later, if label itself is wider than width
            //strLabel += _wrapString;

            _labelControl.Width  = _width;
            _labelControl.Height = _height;
            _labelControl.Label  = strLabel;
            _labelControl.SetPosition(_positionX, _positionY);
            _labelControl.TextAlignment  = _textAlignment;
            _labelControl.TextVAlignment = _textVAlignment;
            _labelControl.TextColor      = _textColor;
            if (_labelControl.TextWidth < _width)
            {
                _labelControl.CacheFont = true;
            }
            else
            {
                _labelControl.CacheFont = false;
            }
            if (GUIGraphicsContext.graphics != null)
            {
                _labelControl.Render(timePassed);
                base.Render(timePassed);
                return;
            }

            // if there is only one label just draw the text
            if (_listLabels.Count == 1)
            {
                if (_labelControl.TextWidth < _width)
                {
                    // Remove the wrap string since we are not scrolling.
                    // SE: not needed since we're adding wrap string later
                    //if (WrapAround())
                    //{
                    //  StripWrapString(_labelControl);
                    //}
                    _labelControl.Render(timePassed);
                    base.Render(timePassed);
                    return;
                }
            }

            strLabel += _wrapString;

            timeElapsed  += timePassed;
            _currentFrame = (int)(timeElapsed / TimeSlice);

            if (_frameLimiter < GUIGraphicsContext.MaxFPS)
            {
                _frameLimiter++;
            }
            else
            {
                _frameLimiter = 1;
            }
            // More than one label
            _isScrolling = true;


            // Make the label fade in
            if (_fadeIn && _allowScrolling)
            {
                long dwAlpha = ((((uint)_textColor) >> 24) * _currentFrame) / 12;
                dwAlpha <<= 24;
                dwAlpha  |= (_textColor & 0x00ffffff);
                _labelControl.TextColor = dwAlpha;

                dwAlpha   = ((((uint)_shadowColor) >> 24) * _currentFrame) / 12;
                dwAlpha <<= 24;
                dwAlpha  |= (_shadowColor & 0x00ffffff);
                _labelControl.ShadowColor = dwAlpha;

                float fwt = 0;
                _labelControl.Label = GetShortenedText(strLabel, _width, ref fwt);
                if (_textAlignment == Alignment.ALIGN_RIGHT)
                {
                    _labelControl.Width = (int)(fwt);
                }
                _labelControl.Render(timePassed);
                if (_currentFrame >= 12)
                {
                    _fadeIn = false;
                }
            }
            else if (_fadeIn && !_allowScrolling)
            {
                _fadeIn = false;
            }
            //no fading
            if (!_fadeIn)
            {
                long color = _textColor;
                if (Dimmed)
                {
                    color &= DimColor;
                }
                if (!_allowScrolling)
                {
                    _currentLabelIndex = 0;
                    _scrollPosition    = 0;
                    _scrollPosititionX = 0;
                    _scrollOffset      = 0.0f;
                    _currentFrame      = 0;
                }
                // render the text
                bool bDone = RenderText(timePassed, (float)_positionX, (float)_positionY, (float)_width, color, strLabel);
                if (bDone)
                {
                    _currentLabelIndex++;
                    _scrollPosition    = 0;
                    _scrollPosititionX = 0;
                    _scrollOffset      = 0.0f;
                    // SE: this looks stupid, don't fade in on each wrap
                    //_fadeIn = true && _allowFadeIn;
                    _currentFrame = 0;
                    // SE: also don't wait on each wrap if not needed
                    if (!WrapAround() || _listLabels.Count > 1)
                    {
                        timeElapsed = 0.0f;
                    }
                    _currentFrame = 0;
                }
            }
            base.Render(timePassed);
        }
Exemple #8
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);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Renders the control.
        /// </summary>
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }


            if (Focus)
            {
                _showSelect = true;
            }
            else
            {
                _showSelect = false;
            }

            //	Are we in selection mode
            if (_showSelect)
            {
                //	Yes, render the select control

                //	render background, left and right arrow

                _imageBackground.Render(timePassed);

                long dwTextColor = Focus ? _textColor : _textColorNoFocus;

                //	User has moved left...
                if (_leftSelected)
                {
                    //	...render focused arrow
                    _startFrame++;
                    if (_autoHide && _startFrame >= 25)
                    {
                        _startFrame   = 0;
                        _leftSelected = false;
                        GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0,
                                                            null);
                        GUIWindowManager.SendThreadMessage(message);
                        _updateNeeded = true;
                    }
                    _imageLeftFocus.Render(timePassed);

                    //	If we are moving left
                    //	render item text as disabled
                    dwTextColor = _disabledColor;
                }
                else
                {
                    //	Render none focused arrow
                    _imageLeft.Render(timePassed);
                }


                //	User has moved right...
                if (_rightSelected)
                {
                    //	...render focused arrow
                    _startFrame++;
                    if (_autoHide && _startFrame >= 25)
                    {
                        _startFrame    = 0;
                        _rightSelected = false;
                        GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0,
                                                            null);
                        GUIWindowManager.SendThreadMessage(message);
                        _updateNeeded = true;
                    }
                    _imageRightFocus.Render(timePassed);

                    //	If we are moving right
                    //	render item text as disabled
                    dwTextColor = _disabledColor;
                }
                else
                {
                    //	Render none focused arrow
                    _imageRight.Render(timePassed);
                }


                //	Render text if a current item is available
                if (SelectedItem >= 0 && null != _font && SelectedItem < _subItemList.Count)
                {
                    _labelControl.FontName = _font.FontName;
                    if (_textAlignment == Alignment.ALIGN_RIGHT)
                    {
                        _labelControl.SetPosition(_positionX + _width - _imageLeft.Width - _textOffsetX, _textOffsetY + _positionY);
                    }
                    else
                    {
                        _labelControl.SetPosition(_positionX + _imageLeft.Width + _textOffsetX, _textOffsetY + _positionY);
                    }

                    _labelControl.TextColor     = dwTextColor;
                    _labelControl.TextAlignment = _textAlignment;
                    _labelControl.Label         = (string)_subItemList[SelectedItem];
                    _labelControl.Width         = _width - (_imageRight.Width + _imageLeft.Width + _textOffsetX);
                    _labelControl.Render(timePassed);
                }

                /*
                 *      //	Select current item, if user doesn't
                 *      //	move left or right for 1.5 sec.
                 *      long dwTicksSpan=DateTime.Now.Ticks-_ticks;
                 *      dwTicksSpan/=10000;
                 *      if ((float)(dwTicksSpan/1000)>0.8f)
                 *      {
                 *        //	User hasn't moved disable selection mode...
                 *        _showSelect=false;
                 *
                 *        //	...and send a thread message.
                 *        //	(Sending a message with SendMessage
                 *        //	can result in a GPF.)
                 *        GUIMessage message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED,WindowId,GetID, ParentID ,0,0,null);
                 *        GUIWindowManager.SendThreadMessage(message);
                 *        _updateNeeded=true;
                 *      }
                 */
            } //	if (_showSelect)
            else
            {
                //	No, render a normal button

                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }

                if (Focus)
                {
/*
 *        int dwAlphaCounter = _frameCounter+2;
 *        int dwAlphaChannel;
 *        if ((dwAlphaCounter%128)>=64)
 *          dwAlphaChannel = dwAlphaCounter%64;
 *        else
 *          dwAlphaChannel = 63-(dwAlphaCounter%64);
 *
 *        dwAlphaChannel += 192;
 *        SetAlpha(dwAlphaChannel );
 *        _imageFocused.IsVisible=true;
 *        _imageNonFocused.IsVisible=false;
 *        _frameCounter++;*/
                    _imageFocused.Render(timePassed);
                }
                else
                {
                    //SetAlpha(0xff);
                    _imageNonFocused.Render(timePassed);
                }

                if (_label != null && _label.Length > 0 && _font != null)
                {
                    _labelControl.FontName = _font.FontName;
                    if (_textAlignment == Alignment.ALIGN_RIGHT)
                    {
                        _labelControl.SetPosition(_positionX + _width - _textOffsetX2, _textOffsetY2 + _positionY);
                    }
                    else
                    {
                        _labelControl.SetPosition(_textOffsetX2 + _positionX, _textOffsetY2 + _positionY);
                    }

                    if (Disabled || _subItemList.Count == 0)
                    {
                        _labelControl.TextColor = _disabledColor;
                    }
                    else
                    {
                        _labelControl.TextColor = Focus ? _textColor : _textColorNoFocus;
                    }
                    _labelControl.TextAlignment = _textAlignment;
                    _labelControl.Label         = _label;
                    _labelControl.Render(timePassed);
                }
            }
            base.Render(timePassed);
        }