Parse() public static method

Parses a property request.
public static Parse ( string line ) : string
line string
return string
示例#1
0
 public override void Render(float timePassed)
 {
     if (!IsVisible)
     {
         base.Render(timePassed);
         return;
     }
     if (_tagLine != string.Empty)
     {
         string percent = GUIPropertyManager.Parse(_tagLine);
         Double perc;
         if (Double.TryParse(percent, out perc))
         {
             Percentage = (int)(Math.Round(perc) * 10d);
         }
         else
         {
             Percentage = 0;
         }
     }
     if (_orientation == eOrientation.Horizontal)
     {
         RenderHorizontal(timePassed);
     }
     else
     {
         RenderVertical(timePassed);
     }
     base.Render(timePassed);
 }
示例#2
0
 public override void Render(float timePassed)
 {
     if (!IsVisible)
     {
         base.Render(timePassed);
         return;
     }
     if (_tagLine != string.Empty)
     {
         string percent = GUIPropertyManager.Parse(_tagLine);
         try
         {
             Percentage = (int)(Math.Round(Double.Parse(percent)) * 10d);
         }
         catch (Exception) {}
     }
     if (_orientation == eOrientation.Horizontal)
     {
         RenderHorizontal(timePassed);
     }
     else
     {
         RenderVertical(timePassed);
     }
     base.Render(timePassed);
 }
        public override void OnAction(Action action)
        {
            base.OnAction(action);
            if (Focus)
            {
                if (action.wID == Action.ActionType.ACTION_MOUSE_CLICK || action.wID == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    _isSelected = !_isSelected;

                    // If this button has a click setting then execute the setting.
                    if (_onclick.Length != 0)
                    {
                        GUIPropertyManager.Parse(_onclick, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS);
                    }

                    if (_hyperLinkWindowId >= 0)
                    {
                        GUIWindowManager.ActivateWindow(_hyperLinkWindowId);
                        return;
                    }
                    // button selected.
                    // send a message
                    int iParam = 1;
                    if (!_isSelected)
                    {
                        iParam = 0;
                    }
                    var message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, iParam, 0, null);
                    GUIGraphicsContext.SendMessage(message);
                }
            }
        }
        /// <summary>
        /// OnAction() method. This method gets called when there's a new action like a
        /// keypress or mousemove or... By overriding this method, the control can respond
        /// to any action
        /// </summary>
        /// <param name="action">action : contains the action</param>
        public override void OnAction(Action action)
        {
            GUIMessage message;

            if (Focus)
            {
                if (action.wID == Action.ActionType.ACTION_MOUSE_CLICK || action.wID == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    // send a message to anyone interested
                    message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
                    GUIGraphicsContext.SendMessage(message);

                    // If this button has a click setting then execute the setting.
                    if (_onclick.Length != 0)
                    {
                        GUIPropertyManager.Parse(_onclick, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS);
                    }
                }
            }

            // Allow the spin control to handle actions first.
            _spinControl.OnAction(action);

            // If the spin control handled the action then avoid the base action handler.
            // In particular this avoids the move up,down,left,right actions from leaving this control too soon.
            if (!_spinControl.ActionHandled)
            {
                base.OnAction(action);
            }
        }
示例#5
0
        private void CachedLabel()
        {
            string v;


            if (_containsProperty)
            {
                v = GUIPropertyManager.Parse(_labelText);
                if (v == null)
                {
                    v = String.Empty;
                }
            }
            else
            {
                v = _labelText;
            }
            if (v != _cachedTextLabel)
            {
                _textwidth       = 0;
                _textheight      = 0;
                _reCalculate     = true;
                _cachedTextLabel = v;
                _context         = null;
            }
        }
        /// <summary>
        /// OnAction() method. This method gets called when there's a new action like a
        /// keypress or mousemove or... By overriding this method, the control can respond
        /// to any action
        /// </summary>
        /// <param name="action">action : contains the action</param>
        public override void OnAction(Action action)
        {
            base.OnAction(action);
            if (Focus)
            {
                if (action.wID == Action.ActionType.ACTION_MOUSE_CLICK || action.wID == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    // If this control does not have a "selected" setting then toggle the value.  The value of _selected (when used) is
                    // determined and set in each render pass based on a condition (value of a property or skin setting).
                    if (_selected.Length == 0)
                    {
                        _isSelected = !_isSelected;
                    }

                    // Send a message that the checkbox was clicked.
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID,
                                                    (int)action.wID, 0, null);
                    GUIGraphicsContext.SendMessage(msg);

                    // If this button has a click setting then execute the setting.
                    if (_onclick.Length != 0)
                    {
                        GUIPropertyManager.Parse(_onclick, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS);
                    }
                }
            }
        }
        /// <summary>
        /// Renders the GUICheckMarkControl.
        /// </summary>
        public override void Render(float timePassed)
        {
            // Do not render if not visible.
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

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

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

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

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

            // Render the selected checkmark image
            if (_isSelected)
            {
                _imageCheckMarkFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkFocused.Render(timePassed);
            }
            else
            {
                // Render the non-selected checkmark image
                _imageCheckMarkNonFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkNonFocused.Render(timePassed);
            }
            base.Render(timePassed);
        }
