【瘋了C#】神奇的換膚(二)

來源:互聯網
上載者:User

標籤:

昨天參照了網上的資料練習了換膚,今天進一步的實現選擇換膚

其實很簡單,需要實現的功能如下點擊combobox中的不同項目然後面板會自動的切換到相應的介面主題。

介面如下:

下述代碼參照 “張雋永” 部落格,http://realzjy.blog.51cto.com/818594/165556

 public class ComboBoxItem        {            private string _text = null;            private object _value = null;            public string Text { get { return this._text; } set { this._text = value; } }            public object Value { get { return this._value; } set { this._value = value; } }            public override string ToString()            {                return this._text;            }        }
        private void Form1_Load(object sender, EventArgs e)        {            ComboBoxItem bt1 = new ComboBoxItem();            ComboBoxItem bt2 = new ComboBoxItem();            ComboBoxItem bt3 = new ComboBoxItem();            ComboBoxItem bt4 = new ComboBoxItem();            bt1.Text = "皮膚1";            bt1.Value = "皮膚1";            bt2.Text = "皮膚2";            bt2.Value = "皮膚2";            bt3.Text = "皮膚3";            bt3.Value = "皮膚3";            bt4.Text = "皮膚4";            bt4.Value = "皮膚4";            Type.Items.Add(bt1);            Type.Items.Add(bt2);            Type.Items.Add(bt3);            Type.Items.Add(bt4);        }

本段代碼是對Combobox進行load時的顯示初始化。

點擊combobox 切換切換index時的code

  private void Type_SelectedIndexChanged(object sender, EventArgs e)        {            string[] A = { "皮膚1", "皮膚2", "皮膚3", "皮膚4" };            Type.Text = A[Type.SelectedIndex];        }

點擊確定按鈕執行換膚動作的code

private void Confirm_Click(object sender, EventArgs e)        {            switch(Type.Text)            {                case "皮膚1":                    this.skinEngine1.SkinFile="DiamondBlue.ssk";                    break;                case "皮膚2":                    this.skinEngine1.SkinFile="SportsBlue.ssk";                    break;                case "皮膚3":                    this.skinEngine1.SkinFile="SportsCyan.ssk";                    break;                case "皮膚4":                    this.skinEngine1.SkinFile="diamondgreen.ssk";                    break;            }                                  }

代碼寫的很垃圾,當然本文的主要目的也僅僅是為了親手實現這個功能。

切換index

【瘋了C#】神奇的換膚(二)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.