c# 矢量图标动态生成库
程序员文章站
2022-04-01 10:43:36
...
在研发中,在这里提供一个非常好用的工具库,其中的海量图标基本满足我们的需求 ,且使用方法非常简单 ,和web使用FontAwesome方式一样 。该库在开源中国上有,浏览看到,觉得非常好用,灵活性强。
库下载见 http://download.csdn.net/download/wangchao712217/10229184
public partial class FormSample : Form
{
public FormSample()
{
InitializeComponent();
this.cmbFontAwesomeType.SelectedIndexChanged+=new EventHandler(cmbFontAwesomeType_SelectedIndexChanged);
}
private void FormSample_Load(object sender, EventArgs e)
{
string[] names = FontAwesome.TypeDict.Select(v => v.Key).ToArray();
this.cmbFontAwesomeType.Items.AddRange(names);
string[] colorNames = Enum.GetNames(typeof(KnownColor));
this.cmbForeColor.Items.AddRange(colorNames);
this.cmbBackColor.Items.AddRange(colorNames);
this.cmbBorderColor.Items.AddRange(colorNames);
this.cmbFontAwesomeType.SelectedIndex = 0;
}
private void cmbFontAwesomeType_SelectedIndexChanged(object sender,EventArgs e)
{
if (this.cmbFontAwesomeType.SelectedIndex<0)
{
return;
}
FontAwesome.IconSize = (int)this.nudIconSize.Value;
if (this.cmbBackColor.SelectedIndex>-1)
{
FontAwesome.BackColer = Color.FromName(this.cmbBackColor.Text);
}
if (this.cmbBorderColor.SelectedIndex > -1)
{
FontAwesome.BorderColer = Color.FromName(this.cmbBorderColor.Text);
}
if (this.cmbForeColor.SelectedIndex > -1)
{
FontAwesome.ForeColer = Color.FromName(this.cmbForeColor.Text);
}
FontAwesome.BorderVisible = this.cbShowBorder.Checked == true;
int val = FontAwesome.TypeDict[this.cmbFontAwesomeType.Text];
//得到bitmap
Bitmap bmp = FontAwesome.GetImage(val);//f188
this.panel1.BackgroundImage = bmp;
//得到icon
this.Icon = FontAwesome.GetIcon(val);//f188;
}
}