示例#8
0
        public override void Render(float timePassed)
        {
            if (null == _font)
            {
                return;
            }
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

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

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

                    _previousProperty = strText;
                    SetText(strText);
                }
            }

            int dwPosY = _positionY;

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

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

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

                if (iPages > 1)
                {
                    _upDownControl.Render(timePassed);
                }
            }
            base.Render(timePassed);
        }
示例#9
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);
        }
        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);
        }
示例#12
0
        /// <summary>
        /// OnAction() method. This method gets called when there's a new action like a
        /// keypress or mousemove or... By overriding this method, the control can respond
        /// to any action
        /// </summary>
        /// <param name="action">action : contains the action</param>
        public override void OnAction(Action action)
        {
            base.OnAction(action);
            if (Focus)
            {
                if (action.wID == Action.ActionType.ACTION_MOUSE_CLICK || action.wID == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    // If this button does not have a "selected" setting then toggle the value.  The value of _selected (when used) is
                    // determined and set in each render pass based on a condition (value of a property or skin setting).
                    if (_selected.Length == 0)
                    {
                        Selected = !Selected;
                    }

                    // send a message to anyone interested
                    var message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
                    GUIGraphicsContext.SendMessage(message);

                    // If this button has a click setting then execute the setting.
                    if (_onclick.Length != 0)
                    {
                        GUIPropertyManager.Parse(_onclick, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS);
                    }

                    // If this button contains scriptactions call the scriptactions.
                    if (_application.Length != 0)
                    {
                        //button should start an external application, so start it
                        var proc = new Process();

                        string strWorkingDir = Path.GetFullPath(_application);
                        string strFileName   = Path.GetFileName(_application);
                        if (strFileName != null)
                        {
                            strWorkingDir           = strWorkingDir.Substring(0, strWorkingDir.Length - (strFileName.Length + 1));
                            proc.StartInfo.FileName = strFileName;
                        }
                        proc.StartInfo.WorkingDirectory = strWorkingDir;
                        proc.StartInfo.Arguments        = _arguments;
                        proc.StartInfo.WindowStyle      = ProcessWindowStyle.Minimized;
                        proc.StartInfo.CreateNoWindow   = true;
                        proc.Start();
                        //proc.WaitForExit();
                    }

                    // If this links to another window go to the window.
                    if (_hyperLinkWindowId >= 0)
                    {
                        GUIWindowManager.ActivateWindow(_hyperLinkWindowId);
                        return;
                    }
                    // If this button corresponds to an action generate that action.
                    if (ActionID >= 0)
                    {
                        var newaction = new Action((Action.ActionType)ActionID, 0, 0);
                        GUIGraphicsContext.OnAction(newaction);
                        return;
                    }

                    // button selected.
                    if (SubItemCount > 0)
                    {
                        // if we got subitems, then change the label of the control to the next
                        //subitem
                        SelectedItem++;
                        if (SelectedItem >= SubItemCount)
                        {
                            SelectedItem = 0;
                        }
                        Label = (string)GetSubItem(SelectedItem);
                    }
                }
            }
        }
