winform界面使用irisskin,可以说做到了一键美化,当然美化的效果仁者见仁智者见智,可以挑选自己喜欢的。

    1、irisskin下载地址:http://www.pc6.com/softview/softview_70918.html#download

    2、将下载的文件放到debug下面。

    3、新建一个winform窗体,命名为main:

     4、main代码实现如下:

        skinengine skinengine = new skinengine();

        public main()
        {
            initializecomponent();

            string[] files = directory.getfiles(path.combine(application.startuppath, @"irisskin4\skins"), "*.ssk", searchoption.alldirectories);
            if (files != null && files.length > 0)
            {
                //变量
                int index = 0;      //按钮序号
                int space = 10;     //按钮间隔
                int btnwidth = 130; //按钮宽度
                int btnheight = 30; //按钮高度
                int btncount = 7;   //每行按钮个数

                //每行显示7个按钮
                for (int rows = 0; rows < (files.length % btncount == 0 ? files.length / btncount : (files.length / btncount) + 1); rows++)
                {
                    //最后一行的按钮个数
                    int lastcout = files.length % btncount;
                    //生成按钮
                    if (index < (files.length / btncount) * btncount)
                    {
                        for (int cols = 0; cols < btncount; cols++)
                        {
                            button btn = new button
                            {
                                location = new point(cols * btnwidth + (cols + 1) * space, rows * btnheight + (rows + 1) * space),
                                width = btnwidth,
                                height = btnheight
                            };
                            string path = files[index];
                            string btnname = path.substring(files[index].lastindexof(@"\") + 1);
                            btn.text = btnname;
                            btn.click += (object sender, eventargs e) => { skinengine.skinallform = true; skinengine.skinfile = path; tsslskinfile.text = path.combine(application.startuppath, btnname); };
                            controls.add(btn);
                            index++;
                        }
                    }
                    else
                    {
                        for (int cols = 0; cols < lastcout; cols++)
                        {
                            button btn = new button
                            {
                                location = new point(cols * btnwidth + (cols + 1) * space, rows * btnheight + (rows + 1) * space),
                                width = btnwidth,
                                height = btnheight
                            };
                            string path = files[index];
                            string btnname = path.substring(files[index].lastindexof(@"\") + 1);
                            btn.text = btnname;
                            btn.click += (object sender, eventargs e) => { skinengine.skinallform = true; skinengine.skinfile = path; tsslskinfile.text = path.combine(application.startuppath, btnname); };
                            this.controls.add(btn);
                            index++;
                        }
                    }
                }
            }
        }

        private void button1_click(object sender, eventargs e)
        {
            messagebox.show("hello world.", "提示", messageboxbuttons.ok, messageboxicon.information);
        }

    5、换肤渲染前效果:

     6、换肤如选deepcyan.ssk,渲染的效果如下:

    注:不想被渲染的控件,可以设其tag属性值为9999,如测试区的datagridview就设了此项。

    好了,分享就到此结束了,希望对有此需要的人有一些帮助。