using System; using System.Drawing; namespace GForms { class GLabel : GControl { private string text = "GLabel"; public bool AutoSize { get; set; } public string Text { get { return text; } set { text = value; RaiseChanged(); } } public override void Draw(Graphics g, Rectangle bounds) { if (this.AutoSize) { Size s = g.MeasureString(this.Text, this.Font).ToSize(); s.Height++; s.Width++; if (this.Width != s.Width) { this.Width = s.Width; } else if (this.Height != s.Height) { this.Height = s.Height; } g.DrawString(this.Text, this.Font, new SolidBrush(this.Color), bounds.Location); } else { g.DrawString(this.Text, this.Font, new SolidBrush(this.Color), this.Bounds); } base.Draw(g, bounds); } public GLabel() { this.AutoSize = true; } } }