示例#13
0
        /// <summary>
        /// OnAction() method. This method gets called when there's a new action like a
        /// keypress or mousemove or... By overriding this method, the control can respond
        /// to any action
        /// </summary>
        /// <param name="action">action : contains the action</param>
        public override void OnAction(Action action)
        {
            GUIMessage message;

            if (!_showSelect)
            {
                if (Focus)
                {
                    if (action.wID == Action.ActionType.ACTION_MOUSE_CLICK || action.wID == Action.ActionType.ACTION_SELECT_ITEM)
                    {
                        //	Enter selection mode
                        _showSelect = true;

                        //	Start timer, if user doesn't select an item
                        //	or moves left/right. The control will
                        //	automatically select the current item.
                        _ticks = DateTime.Now.Ticks;

                        // If this button has a click setting then execute the setting.
                        if (_onclick.Length != 0)
                        {
                            GUIPropertyManager.Parse(_onclick, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS);
                        }

                        return;
                    }
                }
            }
            else
            {
                if (action.wID == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
                    GUIWindowManager.SendThreadMessage(msg);
                    return;
                }
                if (action.wID == Action.ActionType.ACTION_MOUSE_CLICK)
                {
                    if (_rightSelected)
                    {
                        action.wID = Action.ActionType.ACTION_MOVE_RIGHT;
                        OnAction(action);
                        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0,
                                                        null);
                        GUIWindowManager.SendThreadMessage(msg);
                        _updateNeeded = true;
                        return;
                    }
                    else if (_leftSelected)
                    {
                        action.wID = Action.ActionType.ACTION_MOVE_LEFT;
                        OnAction(action);
                        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0,
                                                        null);
                        GUIWindowManager.SendThreadMessage(msg);
                        _updateNeeded = true;
                        return;
                    }
                    else
                    {
                        //	User has selected an item, disable selection mode...
                        _showSelect = false;

                        // ...and send a message.
                        message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
                        GUIGraphicsContext.SendMessage(message);
                        return;
                    }
                }
                else if (action.wID == Action.ActionType.ACTION_MOVE_LEFT)
                {
                    //	Set for visual feedback
                    _leftSelected  = true;
                    _rightSelected = false;
                    _startFrame    = 0;

                    //	Reset timer for automatically selecting
                    //	the current item.
                    _ticks = DateTime.Now.Ticks;

                    //	Switch to previous item
                    if (_subItemList.Count > 0)
                    {
                        SelectedItem--;
                        if (SelectedItem < 0)
                        {
                            SelectedItem = _subItemList.Count - 1;
                        }

                        if (CaptionChanged != null)
                        {
                            CaptionChanged(this, EventArgs.Empty);
                        }
                    }
                    return;
                }
                else if (action.wID == Action.ActionType.ACTION_MOVE_RIGHT)
                {
                    //	Set for visual feedback
                    _rightSelected = true;
                    _leftSelected  = false;
                    _startFrame    = 0;

                    //	Reset timer for automatically selecting
                    //	the current item.
                    _ticks = DateTime.Now.Ticks;

                    //	Switch to next item
                    if (_subItemList.Count > 0)
                    {
                        SelectedItem++;
                        if (SelectedItem >= (int)_subItemList.Count)
                        {
                            SelectedItem = 0;
                        }

                        if (CaptionChanged != null)
                        {
                            CaptionChanged(this, EventArgs.Empty);
                        }
                    }
                    return;
                }
                if (action.wID == Action.ActionType.ACTION_MOVE_UP || action.wID == Action.ActionType.ACTION_MOVE_DOWN)
                {
                    //	Disable selection mode when moving up or down
                    _showSelect = false;
                    if (_resetSelectionAfterFocusLost)
                    {
                        SelectedItem = _defaultItem;
                    }
                }
            }

            base.OnAction(action);

            if (Focus)
            {
                if (action.wID == Action.ActionType.ACTION_MOUSE_CLICK || action.wID == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    if (_scriptAction.Length > 0)
                    {
                        message       = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
                        message.Label = _scriptAction;
                        //g_actionManager.CallScriptAction(message); // TODO!
                    }

                    if (_hyperLinkWindowId >= 0)
                    {
                        GUIWindowManager.ActivateWindow((int)_hyperLinkWindowId);
                        return;
                    }
                    // button selected.
                    // send a message
                    message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
                    GUIGraphicsContext.SendMessage(message);
                }
            }
        }
