Z.IconLibrary.dll的使用
一.在web方面的应用
1. 在Web.Config文件中添加以下
<system.web>
<httpHandlers>
<add path="*/z.axd"verb="*" type="Z.IconLibrary.IconResourceHandler"validate="false" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<addname="Z.IconLibrary.RessourceHandler" verb="*"path="*/z.axd" preCondition="integratedMode"type="Z.IconLibrary.IconResourceHandler" />
</handlers>
</system.webServer>
2. 在page中引用Z.IconLibrary.dll, 添加using Z.IconLibrary;
3. 在Page_Load中添加如下代码即可:
protectedvoid Page_Load(object sender, EventArgs e)
{
Page.AddIconStyleSheet();
}
Label添加图片如下:16表示16位
[LabelID].CssClass= Icon.Accept.GetCssClass16(); // required web.config setup
[LabelID].CssClass = Icon.Accept.GetCssClass32(); // required web.config setup
Image添加图片如下
[ImageID].ImageUrl= Icon.Accept.GetUrl16(); // required web.config setup
[ImageID].ImageUrl = Icon.Accept.GetUrl32(); // required web.config setup
二 在WinForm中使用
1. 此处需要注意版本的添加。我用上面dll在VS2008, VS2010中均提示【无法定义到导航】,所以只要在网上下载
C# Icon Library adds thousands of icons toany kind of project (Web, WinForm, Etc.). All Icons have been designed by aprofessionals.
-------------------------------------------------
FarmFresh 16x16 & 32x32 (3926 icons)
CodePlex:https://ziconlibraryfarmfresh.codeplex.com/releases
NuGet:https://www.nuget.org/packages/Z.IconLibrary.FarmFresh/
-------------------------------------------------
FarmFresh 16x16 (3926 icons)
CodePlex: https://ziconlibraryfarmfresh16.codeplex.com/releases
NuGet:https://www.nuget.org/packages/Z.IconLibrary.FarmFresh16/
-------------------------------------------------
FarmFresh 32x32 (3926 icons)
CodePlex:https://ziconlibraryfarmfresh32.codeplex.com/releases
NuGet:https://www.nuget.org/packages/Z.IconLibrary.FarmFresh32/
-------------------------------------------------
Fugue 16x16 (3570 icons)
CodePlex:https://ziconlibraryfugue.codeplex.com/releases
NuGet:https://www.nuget.org/packages/Z.IconLibrary.Fugue/
-------------------------------------------------
Silk 32x32 (1000 icons)
CodePlex: https://ziconlibrarysilk.codeplex.com/releases
NuGet:https://www.nuget.org/packages/Z.IconLibrary.Silk/
2. 引用文件 usingZ.IconLibrary.Silk;
3. 代码如下:
uiImage16.Image = Z.IconLibrary.Silk.Icon.Accept.GetImage();
uiIcon16.Image = Z.IconLibrary.Silk.Icon.Accept.GetIcon().ToBitmap();
uiBitmap16.Image = Z.IconLibrary.Silk.Icon.Accept.GetBitmap();
using (var stream = Z.IconLibrary.Silk.Icon.Accept.GetStream())
{
uiStream16.Image = newSystem.Drawing.Bitmap(stream);
}
其范例可参考:http://jonathanmagnan.com/icon-library-winform-examples/
如在Button上添加控件:代码如下:
button1.Image =Z.IconLibrary.FarmFresh.Icon.Add.GetBitmap32();
button1.ImageAlign =System.Drawing.ContentAlignment.MiddleLeft;