在 Windows Forms 和 WPF 应用中使用 FontAwesome 图标
前言
FontAwesome 大家都不陌生,精美的图标,出现在各式各样的网页中。
最近在做 Windows Forms 应用程序,要求美观,就想能不能把 FontAwesome 图标用上,于是就有了本文。
本人已经将 FontAwesome 进行了封装,并上传到了 GitHub 和 NuGet。
- GitHub:https://github.com/seayxu/FontAwesome
- 码云:http://git.oschina.net/seayxu/FontAwesome
- NuGet:https://www.nuget.org/packages/FontAwesomeNet/
样图

简介
下面是解决方案列表:

|- .nuget
|- sample
|--- FontAwesomeNet.Sample # Windows Forms Samlpe
|--- FontAwesomeNet.Wpf.Sample # WPF Samlpe
|- src
|--- FontAwesomeNet # FontAwesome for .NET library
使用
可以参考示例源码。
0. 安装字体
安装过请忽略,地址是:fontawesome-webfont-4.7.0.ttf。
1. 安装类库
PM> Install-Package FontAwesomeNet
2. 添加命名空间
using FontAwesomeNet;
3. 生成图片(Image)或图标(Icon)
使用的是 FontAwesome 静态类。
获取字体图标名称:
// get FontAwesome icon class names(type is Dictionary<string, int>)
string[] names = FontAwesome.TypeDict.Select(v => v.Key).ToArray();
获取字体图标名称对应的Unicode码:
// use FontAwesome icon class name get FontAwesome icon Unicode value
int val = FontAwesome.TypeDict["fa-heart"];//0xf004
获取图片和图标:
只有这两个方法。
Bitmap bmp = FontAwesome.GetImage(val);//0xf004
Icon ico = FontAwesome.GetIcon(val);//0xf004
修改默认参数:
直接对静态字段赋值即可。
FontAwesome.IconSize = 128;//change icon size
FontAwesome.ForeColer = Color.Purple;//change icon forecolor
...
如有不好的地方,欢迎大家更正,谢谢。
在 Windows Forms 和 WPF 应用中使用 FontAwesome 图标的更多相关文章
- Oracle 远程访问配置 在 Windows Forms 和 WPF 应用中使用 FontAwesome 图标 C#反序列化XML异常:在 XML文档(0, 0)中有一个错误“缺少根元素” C#[Win32&WinCE&WM]应用程序只能运行一个实例:MutexHelper Decimal类型截取保留N位小数向上取, Decimal类型截取保留N位小数并且不进行四舍五入操作
Oracle 远程访问配置 服务端配置 如果不想自己写,可以通过 Net Manager 来配置. 以下配置文件中的 localhost 改为 ip 地址,否则,远程不能访问. 1.网络监听配置 ...
- Windows Presentation Foundation (WPF) 项目中不支持xxx的解决
一般Windows Presentation Foundation (WPF) 项目中不支持xxx都是由于没引用相应的程序集导致,比如Windows Presentation Foundation ( ...
- Windows Forms和WPF在Net Core 3.0框架下并不会支持跨平台
Windows Forms和WPF在Net Core 3.0框架下并不会支持跨平台 微软将WinForms和WPF带到.NET Core 3.0这一事实,相信大家都有所了解,这是否意味着它在Linux ...
- 在WPF中使用FontAwesome图标字体
原文:在WPF中使用FontAwesome图标字体 版权声明:原创内容转载必须注明出处,否则追究相关责任. https://blog.csdn.net/qq_36663276/article/deta ...
- 直接在 CSS 中引用 FONTAWESOME 图标(附码表)
直接在 CSS 中引用 FONTAWESOME 图标(附码表) 因此我们如果不想用 Fontawesome 提供的类,只想在 css 里面引用图标的话,可以这样子,请自行脑补: .icon:befor ...
- WPF、Windows Forms和Silverlight间的联系和区别(转)
WPF.Windows Forms和Silverlight间的联系和区别http://blog.csdn.net/bitfan/article/details/6128391 .NET Windows ...
- Windows Forms (一)
导读 1.什么是 Windows Forms 2.需要学Windows Forms 么? 3.如何手写一个简单的Windows Forms 程序 4.对上面程序的说明 5.Form 类与Control ...
- 使用XAML在WPF项目中承载ArcGIS Engine地图控件开发
原文 http://blog.csdn.net/flexmapserver/article/details/5868882 用Windows Form进行ArcGIS Engine二次开发时常见的形式 ...
- Windows Forms(二)
导读 1.用VS创建一个Windows Forms程序 2.分析上面的程序 3.Mediator pattern(中介者模式) 4.卡UI怎么办——BackgroundWorker组件 用VS创建一个 ...
随机推荐
- python第三方扩展库及不同类型的测试需安装相对应的第三方库总结
如何安装第三方库 1.通过python的第三方仓库pypi中查找想要的第三方库 pypi地址:https://pypi.python.org/pypi pip是一个安装和管理Python包的工具,通过 ...
- Lua打印Table的数据结构工具类
--这是quick中的工具,作用就是打印Lua中强大的table的结构, 当table的嵌套层级比较多的时候,这个工具非常方便,开发中必备的工具. --具体使用方法:local debug = req ...
- Unity 之 c# 版的 CharacterMotor
using System; using System.Collections; using UnityEngine; // This class just convert from Character ...
- UWSGITOP-----监控uwsgi 性能
启动 uwsgi -x etc/bfdds_cookiemapping_conf.xml --stats /tmp/stats.socket 查看 uwsgitop /tmp/stats.socket ...
- HUST 1027 Enemy Target!
求二分图的最小点覆盖集,并输出 对于每一个a[i][j]=1,我们从行i-->列j建立一条边 显然,这张图是一张二分图.左边的节点代表删除哪一行,右边的节点代表删除哪一列.中间的边代表所有a[i ...
- Ueditor的配置及使用
Ueditor官网:http://ueditor.baidu.com/website/ (项目需要JSP版本:UTF-8版) 1.配置 <script type="text/ja ...
- hibernate---性能优化, 1+N问题
session级缓存 保存一个hashmap, 读出来的对象放在里面, 如果读出来50条放50条, 如果另起session原来的50条就被清除.可以手动session.clear清除. 如果同一个se ...
- 手机端 H5上传头像
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- FZU 1056 扫雷游戏
水题.统计一下周围有几个雷. #include<cstdio> #include<cstring> #include<cmath> #include<algo ...
- MonkeyRecorder
http://www.cnblogs.com/lynn-li/p/5894953.html