示例#14
0
        /// <summary>
        /// OnAction() method. This method gets called when there's a new action like a
        /// keypress or mousemove or... By overriding this method, the control can respond
        /// to any action
        /// </summary>
        /// <param name="action">action : contains the action</param>
        public override void OnAction(Action action)
        {
            if (Focus)
            {
                switch (action.wID)
                {
                case Action.ActionType.ACTION_MOVE_DOWN:
                    _keepLook = _keepLookOnDown;
                    break;

                case Action.ActionType.ACTION_MOVE_UP:
                    _keepLook = _keepLookOnUp;
                    break;

                case Action.ActionType.ACTION_MOVE_LEFT:
                    _keepLook = _keepLookOnLeft;
                    break;

                case Action.ActionType.ACTION_MOVE_RIGHT:
                    _keepLook = _keepLookOnRight;
                    break;
                }
            }

            base.OnAction(action);

            if (Focus)
            {
                if (action.wID == Action.ActionType.ACTION_MOUSE_CLICK || action.wID == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    // If this button has a click setting then execute the setting.
                    if (_onclick.Length != 0)
                    {
                        GUIPropertyManager.Parse(_onclick, GUIExpressionManager.ExpressionOptions.EVALUATE_ALWAYS);
                    }

                    if (ContextMenu != null)
                    {
                        DoContextMenu();
                        return;
                    }

                    // If this button contains scriptactions call the scriptactions.
                    if (_application.Length != 0)
                    {
                        //button should start an external application, so start it
                        Process proc = new Process();

                        string workingFolder = Path.GetFullPath(_application);
                        string fileName      = Path.GetFileName(_application);
                        if (fileName != null)
                        {
                            workingFolder           = workingFolder.Substring(0, workingFolder.Length - (fileName.Length + 1));
                            proc.StartInfo.FileName = fileName;
                        }
                        proc.StartInfo.WorkingDirectory = workingFolder;
                        proc.StartInfo.Arguments        = _arguments;
                        proc.StartInfo.WindowStyle      = ProcessWindowStyle.Minimized;
                        proc.StartInfo.CreateNoWindow   = true;
                        proc.Start();
                        //proc.WaitForExit();
                    }

                    // If this links to another window go to the window.
                    if (_hyperLinkWindowId >= 0)
                    {
                        if (_hyperLinkParameter != null && !_hyperLinkParameter.Equals(""))
                        {
                            // The link also contains a parameter that we want to pass to the plugin
                            GUIWindowManager.ActivateWindow(_hyperLinkWindowId, GUIPropertyManager.Parse(_hyperLinkParameter),
                                                            !_addToHistory);
                        }
                        else
                        {
                            GUIWindowManager.ActivateWindow(_hyperLinkWindowId, !_addToHistory);
                        }
                        return;
                    }
                    // If this button corresponds to an action generate that action.
                    if (ActionID >= 0)
                    {
                        Action newaction = new Action((Action.ActionType)ActionID, 0, 0);
                        GUIGraphicsContext.OnAction(newaction);
                        return;
                    }

                    // button selected.
                    if (SubItemCount > 0)
                    {
                        // if we got subitems, then change the label of the control to the next
                        //subitem
                        SelectedItem++;
                        if (SelectedItem >= SubItemCount)
                        {
                            SelectedItem = 0;
                        }
                        Label = (string)GetSubItem(SelectedItem);
                    }

                    // send a message to anyone interested
                    var message = new GUIMessage(GUIMessage.MessageType.GUI_MSG_CLICKED, WindowId, GetID, ParentID, 0, 0, null);
                    GUIGraphicsContext.SendMessage(message);
                }
            }
        }
示例#15
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);
        }
