小编Ema*_*per的帖子

自定义控件中文本的外发光效果

如何在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)

c# gdi+ custom-controls winforms

0
推荐指数
1
解决办法
3316
查看次数

标签 统计

c# ×1

custom-controls ×1

gdi+ ×1

winforms ×1