using System.Drawing;
using System.Drawing.Text;
using System.Windows.Forms;
using Microsoft.Drawing;
namespace Microsoft.Windows.Forms
{
///
/// 虚拟标签控件
///
public class UILabel : UIControl
{
private TextRenderingHint m_TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
///
/// 文本呈现质量
///
public virtual TextRenderingHint TextRenderingHint
{
get
{
return this.m_TextRenderingHint;
}
set
{
if (value != this.m_TextRenderingHint)
{
this.m_TextRenderingHint = value;
this.Invalidate();
}
}
}
private ContentAlignment m_TextAlign = ContentAlignment.MiddleCenter;
///
/// 文本对齐方式
///
public virtual ContentAlignment TextAlign
{
get
{
return this.m_TextAlign;
}
set
{
if (value != this.m_TextAlign)
{
this.m_TextAlign = value;
this.Invalidate();
}
}
}
///
/// 渲染控件
///
/// 数据
protected override void RenderSelf(PaintEventArgs e)
{
//准备
Graphics g = e.Graphics;
Rectangle rect = RectangleEx.Subtract(this.ClientRectangle, this.Padding);
//渲染
this.Sprite.BackColor = this.BackColor;
this.Sprite.Font = this.Font;
this.Sprite.Text = this.Text;
this.Sprite.TextRenderingHint = this.TextRenderingHint;
this.Sprite.TextAlign = this.TextAlign;
this.Sprite.BorderVisibleStyle = BorderVisibleStyle.None;
this.Sprite.State = this.State;
this.Sprite.BeginRender(g);
this.Sprite.RenderText(rect);
this.Sprite.EndRender();
}
}
}