示例#16
0
        public override void Render(float timePassed)
        {
            try
            {
                _invalidate = false;
                // Nothing visibile - save CPU cycles
                if (null == _font)
                {
                    base.Render(timePassed);
                    return;
                }
                if (GUIGraphicsContext.EditMode == false)
                {
                    if (!IsVisible)
                    {
                        base.Render(timePassed);
                        return;
                    }
                }

                int dwPosY = _positionY;

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

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

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

                    _previousProperty = strText;
                    SetText(strText);
                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                int dwPosY = _positionY;

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

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

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

                        _previousProperty = strText;
                        SetText(strText);
                    }
                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if (GUIGraphicsContext.graphics != null)
                {
                    GUIGraphicsContext.graphics.SetClip(new Rectangle(0, 0, GUIGraphicsContext.Width, GUIGraphicsContext.Height));
                }
                else
                {
                    GUIGraphicsContext.EndClip();
                }
                base.Render(timePassed);
            }
            catch (Exception ex)
            {
                Log.Error("GUITextScrollUpControl: Error during the render process - maybe a threading issue. {0}",
                          ex.ToString());
            }
        }
        public override void FinalizeConstruction()
        {
            base.FinalizeConstruction();
            if (_topTextureName == null)
            {
                _topTextureName = string.Empty;
            }
            if (_bottomTextureName == null)
            {
                _bottomTextureName = string.Empty;
            }
            if (_leftTextureName == null)
            {
                _leftTextureName = string.Empty;
            }
            if (_midTextureName == null)
            {
                _midTextureName = string.Empty;
            }
            if (_rightTextureName == null)
            {
                _rightTextureName = string.Empty;
            }
            if (_tickTextureName == null)
            {
                _tickTextureName = string.Empty;
            }
            if (_tickFill1TextureName == null)
            {
                _tickFill1TextureName = string.Empty;
            }
            if (_tickFill2TextureName == null)
            {
                _tickFill2TextureName = string.Empty;
            }
            if (_tickFill3TextureName == null)
            {
                _tickFill3TextureName = string.Empty;
            }
            if (_markerTextureName == null)
            {
                _markerTextureName = string.Empty;
            }
            if (_fillBackGroundTextureName == null)
            {
                _fillBackGroundTextureName = string.Empty;
            }
            if (_logoTextureName == null)
            {
                _logoTextureName = string.Empty;
            }
            _imageTop    = LoadAnimationControl(_parentControlId, _controlId, 0, 0, 0, 0, _topTextureName);
            _imageBottom = LoadAnimationControl(_parentControlId, _controlId, 0, 0, 0, 0, _bottomTextureName);
            _imageLeft   = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, 0, 0, _leftTextureName);
            _imageMid    = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, 0, 0, _midTextureName);
            _imageRight  = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, 0, 0, _rightTextureName);
            _imageTick   = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, 0, 0, _tickTextureName);
            _imageFill1  = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, 0, 0,
                                                _tickFill1TextureName);
            _imageFill2 = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, 0, 0,
                                               _tickFill2TextureName);
            _imageFill3 = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, 0, 0,
                                               _tickFill3TextureName);
            _imageFillBackground                 = LoadAnimationControl(_parentControlId, _controlId, 0, 0, 0, 0, _fillBackGroundTextureName);
            _imageTop.KeepAspectRatio            = false;
            _imageBottom.KeepAspectRatio         = false;
            _imageMid.KeepAspectRatio            = false;
            _imageRight.KeepAspectRatio          = false;
            _imageTick.KeepAspectRatio           = false;
            _imageFill1.KeepAspectRatio          = false;
            _imageFill2.KeepAspectRatio          = false;
            _imageFill3.KeepAspectRatio          = false;
            _imageFillBackground.KeepAspectRatio = false;

            _imageTop.ParentControl            = this;
            _imageBottom.ParentControl         = this;
            _imageMid.ParentControl            = this;
            _imageRight.ParentControl          = this;
            _imageTick.ParentControl           = this;
            _imageFill1.ParentControl          = this;
            _imageFill2.ParentControl          = this;
            _imageFill3.ParentControl          = this;
            _imageFillBackground.ParentControl = this;
            _imageLogo = LoadAnimationControl(_parentControlId, _controlId, 0, 0, 0, 0, _logoTextureName);
            _imageLogo.ParentControl = this;
            FontName = _fontName;

            //create an image for the markers that we will move around and render as needed.
            string strText = GUIPropertyManager.Parse(LabelMarkerStarts);

            if (strText.Length > 0)
            {
                _imageFillMarker = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, 0, 0,
                                                        _markerTextureName);
                _imageFillMarker.KeepAspectRatio = false;
                _imageFillMarker.ParentControl   = this;
            }
        }
