Yesterday, referring to the online data to practice the skin, today to further realize the choice of skin replacement
In fact, it is very simple to implement the function as follows click on the different items in the ComboBox and then the panel will automatically switch to the corresponding interface theme.
The interface is as follows:
The following code refers to the "Zhang Timeless" blog, http://realzjy.blog.51cto.com/818594/165556
Public classComboBoxItem {Private string_text =NULL; Private Object_value =NULL; Public stringText {Get{return This. _text; }Set{ This. _text =value;} } Public ObjectValue {Get{return This. _value; }Set{ This. _value =value;} } Public Override stringToString () {return This. _text; } }
Private voidForm1_Load (Objectsender, EventArgs e) {ComboBoxItem BT1=NewComboBoxItem (); ComboBoxItem BT2=NewComboBoxItem (); ComboBoxItem BT3=NewComboBoxItem (); ComboBoxItem BT4=NewComboBoxItem (); Bt1. Text="Skin 1"; Bt1. Value="Skin 1"; Bt2. Text="Skin 2"; Bt2. Value="Skin 2"; BT3. Text="Skin 3"; BT3. Value="Skin 3"; Bt4. Text="Skin 4"; Bt4. Value="Skin 4"; TYPE.ITEMS.ADD (BT1); TYPE.ITEMS.ADD (BT2); TYPE.ITEMS.ADD (BT3); TYPE.ITEMS.ADD (BT4); }
This code is the display initialization when the ComboBox is load.
Click ComboBox to toggle the Code at index
Private void Type_selectedindexchanged (object sender, EventArgs e) { string" Skin 1" skin 2"" skin 3"" Skin 4 " }; = A[type.selectedindex]; }
Click the OK button to perform the Skinning action code
Private voidConfirm_click (Objectsender, EventArgs e) { Switch(type.text) { Case "Skin 1": This. skinengine1.skinfile="Diamondblue.ssk"; Break; Case "Skin 2": This. skinengine1.skinfile="Sportsblue.ssk"; Break; Case "Skin 3": This. skinengine1.skinfile="Sportscyan.ssk"; Break; Case "Skin 4": This. skinengine1.skinfile="Diamondgreen.ssk"; Break; } }
The code is very rubbish, of course, the main purpose of this article is simply to achieve this function.
Toggle Index
"Crazy C #" Magical Skin Change (ii)