IrisSkin2.dll是一款很不错的免费皮肤控件,利用它可以轻松的实现winForm窗体换肤!
网上很多朋友说在VS2010中不能使用IrisSkin2.dll,我这里提供一个取巧的办法。
IrisSkin2.dll目前只能在.NET Faremwork 4.0以及之前的版本使用,所以大家在VS2010中可以将自己的项目框架设置为.NET .NET Faremwork 4.0,具体做法见下图:
右键点击你创建的项目—>属性:
将你的目标框架改为.NET Faremwork 4.0或者之前的版本
OK,这样设置,在你的VS2010项目中就可以用IrisSkin2.dll控件了,接下来实现换肤功能只需要几步,非常简单!
首先,最需要的,当然是下载IrisSkin2.dll控件,这里为大家贴出CSDN下载区的地址:
http://download.csdn.net/source/1465571
下载完之后,我们正式进入winForm的换肤之旅…
1. 先把IrisSkin2.dll文件添加到当前项目引用(解决方案资源管理器->当前项目->引用->右键->添加引用,找到IrisSkin2.dll文件.)IrisSkin2.dll文件最好放在当前项目\bin\Debug文件中.
2. 然后把IrisSkin2.dll文件添加到vc2005的工具箱:右键->选择项->浏览找到IrisSkin2.dll文件(文件最好放在当前项目\bin\Debug文件中)按确定,控件就添加到工具箱中了.然后把工具箱中新添加的 SkinEngine控件拖到当前项目中。
IrisSkin2.dll关联的皮肤样式文件是后缀名为ssk文件,为了使程序加载方便,可将.ssk文件复制到当前项目\bin\Debug文件中。
在项目中使用如下代码:
this.skinEngine1.SkinFile="DiamondBlue.ssk";
为了比较样式区分,我在Form窗体上放上了Button、Label、grouBox等控件,来观察不同皮肤样式的区别:
1: private void calmnessToolStripMenuItem_Click(objectsender, EventArgs e)
2: {
3: this.skinEngine1.SkinFile = "Calmness.ssk";
4: this.Text = "Calmness样式效果";
5: }
6:
7: private void deepCyanToolStripMenuItem_Click(objectsender, EventArgs e)
8: {
9: this.skinEngine1.SkinFile = "DeepCyan.ssk";
10: this.Text = "DeepCyan样式效果";
11: }
12:
13: private void eighteenToolStripMenuItem_Click(objectsender, EventArgs e)
14: {
15: this.skinEngine1.SkinFile = "Eighteen.ssk";
16: this.Text = "Eighteen样式效果";
17: }
18:
19: private void mSNToolStripMenuItem_Click(objectsender, EventArgs e)
20: {
21: this.skinEngine1.SkinFile = "MSN.ssk";
22: this.Text = "MSN样式效果";
23: }
24:
25: private void silverToolStripMenuItem_Click(objectsender, EventArgs e)
26: {
27: this.skinEngine1.SkinFile = "Silver.ssk";
28: this.Text = "Silver样式效果";
29: }
30:
31: private void sportsBlackToolStripMenuItem_Click(object sender, EventArgs e)
32: {
33: this.skinEngine1.SkinFile = "SportsBlack.ssk";
34: this.Text = "SportsBlack样式效果";
35: }
36:
37: private void vista2ToolStripMenuItem_Click(objectsender, EventArgs e)
38: {
39: this.skinEngine1.SkinFile = "Vista2.ssk";
40: this.Text = "Vista2样式效果";
41: }
42:
43: private void xPSilverToolStripMenuItem_Click(objectsender, EventArgs e)
44: {
45: this.skinEngine1.SkinFile = "XPSilver.ssk";
46: this.Text = "XPSilver样式效果";
47: }
IrisSkin2.dll 控件换肤的实现就是这么简单,惊呀吧,惊叹吧。呵呵。下面Show一下换肤后的窗体
DiamondBlue.ssk文件的样式
MSN.ssk文件的样式
Vista2.ssk文件的样式