示例#19
0
        /// <summary>
        /// Renders the GUICheckButton.
        /// </summary>
        public override void Render(float timePassed)
        {
            string labelText = _label;

            // Do not render if not visible.
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

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

            // 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 (_textPadding > 0)
            {
                labelWidth -= GUIGraphicsContext.ScaleHorizontal(_textPadding);
            }

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

            // render the text on the button
            if (_labelControl is GUILabelControl)
            {
                ((GUILabelControl)_labelControl).TextAlignment  = _textAlignment;
                ((GUILabelControl)_labelControl).TextVAlignment = _textVAlignment;
                ((GUILabelControl)_labelControl).Label          = labelText;
                ((GUILabelControl)_labelControl).TextColor      = Disabled ? _disabledColor : Focus?_textColor : _textColorNoFocus;
            }
            else
            {
                ((GUIFadeLabel)_labelControl).TextAlignment  = _textAlignment;
                ((GUIFadeLabel)_labelControl).TextVAlignment = _textVAlignment;
                ((GUIFadeLabel)_labelControl).Label          = labelText;
                ((GUIFadeLabel)_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);
        }
示例#20
0
        public override void Render(float timePassed)
        {
            if (!IsVisible)
            {
                base.Render(timePassed);
                return;
            }

            if (_containsProperty && _propertyChanged)
            {
                _propertyChanged = false;
                _newPath         = GUIPropertyManager.Parse(_texturePath);

                if (_cachedPath != _newPath)
                {
                    if (_newPath == null)
                    {
                        _newPath = "";
                    }
                    _cachedPath = _newPath;
                }

                if (_cachedPath == null)
                {
                    base.Render(timePassed);
                    return;
                }

                if (_cachedPath.IndexOf("#", StringComparison.Ordinal) >= 0)
                {
                    base.Render(timePassed);
                    return;
                }

                Dispose();
                LoadDirectory();
            }

            if (!_isAllocated)
            {
                AllocResources();
            }

            if (_imageList.Count != 0)
            {
                _imageList[_currentImage].Render(timePassed);

                int nextImage = _currentImage + 1;
                if (nextImage >= _imageList.Count)
                {
                    nextImage = _loop ? 0 : _currentImage; // stay on the last image if <loop>no</loop>
                }

                if (nextImage != _currentImage)
                {
                    // check if we should be loading a new image yet
                    if (_imageTimer.IsRunning && _imageTimer.ElapsedMilliseconds > _timePerImage)
                    {
                        // load image in a worker thread
                        ThreadPool.QueueUserWorkItem(delegate
                        {
                            try
                            {
                                _imageTimer.Stop();
                                LoadImage(nextImage);
                                _fadeTimer.StartZero();
                            }
                            catch (Exception ex)
                            {
                                Log.Error("GUIMultiImage - error loading next image: {0}", ex.Message);
                            }
                        });
                    }

                    // check if we are still fading
                    if (_fadeTimer.IsRunning)
                    {
                        // check if the fade timer has run out
                        float timeFading = _fadeTimer.ElapsedMilliseconds;
                        if (timeFading > _fadeTime)
                        {
                            _fadeTimer.Stop();
                            // swap images
                            _imageList[_currentImage].SafeDispose();
                            _imageList[nextImage].ColourDiffuse = (_imageList[nextImage].ColourDiffuse | 0xff000000);
                            _currentImage = nextImage;
                            // start the load timer
                            _imageTimer.StartZero();
                        }
                        else
                        {
                            // perform the fade
                            float fadeAmount = timeFading / _fadeTime;
                            long  alpha      = (int)(255 * fadeAmount);
                            alpha <<= 24;
                            alpha  += (_imageList[nextImage].ColourDiffuse & 0x00ffffff);
                            _imageList[nextImage].ColourDiffuse = alpha;
                        }
                        _imageList[nextImage].Render(timePassed);
                    }
                }
            }
            base.Render(timePassed);
        }
        public override void Render(float timePassed)
        {
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
                if (Disabled)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            if (_propertyLabel.Length > 0)
            {
                string m_strText = GUIPropertyManager.Parse(_propertyLabel);
                if (m_strText.Length > 0 && !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);
        }
示例#22
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);
        }