Exemplo n.º 1
0
        /// <summary>
        /// Sets the button's image.
        /// </summary>
        /// <param name="textureName">Texture name. Null to remove.</param>
        /// <param name="center">Determines whether the image should be centered.</param>
        public virtual void SetImage(string textureName, bool center = false)
        {
            if (String.IsNullOrEmpty(textureName))
            {
                if (image != null)
                {
                    image.Dispose();
                }
                image = null;
                return;
            }

            if (image == null)
            {
                image = new ImagePanel(this);
            }

            image.ImageName = textureName;
            image.SizeToContents( );
            image.SetPosition(Math.Max(Padding.Left, 2), 2);
            image.KeyboardInputEnabled = false;
            image.MouseInputEnabled    = false;
            centerImage = center;

            TextPadding = new Padding(image.Right + 2, TextPadding.Top, TextPadding.Right, TextPadding.Bottom);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the button's image.
        /// </summary>
        /// <param name="textureName">Texture name. Null to remove.</param>
        /// <param name="center">Determines whether the image should be centered.</param>
        public virtual void SetImage(String textureName, bool center = false)
        {
            if (String.IsNullOrEmpty(textureName))
            {
                if (m_Image != null)
                {
                    m_Image.Dispose();
                }
                m_Image = null;
                return;
            }

            if (m_Image == null)
            {
                m_Image = new ImagePanel(this);
            }

            m_Image.ImageName = textureName;
            m_Image.SizeToContents( );
            m_Image.SetPosition(Math.Max(Padding.Left, 2), 2);
            m_CenterImage = center;

            TextPadding = new Padding(m_Image.Right + 2, TextPadding.Top, TextPadding.Right, TextPadding.Bottom);
        }