I have a solution: the previous post may not be quite understandable, and I did write a few comments, and the steps are not very detailed. I hope you can correct them again. 1: Controls (cracked version, only. Net2005) and the skin are as follows (downloaded using a download tool such as audio and video conveyor belt): download1.csdn. netdown32
I have a solution: the previous post may not be quite understandable, and I did write a few comments, and the steps are not very detailed. I hope you can correct them again. 1: Controls (cracked version, only. Net2005) and the skin is as follows (with audio and video conveyor belt and other download tools download): http://download1.csdn.net/down3/2
I have a solution:
The previous post may be hard to understand, and I did write a few comments and the steps are not very detailed. I hope you can correct them.
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;
///
/// Added the skin replacement menu
///
///
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;
}
}
}
///
/// Change skin
///
///
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;
}
}
///
/// Remove skin
///
Public static void RemoveSkin ()
{
If (se = null)
{
Return;
}
Else
{
Se. Active = false;
}
}
}
///
/// Skin replacement type
///
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.
Trackback: http://tb.blog.csdn.net/TrackBack.aspx? PostId = 1564072
I am referencing other people! Thank you!
QQ: 8709325