在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
昨天参照了网上的资料练习了换肤,今天进一步的实现选择换肤 其实很简单,需要实现的功能如下点击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 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论