On the Visual Studio 2005 toolbox, right-click and select "select item". Wait...
In the pop-up "select toolbox items" tab, click "Browse", find the location where irisskin2.dll is stored, and double-click,
You will find an additional "skinengine". OK.
Drag the "skinengine" in the public control to the form and add the skin file *. SSK to Solution Explorer.
Add to the debug folder under the bin folder. (Copy the skin file *. SSK first, right-click "Paste" on the debug folder ")
Add the following sentence during initialization:
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Namespace windowsapplication1
{
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
This. skinengine1.skinfile = "*. SSK ";
}
Private void form1_load (Object sender, eventargs E)
{
}
}
}
To restore the default skin, note or delete the red statement.
_______________________________________
1: Controls (cracked version, only. net2005) and the skin are as follows (download with tools such as audio and video conveyor belt ):
Http://download1.csdn.net/down3/20070605/05142029888.rar
Demo program (including source code)
Http://dl2.csdn.net/down4/20070628/28181121698.rar
2: Load
The downloaded rarfile contains an irisskin2.dll and a skin folder.
Add reference and reference irisskin2.dll to the project.
In Solution Explorer, right-click Project> Add> Create a folder named skin.
After the skin folder is created, right-click this folder → add → existing items, and select * in the pop-up file selection box *. * select all files in the extracted skin folder.
At this time, we can see that all the skin replacement files we have added are in the skin folder. Press ctrl to select all the files in the skin folder. In the attribute column, you can see the "generate operation" column. The default option is "NONE ", we changed it to "embedded resources ".
3: Class
Next we will create a new class and copy the following code. Don't forget to change the namespace to your own.
Using system;
Using system. Collections. Generic;
Using system. text;
Using system. Windows. forms;
Using system. Data;
// Testskin Command Space. Do not forget to change it to your own.
Namespace testskin
{
Class skinclass
{
Public static sunisoft. irisskin. skinengine Se = NULL;
/// <Summary>
/// Added the skin replacement menu
/// </Summary>
/// <Param name = "toolmenu"> </param>
Public static void addskinmenu (toolstripmenuitem toolmenu)
{
Dataset Skin = new dataset ();
Try
{
Skin. readxml ("skin. xml", xmlreadmode. Auto );
}
Catch
{
}
If (skin = NULL | skin. Tables. Count <1)
{
Skin = new dataset ();
Skin. Tables. Add ("skin ");
Skin. Tables ["skin"]. Columns. Add ("style ");
System. Data. datarow DR = Skin. Tables ["skin"]. newrow ();
Dr [0] = "System Default ";
Skin. Tables [0]. Rows. Add (DR );
Skin. writexml ("skin. xml", xmlwritemode. ignoreschema );
}
Foreach (skintype ST in (skintype []) system. enum. getvalues (typeof (skintype )))
{
Toolmenu. dropdownitems. Add (New toolstripmenuitem (St. tostring ()));
Toolmenu. dropdownitems [toolmenu. dropdownitems. Count-1]. Click + = new eventhandler (frm_main_click );
If (St. tostring () = Skin. Tables [0]. Rows [0] [0]. tostring ())
{
(Toolstripmenuitem) toolmenu. dropdownitems [toolmenu. dropdownitems. Count-1]). Checked = true;
Frm_main_click (toolmenu. dropdownitems [toolmenu. dropdownitems. Count-1], null );
}
}
Toolmenu. dropdownitems. Add (New toolstripmenuitem ("System Default "));
Toolmenu. dropdownitems [toolmenu. dropdownitems. Count-1]. Click + = new eventhandler (frm_main_click );
If (skin. Tables [0]. Rows [0] [0]. tostring () = "System Default ")
{
(Toolstripmenuitem) toolmenu. dropdownitems [toolmenu. dropdownitems. Count-1]). Checked = true;
}
}
Static void frm_main_click (Object sender, eventargs E)
{
For (INT I = 0; I <(toolstripmenuitem) sender). owneritem). dropdownitems. Count; I ++)
{
If (toolstripmenuitem) sender). Text = (toolstripmenuitem) sender). owneritem). dropdownitems [I]. Text)
{
(Toolstripmenuitem) sender). checkstate = checkstate. checked;
Dataset Skin = new dataset ();
Skin. Tables. Add ("skin ");
Skin. Tables ["skin"]. Columns. Add ("style ");
System. Data. datarow DR = Skin. Tables ["skin"]. newrow ();
Dr [0] = (toolstripmenuitem) sender). owneritem). dropdownitems [I]. text;
Skin. Tables [0]. Rows. Add (DR );
Skin. writexml ("skin. xml", xmlwritemode. ignoreschema );
}
Else
{
(Toolstripmenuitem) sender). owneritem). dropdownitems [I]). checkstate = checkstate. unchecked;
}
}
If (toolstripmenuitem) sender). Text = "System Default ")
{
Removeskin ();
Dataset Skin = new dataset ();
Skin. Tables. Add ("skin ");
Skin. Tables ["skin"]. Columns. Add ("style ");
System. Data. datarow DR = Skin. Tables ["skin"]. newrow ();
Dr [0] = "System Default ";
Skin. Tables [0]. Rows. Add (DR );
Skin. writexml ("skin. xml", xmlwritemode. ignoreschema );
Return;
}
Foreach (skintype ST in (skintype []) system. enum. getvalues (typeof (skintype )))
{
If (St. tostring () = (toolstripmenuitem) sender). Text)
{
Changeskin (ST );
Return;
}
}
}
/// <Summary>
/// Change skin
/// </Summary>
/// <Param name = "St"> </param>
Public static void changeskin (skintype st)
{
System. reflection. Assembly thisdll = system. reflection. Assembly. getexecutingassembly ();
If (Se = NULL)
{
// Testskin refers to the namespace. Here you can change it to your own.
Se = new sunisoft. irisskin. skinengine (application. openforms [0], thisdll. getmanifestresourcestream ("testskin. Skin." + st. tostring () + ". SSK "));
Se. Active = true;
For (INT I = 0; I <application. openforms. Count; I ++)
{
Se. addform (application. openforms [I]);
}
}
Else
{
// Testskin refers to the namespace. Here you can change it to your own.
Se. skinstream = thisdll. getmanifestresourcestream ("testskin. Skin." + st. tostring () + ". SSK ");
Se. Active = true;
}
}
/// <Summary>
/// Remove skin
/// </Summary>
Public static void removeskin ()
{
If (Se = NULL)
{
Return;
}
Else
{
Se. Active = false;
}
}
}
/// <Summary>
/// Skin replacement type
/// </Summary>
Public Enum skintype
{
Calmness,
Deepcyan,
Eighteen,
Emerald,
Glassbrown,
Longhorn,
MacOS,
Midsummer,
Mp10,
MSN,
Oneblue,
Page,
RealOne,
Silver,
Sportsblack,
Steelblack,
Vista1,
Vista2,
Warm,
Wave,
Xpsilver
}
}
4: Call
Add a menustrip menu to your main form, create a level 2 menu (for example, file → skin change), and write the call code in the form_load event:
Private void form1_load (Object sender, eventargs E)
{
// "Skin replacement toolstripmenuitem" is the name of the toolstripmenuitem "skin replacement" in the above example.
Skinclass. addskinmenu (skin replacement toolstripmenuitem );
}
5: Note
The following two methods are mainly used for skin replacement:
Changeskin method skin replacement
The removeskin method restores the default skin of the system.
You do not need to skin a single form directly. The above code generates a skin replacement menu, and All Forms are automatically refreshed.