"Crazy C #" Magical Skin Change (ii)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.