Ejemplo n.º 1
0
        public void Render(double dTime)
        {
            int lTime = (int)(1000.0d * dTime);

            foreach (Line line in m_subs)
            {
                if (lTime >= line.StartTime && lTime <= line.EndTime)
                {
                    if (m_font != null)
                    {
                        try
                        {
                            float fw = 0, fh = 0;
                            m_font.GetTextExtent(line.Text, ref fw, ref fh);
                            int iposx = (GUIGraphicsContext.OverScanWidth - (int)fw) / 2;
                            int iposy = (GUIGraphicsContext.Subtitles - (int)fh);
                            m_font.DrawShadowText((float)iposx, (float)iposy, m_iColor, line.Text, GUIControl.Alignment.ALIGN_LEFT,
                                                  (int)fw, m_iShadow, m_iShadow, 0xff000000);
                        }
                        catch (Exception) {}
                    }
                }
                if (line.StartTime > lTime)
                {
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        // Wraps the calls to the GUIFont.  This provides opportunity to shadow the text if requested.
        public void DrawText(float xpos, float ypos, string label, int width)
        {
            long c = _textColor;

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

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

                GUIGraphicsContext.BeginClip(clipRect);
                _font.DrawTextEx(xpos, ypos, c, label, ref _context, width);
                GUIGraphicsContext.EndClip();
            }
        }
Ejemplo n.º 3
0
        // Wraps the calls to the GUIFont.  This provides opportunity to shadow the text if requested.
        public void DrawText(float xpos, float ypos, string label, int width)
        {
            long c = (uint)_textColor;

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

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

                _font.DrawShadowText(xpos, ypos, c, label, Alignment.ALIGN_LEFT, width, _shadowAngle, _shadowDistance, sc);
            }
            else
            {
                _font.DrawTextEx(xpos, ypos, c, label, ref _context, width);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Renders the GUICheckMarkControl.
        /// </summary>
        public override void Render(float timePassed)
        {
            // Do not render if not visible.
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }

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

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

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

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

            // Render the selected checkmark image
            if (_isSelected)
            {
                _imageCheckMarkFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkFocused.Render(timePassed);
            }
            else
            {
                // Render the non-selected checkmark image
                _imageCheckMarkNonFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkNonFocused.Render(timePassed);
            }
            base.Render(timePassed);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Renders the GUICheckMarkControl.
        /// </summary>
        public override void Render(float timePassed)
        {
            // Do not render if not visible.
            if (GUIGraphicsContext.EditMode == false)
            {
                if (!IsVisible)
                {
                    base.Render(timePassed);
                    return;
                }
            }
            if (Focus)
            {
                GUIPropertyManager.SetProperty("#highlightedbutton", _label);
            }
            int dwTextPosX      = _positionX;
            int dwCheckMarkPosX = _positionX;

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

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

            // Render the selected checkmark image
            if (_isSelected)
            {
                _imageCheckMarkFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkFocused.Render(timePassed);
            }
            else
            {
                // Render the non-selected checkmark image
                _imageCheckMarkNonFocused.SetPosition(dwCheckMarkPosX, _positionY);
                _imageCheckMarkNonFocused.Render(timePassed);
            }
            base.Render(timePassed);
        }