Click here to Skip to main content
15,883,883 members
Articles / Mobile Apps

Windows Mobile - Attractive UI: Part I

Rate me:
Please Sign up or sign in to vote.
4.92/5 (11 votes)
17 Sep 2009GPL32 min read 50.8K   1K   39  
Windows Mobile - attractive UI (description about AlphaMobilecontrols).
using System.Drawing;


namespace AlphaMobileControls
{
    /// <summary>
    /// Simple Alpha Label control.
    /// </summary>
    public class AlphaLabel : AlphaControl
    {
        private bool _border;

        public StringAlignment Allign { get; set; }

        /// <summary>
        /// Active or not a thin border around this label.
        /// </summary>
        public bool Border
        {
            get { return _border; }
            set
            {
                if (_border == value)
                    return;
                _border = value;
                Refresh();
            }
        }


        #region AlphaControl Members

        /// <summary>
        /// Draws the label.
        /// </summary>
        public override void Draw(Graphics gx)
        {
            Rectangle rect =
                new Rectangle(this.Bounds.X, this.Bounds.Y, this.Bounds.Width - 1, this.Bounds.Height - 1);

            // Draw the border
            if (_border)
            {
                Pen pen = new Pen(this.ForeColor);
                gx.DrawRectangle(pen, rect);
            }

            // Specify a rectangle to activate the line wrapping
            rect.Inflate(-4, -2);
            SolidBrush brush = new SolidBrush(this.ForeColor);
            StringFormat format = new StringFormat();
            format.Alignment = Allign;
            gx.DrawString(this.Text, this.Font, brush, rect, format);
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Technical Lead
India India
Atanu Mandal works as a technical lead in a leading Software service company. He is from Kolkata, India. His primary interests are website development, software architecture and integration.

Comments and Discussions