コード例 #1
0
        /// <summary>
        /// Draws the element on the given graphics
        /// </summary>
        /// <param name="graph">Graphics</param>
        public override void DrawElement(Graphics graph)
        {
            if (_wasVisible)
            {
                GUIControl.Alignment alignment = _label.TextAlignment;
                RectangleF           rectangle;
                String text  = GUIPropertyManager.Parse(_label.Label);
                SizeF  sizeF = graph.MeasureString(text, _font);

                int xFromAnim = 0;
                int yFromAnim = 0;
                foreach (VisualEffect effect in _label.Animations)
                {
                    if (effect.CurrentState != AnimationState.None && effect.Effect == EffectType.Slide && (effect.Condition == 0 || GUIInfoManager.GetBool(effect.Condition, 0)))
                    {
                        xFromAnim += (int)effect.EndX;
                        yFromAnim += (int)effect.EndY;
                    }
                }
                int x = _label.XPosition + xFromAnim;
                int y = _label.YPosition + yFromAnim;

                if (alignment == GUIControl.Alignment.ALIGN_LEFT)
                {
                    //rectangle = new RectangleF(_label.XPosition, _label.YPosition, _label._width, Math.Max(sizeF.Height, _label._height));
                    rectangle = new RectangleF(x, y, _label._width, Math.Max(sizeF.Height, _label._height));
                }
                else
                {
                    //rectangle = alignment == GUIControl.Alignment.ALIGN_RIGHT ? new RectangleF((float)_label.Location.X - sizeF.Width, (float)_label.Location.Y, _label.Width, Math.Max(sizeF.Height, _label.Height)) : new RectangleF((float)_label.Location.X - (sizeF.Width / 2), (float)_label.Location.Y - (sizeF.Height / 2), _label.Width, Math.Max(sizeF.Height, _label.Height));
                    rectangle = alignment == GUIControl.Alignment.ALIGN_RIGHT ? new RectangleF((float)x - sizeF.Width, (float)y, _label.Width, Math.Max(sizeF.Height, _label.Height)) : new RectangleF((float)x - (sizeF.Width / 2), (float)y - (sizeF.Height / 2), _label.Width, Math.Max(sizeF.Height, _label.Height));
                }
                graph.DrawString(text, _font, _brush, rectangle, StringFormat.GenericTypographic);
            }
        }
コード例 #2
0
 /// <summary>
 /// Creates the element and retrieves all information from the control
 /// </summary>
 /// <param name="control">GUIControl</param>
 public VolumeBarElement(GUIControl control)
   : base(control)
 {
   _volumeBar = control as GUIVolumeBar;
   if (_volumeBar != null)
   {
     _alignment = _volumeBar.TextAlignment;
     _bitmap = loadBitmap(_volumeBar.TextureName);
     _image1 = _volumeBar.Image1;
     _image2 = _volumeBar.Image2;
     _maximum = _volumeBar.Maximum;
     _current = _volumeBar.Current;
   }
 }
コード例 #3
0
 /// <summary>
 /// Creates the element and retrieves all information from the control
 /// </summary>
 /// <param name="control">GUIControl</param>
 public VolumeBarElement(GUIControl control)
     : base(control)
 {
     _volumeBar = control as GUIVolumeBar;
     if (_volumeBar != null)
     {
         _alignment = _volumeBar.TextAlignment;
         _bitmap    = loadBitmap(_volumeBar.TextureName);
         _image1    = _volumeBar.Image1;
         _image2    = _volumeBar.Image2;
         _maximum   = _volumeBar.Maximum;
         _current   = _volumeBar.Current;
     }
 }
コード例 #4
0
        /// <summary>
        /// Returns the rectangle for the given label
        /// </summary>
        /// <param name="graph">Graphics</param>
        /// <param name="label">Label</param>
        /// <returns>Rectangle</returns>
        public RectangleF GetStringRectangle(Graphics graph, String label)
        {
            GUIControl.Alignment alignment = _label.TextAlignment;
            SizeF      size = graph.MeasureString(label, _font);
            RectangleF rectangle;

            if (alignment == GUIControl.Alignment.ALIGN_LEFT)
            {
                rectangle = new RectangleF((float)_label.Location.X, (float)_label.Location.Y, size.Width, _label.Height);
            }
            else
            {
                rectangle = alignment == GUIControl.Alignment.ALIGN_RIGHT ? new RectangleF((float)_label.Location.X - size.Width, (float)_label.Location.Y, size.Width, _label.Height) : new RectangleF((float)_label.Location.X - (size.Width / 2), (float)_label.Location.Y - (size.Height / 2), size.Width, _label.Height);
            }

            return(rectangle);
        }
コード例 #5
0
        /// <summary>
        /// Draws the element in its standard way
        /// </summary>
        /// <param name="graph">Graphics</param>
        /// <param name="label">Label</param>
        private void DrawStandard(Graphics graph, String label)
        {
            GUIControl.Alignment alignment = _label.TextAlignment;
            RectangleF           rectangle;

            switch (_label.TextAlignment)
            {
            case GUIControl.Alignment.ALIGN_CENTER:
                rectangle = new RectangleF((float)_label.Location.X + ((_label.Width - _label.TextWidth) / 2), (float)_label.Location.Y + ((_label.Height - _label.TextHeight) / 2), _label.Width, _label.Height);
                break;

            case GUIControl.Alignment.ALIGN_RIGHT:
                rectangle = new RectangleF((float)_label.Location.X - _label.TextWidth, (float)_label.Location.Y, _label.Width, _label.Height);
                break;

            default: //left
                rectangle = new RectangleF((float)_label.Location.X, (float)_label.Location.Y, _label.Width, _label.Height);
                break;
            }
            DrawElementAlternative(graph, label, false, rectangle);
        }