如何在c#winforms中的Label文本上应用外发光和模糊效果.使用自定义控件
如您所见,这是自定义面板,我正在尝试为整个文本进行发光效果.
protected override void OnPaint(PaintEventArgs pe)
{
//base.OnPaint(pe);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
GraphicsPath GP = new GraphicsPath();
GP.FillMode = FillMode.Alternate;
GP.AddString(this.Text, this.Font.FontFamily, 2, 12f, new Point(ClientRectangle.X+Text.Length*4-20, ClientRectangle.Y+10), sf);
// In Border
using (SolidBrush brush = new SolidBrush(BackColor))
pe.Graphics.FillRectangle(brush, ClientRectangle);
pe.Graphics.DrawRectangle(new Pen(Color.FromArgb(_InnerBorderColor.R, _InnerBorderColor.B, _InnerBorderColor.G), 1.0f), 0, 0, ClientSize.Width - 2, ClientSize.Height - 2);
pe.Graphics.DrawPath(new Pen(Color.Blue, 2f), GP);
pe.Graphics.DrawString(base.Text, this.Font, Brushes.Black, 2, 2);
}
Run Code Online (Sandbox Code Playgroud)