使用 Segoe MDL2 Assets 字体作为 NotifyIcon 的图标

Use the Segoe MDL2 Assets font as an icon for NotifyIcon

是否可以使用 Segoe MDL2 Assets 字体作为系统托盘应用 (NotifyIcon) 的图标?

我尝试使用 但它不起作用:

您需要传递所需字形的右侧Unicode Point

请考虑以下代码段:

using System.Drawing;
using System.Drawing.Text;

//...

public enum Glyphs
{
    GlobalNavigationButton = 0xE700,
    Wifi = 0xE701,
    Bluetooth = 0xE702,
    Connect = 0xE703,
    InternetSharing = 0xE704,
    VPN = 0xE705,
    //Add more...
}

//...

public static Icon CreateGlyphIcon(Glyphs glyph)
{
    using (var b = new Bitmap(16, 16))
    using (Graphics g = Graphics.FromImage(b))
    using (var f = new Font("Segoe MDL2 Assets", 12, FontStyle.Regular))
    using (var sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
    {
        g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
        g.DrawString(((char)glyph).ToString(), f, Brushes.White, new Rectangle(0, 0, 16, 16), sf);

        return Icon.FromHandle(b.GetHicon());
    }                   
}

用法:

var icon = CreateGlyphIcon(Glyphs.Connect);

//or

var icon = CreateGlyphIcon(Glyphs.Bluetooth);

//...etc.